Example usage for org.jfree.chart.plot DrawingSupplier getNextPaint

List of usage examples for org.jfree.chart.plot DrawingSupplier getNextPaint

Introduction

In this page you can find the example usage for org.jfree.chart.plot DrawingSupplier getNextPaint.

Prototype

public Paint getNextPaint();

Source Link

Document

Returns the next paint in a sequence maintained by the supplier.

Usage

From source file:audio.cords.old.RegressionDemo.java

private static JFreeChart createChart(XYSeriesCollection data) {
    JFreeChart chart = ChartFactory.createScatterPlot(null, "X", "Y", data, PlotOrientation.VERTICAL, true,
            false, false);//from  www. j  av a2 s .c om
    XYPlot plot = (XYPlot) chart.getPlot();
    XYItemRenderer scatterRenderer = plot.getRenderer();
    StandardXYItemRenderer regressionRenderer = new StandardXYItemRenderer();
    regressionRenderer.setBaseSeriesVisibleInLegend(false);
    plot.setDataset(1, regress(data));
    plot.setRenderer(1, regressionRenderer);
    DrawingSupplier ds = plot.getDrawingSupplier();
    for (int i = 0; i < data.getSeriesCount(); i++) {
        Paint paint = ds.getNextPaint();
        scatterRenderer.setSeriesPaint(i, paint);
        regressionRenderer.setSeriesPaint(i, paint);
    }
    return chart;
}

From source file:audio.cords.SimplestChart.java

private static JFreeChart createChart(XYSeriesCollection data) {
    JFreeChart chart = ChartFactory.createScatterPlot(null, "X", "Y", data, PlotOrientation.VERTICAL, true,
            false, false);//from ww w  . j ava 2 s .c o m
    XYPlot plot = (XYPlot) chart.getPlot();
    XYItemRenderer scatterRenderer = plot.getRenderer();

    //        plot.getDomainAxis().resizeRange(2);
    //        plot.getRangeAxis().resizeRange(2);
    plot.zoom(2);

    //StandardXYItemRenderer regressionRenderer = new StandardXYItemRenderer();
    //regressionRenderer.setBaseSeriesVisibleInLegend(false);
    //plot.setDataset(1, regress(data));
    //plot.setRenderer(1, regressionRenderer);
    DrawingSupplier ds = plot.getDrawingSupplier();
    for (int i = 0; i < data.getSeriesCount(); i++) {
        Paint paint = ds.getNextPaint();
        scatterRenderer.setSeriesPaint(i, paint);
        //regressionRenderer.setSeriesPaint(i, paint);
    }
    return chart;
}

From source file:pisco.batch.visu.BatchingChartFactory.java

public final static Paint[] makePalette(int n) {
    final DrawingSupplier drawingSupplier = ChocoColor.createDefaultDrawingSupplier();
    Paint[] palette = new Color[n];
    for (int i = 0; i < n; i++) {
        palette[i] = drawingSupplier.getNextPaint();
    }//from   w w  w  .  jav a 2s. c o m
    return palette;
}

From source file:dr.PlotRenderer.java

public PlotRenderer(XYPlot plot, PCADataset dataset) {
    super(false, true);

    this.setSeriesShape(0, dataPointsShape);

    paintsForGroups = new Paint[dataset.getItemCount(1)];
    DrawingSupplier drawSupp = plot.getDrawingSupplier();
    for (int groupNumber = 0; groupNumber < dataset.getItemCount(1); groupNumber++) {

        Paint nextPaint = drawSupp.getNextPaint();
        while (isAvoidColor((Color) nextPaint)) {
            nextPaint = drawSupp.getNextPaint();
        }//from   w  ww  .j a  v  a 2s  . c  o m

        paintsForGroups[groupNumber] = nextPaint;

    }

}

From source file:net.sf.mzmine.modules.peaklistmethods.dataanalysis.projectionplots.ProjectionPlotRenderer.java

public ProjectionPlotRenderer(XYPlot plot, ProjectionPlotDataset dataset) {
    super(false, true);
    this.dataset = dataset;
    this.setSeriesShape(0, dataPointsShape);

    paintsForGroups = new Paint[dataset.getNumberOfGroups()];
    DrawingSupplier drawSupp = plot.getDrawingSupplier();
    for (int groupNumber = 0; groupNumber < dataset.getNumberOfGroups(); groupNumber++) {

        Paint nextPaint = drawSupp.getNextPaint();
        while (isAvoidColor((Color) nextPaint))
            nextPaint = drawSupp.getNextPaint();

        paintsForGroups[groupNumber] = nextPaint;

    }/* w  w w. ja v  a 2s.com*/

}

From source file:guineu.modules.dataanalysis.PCA.ProjectionPlotRenderer.java

public ProjectionPlotRenderer(XYPlot plot, ProjectionPlotDataset dataset) {
    super(false, true);
    this.dataset = dataset;
    this.setSeriesShape(0, dataPointsShape);

    paintsForGroups = new Paint[dataset.getNumberOfGroups()];
    DrawingSupplier drawSupp = plot.getDrawingSupplier();
    for (int groupNumber = 0; groupNumber < dataset.getNumberOfGroups(); groupNumber++) {

        Paint nextPaint = drawSupp.getNextPaint();
        while (isAvoidColor((Color) nextPaint)) {
            nextPaint = drawSupp.getNextPaint();
        }//w w w  .ja v a2 s . c  o  m

        paintsForGroups[groupNumber] = nextPaint;

    }

}

From source file:org.tsho.dmc2.core.chart.TrajectoryMultiRenderer.java

public TrajectoryMultiRenderer(final DmcRenderablePlot plot, final Stepper[] list,
        TrajectoryComponent component) {

    super(plot, null, component);

    this.plot = plot;
    this.stepperList = list;
    computeRanges = true;/*from  w  w  w  .j  a v  a 2s. c om*/

    prevX = new int[list.length];
    prevY = new int[list.length];

    paintList = new Paint[list.length];
    DrawingSupplier mySupplier = new DefaultDrawingSupplier();
    for (int i = 0; i < list.length; i++) {
        paintList[i] = mySupplier.getNextPaint();
    }
}

From source file:net.sourceforge.processdash.ui.lib.chart.StandardDiscItemRenderer.java

/**
 * Returns the paint for the specified disc.
 * /* www .  j a v a 2 s .co m*/
 * @param key
 *                the disc key.
 * @param autoPopulate
 *                a flag that controls whether the drawing supplier is used
 *                to auto-populate the disc paint settings.
 * 
 * @return The paint.
 */
protected Paint lookupDiscPaint(Comparable key, boolean autoPopulate) {

    // if a paint key mapper is in effect, use it to translate the key
    if (paintKeyMapper != null)
        key = paintKeyMapper.getPaintKey(key);

    // check if there is a paint defined for the specified key
    Paint result = this.discPaintMap.getPaint(key);
    if (result != null) {
        return result;
    }

    // nothing defined - do we autoPopulate?
    if (autoPopulate) {
        DrawingSupplier ds = getDrawingSupplier();
        if (ds != null) {
            result = ds.getNextPaint();
            Paint bg = plot.getBackgroundPaint();
            if (result instanceof Color && bg instanceof Color) {
                result = PaintUtils.adjustForContrast((Color) result, (Color) bg);
            }
            this.discPaintMap.put(key, result);
        } else {
            result = this.baseDiscPaint;
        }
    } else {
        result = this.baseDiscPaint;
    }
    return result;
}

From source file:genlab.gui.jfreechart.EnhancedSpiderWebPlot.java

/**
 * Returns the paint for the specified series.
 *
 * @param series  the series index (zero-based).
 *
 * @return The paint (never <code>null</code>).
 *
 * @see #setSeriesPaint(int, Paint)//from w w  w .  j  av a 2  s .  c om
 */
public Paint getSeriesPaint(int series) {

    // return the override, if there is one...
    if (this.seriesPaint != null) {
        return this.seriesPaint;
    }

    // otherwise look up the paint list
    Paint result = this.seriesPaintList.getPaint(series);
    if (result == null) {
        DrawingSupplier supplier = getDrawingSupplier();
        if (supplier != null) {
            Paint p = supplier.getNextPaint();
            this.seriesPaintList.setPaint(series, p);
            result = p;
        } else {
            result = this.baseSeriesPaint;
        }
    }
    return result;

}

From source file:org.optaplanner.benchmark.impl.statistic.movecountperstep.MoveCountPerStepProblemStatistic.java

@Override
public void writeGraphFiles(BenchmarkReport benchmarkReport) {
    Locale locale = benchmarkReport.getLocale();
    NumberAxis xAxis = new NumberAxis("Time spent");
    xAxis.setNumberFormatOverride(new MillisecondsSpentNumberFormat(locale));
    NumberAxis yAxis = new NumberAxis("Accepted/selected moves per step");
    yAxis.setNumberFormatOverride(NumberFormat.getInstance(locale));
    XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
    DrawingSupplier drawingSupplier = new DefaultDrawingSupplier();
    plot.setOrientation(PlotOrientation.VERTICAL);

    int seriesIndex = 0;
    for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
        XYSeries acceptedSeries = new XYSeries(
                singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix() + " accepted");
        XYSeries selectedSeries = new XYSeries(
                singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix() + " selected");
        XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
        if (singleBenchmarkResult.isSuccess()) {
            MoveCountPerStepSingleStatistic singleStatistic = (MoveCountPerStepSingleStatistic) singleBenchmarkResult
                    .getSingleStatistic(problemStatisticType);
            for (MoveCountPerStepStatisticPoint point : singleStatistic.getPointList()) {
                long timeMillisSpent = point.getTimeMillisSpent();
                long acceptedMoveCount = point.getMoveCountPerStepMeasurement().getAcceptedMoveCount();
                long selectedMoveCount = point.getMoveCountPerStepMeasurement().getSelectedMoveCount();
                acceptedSeries.add(timeMillisSpent, acceptedMoveCount);
                selectedSeries.add(timeMillisSpent, selectedMoveCount);
            }/*from www.jav  a 2s .  com*/
        }
        XYSeriesCollection seriesCollection = new XYSeriesCollection();
        seriesCollection.addSeries(acceptedSeries);
        seriesCollection.addSeries(selectedSeries);
        plot.setDataset(seriesIndex, seriesCollection);

        if (singleBenchmarkResult.getSolverBenchmarkResult().isFavorite()) {
            // Make the favorite more obvious
            renderer.setSeriesStroke(0, new BasicStroke(2.0f));
            // Dashed line for selected move count
            renderer.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
                    1.0f, new float[] { 2.0f, 6.0f }, 0.0f));
        } else {
            // Dashed line for selected move count
            renderer.setSeriesStroke(1, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
                    1.0f, new float[] { 2.0f, 6.0f }, 0.0f));
        }
        // Render both lines in the same color
        Paint linePaint = drawingSupplier.getNextPaint();
        renderer.setSeriesPaint(0, linePaint);
        renderer.setSeriesPaint(1, linePaint);
        plot.setRenderer(seriesIndex, renderer);
        seriesIndex++;
    }

    JFreeChart chart = new JFreeChart(problemBenchmarkResult.getName() + " move count per step statistic",
            JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    graphFile = writeChartToImageFile(chart, problemBenchmarkResult.getName() + "MoveCountPerStepStatistic");
}