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.owasp.benchmark.score.report.ScatterTools.java

private JFreeChart display(String title, int height, OverallResults or) {

    JFrame f = new JFrame(title);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries series = new XYSeries("Scores");
    int totalTools = 0;
    double totalToolTPR = 0;
    double totalToolFPR = 0;
    for (OverallResult r : or.getResults()) {
        series.add(r.falsePositiveRate * 100, r.truePositiveRate * 100);
        totalTools++;// ww w.j  a  v a  2s .  c om
        totalToolTPR += r.truePositiveRate;
        totalToolFPR += r.falsePositiveRate;
    }
    atpr = totalToolTPR / totalTools;
    afpr = totalToolFPR / totalTools;

    if (or.getResults().size() > 1) {
        series.add(afpr * 100, atpr * 100);
    }

    dataset.addSeries(series);

    chart = ChartFactory.createScatterPlot(title, "False Positive Rate", "True Positive Rate", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    theme.apply(chart);

    XYPlot xyplot = chart.getXYPlot();

    initializePlot(xyplot);

    makeDataLabels(or, xyplot);
    makeLegend(or, 103, 93, dataset, xyplot);

    XYTextAnnotation time = new XYTextAnnotation("Tool run time: " + or.getTime(), 12, -5.6);
    time.setTextAnchor(TextAnchor.TOP_LEFT);
    time.setFont(theme.getRegularFont());
    time.setPaint(Color.red);
    xyplot.addAnnotation(time);

    ChartPanel cp = new ChartPanel(chart, height, height, 400, 400, 1200, 1200, false, false, false, false,
            false, false);
    f.add(cp);
    f.pack();
    f.setLocationRelativeTo(null);
    // f.setVisible(true);
    return chart;
}

From source file:wsattacker.plugin.intelligentdos.ui.helper.ChartHelper.java

public static JFreeChart createOverlaidChart(SuccessfulAttack sa) {

    // create subplot 1...
    final XYSeries data1 = createDatasetResponseTime(RequestType.UNTAMPERED, sa.getUntamperedMetrics());
    final XYSeries data2 = createDatasetResponseTime(RequestType.TAMPERED, sa.getTamperedMetrics());
    final XYSeries data3 = createDatasetResponseTime(RequestType.TESTPROBES, sa.getTestProbes());

    final XYSeriesCollection collection = new XYSeriesCollection();
    collection.addSeries(data1);//  w  ww .ja  va2 s  .c  om
    collection.addSeries(data2);
    collection.addSeries(data3);

    final XYItemRenderer renderer = new StandardXYItemRenderer();
    final NumberAxis rangeAxis1 = new NumberAxis("duration in ms");
    final XYPlot plot = new XYPlot(collection, new NumberAxis(""), rangeAxis1, renderer);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    renderer.setSeriesPaint(0, Color.GREEN);
    renderer.setSeriesPaint(1, Color.RED);
    renderer.setSeriesPaint(2, Color.BLUE);

    // return a new chart containing the overlaid plot...
    return new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
}

From source file:playground.anhorni.crossborder.verification.TGZMCompare.java

public JFreeChart createChart(String actType) {

    XYSeriesCollection dataset0 = new XYSeriesCollection();
    XYSeries series0 = new XYSeries(actType + " Trips MATSim");
    XYSeries series1 = new XYSeries(actType + " Trips TGZM");

    for (int i = 0; i < 24; i++) {
        double realVal = this.aggregatedVolumePerHour[i];
        int calcVal = this.xTripsPerHour[i];
        series0.add(i, calcVal);// w  w w  .  j  a  v a  2  s .  c  o m
        series1.add(i, realVal);
    }
    dataset0.addSeries(series0);
    dataset0.addSeries(series1);

    String title = "Compare TGZM and MATSim volumes per hour";
    this.chart = ChartFactory.createXYLineChart(title, "hour", // x axis label
            "Trips", // y axis label
            dataset0, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    XYPlot plot = this.chart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setLinesVisible(true);
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesShape(0, new Rectangle2D.Double(-1.5, -1.5, 3.0, 3.0));
    renderer.setSeriesPaint(1, Color.black);
    renderer.setSeriesShape(1, new Rectangle2D.Double(-1.5, -1.5, 3.0, 3.0));

    plot.setRenderer(0, renderer);

    return this.chart;
}

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

@Test
@Ignore//from   w  w w. j av a 2s . com
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:controller.DrawCurve.java

private XYDataset createDataset() {
    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries series1 = new XYSeries("Red", false);
    XYSeries series2 = new XYSeries("Green", false);
    XYSeries series3 = new XYSeries("Blue", false);

    for (int Z = 0; Z < 256; Z++) {
        for (int i = 0; i < 3; i++) {
            if (i == 0) {
                series1.add(G[i][Z], Z);
            } else if (i == 1) {
                series2.add(G[i][Z], Z);
            } else {
                series3.add(G[i][Z], Z);
            }//w w  w  . j  a v  a 2  s  .  c o  m
        }
    }

    dataset.addSeries(series1);
    dataset.addSeries(series2);
    dataset.addSeries(series3);

    return dataset;
}

From source file:netplot.XYPlotPanel.java

public void addPlot() {
    int plotIndex = xySeriesList.size();
    XYSeries xySeries = new XYSeries(plotName);
    xySeriesList.add(xySeries);//from  www . jav a  2s  .  c om

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(xySeries);
    ((XYPlot) chart.getPlot()).setDataset(plotIndex, (XYDataset) dataset);
    genericConfig(chart, (XYPlot) chart.getPlot(), plotIndex);
    itemCountList.add(new Integer(0));
}

From source file:org.jgrasstools.gears.utils.chart.Scatter.java

public Scatter(String title) {
    this.title = title;
    dataset = new XYSeriesCollection();
}

From source file:org.ow2.clif.jenkins.chart.MovingStatChart.java

@Override
protected JFreeChart createChart() {
    XYSeriesCollection coreDataset = new XYSeriesCollection();
    coreDataset.addSeries(this.eventSerie);

    long periodMs = this.chartConfiguration.getStatisticalPeriod() * 1000L;

    XYSeriesCollection movingDataset = calculateMovingDataset(coreDataset, periodMs);
    XYSeriesCollection throughputDataset = calculateThroughputDataset(coreDataset, periodMs);

    JFreeChart chart;//from   w ww. j  a v a  2 s  .c o  m
    chart = ChartFactory
            .createXYLineChart(
                    getBasicTitle() + " "
                            + Messages.MovingChart_StatisticalPeriod(
                                    this.chartConfiguration.getStatisticalPeriod()),
                    // chart title
                    Messages.MovingChart_Time(), // x axis label
                    Messages.MovingChart_ResponseTime(), // y axis label
                    movingDataset, // data
                    PlotOrientation.VERTICAL, true, // include legend
                    true, // tooltips
                    false // urls
    );

    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    XYPlot plot = (XYPlot) chart.getPlot();
    configureBasicPlotProperties(plot);

    // Force the 0 on vertical axis
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(true);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // Force the 0 on horizontal axis
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(true);

    attachThroughputDatasetToDedicatedAxis(throughputDataset, plot);

    // Global renderer for moving stats
    plot.setRenderer(getGlobalRenderer());

    // Dedicated Throughput renderer
    plot.setRenderer(1, getThroughputRenderer());

    return chart;
}

From source file:com.planetmayo.debrief.satc.util.StraightLineCullingTestForm.java

private void createChart() {
    collections = new XYSeriesCollection();
    chart = ChartFactory.createXYLineChart("main", "x", "y", collections, PlotOrientation.VERTICAL, false,
            false, false);/*from   w w  w .  j ava  2 s  .c o m*/

    ChartPanel panel = new ChartPanel(chart);
    panel.setPreferredSize(new Dimension(800, 600));
    setContentPane(panel);
}

From source file:TradeMonitorGui.java

private void startGui() {
    XYSeriesCollection dataset = new XYSeriesCollection();
    createChartFrame(dataset);/* www  .  ja v  a 2s. c  o m*/
    EntryAddedUpdatedListener<String, KeyedWindowResult<String, Double>> listener = (key, value) -> {
        if (!TICKERS.contains(key)) {
            return;
        }
        Long ts = value.end();
        double val = value.result() / 100.0;
        int idx = dataset.getSeriesIndex(key);
        XYSeries series;
        if (idx == -1) {
            series = new XYSeries(key, true, false);
            dataset.addSeries(series);
        } else {
            series = dataset.getSeries(idx);
        }
        series.addOrUpdate((long) ts, val);
    };
    this.listenerId = avgPrices.addEntryListener(listener, true);
}