Example usage for org.jfree.data.xy XYSeriesCollection addSeries

List of usage examples for org.jfree.data.xy XYSeriesCollection addSeries

Introduction

In this page you can find the example usage for org.jfree.data.xy XYSeriesCollection addSeries.

Prototype

public void addSeries(XYSeries series) 

Source Link

Document

Adds a series to the collection and sends a DatasetChangeEvent to all registered listeners.

Usage

From source file:dla_franctal.LineChart.java

public XYDataset createBBAreaRationDataset(ArrayList<Double> bbAreaRatio,
        ArrayList<Integer> staticParticlesAtCurrentTick) {
    final XYSeries currentBBAreaRatio = new XYSeries("");
    for (int i = 0; i < bbAreaRatio.size(); i++) {
        currentBBAreaRatio.add(staticParticlesAtCurrentTick.get(i), bbAreaRatio.get(i));
    }/*from   w w w  . j  av a2 s. c  o  m*/
    final XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(currentBBAreaRatio);
    return dataset;
}

From source file:edu.utexas.ece.pharos.proteus3.sensors.CompassChartGUI.java

/**
 * Creates a sample dataset./* w  ww. j  a  v  a  2  s  .  c o m*/
 * 
 * @return a sample dataset.
 */
private XYDataset createDataset() {

    dataSeries = new XYSeries("Compass Measurements");
    //        series1.add(2.0, 1.0);
    //        series1.add(3.0, 2.0);
    //        series1.add(4.0, 3.0);
    //        series1.add(5.0, 4.0);
    //        series1.add(6.0, 5.0);
    //        series1.add(7.0, 6.0);
    //        series1.add(8.0, 7.0);
    //        series1.add(9.0, 8.0);

    final XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(dataSeries);

    return dataset;

}

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

public XYSeriesCollection createDeltaScoreIncomeModeChoiceDataset(String runId1, String runId2) {
    List<Tuple<Double, Double>> valuesCarCar = new ArrayList<Tuple<Double, Double>>();
    List<Tuple<Double, Double>> valuesPtPt = new ArrayList<Tuple<Double, Double>>();
    List<Tuple<Double, Double>> valuesPtCar = new ArrayList<Tuple<Double, Double>>();
    List<Tuple<Double, Double>> valuesCarPt = new ArrayList<Tuple<Double, Double>>();
    List<DgPersonData> sortedPop = new ArrayList<DgPersonData>();
    sortedPop.addAll(this.ana.getPersonData().values());
    Collections.sort(sortedPop, new DgPersonDataIncomeComparator());
    //calculations
    //      double currentIncome = 0.0;
    double i = 0.0;
    double size = this.ana.getPersonData().size();
    for (DgPersonData d : sortedPop) {
        i++;//  ww w.j a  va  2  s . co  m
        //         currentIncome += d.getIncome().getIncome();
        DgPlanData planDataRun1 = d.getPlanData().get(runId1);
        DgPlanData planDataRun2 = d.getPlanData().get(runId2);
        Double scoreDiff = planDataRun2.getScore() - planDataRun1.getScore();
        Tuple<Double, Double> t = new Tuple<Double, Double>(100.0 * i / size, scoreDiff);

        if (((PlanImpl) planDataRun1.getPlan()).getType().equals(TransportMode.car)
                && ((PlanImpl) planDataRun2.getPlan()).getType().equals(TransportMode.car)) {
            valuesCarCar.add(t);
        } else if (((PlanImpl) planDataRun1.getPlan()).getType().equals(TransportMode.pt)
                && ((PlanImpl) planDataRun2.getPlan()).getType().equals(TransportMode.pt)) {
            valuesPtPt.add(t);
        } else if (((PlanImpl) planDataRun1.getPlan()).getType().equals(TransportMode.pt)
                && ((PlanImpl) planDataRun2.getPlan()).getType().equals(TransportMode.car)) {
            valuesPtCar.add(t);
        } else if (((PlanImpl) planDataRun1.getPlan()).getType().equals(TransportMode.car)
                && ((PlanImpl) planDataRun2.getPlan()).getType().equals(TransportMode.pt)) {
            valuesCarPt.add(t);
        }
    }

    //compose the dataset
    XYSeriesCollection ds = new XYSeriesCollection();
    if (!writeModeSwitcherOnly) {
        ds.addSeries(this.createSeries("Car2Car", valuesCarCar));
    }
    if (!writeModeSwitcherOnly) {
        ds.addSeries(this.createSeries("Pt2Pt", valuesPtPt));
    }
    ds.addSeries(this.createSeries("Pt2Car", valuesPtCar));
    ds.addSeries(this.createSeries("Car2Pt", valuesCarPt));
    return ds;
}

From source file:Main.Chart.java

/**
 * Creates a sample dataset.// w w  w .  j  a va2s  . c  om
 * 
 * @return a sample dataset.
 */
private XYDataset createDataset(WeatherData wd) {

    final XYSeries series1 = new XYSeries("Temperature");
    final XYSeries series2 = new XYSeries("Wind speed");

    TimeSerie first = wd.getTimeseries().get(0);

    int offset = first.getValidTime().get(Calendar.HOUR_OF_DAY);

    for (int i = 0; i < wd.getTimeseries().size(); i++) {
        TimeSerie temp = wd.getTimeseries().get(i);
        series1.add(offset + i, temp.getT());
        series2.add(offset + i, temp.getWs());
    }

    final XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series1);
    dataset.addSeries(series2);

    return dataset;

}

From source file:org.drools.planner.benchmark.core.statistic.bestscore.BestScoreProblemStatistic.java

protected void writeGraphStatistic() {
    NumberAxis xAxis = new NumberAxis("Time spend");
    xAxis.setNumberFormatOverride(new MillisecondsSpendNumberFormat());
    NumberAxis yAxis = new NumberAxis("Score");
    yAxis.setAutoRangeIncludesZero(false);
    XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
    int seriesIndex = 0;
    for (SingleBenchmark singleBenchmark : problemBenchmark.getSingleBenchmarkList()) {
        BestScoreSingleStatistic singleStatistic = (BestScoreSingleStatistic) singleBenchmark
                .getSingleStatistic(problemStatisticType);
        XYSeries series = new XYSeries(singleBenchmark.getSolverBenchmark().getName());
        for (BestScoreSingleStatisticPoint point : singleStatistic.getPointList()) {
            long timeMillisSpend = point.getTimeMillisSpend();
            Score score = point.getScore();
            Double scoreGraphValue = scoreDefinition.translateScoreToGraphValue(score);
            if (scoreGraphValue != null) {
                series.add(timeMillisSpend, scoreGraphValue);
            }//from w  w w . ja  va2  s.  c  o  m
        }
        XYSeriesCollection seriesCollection = new XYSeriesCollection();
        seriesCollection.addSeries(series);
        plot.setDataset(seriesIndex, seriesCollection);
        XYItemRenderer renderer;
        // No direct lines between 2 points
        renderer = new XYStepRenderer();
        if (singleStatistic.getPointList().size() <= 1) {
            // Workaround for https://sourceforge.net/tracker/?func=detail&aid=3387330&group_id=15494&atid=115494
            renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES);
        }
        plot.setRenderer(seriesIndex, renderer);
        seriesIndex++;
    }
    plot.setOrientation(PlotOrientation.VERTICAL);
    JFreeChart chart = new JFreeChart(problemBenchmark.getName() + " best score statistic",
            JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    BufferedImage chartImage = chart.createBufferedImage(1024, 768);
    graphStatisticFile = new File(problemBenchmark.getProblemReportDirectory(),
            problemBenchmark.getName() + "BestScoreStatistic.png");
    OutputStream out = null;
    try {
        out = new FileOutputStream(graphStatisticFile);
        ImageIO.write(chartImage, "png", out);
    } catch (IOException e) {
        throw new IllegalArgumentException("Problem writing graphStatisticFile: " + graphStatisticFile, e);
    } finally {
        IOUtils.closeQuietly(out);
    }
}

From source file:com.yahoo.egads.utilities.GUIUtils.java

/**
 * Creates a float[] time-series/*w  w w  .j  av a 2 s .  c o  m*/
 */
public XYDataset createDataset(Float[] ds, String label) {
    XYSeries observations = new XYSeries(label);
    int n = ds.length;
    for (int i = 0; i < n; i++) {
        observations.add(i, ds[i]);
    }
    XYSeriesCollection collection = new XYSeriesCollection();
    collection.addSeries(observations);
    return collection;
}

From source file:com.yahoo.egads.utilities.GUIUtils.java

/**
 * Creates a dataset./*w ww .j  a  v  a 2  s  . c o  m*/
 * @return the dataset.
 */
public XYDataset createDataset(DataSequence ds, String label) {
    XYSeries observations = new XYSeries(label);
    int n = ds.size();
    for (int i = 0; i < n; i++) {
        observations.add(i, ds.get(i).value);
    }
    XYSeriesCollection collection = new XYSeriesCollection();
    collection.addSeries(observations);
    return collection;
}

From source file:br.fapesp.myutils.TestMyUtils.java

@Test
@Ignore/*from  w w w  .j  a va  2s . c o  m*/
public void testJFreeChart() {
    double[][] data = new double[][] { { 1, 2 }, { 3, 4 }, { 5, 6 } };
    XYSeries xy = new XYSeries("Teste");
    xy.add(1, 2);
    xy.add(2, 4);
    xy.add(3, 6);

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(xy);

    JFreeChart chart = ChartFactory.createScatterPlot("Scatter teste", "x", "y", dataset);

    ChartFrame frame = new ChartFrame("XYLine Chart", chart);
    frame.pack();
    frame.setVisible(true);
}

From source file:dla_franctal.LineChart.java

public XYDataset createSimulationGraphs(Map<Integer, Integer> snowMap, Map<Integer, Integer> randMap,
        Map<Integer, Integer> balisticMap, Map<Integer, Integer> spiralMap) {
    final XYSeries snowFlakeSeries = new XYSeries("snowFlake");
    final XYSeries randomSeries = new XYSeries("randomSeries");
    final XYSeries balisticSeries = new XYSeries("balisticSeries");
    final XYSeries spiralSeries = new XYSeries("spiralSeries");
    for (int i = 10000; i <= 60000; i += 10000) {
        snowFlakeSeries.add(i, snowMap.get(new Integer(i)));
        randomSeries.add(i, randMap.get(new Integer(i)));
        balisticSeries.add(i, balisticMap.get(new Integer(i)));
        spiralSeries.add(i, spiralMap.get(new Integer(i)));
    }/*from  w  ww.  j  a v  a 2 s. co  m*/
    final XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(snowFlakeSeries);
    dataset.addSeries(randomSeries);
    dataset.addSeries(balisticSeries);
    dataset.addSeries(spiralSeries);
    return dataset;
}

From source file:cmsc105_mp2.Plot.java

public void createGraph(Data d, float window, Double threshold) {
    XYSeries data = new XYSeries("data");
    double min = Double.MAX_VALUE;
    double max = Double.MIN_VALUE;
    for (double num : d.plots) {
        if (max < num)
            max = num;//from w  ww.j  av a2 s .com
        if (min > num)
            min = num;
    }
    max += 3;
    min -= 3;

    ArrayList<XYSeries> xy = new ArrayList();
    ArrayList<Integer> points = new ArrayList();

    for (int j = (int) (window / 2); j < d.plots.length - (window / 2); j++) {
        data.add(j, d.plots[j]);
        System.out.println(points.size());
        if (d.plots[j] > threshold) {
            points.add(j);

        } else {
            if (points.size() >= window) {
                System.out.println("MIN!");
                XYSeries series = new XYSeries("trend");
                for (int n : points) {
                    series.add(n, max);
                }
                xy.add(series);
            }
            points = new ArrayList();
        }
    }
    if (points.size() >= window) {
        XYSeries series = new XYSeries("trend");
        for (int n : points) {
            series.add(n, max);
        }
        xy.add(series);
    }
    XYSeriesCollection my_data_series = new XYSeriesCollection();
    my_data_series.addSeries(data);
    for (XYSeries x : xy) {
        my_data_series.addSeries(x);
    }

    XYSeries thresh = new XYSeries("threshold");
    for (int j = 0; j < d.plots.length; j++) {
        thresh.add(j, threshold);
    }
    my_data_series.addSeries(thresh);

    System.out.println(d.name);
    JFreeChart XYLineChart = ChartFactory.createXYLineChart(d.name, "Position", "Average", my_data_series,
            PlotOrientation.VERTICAL, true, true, false);
    bImage1 = (BufferedImage) XYLineChart.createBufferedImage(600, 300);
    ImageIcon imageIcon = new ImageIcon(bImage1);
    jLabel1.setIcon(imageIcon);
}