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

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

Introduction

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

Prototype

public XYSeriesCollection() 

Source Link

Document

Constructs an empty dataset.

Usage

From source file:org.jfree.data.xy.XYSeriesCollectionTest.java

/**
 * Confirm that the equals method can distinguish all the required fields.
 *///  ww  w.ja v  a 2 s  .  c o  m
@Test
public void testEquals() {
    XYSeries s1 = new XYSeries("Series");
    s1.add(1.0, 1.1);
    XYSeriesCollection c1 = new XYSeriesCollection();
    c1.addSeries(s1);
    XYSeries s2 = new XYSeries("Series");
    s2.add(1.0, 1.1);
    XYSeriesCollection c2 = new XYSeriesCollection();
    c2.addSeries(s2);
    assertEquals(c1, c2);
    assertEquals(c2, c1);

    c1.addSeries(new XYSeries("Empty Series"));
    assertFalse(c1.equals(c2));
    c2.addSeries(new XYSeries("Empty Series"));
    assertEquals(c1, c2);

    c1.setIntervalWidth(5.0);
    assertFalse(c1.equals(c2));
    c2.setIntervalWidth(5.0);
    assertEquals(c1, c2);

    c1.setIntervalPositionFactor(0.75);
    assertFalse(c1.equals(c2));
    c2.setIntervalPositionFactor(0.75);
    assertEquals(c1, c2);

    c1.setAutoWidth(true);
    assertFalse(c1.equals(c2));
    c2.setAutoWidth(true);
    assertEquals(c1, c2);

}

From source file:org.matsim.pt.counts.obsolete.PtCountsSimRealPerHourGraph.java

/**
 * @param hour/*  w  w w. j a  va  2  s.  c  om*/
 *            A value in 1..24, 1 for 0 a.m. to 1 a.m., 2 for 1 a.m. to 2
 *            a.m. ...
 */
@Override
@Deprecated // use standard counts package
public JFreeChart createChart(final int hour) {
    this.hour = hour;

    XYSeriesCollection dataset0 = new XYSeriesCollection();
    XYSeries series = new XYSeries("MATSim volumes");
    // easier to use another dataset
    XYSeriesCollection dataset_outliers = new XYSeriesCollection();
    XYSeries series_outliers = new XYSeries("MATSim outliers");

    CustomXYURLGenerator url_gen = new CustomXYURLGenerator();
    CustomXYToolTipGenerator tt_gen = new CustomXYToolTipGenerator();

    final ArrayList<String> urls = new ArrayList<String>();
    final ArrayList<String> tooltips = new ArrayList<String>();
    List<Comp> comps = new Vector<Comp>();

    Iterator<CountSimComparison> l_it = this.ccl_.iterator();
    // int elementCounter=0;
    while (l_it.hasNext()) {
        CountSimComparison cc = l_it.next();

        /*
         * values with simVal==0.0 or countVal==0.0 are drawn on the x==1
         * or/and y==1-line Such values are the result of a poor simulation
         * run, but they can also represent a valid result (closing summer
         * road during winter time)
         */
        if (cc.getHour() == hour) {
            // elementCounter++;
            double realVal = 1.0;
            double simVal = 1.0;
            if (cc.getCountValue() > 0.0 && cc.getSimulationValue() > 0.0) {
                realVal = cc.getCountValue();
                simVal = cc.getSimulationValue();
                series.add(realVal, simVal);
                comps.add(new Comp(realVal, "link" + cc.getId() + ".html",
                        "Link " + cc.getId() + "; " + "Count: " + realVal + ", Sim: " + simVal));
            } else {
                realVal = Math.max(1.0, cc.getCountValue());
                simVal = Math.max(1.0, cc.getSimulationValue());
                series_outliers.add(realVal, simVal);
            }

        } // if
    } // while
    dataset0.addSeries(series);
    dataset_outliers.addSeries(series_outliers);

    /*
     * first we have to sort the vector according to the rendering ordering
     * (which is the x value). REALLY??? After hours of searching no better
     * solution found! please help!
     */

    Collections.sort(comps, new MyComparator());

    for (Iterator<Comp> iter = comps.iterator(); iter.hasNext();) {
        Comp cp = iter.next();
        urls.add(cp.getURL());
        tooltips.add(cp.getTooltip());
    }

    url_gen.addURLSeries(urls);
    tt_gen.addToolTipSeries(tooltips);

    String title = "[" + this.countsType + "]\tVolumes " + (hour - 1) + ":00 - " + (hour) + ":00, Iteration: "
            + this.iteration_;
    this.setChartTitle(title);
    this.chart_ = ChartFactory.createXYLineChart(title, "Count Volumes [veh/h]", // x axis label
            "Sim Volumes [veh/h]", // y axis label
            dataset0, // data
            PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips
            true // urls
    );
    XYPlot plot = this.chart_.getXYPlot();
    final LogarithmicAxis axis_x = new LogarithmicAxis("Count Volumes [veh/h]");
    final LogarithmicAxis axis_y = new LogarithmicAxis("Sim Volumes [veh/h]");
    axis_x.setAllowNegativesFlag(false);
    axis_y.setAllowNegativesFlag(false);

    // regular values
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setLinesVisible(false);
    renderer.setURLGenerator(url_gen);
    renderer.setSeriesPaint(0, Color.black);
    renderer.setSeriesToolTipGenerator(0, tt_gen);
    renderer.setSeriesShape(0, new Rectangle2D.Double(-1.5, -1.5, 3.0, 3.0));

    // outliers
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    renderer2.setLinesVisible(false);
    renderer2.setSeriesPaint(0, Color.red);
    renderer2.setSeriesShape(0, new Ellipse2D.Double(-3.0, -3.0, 6.0, 6.0));

    // error band
    DefaultXYDataset dataset1 = new DefaultXYDataset();
    dataset1.addSeries("f1x", new double[][] { { 1.0, 10000.0 }, { 1.0, 10000.0 } });
    dataset1.addSeries("f2x", new double[][] { { 1.0, 10000.0 }, { 2.0, 20000.0 } });
    dataset1.addSeries("f05x", new double[][] { { 2.0, 10000.0 }, { 1.0, 5000.0 } });

    XYLineAndShapeRenderer renderer3 = new XYLineAndShapeRenderer();
    renderer3.setShapesVisible(false);
    renderer3.setSeriesPaint(0, Color.blue);
    renderer3.setSeriesPaint(1, Color.blue);
    renderer3.setSeriesPaint(2, Color.blue);
    renderer3.setBaseSeriesVisibleInLegend(false);
    renderer3.setSeriesItemLabelsVisible(0, true);
    renderer3.setSeriesItemLabelsVisible(1, false);
    renderer3.setSeriesItemLabelsVisible(2, false);

    XYTextAnnotation annotation0 = new XYTextAnnotation("2.0 count", 12000.0, 15500.0);
    annotation0.setFont(new Font("SansSerif", Font.BOLD, 11));
    plot.addAnnotation(annotation0);
    XYTextAnnotation annotation1 = new XYTextAnnotation("count", 13000.0, 10000.0);
    annotation1.setFont(new Font("SansSerif", Font.BOLD, 11));
    plot.addAnnotation(annotation1);
    XYTextAnnotation annotation2 = new XYTextAnnotation("0.5 count", 11000.0, 3500.0);
    annotation2.setFont(new Font("SansSerif", Font.BOLD, 11));
    plot.addAnnotation(annotation2);

    plot.setDomainAxis(axis_x);
    plot.setRangeAxis(axis_y);
    plot.setRenderer(0, renderer);

    plot.setRenderer(1, renderer2);
    plot.setDataset(1, dataset_outliers);

    plot.setRenderer(2, renderer3);
    plot.setDataset(2, dataset1);

    plot.getRangeAxis().setRange(1.0, 19000.0);
    plot.getDomainAxis().setRange(1.0, 19000.0);

    return this.chart_;
}

From source file:br.usp.icmc.gazetteer.SemanticSearchTest.Grafico.java

private XYDataset createDataset1() {
    XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
    XYSeries team1_xy_data = new XYSeries("MAP1");
    int k = 126;/*from  ww  w.ja va 2 s.  c  o m*/
    for (BigDecimal d : cm.getMapQ()) {
        team1_xy_data.add(k, d.floatValue());
        k++;
    }
    xySeriesCollection.addSeries(team1_xy_data);
    return xySeriesCollection;
}

From source file:edu.ucla.stat.SOCR.chart.demo.SymbolAxisDemo1.java

/**
 * Creates a sample dataset.// w  w  w. ja va2s.c o  m
 */
protected XYDataset createDataset(boolean isDemo) {
    if (isDemo) {
        XYSeries s1 = new XYSeries("Series 1");
        s1.add(0, 3);
        s1.add(1, 3);
        s1.add(2, 0);
        s1.add(3, 1);
        XYSeries s2 = new XYSeries("Series 2");
        s2.add(0, 1);
        s2.add(1, 2);
        s2.add(2, 1);
        s2.add(3, 3);

        XYSeriesCollection dataset = new XYSeriesCollection();
        dataset.addSeries(s1);
        dataset.addSeries(s2);
        return dataset;
    } else
        return super.createDataset(false);
}

From source file:chartsPK.LineChart.java

private XYDataset createDataset() {

    XYSeriesCollection dataset = new XYSeriesCollection();
    Vector<XYSeries> series = new Vector<>();

    for (LineChartDataSeries dataSerie : dataSeries) {
        series.add(new XYSeries(dataSerie.getTitle()));
    }//www  .  j av a 2 s  .  co m

    for (int i = 0; i < dataSeries.size(); i++) {
        for (int j = 0; j < dataSeries.get(i).getXValues().size(); j++) {
            series.get(i).add(dataSeries.get(i).getXValues().get(j), dataSeries.get(i).getYValues().get(j));
        }
    }

    for (XYSeries serie : series) {
        dataset.addSeries(serie);
    }

    return dataset;
}

From source file:edu.wustl.cab2b.client.ui.visualization.charts.ScatterPlot.java

@Override
protected Dataset createRowWiseData() {

    List<String> selectedRowNames = chartModel.getSelectedRowNames();
    List<String> selectedColumnsNames = chartModel.getSelectedColumnsNames();

    XYSeriesCollection xySeriesCollection = new XYSeriesCollection();

    if (selectedRowNames.size() == 1) {
        String seriesName = selectedRowNames.get(0) + "";
        XYSeries xySeries = new XYSeries(seriesName);
        for (int j = 0; j < selectedColumnsNames.size(); j++) {
            Object value = null;//from w  ww  .  j  a va2 s .c o m
            if (chartModel.isWholeColumnSelected()) {
                value = chartModel.getValueAt(0, j);
            }

            xySeries.add(convertValue(selectedRowNames.get(j)), convertValue(value));
        }
        xySeriesCollection.addSeries(xySeries);
    } else {
        for (int i = 1; i < selectedRowNames.size(); i++) {
            String seriesName = selectedRowNames.get(i) + "";
            XYSeries xySeries = new XYSeries(seriesName);

            for (int j = 0; j < selectedColumnsNames.size(); j++) {
                Object xValueString = chartModel.getValueAt(0, j);
                Object yValueString = chartModel.getValueAt(i, j);
                xySeries.add(convertValue(xValueString), convertValue(yValueString));
            }
            xySeriesCollection.addSeries(xySeries);
        }
    }
    return xySeriesCollection;
}

From source file:com.griddynamics.jagger.reporting.LatencyPlotReportProvider.java

public static XYSeriesCollection getSeriesCollection(int seriesCount) {
    XYSeriesCollection result = new XYSeriesCollection();
    Random rnd = new Random();
    for (int i = 0; i < seriesCount; i++) {
        XYSeries series = new XYSeries(i, false, false);
        result.addSeries(series);//from w ww. j  a v a2 s . com
        for (int t = 0; t < 100; t++) {
            series.add(t, rnd.nextInt(50));
        }
    }

    return result;
}

From source file:erigo.filewatch.DisplayPlot.java

/**
 * Add all the data to a new XYDataset//from w  w  w .j  a  v a2 s . com
 */
private XYDataset createDataset() {

    XYSeriesCollection dataset = new XYSeriesCollection();

    XYSeries series = new XYSeries("data");
    for (int i = 0; i < xData.size(); ++i) {
        series.add(xData.get(i).doubleValue(), yData.get(i).doubleValue());
    }

    //Add series to dataset
    dataset.addSeries(series);

    return dataset;

}

From source file:org.graphstream.algorithm.measure.ChartSeriesMeasure.java

public JFreeChart createChart(PlotParameters params) throws PlotException {
    JFreeChart chart;/* ww w  .ja va2  s.com*/
    XYSeriesCollection dataset = new XYSeriesCollection();

    dataset.addSeries(getXYSeries());

    switch (params.type) {
    case LINE:
        chart = ChartFactory.createXYLineChart(params.title, params.xAxisLabel, params.yAxisLabel, dataset,
                params.orientation, params.showLegend, false, false);
        break;
    case BAR:
        chart = ChartFactory.createXYBarChart(params.title, params.xAxisLabel, false, params.yAxisLabel,
                dataset, params.orientation, params.showLegend, false, false);
        break;
    case SCATTER:
        chart = ChartFactory.createScatterPlot(params.title, params.xAxisLabel, params.yAxisLabel, dataset,
                params.orientation, params.showLegend, false, false);
        break;
    default:
        throw new PlotException("unsupported plot type");
    }

    return chart;
}

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

private XYSeriesCollection createDatasets(String runId1, String runId2) {
    XYSeriesCollection ds = new XYSeriesCollection();
    Tuple<XYSeries, List<String>> seriesLabels = this.createXYSeries("Mean " + '\u0394' + "Utility", this.ana,
            runId1, runId2);/*  w  w w.  j  a va 2  s .  c  o  m*/
    ds.addSeries(seriesLabels.getFirst());
    this.labelGenerator.setLabels(0, seriesLabels.getSecond());
    return ds;
}