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

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

Introduction

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

Prototype

public void setDataset(int index, XYDataset dataset) 

Source Link

Document

Sets a dataset for the plot and sends a change event to all registered listeners.

Usage

From source file:be.nbb.demetra.dfm.output.simulation.RealTimePerspGraphView.java

private void displayResults(DfmSimulation dfmSimulation) {
    graphs_.clear();// www .  j av a2  s. c o  m
    chartPanel.setChart(null);

    BasicXYDataset fctsDataset = new BasicXYDataset();
    BasicXYDataset trueDataset = new BasicXYDataset();
    BasicXYDataset arimaDataset = new BasicXYDataset();

    Objects.requireNonNull(dfmSimulation);

    int selectedIndex = comboBox.getSelectedIndex();
    DfmSimulationResults dfm = dfmSimulation.getDfmResults().get(selectedIndex);
    DfmSimulationResults arima = dfmSimulation.getArimaResults().get(selectedIndex);
    List<Double> trueValues = dfm.getTrueValues();
    horizons = dfm.getForecastHorizons();
    periods = dfm.getEvaluationSample();

    // Remove periods of evaluation sample not in true values domain
    filteredPeriods = filterEvaluationSample(trueValues);

    if (filterPanel == null) {
        filterPanel = new FilterEvaluationSamplePanel(filteredPeriods);
    }

    int np = horizons.size() - 1; // - 1 ???
    double xstart = -0.4;
    double xend = 0.4;
    final double xstep = 0.8 / np;

    Double[][] dfmFcts = dfm.getForecastsArray();
    Double[][] arimaFcts = arima.getForecastsArray();

    //Double[][] arimaFcts = arima.getForecastsArray();
    TsPeriod start = filteredPeriods.get(filterPanel.getStart());
    TsPeriod end = filteredPeriods.get(filterPanel.getEnd());
    int startIndex = periods.indexOf(start);
    int endIndex = periods.indexOf(end);

    for (int i = startIndex; i <= endIndex; i++) {
        double x = xstart;
        double[] dfmData = new double[horizons.size()];
        double[] arimaData = new double[horizons.size()];
        for (int j = 0; j < horizons.size(); j++) {
            dfmData[j] = dfmFcts[j][i] == null ? Double.NaN : dfmFcts[j][i];
            arimaData[j] = arimaFcts[j][i] == null ? Double.NaN : arimaFcts[j][i];
        }

        int n = dfmData.length;
        double m = trueValues.get(i) == null ? Double.NaN : trueValues.get(i);
        double[] trueX = { xstart, xend };
        double[] true2X = { horizons.get(0), horizons.get(np) };
        double[] trueY = { m, m };
        double[] dfmX = new double[n], dfm2X = new double[n];
        double[] dfmY = new double[n], dfm2Y = new double[n];
        double[] arimaX = new double[n], arima2X = new double[n];
        double[] arimaY = new double[n], arima2Y = new double[n];

        for (int j = 0; j < n; j++) {
            dfmX[j] = x;
            dfmY[j] = dfmData[j];
            dfm2X[j] = horizons.get(j).doubleValue();
            dfm2Y[j] = dfmData[j];

            arimaX[j] = x;
            arimaY[j] = arimaData[j];
            arima2X[j] = horizons.get(j).doubleValue();
            arima2Y[j] = arimaData[j];

            x += xstep;
        }

        String itemName = periods.get(i).toString();
        BasicXYDataset.Series mean = BasicXYDataset.Series.of(itemName, trueX, trueY);
        BasicXYDataset.Series mean2 = BasicXYDataset.Series.of(itemName, true2X, trueY);
        BasicXYDataset.Series points = BasicXYDataset.Series.of(itemName, dfmX, dfmY);
        BasicXYDataset.Series points2 = BasicXYDataset.Series.of(itemName, dfm2X, dfm2Y);
        BasicXYDataset.Series arimaSeries = BasicXYDataset.Series.of(itemName, arimaX, arimaY);
        BasicXYDataset.Series arima2Series = BasicXYDataset.Series.of(itemName, arima2X, arima2Y);

        Bornes b = new Bornes(xstart, xend);
        Graphs g = new Graphs(mean2, points2, arima2Series, itemName);
        graphs_.put(b, g);

        trueDataset.addSeries(mean);
        fctsDataset.addSeries(points);
        arimaDataset.addSeries(arimaSeries);

        xstart++;
        xend++;
    }

    XYPlot plot = mainChart.getXYPlot();
    configureAxis(plot, startIndex, endIndex);
    plot.setDataset(TRUE_DATA_INDEX, trueDataset);
    plot.setDataset(FCTS_INDEX, fctsDataset);
    plot.setDataset(ARIMA_DATA_INDEX, arimaDataset);
}

From source file:playground.dgrether.analysis.charts.DgMixedDeltaUtilsModeGroupChart.java

public JFreeChart createChart() {
    XYPlot plot = new XYPlot();
    ValueAxis xAxis = this.axisBuilder.createValueAxis("% of Population Sorted by Income");
    ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]");
    plot.setDomainAxis(xAxis);/*from   w  ww .  j av  a  2  s.  c om*/
    plot.setRangeAxis(yAxis);
    //RANGE
    xAxis.setRange(0.0, 102.0);
    yAxis.setRange(-0.31, 0.61);

    DgColorScheme colorScheme = new DgColorScheme();

    XYItemRenderer renderer1 = new XYLineAndShapeRenderer(false, true);
    renderer1.setSeriesPaint(0, colorScheme.COLOR1B);
    renderer1.setSeriesPaint(1, colorScheme.COLOR2B);
    renderer1.setSeriesPaint(2, colorScheme.COLOR3B);
    renderer1.setSeriesPaint(3, colorScheme.COLOR4B);
    plot.setDataset(0, this.inomeModeChoiceDs);
    plot.setRenderer(0, renderer1);

    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, true);
    plot.setDataset(1, this.avgDeltaScoreIncomeDs);
    for (int i = 0; i <= 3; i++) {
        renderer2.setSeriesStroke(i, new BasicStroke(2.0f));
        renderer2.setSeriesOutlineStroke(i, new BasicStroke(3.0f));
        renderer2.setSeriesPaint(i, colorScheme.getColor(i + 1, "a"));
    }
    plot.setRenderer(1, renderer2);
    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    return chart;
}

From source file:OAT.ui.BarChartFrame.java

public void addDataset(ChartDataset dataset) {
    if (dataset == null || dataset.getSeriesCount() == 0) {
        return;/*from w ww  . j a va  2  s. c  om*/
    }

    XYPlot plot = getChart().getXYPlot();
    int i = plot.getDatasetCount();

    for (int j = 0; j < i; j++) {
        if (plot.getDataset(j).equals(dataset)) {
            //                System.out.println("eq " + i
            //                        + " " + ((ChartDataset) plot.getDataset(j)).getTitle()
            //                        + " " + dataset.getTitle());
            return;
        }
    }

    plot.setDataset(i, dataset);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);
    Double[] range = dataset.getAxisRange();

    //axis
    int axisId = 0;

    if (range != null) {
        //        if (range == null || range.length < 2) {
        //            plot.mapDatasetToRangeAxis(i, 0);
        //        } else {

        //scan for equal axis range, reuse if found
        boolean hasSameRange = false;

        if (range.length > 1) {
            for (int j = 1; j < plot.getRangeAxisCount(); j++) {
                Range otherRange = plot.getRangeAxis(j).getRange();

                if (otherRange != null && otherRange.getLowerBound() == range[0]
                        && otherRange.getUpperBound() == range[1]) {
                    axisId = j;
                    hasSameRange = true;
                    break;
                }
            }
        }

        if (!hasSameRange) {
            NumberAxis newAxis = new NumberAxis();

            if (range.length > 1) {
                newAxis.setAutoRange(false);
                newAxis.setRange(range[0], range[1]);
            }

            if (range.length > 2) {
                newAxis.setAutoTickUnitSelection(false, false);
                newAxis.setTickUnit(new NumberTickUnit(range[2]));
            }

            newAxis.setNumberFormatOverride(TextUtil.SIMPLE_FORMATTER);
            //                    newAxis.setAxisLinePaint(new Color(100, 0, 0));
            //                    newAxis.setLabelPaint(paints[i][0]);
            //                    newAxis.setTickLabelPaint(paints[i][0]);
            //                    newAxis.setTickMarkPaint(paints[i][0]);
            //                    newAxis.setTickLabelsVisible(true);

            axisId = plot.getRangeAxisCount();
            plot.setRangeAxis(axisId, newAxis, false);
            plot.setRangeAxisLocation(axisId, AxisLocation.BOTTOM_OR_LEFT, false);
        }
        //            plot.mapDatasetToRangeAxis(i, newAxisId);
    }
    plot.mapDatasetToRangeAxis(i, axisId);
    //

    //renderer
    XYLineAndShapeRenderer renderer;

    if (dataset instanceof TradeDataset) {
        renderer = new TradeRenderer();

        for (int j = 0; j < dataset.getSeriesCount(); j++) {
            renderer.setSeriesLinesVisible(j, false);
        }
    } else {

        Shape shape = Main.defaultShape;
        Paint[][] seriesPaints;
        Stroke stroke;

        if (dataset.getSource() instanceof Stopper && !(dataset.getSource() instanceof Calculator)) {
            seriesPaints = Main.greyPaints;
            stroke = Main.dottedStoke;
        } else {
            seriesPaints = Main.defaultPaints;
            stroke = Main.defaultStoke;
        }

        renderer = new IndicatorRenderer(seriesPaints[(i - 1) % seriesPaints.length], shape, stroke);
    }

    plot.setRenderer(i, renderer, false);
}

From source file:be.nbb.demetra.dfm.output.simulation.RMSEGraphView.java

private void toDataset(DfmSimulation dfmSimulation) {
    DefaultXYDataset dfmDataset = new DefaultXYDataset();
    DefaultXYDataset arimaDataset = new DefaultXYDataset();
    DefaultXYDataset stdevDataset = new DefaultXYDataset();

    Objects.requireNonNull(dfmSimulation);

    int selectedIndex = comboBox.getSelectedIndex();
    DfmSimulationResults dfm = dfmSimulation.getDfmResults().get(selectedIndex);
    DfmSimulationResults arima = dfmSimulation.getArimaResults().get(selectedIndex);
    List<Double> trueValues = dfm.getTrueValues();
    horizons = dfm.getForecastHorizons();
    periods = dfm.getEvaluationSample();

    // Remove periods of evaluation sample not in true values domain
    filteredPeriods = filterEvaluationSample(trueValues);

    if (filterPanel == null) {
        filterPanel = new FilterEvaluationSamplePanel(filteredPeriods);
    }/*from  ww w . j av  a 2  s .c om*/

    Double[][] dfmFcts = dfm.getForecastsArray();
    Double[][] arimaFcts = arima.getForecastsArray();

    Map<Integer, TsData> dfmTs = new HashMap<>();
    Map<Integer, TsData> arimaTs = new HashMap<>();

    TsFrequency freq = periods.get(0).getFrequency();

    TsDataCollector coll = new TsDataCollector();
    for (int i = 0; i < periods.size(); i++) {
        if (trueValues.get(i) != null) {
            coll.addObservation(periods.get(i).middle(), trueValues.get(i));
        } else {
            coll.addMissingValue(periods.get(i).middle());
        }
    }
    TsData trueTsData = coll.make(freq, TsAggregationType.None);

    fillMap(dfmTs, dfmFcts, freq);
    fillMap(arimaTs, arimaFcts, freq);

    int size = dfmTs.size();
    xvalues = new double[size];
    dfmValues = new double[size];
    arimaValues = new double[size];

    TsPeriod start = filteredPeriods.get(filterPanel.getStart());
    TsPeriod end = filteredPeriods.get(filterPanel.getEnd());
    TsDomain dom = new TsDomain(start, end.minus(start) + 1);

    int index = 0;
    for (Integer horizon : horizons) {
        if (dfmTs.containsKey(horizon)) {
            ForecastEvaluationResults rslt = new ForecastEvaluationResults(dfmTs.get(horizon).fittoDomain(dom),
                    arimaTs.get(horizon).fittoDomain(dom), trueTsData);
            dfmValues[index] = rslt.calcRMSE();
            arimaValues[index] = rslt.calcRMSE_Benchmark();
            xvalues[index] = horizon;
            index++;
        }
    }
    dfmDataset.addSeries("RMSE (simulation based rec. est.)", new double[][] { xvalues, dfmValues });
    arimaDataset.addSeries("RMSE (Arima recursive est.)", new double[][] { xvalues, arimaValues });

    // Stdev
    Map<Day, SimulationResultsDocument> results = dfmSimulation.getResults();
    Day[] cal = new Day[results.size()];
    cal = results.keySet().toArray(cal);
    Arrays.sort(cal);
    TsPeriod lastPeriod = filteredPeriods.get(filterPanel.getEnd());

    xStdev = new ArrayList<>();
    yStdev = new ArrayList<>();

    DfmSeriesDescriptor selected = (DfmSeriesDescriptor) comboBox.getSelectedItem();
    List<DfmSeriesDescriptor> descs = dfmSimulation.getDescriptions();
    int realIndex = 0;
    boolean found = false;
    while (!found) {
        if (selected.description.equals(descs.get(realIndex).description)) {
            found = true;
        } else {
            realIndex++;
        }
    }

    for (Day d : cal) {
        int horizon = d.difference(lastPeriod.lastday());
        if (dfmTs.containsKey(horizon)) {
            TsData[] smoothStdev = results.get(d).getSmoothedSeriesStdev();
            if (smoothStdev != null) {
                TsData stdevs = results.get(d).getSmoothedSeriesStdev()[selectedIndex];
                if (!stdevs.getFrequency().equals(lastPeriod.getFrequency())) {
                    stdevs = stdevs.changeFrequency(lastPeriod.getFrequency(), TsAggregationType.Last, true);
                }
                Double stdev = stdevs.get(lastPeriod);
                xStdev.add(horizon);
                yStdev.add(stdev);
            }
        }
    }

    double[] xStdevArray = new double[xStdev.size()];
    double[] yStdevArray = new double[xStdev.size()];
    for (int i = 0; i < xStdevArray.length; i++) {
        xStdevArray[i] = xStdev.get(i);
        yStdevArray[i] = yStdev.get(i);
    }

    stdevDataset.addSeries("Stdev", new double[][] { xStdevArray, yStdevArray });

    XYPlot plot = chartPanel.getChart().getXYPlot();

    plot.setDataset(DFM_INDEX, dfmDataset);
    plot.setDataset(ARIMA_INDEX, arimaDataset);
    plot.setDataset(STDEV_INDEX, stdevDataset);

    chartPanel.getChart()
            .setTitle("Evaluation sample from " + filteredPeriods.get(filterPanel.getStart()).toString()
                    + " to " + filteredPeriods.get(filterPanel.getEnd()).toString());
}

From source file:daylightchart.sunchart.chart.SunChart.java

/**
 * Creates bands for the sunrise and sunset times for the whole year.
 *//*  w ww  . j a  va 2  s .c  o m*/
private void createBandsInPlot(final XYPlot plot) {
    final VectorSeriesCollection vectorSeriesCollection = new VectorSeriesCollection();
    final List<SunPositions> sunPositionsList = sunChartData.getSunPositionsList();
    for (final SunPositions sunPositions : sunPositionsList) {
        final VectorSeries vectorSeries = new VectorSeries(sunPositions.getDate().toString());
        for (final SunPosition sunPosition : sunPositions) {
            vectorSeries.add(sunPosition.getAzimuth(), sunPosition.getAltitude(), 0, 0);
        }
        vectorSeriesCollection.addSeries(vectorSeries);
    }
    final int currentDatasetNumber = plot.getDatasetCount();
    plot.setDataset(currentDatasetNumber, vectorSeriesCollection);
}

From source file:de.uka.aifb.com.systemDynamics.gui.ModelExecutionChartPanel.java

/**
 * Creates panel./*  ww  w  .ja  va 2s .  c om*/
 */
private void createPanel() {
    setLayout(new BorderLayout());

    // CENTER: chart
    ChartPanel chartPanel = new ChartPanel(createChart());
    // no context menu
    chartPanel.setPopupMenu(null);
    // not zoomable
    chartPanel.setMouseZoomable(false);
    add(chartPanel, BorderLayout.CENTER);

    // LINE_END: series table
    JPanel tablePanel = new JPanel(new GridBagLayout());
    String[] columnNames = { messages.getString("ModelExecutionChartPanel.Table.ColumnNames.ExtraAxis"),
            messages.getString("ModelExecutionChartPanel.Table.ColumnNames.LevelNode") };
    final MyTableModel tableModel = new MyTableModel(columnNames, xySeriesArray.length);
    for (int i = 0; i < xySeriesArray.length; i++) {
        tableModel.addEntry((String) xySeriesArray[i].getKey());
    }
    JTable table = new JTable(tableModel);
    table.setRowSelectionAllowed(false);
    JScrollPane tableScrollPane = new JScrollPane(table);
    int width = (int) Math.min(300, table.getPreferredSize().getWidth());
    int height = (int) Math.min(200, table.getPreferredSize().getHeight());
    tableScrollPane.getViewport().setPreferredSize(new Dimension(width, height));
    tableScrollPane.setMaximumSize(tableScrollPane.getViewport().getPreferredSize());
    axesButton = new JButton(messages.getString("ModelExecutionChartPanel.AxesButton.Text"));
    axesButton.setToolTipText(messages.getString("ModelExecutionChartPanel.AxesButton.ToolTipText"));
    axesButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // create XYSeriesCollections (and renderer)
            XYSeriesCollection standardData = new XYSeriesCollection();
            XYLineAndShapeRenderer standardRenderer = new XYLineAndShapeRenderer(true, false);
            LinkedList<XYSeriesCollection> extraDataList = new LinkedList<XYSeriesCollection>();
            LinkedList<XYLineAndShapeRenderer> extraRendererList = new LinkedList<XYLineAndShapeRenderer>();
            for (int i = 0; i < tableModel.getRowCount(); i++) {
                if (tableModel.getValueAt(i, 0).equals(Boolean.FALSE)) {
                    standardData.addSeries(xySeriesArray[i]);
                    standardRenderer.setSeriesPaint(standardData.getSeriesCount() - 1,
                            DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[i
                                    % DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length]);
                } else {
                    // extra axis
                    XYSeriesCollection extraData = new XYSeriesCollection();
                    extraData.addSeries(xySeriesArray[i]);
                    extraDataList.add(extraData);
                    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
                    extraRendererList.add(renderer);
                    renderer.setSeriesPaint(0, DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[i
                            % DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length]);
                }
            }
            LinkedList<XYSeriesCollection> dataList = new LinkedList<XYSeriesCollection>();
            LinkedList<XYLineAndShapeRenderer> rendererList = new LinkedList<XYLineAndShapeRenderer>();
            if (!standardData.getSeries().isEmpty()) {
                dataList.add(standardData);
                rendererList.add(standardRenderer);
            }
            for (XYSeriesCollection data : extraDataList) {
                dataList.add(data);
            }
            for (XYLineAndShapeRenderer renderer : extraRendererList) {
                rendererList.add(renderer);
            }

            // creates axes
            LinkedList<NumberAxis> axesList = new LinkedList<NumberAxis>();
            if (!standardData.getSeries().isEmpty()) {
                NumberAxis axis = new NumberAxis(messages.getString("ModelExecutionChartPanel.Value"));
                axis.setNumberFormatOverride(NumberFormat.getInstance(locale));
                axesList.add(axis);
            }
            for (XYSeriesCollection data : extraDataList) {
                NumberAxis axis = new NumberAxis((String) data.getSeries(0).getKey());
                axis.setNumberFormatOverride(NumberFormat.getInstance(locale));
                axesList.add(axis);
            }

            // store data and axes in plot
            XYPlot plot = chart.getXYPlot();
            plot.clearRangeAxes();
            plot.setRangeAxes(axesList.toArray(new NumberAxis[0]));
            for (int i = 0; i < plot.getDatasetCount(); i++) {
                plot.setDataset(i, null);
            }
            int datasetIndex = 0;
            Iterator<XYSeriesCollection> datasetIterator = dataList.iterator();
            Iterator<XYLineAndShapeRenderer> rendererIterator = rendererList.iterator();
            while (datasetIterator.hasNext()) {
                plot.setDataset(datasetIndex, datasetIterator.next());
                plot.setRenderer(datasetIndex, rendererIterator.next());
                datasetIndex++;
            }
            for (int i = 0; i < plot.getDatasetCount(); i++) {
                plot.mapDatasetToRangeAxis(i, i);
            }
        }
    });
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.CENTER;
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(0, 0, 10, 0);
    tablePanel.add(tableScrollPane, c);
    c.gridx = 0;
    c.gridy = 1;
    tablePanel.add(axesButton, c);
    add(tablePanel, BorderLayout.LINE_END);

    // PAGE_END: number of rounds and execution button
    JPanel commandPanel = new JPanel();
    commandPanel.add(new JLabel(messages.getString("ModelExecutionChartPanel.NumberRounds")));
    final JTextField numberRoundsField = new JTextField("1", 5);
    numberRoundsField.addFocusListener(this);
    commandPanel.add(numberRoundsField);
    executionButton = new JButton(messages.getString("ModelExecutionChartPanel.ExecutionButton.Text"));
    executionButton.setToolTipText(messages.getString("ModelExecutionChartPanel.ExecutionButton.ToolTipText"));
    executionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int numberRounds = 0;
            boolean correctNumber = false;
            try {
                numberRounds = integerNumberFormatter.parse(numberRoundsField.getText()).intValue();
            } catch (ParseException parseExcep) {
                // do nothing
            }

            if (numberRounds >= 1) {
                correctNumber = true;
            }

            if (correctNumber) {
                ModelExecutionThread executionThread = new ModelExecutionThread(numberRounds);
                executionThread.start();
            } else {
                JOptionPane.showMessageDialog(null,
                        messages.getString("ModelExecutionChartPanel.Error.Message"),
                        messages.getString("ModelExecutionChartPanel.Error.Title"), JOptionPane.ERROR_MESSAGE);
            }
        }
    });
    commandPanel.add(executionButton);
    add(commandPanel, BorderLayout.PAGE_END);
}

From source file:playground.dgrether.analysis.charts.DgAvgDeltaUtilsQuantilesChart.java

public JFreeChart createChart() {
    XYPlot plot = new XYPlot();
    ValueAxis xAxis = this.axisBuilder.createValueAxis("% of Population Sorted by Income");
    xAxis.setRange(0.0, 102.0);/*from   w  w  w. j a  v  a 2 s  .c om*/
    ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]");
    yAxis.setRange(-0.05, 0.3);
    //      xAxis.setVisible(false);
    //      xAxis.setFixedAutoRange(1.0);
    plot.setDomainAxis(xAxis);
    plot.setRangeAxis(yAxis);

    DgColorScheme colorScheme = new DgColorScheme();

    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, true);
    renderer2.setSeriesItemLabelsVisible(0, true);
    //      renderer2.setSeriesItemLabelGenerator(0, this.labelGenerator);
    plot.setDataset(0, this.dataset);
    renderer2.setSeriesStroke(0, new BasicStroke(2.0f));
    renderer2.setSeriesOutlineStroke(0, new BasicStroke(3.0f));
    renderer2.setSeriesPaint(0, colorScheme.getColor(1, "a"));
    plot.setRenderer(0, renderer2);

    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    chart.removeLegend();
    return chart;
}

From source file:org.optaplanner.benchmark.impl.report.BenchmarkReport.java

private XYPlot createScalabilityPlot(List<XYSeries> seriesList, String xAxisLabel,
        NumberFormat xAxisNumberFormat, String yAxisLabel, NumberFormat yAxisNumberFormat) {
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setNumberFormatOverride(xAxisNumberFormat);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setNumberFormatOverride(yAxisNumberFormat);
    XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
    int seriesIndex = 0;
    for (XYSeries series : seriesList) {
        XYSeriesCollection seriesCollection = new XYSeriesCollection();
        seriesCollection.addSeries(series);
        plot.setDataset(seriesIndex, seriesCollection);
        XYItemRenderer renderer = createScalabilityPlotRenderer(yAxisNumberFormat);
        plot.setRenderer(seriesIndex, renderer);
        seriesIndex++;// ww  w .  j  a  v a  2 s  .c  o  m
    }
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}

From source file:ucar.unidata.idv.control.chart.ChartHolder.java

/**
 * add data set/*from   w ww.  ja v  a  2s .com*/
 *
 * @param dataset dataset
 * @param rangeAxis axis
 * @param renderer renderer
 * @param side which side
 */
protected void add(XYDataset dataset, ValueAxis rangeAxis, XYItemRenderer renderer, AxisLocation side) {
    synchronized (chartManager.getMutex()) {
        XYPlot xyPlot = (XYPlot) plot;
        xyPlot.setRangeAxis(paramCount, rangeAxis, false);
        xyPlot.setDataset(paramCount, dataset);
        xyPlot.mapDatasetToRangeAxis(paramCount, paramCount);
        xyPlot.setRenderer(paramCount, renderer);
        if (side != null) {
            xyPlot.setRangeAxisLocation(paramCount, side);
        }
        paramCount++;
    }
}

From source file:playground.thibautd.utils.charts.BoxAndWhiskersChart.java

private void createChart() {
    boolean legend = false;

    this.createDataSet();

    this.chart = ChartFactory.createBoxAndWhiskerChart(this.chartTitle, this.xAxisLabel, this.yAxisLabel,
            this.boxes, legend);

    XYPlot plot = this.chart.getXYPlot();
    plot.setDomainAxis(new NumberAxis(this.xAxisLabel));
    plot.getDomainAxis().configure();/*w  ww  .  j a v  a 2  s .  c om*/

    if (plotStdDev) {
        XYErrorRenderer renderer = new XYErrorRenderer();
        // in black
        renderer.setErrorPaint(Color.BLACK);
        // only plot Y error
        renderer.setDrawXError(false);
        // do not render average (already done by the B&W)
        renderer.setBaseShapesVisible(false);
        plot.setRenderer(1, renderer);
        plot.setDataset(1, deviationBars);
        plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    }

    //this.addMatsimLogo();

    //try {
    //   this.addDefaultFormatting();
    //} catch (NullPointerException e) {
    //   // occurs if no legend
    //}

    //this.chart.setBackgroundPaint(Color.white);
    plot.setBackgroundPaint(Color.white);
    XYBoxAndWhiskerRenderer renderer = (XYBoxAndWhiskerRenderer) plot.getRenderer();
    //renderer.setFillBox(false);
    //renderer.setSeriesOutlinePaint(0, Color.black);
    //renderer.setSeriesPaint(0, Color.black);
    renderer.setBoxPaint(renderer.getSeriesPaint(0));
    //auto-adjust
    renderer.setBoxWidth(-1);
}