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:com.opendoorlogistics.components.linegraph.LineGraphPanel.java

@Override
protected JFreeChart createChart(ODLTableReadOnly table, int[] rowFilter) {

    // split by key
    Map<String, List<XY>> lines = api.stringConventions().createStandardisedMap();

    if (rowFilter != null) {
        for (int row : rowFilter) {
            readLine(table, row, lines);
        }/*from ww  w  .  ja va  2 s.  co  m*/
    } else {
        int n = table.getRowCount();
        for (int row = 0; row < n; row++) {
            readLine(table, row, lines);
        }
    }

    XYSeriesCollection dataset = new XYSeriesCollection();

    for (Map.Entry<String, List<XY>> line : lines.entrySet()) {
        XYSeries s = new XYSeries(line.getKey());
        for (XY xy : line.getValue()) {
            s.add(xy.X, xy.Y);
        }
        dataset.addSeries(s);
    }

    JFreeChart chart = ChartFactory.createXYLineChart(
            api.stringConventions().isEmptyString(config.getTitle()) ? null : config.getTitle(), // chart title
            config.getXLabel(), // x axis label
            config.getYLabel(), // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, lines.size() > 0, // include legend
            true, // tooltips
            false // urls
    );

    // make lines thicker
    for (int i = 0; i < lines.size(); i++) {
        ((XYPlot) chart.getPlot()).getRenderer().setSeriesStroke(i, new BasicStroke(2));
    }

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.WHITE);

    return chart;
}

From source file:loadmaprenderer.ResultDisplayChart.java

private XYSeriesCollection makeChartDataset(List<ResultDataPair> values, String dataTitle, double average) {
    XYSeriesCollection collection = new XYSeriesCollection();
    dataLine = new XYSeries(dataTitle);
    averageLine = new XYSeries("Average");
    for (int i = 0; i < values.size(); i++) {
        dataLine.add(values.get(i).getYear(), values.get(i).getData());
        averageLine.add(values.get(i).getYear(), average);
    }/*from w w  w .j a  v  a  2  s  . c om*/
    collection.addSeries(dataLine);
    collection.addSeries(averageLine);
    return collection;
}

From source file:celeste.Celeste.java

public void pintarTodosTrayectorias() {
    XYSeriesCollection coleccion = new XYSeriesCollection();

    for (int i = 0; i < planetas.size(); i++) {
        String name = planetas.get(i)[0];
        double a = Double.parseDouble(planetas.get(i)[1]);
        double epsilon = Double.parseDouble(planetas.get(i)[2]);
        double p = Double.parseDouble(planetas.get(i)[3]);

        Planeta planeta = new Planeta(a, epsilon, p);
        XYSeries serie = planeta.generarPosiciones();
        serie.setKey(name);/*from   ww  w  . jav  a2s  . c  o m*/
        coleccion.addSeries(serie);
    }
    generarGrafica(coleccion, false);
}

From source file:eu.cassandra.training.utils.ChartUtils.java

/**
 * This function is used for the visualization of a Comparative Response Model
 * Histogram./*  w w  w . ja v a2  s.  c o  m*/
 * 
 * @param title
 *          The title of the chart.
 * @param x
 *          The unit on the X axis of the chart.
 * @param y
 *          The unit on the Y axis of the chart.
 * @param dataBefore
 *          The array of values before the response.
 * @param dataAfter
 *          The array of values after the response.
 * @return a chart panel with the graphical representation.
 */
public static ChartPanel createResponseHistogram(String title, String x, String y, double[] dataBefore,
        double[] dataAfter) {
    XYSeries series1 = new XYSeries("Basic Pricing Scheme");
    for (int i = 0; i < dataBefore.length; i++) {
        series1.add(i, dataBefore[i]);
    }

    XYSeries series2 = new XYSeries("New Pricing Scheme");
    for (int i = 0; i < dataAfter.length; i++) {
        series2.add(i, dataAfter[i]);
    }

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

    PlotOrientation orientation = PlotOrientation.VERTICAL;
    boolean show = true;
    boolean toolTips = false;
    boolean urls = false;

    JFreeChart chart = ChartFactory.createXYLineChart(title, x, y, dataset, orientation, show, toolTips, urls);
    XYPlot xyplot = (XYPlot) chart.getPlot();
    xyplot.setDomainPannable(true);
    xyplot.setRangePannable(true);
    xyplot.setForegroundAlpha(0.85F);
    NumberAxis domainAxis = (NumberAxis) xyplot.getDomainAxis();

    // domainAxis.setRange(0.0, 1440.0);
    domainAxis.setTickUnit(new NumberTickUnit(10));
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setTickUnit(new NumberTickUnit(0.1));

    return new ChartPanel(chart);
}

From source file:cs.register.geraGrafico.java

private XYSeriesCollection datawld(List<partida> list1) {
    XYSeriesCollection data = new XYSeriesCollection();
    XYSeries ser = new XYSeries("kda");
    for (partida p : list1) {
        ser.add(list1.indexOf(p) + 1, (p.getWld()));
    }/*from w  w  w .  j a v  a  2 s.c  o  m*/
    data.addSeries(ser);

    return data;
}

From source file:MSUmpire.DIA.RTAlignedPepIonMapping.java

public void GenerateModel() throws IOException {

    XYPointCollection points = new XYPointCollection();
    XYSeries series = new XYSeries("Peptide ions");
    XYSeriesCollection xySeriesCollection = new XYSeriesCollection();

    for (PepIonID pepA : LCMSA.GetPepIonList().values()) {
        if (LCMSB.GetPepIonList().containsKey(pepA.GetKey())) {
            PepIonID pepB = LCMSB.GetPepIonList().get(pepA.GetKey());
            points.AddPoint(pepA.GetRT(), pepB.GetRT());
            series.add(new XYDataItem(pepA.GetRT(), pepB.GetRT()));
        }//w  w  w. j ava  2 s  . c  o  m
    }
    regression = new PiecewiseRegression(parameter.MaxCurveRTRange, parameter.MaxCurveRTRange);
    regression.SetData(points);
    float R2 = regression.GetR2();
    Logger.getRootLogger()
            .info("Retention time prediction model:(" + FilenameUtils.getBaseName(LCMSA.mzXMLFileName) + "-"
                    + FilenameUtils.getBaseName(LCMSB.mzXMLFileName) + ")..R2=" + R2
                    + "(No. of commonly identified peptide ions=" + points.PointCount() + ")");

    GenerateRTMapPNG(xySeriesCollection, series, R2);
}

From source file:com.att.aro.ui.view.diagnostictab.plot.AttenuatorPlot.java

/**
 * @param plot/*  w w w.ja  v  a2  s.  c om*/
 * @param seriesDL
 * @param seriesUP
 */
private void setDataPlot(XYPlot plot, XYSeries seriesDL, XYSeries seriesUP) {
    XYSeriesCollection sercollection = new XYSeriesCollection();
    sercollection.addSeries(seriesDL);
    sercollection.addSeries(seriesUP);

    XYStepRenderer renderer = new XYStepRenderer();
    XYPlot plot1 = (XYPlot) plot;
    plot1.getRangeAxis().setAutoRangeMinimumSize(2.0);//for the data set is constant value(ex. 0)      
    renderer = (XYStepRenderer) plot1.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setSeriesStroke(0, new BasicStroke(2.0f));
    renderer.setSeriesStroke(1, new BasicStroke(4.0f));

    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    renderer.setDefaultEntityRadius(6);
    renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {
        @Override
        public String generateToolTip(XYDataset dataset, int series, int item) {
            StringBuffer displayInfo = new StringBuffer();
            java.lang.Number tempx = dataset.getX(series, item);
            java.lang.Number tempy = dataset.getY(series, item);
            // series 0 -> downstream , stries 1 -> upstream
            String streamInfo = "";
            if (series == 0) {
                streamInfo = "Downlink Delay";
            } else {
                streamInfo = "Uplink Delay";
            }
            return displayInfo.append("Time: " + tempx + " , " + streamInfo + " : " + tempy + "ms").toString();
        }
    });
    plot.setRenderer(renderer);
    plot.setDataset(sercollection);

}

From source file:com.github.dougkelly88.FLIMPlateReaderGUI.FLIMClasses.Classes.FindMaxpoint.java

private XYDataset createDummyMaxpointData(int offset) {

    final XYSeries s1 = new XYSeries("DummyMaxpoint");
    for (int i = 0; i < 16666; i = i + resolution_) {
        if (i < 1000)
            s1.add(i, 0);//from   w ww. j av  a2 s. com
        else {
            int num = (int) (4000 * exp(-((double) ((i - maxpointDelay_)) / (2000))));
            s1.add(i, num);
        }
        //                s1.add(i, 4000* exp(-((double) (i - maxpointDelay_))));
    }
    //        delays_ = 
    final XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(s1);

    return dataset;
}

From source file:dbseer.gui.chart.DBSeerChartFactory.java

public static XYSeriesCollection getXYSeriesCollection(String chartName, DBSeerDataSet dataset)
        throws Exception {
    StatisticalPackageRunner runner = DBSeerGUI.runner;

    runner.eval("[title legends Xdata Ydata Xlabel Ylabel timestamp] = plotter.plot" + chartName + ";");

    String title = runner.getVariableString("title");
    Object[] legends = (Object[]) runner.getVariableCell("legends");
    Object[] xCellArray = (Object[]) runner.getVariableCell("Xdata");
    Object[] yCellArray = (Object[]) runner.getVariableCell("Ydata");
    String xLabel = runner.getVariableString("Xlabel");
    String yLabel = runner.getVariableString("Ylabel");

    timestamp = runner.getVariableDouble("timestamp");

    XYSeriesCollection XYdataSet = new XYSeriesCollection();

    int numLegends = legends.length;
    int numXCellArray = xCellArray.length;
    int numYCellArray = yCellArray.length;
    int dataCount = 0;

    if (numXCellArray != numYCellArray) {
        JOptionPane.showMessageDialog(null, "The number of X dataset and Y dataset does not match.",
                "The number of X dataset and Y dataset does not match.", JOptionPane.ERROR_MESSAGE);
        System.out.println(numXCellArray + " : " + numYCellArray);
        return null;
    }//from w w  w . ja  v a  2  s.  com

    java.util.List<String> transactionNames = dataset.getTransactionTypeNames();

    for (int i = 0; i < numLegends; ++i) {
        String legend = (String) legends[i];
        for (int j = 0; j < transactionNames.size(); ++j) {
            if (legend.contains("Type " + (j + 1))) {
                legends[i] = legend.replace("Type " + (j + 1), transactionNames.get(j));
                break;
            }
        }
    }

    for (int i = 0; i < numYCellArray; ++i) {
        double[] xArray = (double[]) xCellArray[i];
        int row = 0, col = 0;
        int xLength = 0;

        runner.eval("yArraySize = size(Ydata{" + (i + 1) + "});");
        runner.eval("yArray = Ydata{" + (i + 1) + "};");
        double[] yArraySize = runner.getVariableDouble("yArraySize");
        double[] yArray = runner.getVariableDouble("yArray");

        xLength = xArray.length;
        row = (int) yArraySize[0];
        col = (int) yArraySize[1];

        for (int c = 0; c < col; ++c) {
            XYSeries series;
            String legend = "";
            int legendIdx = (dataCount >= numLegends) ? numLegends - 1 : dataCount;
            if (legendIdx >= 0) {
                legend = (String) legends[legendIdx];
            }
            if (numLegends == 0) {
                series = new XYSeries("Data " + dataCount + 1);
            } else if (dataCount >= numLegends) {
                series = new XYSeries(legend + (dataCount + 1));
            } else {
                series = new XYSeries(legend);
            }

            for (int r = 0; r < row; ++r) {
                int xRow = (r >= xLength) ? xLength - 1 : r;
                double yValue = yArray[r + c * row];
                // remove negatives
                if (yValue < 0) {
                    yValue = 0;
                }
                series.add(xArray[xRow], yValue);
            }
            XYdataSet.addSeries(series);
            ++dataCount;
        }
    }

    return XYdataSet;
}

From source file:simx.profiler.discovery.latency.LatencyReportTopComponent.java

public LatencyReportTopComponent() {
    initComponents();/*from   w  ww  . java 2s .  c  o m*/
    setName(Bundle.CTL_LatencyReportTopComponent());
    setToolTipText(Bundle.HINT_LatencyReportTopComponent());

    this.latencyPlotData = new XYSeriesCollection();

    JFreeChart chart = ChartFactory.createXYLineChart("", "", "", this.latencyPlotData);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(261, 157));
    this.latencyOverTimePanel.setLayout(new BorderLayout());
    this.latencyOverTimePanel.add(chartPanel, BorderLayout.CENTER);

}