Example usage for org.jfree.chart.plot XYPlot getRenderer

List of usage examples for org.jfree.chart.plot XYPlot getRenderer

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot getRenderer.

Prototype

public XYItemRenderer getRenderer(int index) 

Source Link

Document

Returns the renderer with the specified index, or null .

Usage

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

@Override
protected void onColorSchemeChange() {
    XYPlot plot = chartPanel.getChart().getXYPlot();
    plot.setBackgroundPaint(themeSupport.getPlotColor());
    plot.setDomainGridlinePaint(themeSupport.getGridColor());
    plot.setRangeGridlinePaint(themeSupport.getGridColor());
    chartPanel.getChart().setBackgroundPaint(themeSupport.getBackColor());

    XYLineAndShapeRenderer main = (XYLineAndShapeRenderer) plot.getRenderer(DAILY_INDEX);
    main.setBasePaint(themeSupport.getLineColor(DAILY_COLOR));

    XYDifferenceRenderer difference = ((XYDifferenceRenderer) plot.getRenderer(DIFF_INDEX));
    difference.setPositivePaint(themeSupport.getAreaColor(DIFF_COLOR));
    difference.setNegativePaint(themeSupport.getAreaColor(DIFF_COLOR));
    difference.setBasePaint(themeSupport.getLineColor(DIFF_COLOR));

    XYLineAndShapeRenderer smooth = (XYLineAndShapeRenderer) plot.getRenderer(SMOOTH_INDEX);
    smooth.setBasePaint(themeSupport.getLineColor(SMOOTH_COLOR));
}

From source file:be.nbb.demetra.dfm.output.ConfidenceGraph.java

private void onVisibilityChange() {
    XYPlot plot = chartPanel.getChart().getXYPlot();
    XYLineAndShapeRenderer original = (XYLineAndShapeRenderer) plot.getRenderer(ORIGINAL_DATA_INDEX);
    original.setSeriesVisible(0, originalVisible);
}

From source file:no.met.jtimeseries.netcdf.plot.SimplePlotProvider.java

@Override
public XYPlot getPlot(List<NumberPhenomenon> dataList) {

    XYPlot plot = new XYPlot();

    plot.setDomainAxis(getDomainAxis(dataList));

    Map<String, Integer> axes = createRangeAxes(dataList, plot);

    for (int i = 0; i < dataList.size(); i++) {
        NumberPhenomenon phenomenon = dataList.get(i);
        //addTimeSeries(plot, phenomenon, i, colors[i % colors.length]);

        plot.setDataset(i, getTimeSeries(phenomenon));
        plot.setRenderer(i, new XYSplineRenderer());
        plot.getRenderer(i).setSeriesPaint(0, colors[i % colors.length]);

        plot.mapDatasetToRangeAxis(i, axes.get(phenomenon.getPhenomenonUnit()));
    }/*  w  w  w  . jav  a2s .  com*/

    return plot;
}

From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.MarkerTimeChartDecorator.java

/**
 * Creates a legend item block.//from w  w  w .  j a v a 2  s  .c o  m
 * 
 * @param item
 *            the legend item.
 * 
 * @return The block.
 */
protected void createLegendBlock(BlockContainer blockcontainerLabel) {

    XYPlot xyplot = (XYPlot) report.getPlot();

    int nbRenderer = xyplot.getDatasetCount();
    BlockContainer blockcontainer = new BlockContainer(new BorderArrangement());
    if (nbRenderer > 1) {
        BlockContainer oldLegendBlockContainer = new BlockContainer(
                new FlowArrangement(HorizontalAlignment.LEFT, VerticalAlignment.TOP, 2.0D, 2.0D));
        for (int i = 0; i < nbRenderer; i++) {
            LegendTitle legendtitle = new LegendTitle(xyplot.getRenderer(i));
            legendtitle.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
            legendtitle.setFrame(new LineBorder());
            legendtitle.setBackgroundPaint(ChartColor.WHITE);
            oldLegendBlockContainer.add(legendtitle);
        }

        blockcontainer.add(oldLegendBlockContainer, RectangleEdge.LEFT);
    } else {
        LegendTitle legendtitle = new LegendTitle(xyplot.getRenderer(0));
        legendtitle.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
        legendtitle.setFrame(new LineBorder());
        legendtitle.setBackgroundPaint(ChartColor.WHITE);
        blockcontainer.add(legendtitle, RectangleEdge.LEFT);
    }

    LegendTitle legendtitle1 = new LegendTitle(xyplot.getRenderer());
    legendtitle1.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
    legendtitle1.setFrame(new LineBorder());
    legendtitle1.setBackgroundPaint(ChartColor.WHITE);
    legendtitle1.setWrapper(blockcontainerLabel);

    blockcontainer.add(legendtitle1, RectangleEdge.RIGHT);
    blockcontainer.add(new EmptyBlock(1000D, 0.0D));

    CompositeTitle compositetitle = new CompositeTitle(blockcontainer);
    compositetitle.setPosition(RectangleEdge.BOTTOM);
    report.clearSubtitles();
    report.addSubtitle(compositetitle);
}

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

@Override
protected void onColorSchemeChange() {
    XYPlot plot = chartPanel.getChart().getXYPlot();
    plot.setBackgroundPaint(themeSupport.getPlotColor());
    plot.setDomainGridlinePaint(themeSupport.getGridColor());
    plot.setRangeGridlinePaint(themeSupport.getGridColor());
    chartPanel.getChart().setBackgroundPaint(themeSupport.getBackColor());

    plot.getRenderer(HISTOGRAM_INDEX).setBasePaint(themeSupport.getAreaColor(HISTOGRAM_COLOR));
    plot.getRenderer(HISTOGRAM_INDEX).setBaseOutlinePaint(themeSupport.getLineColor(HISTOGRAM_COLOR));
    plot.getRenderer(DISTRIBUTION_INDEX).setBasePaint(themeSupport.getLineColor(DISTRIBUTION_COLOR));
}

From source file:org.interpss.chart.dstab.SimpleOneStateChart.java

/**
 * create the chart based on the data attributes
 * /*from w  w w  .j  a  va2s . c  o  m*/
 */
public void createChart() {
    final JFreeChart chart = ChartFactory.createXYLineChart(plotTitle, xLabel, yLabel,
            createXYDataSet(xDataAry, yDataAry, yDataLabel), PlotOrientation.VERTICAL, true, false, false);

    final XYPlot plot = (XYPlot) chart.getPlot();
    final StandardXYItemRenderer renderer = new StandardXYItemRenderer();
    renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    plot.setRenderer(renderer);

    //NumberAxis axis_x = (NumberAxis) plot.getDomainAxis();
    //axis_x.setRangeAboutValue(12.0, 24.0);

    final NumberAxis axisLeft = (NumberAxis) plot.getRangeAxis();
    axisLeft.setAutoRangeIncludesZero(false);
    axisLeft.setAutoRangeMinimumSize(autoRangeMinimumSize);

    final XYItemRenderer v_renderer = plot.getRenderer(0);
    v_renderer.setSeriesPaint(0, yColor);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(Chart_Width, Chart_Height));
    setContentPane(chartPanel);
}

From source file:be.nbb.demetra.dfm.output.FactorChart.java

@Override
protected void onColorSchemeChange() {
    XYPlot plot = chartPanel.getChart().getXYPlot();
    plot.setBackgroundPaint(themeSupport.getPlotColor());
    plot.setDomainGridlinePaint(themeSupport.getGridColor());
    plot.setRangeGridlinePaint(themeSupport.getGridColor());
    chartPanel.getChart().setBackgroundPaint(themeSupport.getBackColor());

    XYLineAndShapeRenderer factor = (XYLineAndShapeRenderer) plot.getRenderer(FACTOR_INDEX);
    factor.setBasePaint(themeSupport.getLineColor(FACTOR_COLOR));

    XYLineAndShapeRenderer filtered = (XYLineAndShapeRenderer) plot.getRenderer(FILTERED_INDEX);
    filtered.setBasePaint(themeSupport.getLineColor(FILTERED_COLOR));

    XYDifferenceRenderer difference = ((XYDifferenceRenderer) plot.getRenderer(DIFFERENCE_INDEX));
    Color diffArea = SwingColorSchemeSupport.withAlpha(themeSupport.getAreaColor(DIFFERENCE_COLOR), 150);
    difference.setPositivePaint(diffArea);
    difference.setNegativePaint(diffArea);
    difference.setBasePaint(themeSupport.getLineColor(DIFFERENCE_COLOR));
}

From source file:uk.co.moonsit.sockets.GraphClient.java

private void setSeriesColors(XYPlot plot) {
    int colorIndex = 0;

    for (int i = 0; i < plot.getDatasetCount(); i++) {
        if (plot.getDataset(i) == null) {
            continue;
        }//from  w  w w  .  j a v  a2 s  .c om
        for (int ii = 0; ii < plot.getDataset(i).getSeriesCount(); ii++) {
            plot.getRenderer(i).setSeriesPaint(ii, getSeriesColor(colorIndex++));
            //chart.getXYPlot().getRenderer(i).setSeriesStroke(                    ii,new BasicStroke(NORMAL_SERIES_LINE_WEIGHT, BasicStroke.CAP_BUTT,  BasicStroke.JOIN_BEVEL));
        }
    }

}

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

@Override
protected void onColorSchemeChange() {
    XYPlot plot = chartPanel.getChart().getXYPlot();
    plot.setBackgroundPaint(themeSupport.getPlotColor());
    plot.setDomainGridlinePaint(themeSupport.getGridColor());
    plot.setRangeGridlinePaint(themeSupport.getGridColor());
    chartPanel.getChart().setBackgroundPaint(themeSupport.getBackColor());

    XYLineAndShapeRenderer main = (XYLineAndShapeRenderer) plot.getRenderer(MAIN_INDEX);
    main.setBasePaint(themeSupport.getLineColor(MAIN_COLOR));

    XYDifferenceRenderer difference = ((XYDifferenceRenderer) plot.getRenderer(DIFFERENCE_INDEX));
    Color diffArea = SwingColorSchemeSupport.withAlpha(themeSupport.getAreaColor(DIFFERENCE_COLOR), 150);
    difference.setPositivePaint(diffArea);
    difference.setNegativePaint(diffArea);
    difference.setBasePaint(themeSupport.getLineColor(DIFFERENCE_COLOR));

    Collection<Marker> markers = (Collection<Marker>) plot.getDomainMarkers(Layer.FOREGROUND);
    if (!Jdk6.Collections.isNullOrEmpty(markers)) {
        Color markerColor = themeSupport.getLineColor(DATE_MARKER_COLOR);
        for (Marker o : markers) {
            o.setPaint(markerColor);/*w  w  w .  j a  v a  2 s  . c  o m*/
        }
    }

    Collection<Marker> intervalMarkers = (Collection<Marker>) plot.getDomainMarkers(Layer.BACKGROUND);
    if (!Jdk6.Collections.isNullOrEmpty(intervalMarkers)) {
        Color markerColor = themeSupport.getLineColor(KnownColor.ORANGE);
        for (Marker o : intervalMarkers) {
            o.setPaint(markerColor);
        }
    }
}

From source file:org.interpss.chart.dist.LoadScheduleChart.java

public void createChart() {
    final JFreeChart chart = ChartFactory.createXYLineChart(plotTitle, xLabel, voltYLabel,
            createDataSet(voltDataAry, voltDataLabel), PlotOrientation.VERTICAL, true, false, false);

    final XYPlot plot = (XYPlot) chart.getPlot();
    final XYStepRenderer renderer = new XYStepRenderer();
    renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    plot.setRenderer(renderer);// ww w.j a v  a  2  s .com

    //NumberAxis axis_x = (NumberAxis) plot.getDomainAxis();
    //axis_x.setRangeAboutValue(12.0, 24.0);

    final NumberAxis axisLeft = (NumberAxis) plot.getRangeAxis();
    axisLeft.setAutoRangeIncludesZero(false);
    axisLeft.setAutoRangeMinimumSize(1.0);

    final NumberAxis axisRight = new NumberAxis(pqYLabel);
    axisRight.setAutoRangeIncludesZero(false);
    axisRight.setAutoRangeMinimumSize(1.0);
    plot.setRangeAxis(1, axisRight);

    final XYItemRenderer v_renderer = plot.getRenderer(0);
    v_renderer.setSeriesPaint(0, vColor);

    plot.setDataset(1, createDataSet(pDataAry, pDataLabel));
    plot.mapDatasetToRangeAxis(1, 1);
    final XYStepRenderer p_renderer = new XYStepRenderer();
    p_renderer.setSeriesPaint(0, pColor);
    p_renderer.setBaseShapesVisible(false);
    plot.setRenderer(1, p_renderer);

    plot.setDataset(2, createDataSet(qDataAry, qDataLabel));
    plot.mapDatasetToRangeAxis(2, 1);
    final XYStepRenderer q_renderer = new XYStepRenderer();
    q_renderer.setSeriesPaint(0, qColor);
    q_renderer.setBaseShapesVisible(false);
    plot.setRenderer(2, q_renderer);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(Chart_Width, Chart_Height));
    setContentPane(chartPanel);
}