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

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

Introduction

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

Prototype

public void setOutlinePaint(Paint paint) 

Source Link

Document

Sets the paint used to draw the outline of the plot area 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  w  w  w .ja  v  a2  s.  c o  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 ww  .  jav  a2 s. c o  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(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:org.openfaces.component.chart.impl.plots.PlotUtil.java

public static void setupColorProperties(Chart chart, Plot plot) {
    StyleObjectModel cssChartViewModel = chart.getChartView().getStyleObjectModel();

    plot.setBackgroundPaint(cssChartViewModel.getBackground());

    StyleBorderModel border = cssChartViewModel.getBorder();
    plot.setOutlinePaint(
            border == null || border.isNone() ? cssChartViewModel.getBackground() : border.getColor());
}

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

/**
 * Sets the colours and gradients to be used when painting the given JFreeChart.
 * /*from  w  w w.jav a2s  .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:org.gvsig.gui.beans.graphic.GraphicChartPanel.java

public GraphicChartPanel() {
    dataset = new XYSeriesCollection();

    createChart();/*from   www .j  a  va2s  .c  o m*/

    initialize();

    Plot plot = this.jPanelChart.getChart().getPlot();
    plot.setOutlineStroke(new BasicStroke(1));
    plot.setOutlinePaint(Color.black);

    chart.setBackgroundPaint(Color.white);
    plot.setBackgroundPaint(new Color(245, 245, 245));
}

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

/**
 * {@inheritDoc}//  w  w  w .jav a2 s .  com
 *
 * @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.openfaces.component.chart.impl.configuration.PlotColorsConfigurator.java

public void configure(ConfigurablePlot configurablePlot, ChartView view) {
    StyleObjectModel cssChartViewModel = view.getStyleObjectModel();

    Plot plot = (Plot) configurablePlot;

    if (view.getBackgroundPaint() != null) {
        plot.setBackgroundPaint(null);/*from   w ww .  j av  a  2s.c  om*/
    } else {
        plot.setBackgroundPaint(cssChartViewModel.getBackground());
    }

    StyleBorderModel border = cssChartViewModel.getBorder();
    plot.setOutlinePaint(
            border == null || border.isNone() ? cssChartViewModel.getBackground() : border.getColor());
}

From source file:org.jfree.chart.demo.XYStepAreaChartDemo.java

/**
 * Creates a new demo.//from   w w w.java 2s. com
 *
 * @param title  the frame title.
 */
public XYStepAreaChartDemo(final String title) {

    super(title);

    this.xySeries = new XYSeries("Some data");
    for (int i = 0; i < TEST_DATA.length; i++) {
        this.xySeries.add((Integer) TEST_DATA[i][0], (Integer) TEST_DATA[i][1]);
    }

    final XYSeriesCollection dataset = new XYSeriesCollection(this.xySeries);

    final JFreeChart chart = createChart(dataset);

    this.chartPanel = new ChartPanel(chart);

    // allow zooming
    //        this.chartPanel.setHorizontalZoom(true);
    //        this.chartPanel.setVerticalZoom(true);

    // size
    this.chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    // make stroke more striking
    final Plot plot = this.chartPanel.getChart().getPlot();
    plot.setOutlineStroke(new BasicStroke(2));
    plot.setOutlinePaint(Color.magenta);

    // add some components to make options changable
    final JPanel main = new JPanel(new BorderLayout());
    final JPanel optionsPanel = new JPanel();

    final String[] options = { ORIENT_VERT, ORIENT_HORIZ };
    this.orientationComboBox = new JComboBox(options);
    this.orientationComboBox.addActionListener(this);
    optionsPanel.add(this.orientationComboBox);

    this.outlineCheckBox = new JCheckBox("Outline");
    this.outlineCheckBox.addActionListener(this);
    optionsPanel.add(this.outlineCheckBox);

    optionsPanel.add(new JLabel("Base"));
    this.rangeBaseTextField = new JTextField("0", 5);
    this.rangeBaseTextField.addActionListener(this);
    optionsPanel.add(this.rangeBaseTextField);

    this.nullValuesCheckBox = new JCheckBox("NULL values");
    this.nullValuesCheckBox.addActionListener(this);
    optionsPanel.add(this.nullValuesCheckBox);

    main.add(optionsPanel, BorderLayout.SOUTH);
    main.add(this.chartPanel);
    setContentPane(main);
}

From source file:com.rcp.wbw.demo.editor.SWTPlotEditor.java

/**
 * Updates the plot properties to match the properties
 * defined on the panel./*from   w  ww  .ja  v a  2  s. c om*/
 * 
 * @param plot
 *            The plot.
 */
public void updatePlotProperties(Plot plot) {
    // set the plot properties...
    plot.setBackgroundPaint(SWTUtils.toAwtColor(getBackgroundPaint()));
    plot.setOutlinePaint(SWTUtils.toAwtColor(getOutlinePaint()));
    plot.setOutlineStroke(getOutlineStroke());

    // set 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);
    }
    if (this.plotAppearance.getPlotOrientation() != null) {
        if (plot instanceof CategoryPlot) {
            CategoryPlot p = (CategoryPlot) plot;
            p.setOrientation(this.plotAppearance.getPlotOrientation());
        } else if (plot instanceof XYPlot) {
            XYPlot p = (XYPlot) plot;
            p.setOrientation(this.plotAppearance.getPlotOrientation());
        }
    }
}

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  va 2  s.c o  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));
    }
}