Example usage for org.jfree.chart.plot Plot setInsets

List of usage examples for org.jfree.chart.plot Plot setInsets

Introduction

In this page you can find the example usage for org.jfree.chart.plot Plot setInsets.

Prototype

public void setInsets(RectangleInsets insets) 

Source Link

Document

Sets the insets for the plot and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:org.eobjects.datacleaner.util.ChartUtils.java

public static void applyStyles(JFreeChart chart) {
    TextTitle title = chart.getTitle();//from ww  w .  j  a v  a2 s.  co  m
    if (title != null) {
        title.setFont(WidgetUtils.FONT_HEADER1);
        title.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    }

    for (int i = 0; i < chart.getSubtitleCount(); i++) {
        Title subtitle = chart.getSubtitle(i);
        if (subtitle instanceof TextTitle) {
            ((TextTitle) subtitle).setFont(WidgetUtils.FONT_NORMAL);
        }
    }

    LegendTitle legend = chart.getLegend();
    if (legend != null) {
        legend.setItemFont(WidgetUtils.FONT_SMALL);
    }

    // transparent background
    chart.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    chart.setBorderVisible(false);

    final Plot plot = chart.getPlot();
    plot.setInsets(new RectangleInsets(UnitType.ABSOLUTE, 0d, 0d, 0d, 0d));
    plot.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    plot.setOutlinePaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    plot.setOutlineVisible(true);

    if (plot instanceof PiePlot) {
        // tweaks for pie charts
        final PiePlot piePlot = (PiePlot) plot;
        piePlot.setBaseSectionOutlinePaint(WidgetUtils.BG_COLOR_DARK);
        piePlot.setBaseSectionOutlineStroke(normalStroke);
        piePlot.setLabelFont(WidgetUtils.FONT_SMALL);
        piePlot.setLabelBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHT);
        piePlot.setLabelOutlineStroke(normalStroke);
        piePlot.setLabelPaint(WidgetUtils.BG_COLOR_DARK);
        piePlot.setSectionOutlinesVisible(false);
        piePlot.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE);
    } else if (plot instanceof CategoryPlot) {
        // tweaks for bar charts
        final CategoryPlot categoryPlot = (CategoryPlot) plot;

        int columnCount = categoryPlot.getDataset().getColumnCount();
        if (columnCount > 1) {
            categoryPlot.setDomainGridlinesVisible(true);
        } else {
            categoryPlot.setDomainGridlinesVisible(false);
        }
        categoryPlot.setDomainGridlinePaint(WidgetUtils.BG_COLOR_DARK);
        categoryPlot.setDomainGridlinePosition(CategoryAnchor.END);

        categoryPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.setDrawingSupplier(new DCDrawingSupplier());

        final CategoryItemRenderer renderer = categoryPlot.getRenderer();
        renderer.setBaseOutlinePaint(WidgetUtils.BG_COLOR_DARK);
        renderer.setBaseOutlineStroke(wideStroke);

        if (renderer instanceof BarRenderer) {
            BarRenderer barRenderer = (BarRenderer) renderer;
            barRenderer.setShadowPaint(WidgetUtils.BG_COLOR_BRIGHT);
            barRenderer.setBarPainter(new StandardBarPainter());
        }

    } else if (plot instanceof XYPlot) {
        // tweaks for line charts
        final XYPlot xyPlot = (XYPlot) plot;

        xyPlot.setDrawingSupplier(new DCDrawingSupplier());

        xyPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        xyPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);
        xyPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        xyPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);

        final XYItemRenderer renderer = xyPlot.getRenderer();
        final int seriesCount = xyPlot.getSeriesCount();
        for (int i = 0; i < seriesCount; i++) {
            renderer.setSeriesStroke(i, wideStroke);
        }
    }
}

From source file:org.datacleaner.util.ChartUtils.java

public static void applyStyles(JFreeChart chart) {
    TextTitle title = chart.getTitle();//from   w  w  w.  ja  va  2s. c om
    if (title != null) {
        title.setFont(WidgetUtils.FONT_HEADER1);
        title.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    }

    for (int i = 0; i < chart.getSubtitleCount(); i++) {
        Title subtitle = chart.getSubtitle(i);
        if (subtitle instanceof TextTitle) {
            ((TextTitle) subtitle).setFont(WidgetUtils.FONT_NORMAL);
        }
    }

    LegendTitle legend = chart.getLegend();
    if (legend != null) {
        legend.setItemFont(WidgetUtils.FONT_SMALL);
    }

    // transparent background
    chart.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    chart.setBorderVisible(false);

    final Plot plot = chart.getPlot();
    plot.setInsets(new RectangleInsets(UnitType.ABSOLUTE, 0d, 0d, 0d, 0d));
    plot.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    plot.setOutlinePaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    plot.setOutlineVisible(true);

    if (plot instanceof PiePlot) {
        // tweaks for pie charts
        final PiePlot piePlot = (PiePlot) plot;
        piePlot.setBaseSectionOutlinePaint(WidgetUtils.BG_COLOR_DARK);
        piePlot.setBaseSectionOutlineStroke(STROKE_NORMAL);
        piePlot.setLabelFont(WidgetUtils.FONT_SMALL);
        piePlot.setLabelBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHT);
        piePlot.setLabelOutlineStroke(STROKE_NORMAL);
        piePlot.setLabelPaint(WidgetUtils.BG_COLOR_DARK);
        piePlot.setSectionOutlinesVisible(false);
        piePlot.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE);
        piePlot.setDrawingSupplier(new DCDrawingSupplier());

    } else if (plot instanceof CategoryPlot) {
        // tweaks for bar charts
        final CategoryPlot categoryPlot = (CategoryPlot) plot;

        int columnCount = categoryPlot.getDataset().getColumnCount();
        if (columnCount > 1) {
            categoryPlot.setDomainGridlinesVisible(true);
        } else {
            categoryPlot.setDomainGridlinesVisible(false);
        }
        categoryPlot.setDomainGridlinePaint(WidgetUtils.BG_COLOR_DARK);
        categoryPlot.setDomainGridlinePosition(CategoryAnchor.END);

        categoryPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);
        categoryPlot.setDrawingSupplier(new DCDrawingSupplier());

        final CategoryItemRenderer renderer = categoryPlot.getRenderer();
        renderer.setBaseOutlinePaint(WidgetUtils.BG_COLOR_DARK);
        renderer.setBaseOutlineStroke(STROKE_WIDE);

        if (renderer instanceof BarRenderer) {
            BarRenderer barRenderer = (BarRenderer) renderer;
            barRenderer.setShadowPaint(WidgetUtils.BG_COLOR_BRIGHT);
            barRenderer.setBarPainter(new StandardBarPainter());
        }

    } else if (plot instanceof XYPlot) {
        // tweaks for line charts
        final XYPlot xyPlot = (XYPlot) plot;

        xyPlot.setDrawingSupplier(new DCDrawingSupplier());

        xyPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        xyPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);
        xyPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL);
        xyPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);

        final XYItemRenderer renderer = xyPlot.getRenderer();
        final int seriesCount = xyPlot.getSeriesCount();
        for (int i = 0; i < seriesCount; i++) {
            renderer.setSeriesStroke(i, STROKE_WIDE);
        }
    }
}

From source file:ca.sqlpower.wabit.swingui.chart.ChartSwingUtil.java

/**
 * Sets the colours and gradients to be used when painting the given JFreeChart.
 * // www . java 2s  .c  o m
 * @param chart
 *          The JFreeChart to make nice.
 */
public static void makeChartNice(JFreeChart chart) {
    Plot plot = chart.getPlot();
    chart.setBackgroundPaint(null);
    chart.setBorderStroke(new BasicStroke(1f));
    chart.setBorderPaint(new Color(0xDDDDDD));
    chart.setBorderVisible(true);

    // TODO Should we add an option for subtitles, this is where it would go.
    //        TextTitle subTitle = new TextTitle("What's up doc?",
    //             new Font("SansSerif", Font.BOLD, 8));
    //       chart.addSubtitle(subTitle);

    // overall plot
    plot.setOutlinePaint(null);
    plot.setInsets(new RectangleInsets(0, 5, 0, 5)); // also the overall chart panel
    plot.setBackgroundPaint(null);
    plot.setDrawingSupplier(new WabitDrawingSupplier());

    // legend
    LegendTitle legend = chart.getLegend();
    if (legend != null) {
        legend.setBorder(0, 0, 0, 0);
        legend.setBackgroundPaint(null);
        legend.setPadding(2, 2, 2, 2);
    }

    if (plot instanceof CategoryPlot) {
        CategoryPlot cplot = (CategoryPlot) plot;

        CategoryItemRenderer renderer = cplot.getRenderer();
        if (renderer instanceof BarRenderer) {
            BarRenderer brenderer = (BarRenderer) renderer;

            brenderer.setBarPainter(new StandardBarPainter());
            brenderer.setDrawBarOutline(false);
            brenderer.setShadowVisible(false);

            brenderer.setGradientPaintTransformer(
                    new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));

        } else if (renderer instanceof LineAndShapeRenderer) {
            // it's all taken care of by WabitDrawingSupplier

        } else {
            logger.warn("I don't know how to make " + renderer + " pretty. Leaving ugly.");
        }

        cplot.setRangeGridlinePaint(Color.BLACK);
        cplot.setRangeGridlineStroke(GRIDLINE_STROKE);

        // axes
        for (int i = 0; i < cplot.getDomainAxisCount(); i++) {
            CategoryAxis axis = cplot.getDomainAxis(i);
            axis.setAxisLineVisible(false);
        }

        for (int i = 0; i < cplot.getRangeAxisCount(); i++) {
            ValueAxis axis = cplot.getRangeAxis(i);
            axis.setAxisLineVisible(false);
        }
    }

    if (plot instanceof MultiplePiePlot) {
        MultiplePiePlot mpplot = (MultiplePiePlot) plot;
        JFreeChart pchart = mpplot.getPieChart();
        PiePlot3DGradient pplot = (PiePlot3DGradient) pchart.getPlot();
        pplot.setBackgroundPaint(null);
        pplot.setOutlinePaint(null);

        pplot.setFaceGradientPaintTransformer(
                new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));
        pplot.setSideGradientPaintTransformer(
                new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));

        CategoryDataset data = mpplot.getDataset();
        Color[][] colours = WabitDrawingSupplier.SERIES_COLOURS;

        //Set all colours
        for (int i = 0; i < colours.length; i++) {
            if (data.getColumnCount() >= i + 1) {
                pplot.setSectionOutlinePaint(data.getColumnKey(i), null);
                GradientPaint gradient = new GradientPaint(0, 0f, colours[i][0], 100, 0f, colours[i][1]);
                pplot.setSectionPaint(data.getColumnKey(i), gradient);
                gradient = new GradientPaint(0, 0f, colours[i][1], 100, 0f, colours[i][0]);
                pplot.setSidePaint(data.getColumnKey(i), gradient);
            }
        }
    }

    // Tweak the title font size
    chart.getTitle().setFont(chart.getTitle().getFont().deriveFont(14f));
    chart.getTitle().setPadding(5, 0, 5, 0);
    chart.setAntiAlias(true);

    // shrink padding
    chart.setPadding(new RectangleInsets(0, 0, 0, 0));
}

From source file:com.xpn.xwiki.plugin.charts.ChartCustomizer.java

public static void customizePlot(Plot plot, ChartParams params) {
    if (params.get(ChartParams.PLOT_BACKGROUND_COLOR) != null) {
        plot.setBackgroundPaint(params.getColor(ChartParams.PLOT_BACKGROUND_COLOR));
    }//  w ww .j  a v a  2s .  co  m

    if (params.get(ChartParams.PLOT_BACKGROUND_ALPHA) != null) {
        plot.setBackgroundAlpha(params.getFloat(ChartParams.PLOT_BACKGROUND_ALPHA).floatValue());
    }

    if (params.get(ChartParams.PLOT_FOREGROUND_ALPHA) != null) {
        plot.setForegroundAlpha(params.getFloat(ChartParams.PLOT_FOREGROUND_ALPHA).floatValue());
    }

    if (params.get(ChartParams.PLOT_INSERTS) != null) {
        plot.setInsets(params.getRectangleInsets(ChartParams.PLOT_INSERTS));
    }

    if (params.get(ChartParams.PLOT_OUTLINE_COLOR) != null) {
        plot.setOutlinePaint(params.getColor(ChartParams.PLOT_OUTLINE_COLOR));
    }

    if (params.get(ChartParams.PLOT_OUTLINE_STROKE) != null) {
        plot.setOutlineStroke(params.getStroke(ChartParams.PLOT_OUTLINE_STROKE));
    }
}

From source file:daylightchart.options.chart.PlotOptions.java

/**
 * {@inheritDoc}/*from  w  w w.  j  a  va 2 s  .c o  m*/
 *
 * @see BaseChartOptions#updateChart(org.jfree.chart.JFreeChart)
 */
@Override
public void updateChart(final JFreeChart chart) {
    final Plot plot = chart.getPlot();

    plot.setBackgroundPaint(backgroundPaint);
    plot.setOutlinePaint(outlinePaint);
    plot.setOutlineStroke(outlineStroke);
    if (insets != null) {
        plot.setInsets(insets);
    }

    // Update axes
    Axis domainAxis = null;
    if (plot instanceof CategoryPlot) {
        final CategoryPlot p = (CategoryPlot) plot;
        domainAxis = p.getDomainAxis();
    } else if (plot instanceof XYPlot) {
        final XYPlot p = (XYPlot) plot;
        domainAxis = p.getDomainAxis();
    }
    if (domainAxis != null) {
        domainAxisOptions.setAxisProperties(domainAxis);
    }

    Axis rangeAxis = null;
    if (plot instanceof CategoryPlot) {
        final CategoryPlot p = (CategoryPlot) plot;
        rangeAxis = p.getRangeAxis();
    } else if (plot instanceof XYPlot) {
        final XYPlot p = (XYPlot) plot;
        rangeAxis = p.getRangeAxis();
    }
    if (rangeAxis != null) {
        rangeAxisOptions.setAxisProperties(rangeAxis);
    }

}

From source file:org.toobsframework.pres.chart.ChartUtil.java

public static void configurePlot(IRequest componentRequest, Plot plot,
        org.toobsframework.pres.chart.config.BasePlot plotDef, DomainAxisDef categoryAxisDef,
        RangeAxisDef valueAxisDef, Map params) {
    if (plotDef != null) {
        float foregroundAlpha = Float.parseFloat(
                ParameterUtil.resolveParam(componentRequest, plotDef.getForegroundAlpha(), params, "1.0")[0]);
        plot.setForegroundAlpha(foregroundAlpha);

        if (plot instanceof CategoryPlot && ParameterUtil.resolveParam(componentRequest,
                plotDef.getOrientation(), params, "horizontal")[0].equals("horizontal")) {
            ((CategoryPlot) plot).setOrientation(PlotOrientation.HORIZONTAL);
            boolean is3D = (ParameterUtil.resolveParam(componentRequest, plotDef.getIs3D(), params, "false")[0]
                    .equals("false") ? false : true);
            if (is3D) {
                ((CategoryPlot) plot).setRowRenderingOrder(SortOrder.DESCENDING);
                ((CategoryPlot) plot).setColumnRenderingOrder(SortOrder.DESCENDING);
            }/* ww  w  .  j  ava  2  s  .c o  m*/
        } else if (plot instanceof CategoryPlot) {
            ((CategoryPlot) plot).setOrientation(PlotOrientation.VERTICAL);
        }

        if (plotDef.getInsets() != null) {
            plot.setInsets(getRectangle(componentRequest, plotDef.getInsets(), params));
        }
        if (plot instanceof CategoryPlot && plotDef.getAxisOffsets() != null) {
            ((CategoryPlot) plot)
                    .setAxisOffset(getRectangle(componentRequest, plotDef.getAxisOffsets(), params));
        }

        if (plotDef.getBackgroundColor() != null) {
            plot.setBackgroundPaint(getColor(plotDef.getBackgroundColor()));
        }
        if (plot instanceof CategoryPlot && categoryAxisDef != null) {
            AxisLocation dLabelPos = axisLocations.get(ParameterUtil.resolveParam(componentRequest,
                    categoryAxisDef.getLocation(), params, "bottomOrLeft")[0]);
            if (dLabelPos != null) {
                ((CategoryPlot) plot).setDomainAxisLocation(dLabelPos);
            }
            ((CategoryPlot) plot).setDomainGridlinesVisible(categoryAxisDef.getShowGridlines());
            if (categoryAxisDef.getGridColor() != null) {
                ((CategoryPlot) plot).setDomainGridlinePaint(getColor(categoryAxisDef.getGridColor()));
            }
        }
        if (plot instanceof CategoryPlot && valueAxisDef != null) {
            AxisLocation rLabelPos = axisLocations.get(ParameterUtil.resolveParam(componentRequest,
                    valueAxisDef.getLocation(), params, "bottomOrRight")[0]);
            if (rLabelPos != null) {
                ((CategoryPlot) plot).setRangeAxisLocation(rLabelPos);
            }
            ((CategoryPlot) plot).setRangeGridlinesVisible(valueAxisDef.getShowGridlines());
            if (valueAxisDef.getGridColor() != null) {
                ((CategoryPlot) plot).setRangeGridlinePaint(getColor(valueAxisDef.getGridColor()));
            }
        }
    }
}

From source file:ch.zhaw.simulation.diagram.charteditor.DefaultPlotEditor.java

/**
 * Updates the plot properties to match the properties defined on the panel.
 * /*from   w  ww. j av  a 2  s . c  o  m*/
 * @param plot
 *            The plot.
 */
@SuppressWarnings("deprecation")
public void updatePlotProperties(Plot plot) {

    this.outlineStrokeSample.setStroke((Stroke) this.cbOutlineStroke.getSelectedItem());

    // set the plot properties...
    plot.setOutlinePaint(getOutlinePaint());
    plot.setOutlineStroke(getOutlineStroke());
    plot.setBackgroundPaint(getBackgroundPaint());
    plot.setInsets(getPlotInsets());

    // then the axis properties...
    if (this.domainAxisPropertyPanel != null) {
        Axis domainAxis = null;
        if (plot instanceof CategoryPlot) {
            CategoryPlot p = (CategoryPlot) plot;
            domainAxis = p.getDomainAxis();
        } else if (plot instanceof XYPlot) {
            XYPlot p = (XYPlot) plot;
            domainAxis = p.getDomainAxis();
        }
        if (domainAxis != null) {
            this.domainAxisPropertyPanel.setAxisProperties(domainAxis);
        }
    }

    if (this.rangeAxisPropertyPanel != null) {
        Axis rangeAxis = null;
        if (plot instanceof CategoryPlot) {
            CategoryPlot p = (CategoryPlot) plot;
            rangeAxis = p.getRangeAxis();
        } else if (plot instanceof XYPlot) {
            XYPlot p = (XYPlot) plot;
            rangeAxis = p.getRangeAxis();
        }
        if (rangeAxis != null) {
            this.rangeAxisPropertyPanel.setAxisProperties(rangeAxis);
        }
    }

    // Disabled because makes no sense for us
    // if (this.plotOrientation != null) {
    // if (plot instanceof CategoryPlot) {
    // CategoryPlot p = (CategoryPlot) plot;
    // p.setOrientation(this.plotOrientation);
    // } else if (plot instanceof XYPlot) {
    // XYPlot p = (XYPlot) plot;
    // p.setOrientation(this.plotOrientation);
    // }
    // }

    if (this.drawLines != null) {
        if (plot instanceof CategoryPlot) {
            CategoryPlot p = (CategoryPlot) plot;
            CategoryItemRenderer r = p.getRenderer();
            if (r instanceof LineAndShapeRenderer) {
                ((LineAndShapeRenderer) r).setLinesVisible(this.drawLines.booleanValue());
            }
        } else if (plot instanceof XYPlot) {
            XYPlot p = (XYPlot) plot;
            XYItemRenderer r = p.getRenderer();
            if (r instanceof StandardXYItemRenderer) {
                ((StandardXYItemRenderer) r).setPlotLines(this.drawLines.booleanValue());
            }
        }
    }

    if (this.drawShapes != null) {
        if (plot instanceof CategoryPlot) {
            CategoryPlot p = (CategoryPlot) plot;
            CategoryItemRenderer r = p.getRenderer();
            if (r instanceof LineAndShapeRenderer) {
                ((LineAndShapeRenderer) r).setShapesVisible(this.drawShapes.booleanValue());
            }
        } else if (plot instanceof XYPlot) {
            XYPlot p = (XYPlot) plot;
            XYItemRenderer r = p.getRenderer();
            if (r instanceof StandardXYItemRenderer) {
                ((StandardXYItemRenderer) r).setBaseShapesVisible(this.drawShapes.booleanValue());
            }
        }
    }

}

From source file:org.toobsframework.pres.chart.ChartBuilder.java

private Plot configurePlot(IRequest componentRequest, String id,
        org.toobsframework.pres.chart.config.Plot plotDef, Map params) throws ChartException {

    Plot plot = null;
    if (plotDef.getSubPlotCount() > 0) {
        boolean is3D = (ParameterUtil.resolveParam(componentRequest, plotDef.getIs3D(), params, "false")[0]
                .equals("false") ? false : true);
        int plotType = ChartUtil.getSupportedPlots().get(
                ParameterUtil.resolveParam(componentRequest, plotDef.getType(), params, "multiCategory")[0]);
        PlotOrientation orientation = (ParameterUtil.resolveParam(componentRequest, plotDef.getOrientation(),
                params, "vertical")[0].equals("horizontal") ? PlotOrientation.HORIZONTAL
                        : PlotOrientation.VERTICAL);
        switch (plotType) {
        case ChartUtil.PLOT_MULTICATEGORY_TYPE:
            plot = new MultiCategoryPlot();
            for (int p = 0; p < plotDef.getSubPlotCount(); p++) {
                ((MultiCategoryPlot) plot).add((CategoryPlot) this.configurePlot(componentRequest, id,
                        plotDef.getSubPlot(p), params, true, plotType, plotDef));
            }//from   w ww . j a va  2 s . co m
            ((MultiCategoryPlot) plot).setOrientation(orientation);
            ((MultiCategoryPlot) plot).setGap(plotDef.getGap());
            if (plotDef.getInsets() != null) {
                plot.setInsets(ChartUtil.getRectangle(componentRequest, plotDef.getInsets(), params));
            }
            break;
        case ChartUtil.PLOT_COMBINEDDOMAINCATEGORY_TYPE:
            CategoryAxis domainAxis = ChartUtil.createCategoryAxis(componentRequest, plotDef.getDomainAxisDef(),
                    params, is3D);
            plot = new CombinedDomainCategoryPlotEx(domainAxis);
            for (int p = 0; p < plotDef.getSubPlotCount(); p++) {
                ((CombinedDomainCategoryPlotEx) plot).add((CategoryPlot) this.configurePlot(componentRequest,
                        id, plotDef.getSubPlot(p), params, true, plotType, plotDef));
            }
            ((CombinedDomainCategoryPlotEx) plot).setOrientation(orientation);
            ((CombinedDomainCategoryPlotEx) plot).setGap(plotDef.getGap());
            if (plotDef.getInsets() != null) {
                plot.setInsets(ChartUtil.getRectangle(componentRequest, plotDef.getInsets(), params));
            }
            break;
        case ChartUtil.PLOT_COMBINEDRANGECATEGORY_TYPE:
            ValueAxis rangeAxis = createValueAxis(componentRequest, plotDef.getRangeAxisDef(), params, is3D);
            plot = new CombinedRangeCategoryPlotEx(rangeAxis);
            for (int p = 0; p < plotDef.getSubPlotCount(); p++) {
                ((CombinedRangeCategoryPlotEx) plot).add((CategoryPlot) this.configurePlot(componentRequest, id,
                        plotDef.getSubPlot(p), params, true, plotType, plotDef));
            }
            ((CombinedRangeCategoryPlotEx) plot).setOrientation(orientation);
            if (plotDef.getInsets() != null) {
                plot.setInsets(ChartUtil.getRectangle(componentRequest, plotDef.getInsets(), params));
            }
            break;
        }
    } else {
        plot = this.configurePlot(componentRequest, id, plotDef, params, false, -1, null);
    }

    return plot;
}

From source file:org.operamasks.faces.render.graph.ChartRenderer.java

protected void setChartStyles(JFreeChart chart, UIChart comp) {
    Plot plot = chart.getPlot();

    RectangleInsets insets = plot.getInsets();
    Double tm = comp.getTopMargin();
    Double lm = comp.getLeftMargin();
    Double bm = comp.getBottomMargin();
    Double rm = comp.getRightMargin();
    if (tm == null || tm < 0)
        tm = insets.getTop();/*from  www .ja v  a2  s .  co m*/
    if (lm == null || lm < 0)
        lm = insets.getLeft();
    if (bm == null || bm < 0)
        bm = insets.getBottom();
    if (rm == null || rm < 0)
        rm = insets.getRight();
    plot.setInsets(new RectangleInsets(tm, lm, bm, rm));

    Paint color = comp.getBackgroundColor();
    if (color != null) {
        chart.setBackgroundPaint(color);
    }

    Image image = loadImage(comp.getBackgroundImage());
    if (image != null) {
        chart.setBackgroundImage(image);
        chart.setBackgroundImageAlignment(getImageAlign(comp.getBackgroundImagePosition()));
        chart.setBackgroundImageAlpha(comp.getBackgroundImageAlpha());
    }

    color = comp.getPlotColor();
    if (color != null) {
        plot.setBackgroundPaint(color);
    }

    Float alpha;
    if ((alpha = comp.getBackgroundAlpha()) != null) {
        plot.setBackgroundAlpha(alpha);
    }
    if ((alpha = comp.getForegroundAlpha()) != null) {
        plot.setForegroundAlpha(alpha);
    }

    image = loadImage(comp.getPlotImage());
    if (image != null) {
        plot.setBackgroundImage(image);
        plot.setBackgroundImageAlignment(getImageAlign(comp.getPlotImagePosition()));
        plot.setBackgroundImageAlpha(comp.getBackgroundImageAlpha());
    }

    Paint[] colorPalette = comp.getColorPalette();
    if (colorPalette != null) {
        plot.setDrawingSupplier(new CustomDrawingSupplier(colorPalette));
    } else {
        plot.setDrawingSupplier(new CustomDrawingSupplier());
    }
}

From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java

/**
 *
 *//* w  w  w.  ja  v  a 2 s  .  co  m*/
protected void configurePlot(Plot plot, JRChartPlot jrPlot) {
    RectangleInsets padding = getPlotSettings().getPadding();
    if (padding != null)
        plot.setInsets(padding);

    Boolean plotOutlineVisible = getPlotSettings().getOutlineVisible();
    if (plotOutlineVisible == null || plotOutlineVisible.booleanValue()) {
        Paint outlinePaint = getPlotSettings().getOutlinePaint() == null ? null
                : getPlotSettings().getOutlinePaint().getPaint();
        if (outlinePaint != null)
            plot.setOutlinePaint(outlinePaint);

        Stroke plotOutlineStroke = getPlotSettings().getOutlineStroke();
        if (plotOutlineStroke != null)
            plot.setOutlineStroke(plotOutlineStroke);

        plot.setOutlineVisible(true);
    } else {
        plot.setOutlineVisible(false);
    }

    setPlotBackground(plot, jrPlot);
    setPlotDrawingDefaults(plot, jrPlot);

    if (plot instanceof CategoryPlot) {
        handleCategoryPlotSettings((CategoryPlot) plot, jrPlot);
    }

    if (plot instanceof XYPlot) {
        handleXYPlotSettings((XYPlot) plot, jrPlot);
    }

}