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:edu.msu.cme.rdp.rarefaction.RarefactionPlotter.java

private static void plotToFile(List<RarefactionResult> resultsToPlot, int numSeqs, String title,
        File outputFile) throws IOException {
    XYSeriesCollection dataset = new XYSeriesCollection();

    for (RarefactionResult result : resultsToPlot) {
        XYSeries series = new XYSeries(RarefactionWriter.dformat.format(result.distance) + " distance");

        for (int plotIndex : RarefactionWriter.getIndiciesToPlot(numSeqs)) {
            series.add(result.geteArray()[plotIndex], plotIndex);
        }//from  w ww .java  2 s.c  om

        dataset.addSeries(series);
    }

    JFreeChart chart = ChartFactory.createXYLineChart(title, "", "", dataset, PlotOrientation.HORIZONTAL, true,
            false, false);
    ChartUtilities.saveChartAsPNG(outputFile, chart, 1280, 1024);
}

From source file:umontreal.iro.lecuyer.charts.YListSeriesCollection.java

private void initYListSeries(double h, double[] data, int numPoints) {
    renderer = new XYLineAndShapeRenderer(true, false);
    seriesCollection = new XYSeriesCollection();

    XYSeriesCollection tempSeriesCollection = (XYSeriesCollection) seriesCollection;
    XYSeries serie = new XYSeries(" ");
    for (int j = 0; j < numPoints; j++)
        serie.add(h * (j + 1), data[j]);
    tempSeriesCollection.addSeries(serie);

    // set default colors
    renderer.setSeriesPaint(0, getDefaultColor(0));

    // set default plot style
    plotStyle = new String[1];
    marksType = new String[1];
    dashPattern = new String[1];
    marksType[0] = " ";
    plotStyle[0] = "smooth";
    dashPattern[0] = "solid";
}

From source file:org.mc.okapi.Plot.java

public Plot(double[] X, double[] Y, String xLab, String yLab, String seriesName, String applicationTitle,
        String chartTitle) {/*  w  w  w . j a  v a 2  s  . c  o m*/
    super(applicationTitle);

    XYSeries series = new XYSeries(seriesName);

    for (int i = 0; i < X.length; i++) {
        series.add(X[i], Y[i]);
    }
    // create a dataset...
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);

    // based on the dataset we create the chart        
    JFreeChart chart = ChartFactory.createScatterPlot(chartTitle, xLab, yLab, dataset, PlotOrientation.VERTICAL,
            true, rootPaneCheckingEnabled, rootPaneCheckingEnabled);
    Shape cross = ShapeUtilities.createDiagonalCross(3, 1);
    XYPlot xyPlot = (XYPlot) chart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);
    XYItemRenderer renderer = xyPlot.getRenderer();
    renderer.setSeriesShape(0, cross);
    renderer.setSeriesPaint(0, Color.red);

    // we put the chart into a panel
    ChartPanel chartPanel = new ChartPanel(chart);
    setIconImage(Toolkit.getDefaultToolkit().getImage("images/ico/extra/science_32.png"));

    // default size
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    // add it to our application
    setContentPane(chartPanel);

}

From source file:de.hs.mannheim.modUro.reader.JCellCountDiagram.java

private XYDataset createDataset(List<String> cellTypes, List<CellCountEntry> cellcountList) {

    XYSeriesCollection dataset = new XYSeriesCollection();

    XYSeries xySerieSum = new XYSeries("total");
    for (String cellType : cellTypes) {
        XYSeries xySerie = new XYSeries(cellType);
        for (CellCountEntry e : cellcountList) {
            double x = e.time;
            double y = 0;
            if (e.count.containsKey(cellType)) {
                y = (double) e.count.get(cellType);
            }//from  w w w. ja v  a2  s .c om
            xySerie.add(x, y);
        }
        dataset.addSeries(xySerie);
    }
    for (CellCountEntry e : cellcountList) {
        double x = e.time;
        double y = e.count.values().stream().mapToDouble(i -> i.intValue()).sum();
        if (y != Double.NaN) {
            xySerieSum.add(x, y);
        }
    }
    dataset.addSeries(xySerieSum);
    return dataset;
}

From source file:fr.crnan.videso3d.ihm.TrajectoryProjectionGUI.java

public TrajectoryProjectionGUI(List<VidesoTrack> tracks, Globe globe) {

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);/* w  w  w . j  ava  2 s. c  o m*/

    JMenu mnParamtres = new JMenu("Paramtres");
    menuBar.add(mnParamtres);

    JMenuItem mntmNewMenuItem = new JMenuItem("New menu item");
    mnParamtres.add(mntmNewMenuItem);

    double ref = TracksStatsProducer.computeReferenceAltitude(tracks);
    XYSeriesCollection dataset = new XYSeriesCollection();

    for (VidesoTrack t : tracks) {
        dataset.addSeries(TracksStatsProducer.computeDevelopedPath(t, ref, false, globe));
    }

    JFreeChart chart = ChartFactory.createXYLineChart("Projection", "Distance (NM)", "Altitude (FL)", dataset,
            PlotOrientation.VERTICAL, false, true, false);

    ChartPanel panel = new ChartPanel(chart);
    setContentPane(panel);
    pack();
}

From source file:de.hs.mannheim.modUro.diagram.JCellcycletimeDiagram.java

private XYDataset createDataset(List<String> cellTypes, List<CellCycletimeEntry> cycletimesList) {

    XYSeriesCollection dataset = new XYSeriesCollection();

    for (String cellType : cellTypes) {
        XYSeries xySerie = new XYSeries(cellType);
        for (CellCycletimeEntry e : cycletimesList) {
            double x = e.time;
            double y = 0;
            if (e.meanValues.containsKey(cellType)) {
                y = (double) e.meanValues.get(cellType);
            }/* w w w .  ja v  a2s.  co m*/
            if (y != Double.NaN) {
                xySerie.add(x, y);
            }
        }
        dataset.addSeries(xySerie);
    }
    return dataset;
}

From source file:SystemAnomalies.bouncedLogInRate.java

public ChartPanel getChartPanel() {
    XYSeries series = new XYSeries("Annual Composite Production Vs Farmers Experience");
    series.add(0, 0);/*w ww  .ja v a 2s .  c om*/
    series.add(1, 100);
    series.add(2, 100);
    series.add(3, 100);
    series.add(4, 120);
    series.add(5, 120);
    series.add(6, 1040);
    series.add(7, 1040);
    series.add(8, 1040);
    series.add(9, 2000);
    series.add(10, 2000);
    series.add(11, 100);
    series.add(12, 100);
    series.add(13, 100);
    series.add(14, 120);
    series.add(15, 120);
    series.add(16, 1040);
    series.add(17, 1040);
    series.add(18, 1040);
    series.add(19, 2000);
    series.add(20, 2000);
    series.add(21, 1845);
    series.add(22, 1040);
    series.add(23, 2000);

    // Add the series to your data set
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);
    // Generate the graph
    JFreeChart chart = ChartFactory.createXYLineChart("Sign-in Bounce off Rate", // Title
            "Time of Day", // x-axis Label
            "Number of Attempts", // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            true, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );

    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setBackground(Color.WHITE);
    chartPanel.setBounds(2, 5, 750, 500);
    chartPanel.setBorder(new LineBorder(Color.decode("#f5f5f5"), 2));

    return chartPanel;
}

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

private void createDataSet() {

    double xvalue = 0;
    double yvalue = 0;

    this.dataset = new XYSeriesCollection();
    XYSeries series = new XYSeries("Series name", false, true);
    this.dataset.addSeries(series);
    series.add(xvalue, yvalue);/*from w w w. java2  s.co  m*/
}

From source file:web.diva.server.model.PCAGenerator.java

/**
 *
 *
 * @return dataset./*from w w  w  . j  a v a  2s .  c o m*/
 */
private XYDataset createDataset(TreeMap<Integer, PCAPoint> points, int[] subSelectionData, int[] selection,
        boolean zoom, DivaDataset divaDataset) {

    final XYSeriesCollection dataset = new XYSeriesCollection();
    seriesList = new TreeMap<String, XYSeries>();
    seriesList.put("#000000", new XYSeries("#000000"));
    seriesList.put("unGrouped", new XYSeries("LIGHT_GRAY"));

    for (Group g : divaDataset.getRowGroups()) {
        if (g.isActive() && !g.getName().equalsIgnoreCase("all")) {
            seriesList.put(g.getHashColor(), new XYSeries(g.getHashColor()));
        }
    }

    if (!zoom && (selection == null || selection.length == 0) && subSelectionData == null) {
        for (int key : points.keySet()) {
            PCAPoint point = points.get(key);
            if (seriesList.containsKey(point.getColor())) {
                seriesList.get(divaDataset.getGeneColorArr()[point.getGeneIndex()]).add(point.getX(),
                        point.getY());
            } else {
                seriesList.get("unGrouped").add(point.getX(), point.getY());
            }

        }

    } else if (zoom) {
        selectionSet.clear();
        for (int i : selection) {
            selectionSet.add(i);
        }

        for (int x : subSelectionData) {
            PCAPoint point = points.get(x);
            if (selectionSet.contains(point.getGeneIndex())) {
                if (seriesList.containsKey(point.getColor())) {
                    seriesList.get(divaDataset.getGeneColorArr()[point.getGeneIndex()]).add(point.getX(),
                            point.getY());

                } else {

                    seriesList.get("#000000").add(point.getX(), point.getY());
                }

            } else {
                seriesList.get("unGrouped").add(point.getX(), point.getY());
            }
        }

    } else if (subSelectionData != null) {
        selectionSet.clear();
        for (int i : selection) {
            selectionSet.add(i);
        }
        for (int key : subSelectionData) {
            PCAPoint point = points.get(key);
            if (selectionSet.contains(point.getGeneIndex())) {
                if (seriesList.containsKey(divaDataset.getGeneColorArr()[point.getGeneIndex()])) {
                    seriesList.get(divaDataset.getGeneColorArr()[point.getGeneIndex()]).add(point.getX(),
                            point.getY());

                } else {

                    seriesList.get("#000000").add(point.getX(), point.getY());
                }

            } else {

                seriesList.get("unGrouped").add(point.getX(), point.getY());
            }

        }

    } else //selection without zoom
    {
        selectionSet.clear();
        for (int i : selection) {
            selectionSet.add(i);
        }
        for (int key : points.keySet()) {
            PCAPoint point = points.get(key);

            if (selectionSet.contains(point.getGeneIndex())) {
                if (seriesList.containsKey(divaDataset.getGeneColorArr()[point.getGeneIndex()])) {
                    seriesList.get(divaDataset.getGeneColorArr()[point.getGeneIndex()]).add(point.getX(),
                            point.getY());

                } else {

                    seriesList.get("#000000").add(point.getX(), point.getY());
                }

            } else {

                seriesList.get("unGrouped").add(point.getX(), point.getY());
            }

        }

    }
    for (XYSeries ser : seriesList.values()) {
        dataset.addSeries(ser);
    }

    return dataset;

}

From source file:analisisnumerico.Graficador.java

private XYDataset generarDatos(Funcion F, double lower, double upper) {
    //le pasamos una funcion generadora f(x)
    XYSeries datos = new XYSeries("Linea Funcion");
    for (double x = lower; x <= upper; x += 0.2)
        datos.add(x, f(x, F));//from   www. jav  a2  s. c  om
    XYSeriesCollection conjuntoDatos = new XYSeriesCollection();
    conjuntoDatos.addSeries(datos);

    return conjuntoDatos;
}