Example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setAutoPopulateSeriesPaint

List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setAutoPopulateSeriesPaint

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setAutoPopulateSeriesPaint.

Prototype

public void setAutoPopulateSeriesPaint(boolean auto) 

Source Link

Document

Sets the flag that controls whether or not the series paint list is automatically populated when #lookupSeriesPaint(int) is called.

Usage

From source file:ec.nbdemetra.benchmarking.calendarization.CalendarizationChartView.java

private static JFreeChart createChart(String title) {
    JFreeChart result = ChartFactory.createXYLineChart("", "", "", Charts.emptyXYDataset(),
            PlotOrientation.VERTICAL, false, false, false);
    result.setPadding(TsCharts.CHART_PADDING);

    result.setTitle(new TextTitle(title, new Font("SansSerif", Font.PLAIN, 12)));

    XYPlot plot = result.getXYPlot();//from   w ww  .j  av  a 2  s  .  co m
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    LinesThickness linesThickness = LinesThickness.Thin;

    XYLineAndShapeRenderer daily = new XYLineAndShapeRenderer(true, false);
    daily.setAutoPopulateSeriesPaint(false);

    daily.setAutoPopulateSeriesStroke(false);
    daily.setBaseStroke(TsCharts.getStrongStroke(linesThickness));
    plot.setRenderer(DAILY_INDEX, daily);

    XYDifferenceRenderer difference = new XYDifferenceRenderer();
    difference.setAutoPopulateSeriesPaint(false);
    difference.setAutoPopulateSeriesStroke(false);
    difference.setBaseStroke(TsCharts.getNormalStroke(linesThickness));
    plot.setRenderer(DIFF_INDEX, difference);

    XYLineAndShapeRenderer smooth = new XYLineAndShapeRenderer(true, false);
    smooth.setAutoPopulateSeriesPaint(false);
    smooth.setAutoPopulateSeriesStroke(false);
    smooth.setBaseStroke(TsCharts.getStrongStroke(linesThickness));
    plot.setRenderer(SMOOTH_INDEX, smooth);

    DateAxis domainAxis = new DateAxis();
    domainAxis.setTickMarkPosition(DateTickMarkPosition.START);
    domainAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setDomainAxis(domainAxis);

    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setRangeAxis(rangeAxis);

    return result;
}

From source file:org.jax.maanova.plot.PlotUtil.java

/**
 * Create a simple XY renderer which can be used for scatter plots
 * @return  the renderer/*from   w  w  w . j a v  a 2s  . c  o m*/
 */
public static XYLineAndShapeRenderer createSimpleScatterPlotRenderer() {
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true);

    renderer.setAutoPopulateSeriesShape(false);
    renderer.setAutoPopulateSeriesOutlinePaint(false);
    renderer.setAutoPopulateSeriesOutlineStroke(false);
    renderer.setAutoPopulateSeriesPaint(false);

    renderer.setBaseShape(new Ellipse2D.Float(-PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS / 2F,
            -PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS / 2F, PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS,
            PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS));

    renderer.setUseOutlinePaint(true);
    renderer.setBaseOutlinePaint(Color.BLACK);
    renderer.setBaseOutlineStroke(new BasicStroke(0.25F));

    renderer.setSeriesPaint(0, new Color(0x55, 0x55, 0xFF)); // blue
    renderer.setSeriesPaint(1, new Color(0xFF, 0x55, 0x55)); // red

    return renderer;
}

From source file:org.jax.maanova.plot.PlotUtil.java

/**
 * Create a simple monochrome XY renderer which can be used for scatter plots
 * @return  the renderer/*from w ww .ja va2s.co m*/
 */
public static XYLineAndShapeRenderer createMonochromeScatterPlotRenderer() {
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true);

    renderer.setAutoPopulateSeriesShape(false);
    renderer.setAutoPopulateSeriesOutlinePaint(false);
    renderer.setAutoPopulateSeriesOutlineStroke(false);
    renderer.setAutoPopulateSeriesPaint(false);

    renderer.setBaseShape(new Ellipse2D.Float(-PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS / 2F,
            -PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS / 2F, PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS,
            PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS));

    renderer.setUseOutlinePaint(true);
    renderer.setBaseOutlinePaint(Color.BLACK);
    renderer.setBaseOutlineStroke(new BasicStroke(0.25F));

    renderer.clearSeriesPaints(false);
    renderer.setBasePaint(new Color(0x55, 0x55, 0xFF)); // blue

    return renderer;
}

From source file:ec.ui.view.DistributionView.java

private static JFreeChart createDistributionViewChart() {
    XYPlot plot = new XYPlot();

    XYLineAndShapeRenderer dRenderer = new XYSplineRenderer();
    dRenderer.setBaseShapesVisible(false);
    dRenderer.setAutoPopulateSeriesPaint(false);
    dRenderer.setAutoPopulateSeriesStroke(false);
    dRenderer.setBaseStroke(TsCharts.getStrongStroke(LinesThickness.Thin));
    dRenderer.setDrawSeriesLineAsPath(true); // not sure if useful
    plot.setDataset(DISTRIBUTION_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(DISTRIBUTION_INDEX, dRenderer);

    XYBarRenderer hRenderer = new XYBarRenderer();
    hRenderer.setShadowVisible(false);//from  ww  w.  ja v  a 2  s.com
    hRenderer.setDrawBarOutline(true);
    hRenderer.setAutoPopulateSeriesPaint(false);
    hRenderer.setAutoPopulateSeriesOutlinePaint(false);
    hRenderer.setBaseSeriesVisibleInLegend(false);
    plot.setDataset(HISTOGRAM_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(HISTOGRAM_INDEX, hRenderer);

    NumberAxis domainAxis = new NumberAxis();
    domainAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setDomainAxis(domainAxis);
    plot.setDomainGridlinesVisible(false);

    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    rangeAxis.setTickUnit(new NumberTickUnit(0.05));
    rangeAxis.setNumberFormatOverride(new DecimalFormat("0.###"));
    plot.setRangeAxis(rangeAxis);

    plot.mapDatasetToDomainAxis(0, 0);
    plot.mapDatasetToRangeAxis(0, 0);
    plot.mapDatasetToDomainAxis(1, 0);
    plot.mapDatasetToRangeAxis(1, 0);

    JFreeChart result = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    result.setPadding(TsCharts.CHART_PADDING);
    result.getTitle().setFont(TsCharts.CHART_TITLE_FONT);
    result.getLegend().setFrame(BlockBorder.NONE);
    result.getLegend().setBackgroundPaint(null);
    return result;
}

From source file:ec.nbdemetra.chainlinking.outlineview.ChainLinkingChart.java

private JFreeChart createChart() {
    XYPlot plot = new XYPlot();

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setAutoPopulateSeriesStroke(false);
    renderer.setBaseStroke(TsCharts.getStrongStroke(ITsChart.LinesThickness.Thin));
    plot.setRenderer(renderer);/* www . ja  v a  2  s  .  c om*/

    JFreeChart r = new JFreeChart("", TsCharts.CHART_TITLE_FONT, plot, true);
    r.setPadding(TsCharts.CHART_PADDING);
    r.setTitle("Chain Linking");

    return r;
}

From source file:ec.nbdemetra.sa.revisionanalysis.RevisionAnalysisChart.java

private JFreeChart createChart() {
    XYPlot plot = new XYPlot();

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setAutoPopulateSeriesStroke(false);
    renderer.setBaseStroke(TsCharts.getStrongStroke(ITsChart.LinesThickness.Thin));
    plot.setRenderer(renderer);// ww w  .  j  av  a2 s . c  o m

    JFreeChart result = new JFreeChart("", TsCharts.CHART_TITLE_FONT, plot, true);
    result.setPadding(TsCharts.CHART_PADDING);
    result.setTitle("Standard deviations");

    return result;
}

From source file:org.jfree.eastwood.ChartEngine.java

/**
 * Creates a scatter chart.// w w w . jav a  2 s.  com
 *
 * @return A scatter chart.
 */
private static JFreeChart createScatterChart() {
    JFreeChart chart = ChartFactory.createScatterPlot(null, null, null, null, PlotOrientation.VERTICAL, false,
            false, false);
    chart.setBackgroundPaint(Color.white);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setOutlinePaint(null);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBasePaint(new Color(0x76A4FB));
    renderer.setAutoPopulateSeriesPaint(false);

    GValueAxis xAxis = new GValueAxis();
    xAxis.setTickLabelsVisible(false);
    xAxis.setTickMarksVisible(false);
    plot.setDomainAxis(xAxis);
    GValueAxis yAxis = new GValueAxis();
    yAxis.setTickLabelsVisible(false);
    yAxis.setTickMarksVisible(false);
    plot.setRangeAxis(yAxis);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    return chart;
}

From source file:org.jfree.eastwood.ChartEngine.java

/**
 * Creates a line chart.//w  w w.  j  av a  2  s. c  om
 *
 * @return A line chart.
 */
private static JFreeChart createLineChart() {
    GXYPlot plot = new GXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setBaseShapesVisible(false);
    plot.setRenderer(renderer);
    JFreeChart chart = new JFreeChart(plot);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);
    renderer.setBasePaint(new Color(0xFF9900));
    renderer.setBaseStroke(new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));

    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setItemLabelsVisible(true);
    renderer.setItemLabelGenerator(new GXYPlot.LabelGenerator());
    renderer.setItemLabelPaint(new Color(0x333435));

    renderer.setPositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT));

    GValueAxis xAxis = new GValueAxis();
    xAxis.setTickLabelsVisible(false);
    xAxis.setTickMarksVisible(false);
    plot.setDomainAxis(xAxis);
    GValueAxis yAxis = new GValueAxis();
    yAxis.setTickLabelsVisible(false);
    yAxis.setTickMarksVisible(false);
    plot.setRangeAxis(yAxis);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    return chart;
}

From source file:org.jfree.eastwood.ChartEngine.java

/**
 * Creates a sparkline chart./*from w  w  w  . j  av  a 2  s.c om*/
 *
 * @return A sparkline chart.
 */
private static JFreeChart createSparklineChart() {
    GXYPlot plot = new GXYPlot();
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setBaseShapesVisible(false);
    plot.setRenderer(renderer);
    JFreeChart chart = new JFreeChart(plot);
    chart.setPadding(RectangleInsets.ZERO_INSETS);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);
    renderer.setBasePaint(new Color(0xFF9900));
    renderer.setBaseStroke(new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
    renderer.setAutoPopulateSeriesPaint(false);

    GValueAxis xAxis = new GValueAxis();
    xAxis.setVisible(false);
    plot.setDomainAxis(xAxis);
    GValueAxis yAxis = new GValueAxis();
    yAxis.setVisible(false);
    plot.setRangeAxis(yAxis);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    return chart;
}

From source file:userinterface.graph.Graph.java

/**
 * Initialises the GraphModel's series and canvas list. Also starts off the
 * graph update timer (one per chart).//from   ww  w . ja  v a  2  s  . c  om
 * 
 * @param title
 *            Title of the graph.
 */
public Graph(String title) {
    super(ChartFactory.createXYLineChart(title, "X", "Y", new XYSeriesCollection(), PlotOrientation.VERTICAL,
            true, true, false));

    graphCache = new HashMap<SeriesKey, LinkedList<XYDataItem>>();
    keyToSeries = new HashMap<SeriesKey, XYSeries>();
    keyToGraphSeries = new HashMap<SeriesKey, SeriesSettings>();
    graphTitle = new MultipleLineStringSetting("title", title, "The main title heading for the chart.", this,
            false);
    titleFont = new FontColorSetting("title font",
            new FontColorPair(new Font("SansSerif", Font.PLAIN, 14), Color.black),
            "The font for the chart's title", this, false);
    legendVisible = new BooleanSetting("legend visible?", new Boolean(true),
            "Should the legend, which displays all of the series headings, be displayed?", this, false);

    String[] choices = { "Left", "Right", "Bottom", "Top" };
    legendPosition = new ChoiceSetting("legend position", choices, choices[RIGHT], "The position of the legend",
            this, false);
    legendFont = new FontColorSetting("legend font",
            new FontColorPair(new Font("SansSerif", Font.PLAIN, 11), Color.black), "The font for the legend",
            this, false);

    // Some easy references
    chart = super.getChart();
    plot = chart.getXYPlot();
    plot.setBackgroundPaint((Paint) Color.white);
    seriesCollection = (XYSeriesCollection) plot.getDataset();

    xAxisSettings = new AxisSettings("X", true, this);
    yAxisSettings = new AxisSettings("Y", false, this);

    xAxisSettings.addObserver(this);
    yAxisSettings.addObserver(this);

    displaySettings = new DisplaySettings(this);
    displaySettings.addObserver(this);

    seriesList = new SeriesSettingsList(this);

    // create a regular XY line chart
    XYItemRenderer r = plot.getRenderer();
    // if possible, try to match the old grapher
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
        renderer.setAutoPopulateSeriesPaint(true);
        renderer.setAutoPopulateSeriesShape(true);
    }

    plot.setDrawingSupplier(new DefaultDrawingSupplier(SeriesSettings.DEFAULT_PAINTS,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, SeriesSettings.DEFAULT_SHAPES));

    super.setPopupMenu(null);

    /* Make sure the graph resembles its default settings. */
    updateGraph();

    // schedule a periodic timer for graph updates
    new java.util.Timer().scheduleAtFixedRate(new GraphUpdateTask(), 0, // start now
            updateInterval);
}