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

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

Introduction

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

Prototype

public XYSeries(Comparable key) 

Source Link

Document

Creates a new empty series.

Usage

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

private XYDataset createDummyGatingData() {

    final XYSeries s1 = new XYSeries("DummyGating");
    s1.add(0, 0);/* w w  w. j  a  v a  2  s .com*/
    s1.add(1000, 0);
    s1.add(2000, 0);
    s1.add(3000, 0);
    s1.add(4000, 0);
    s1.add(5000, 0);

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

    return dataset;
}

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  w w  . j ava2  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:br.prof.salesfilho.oci.image.GraphicBuilder.java

public void addSeire(double[] values, String serieName) {
    final XYSeries serie = new XYSeries(serieName);
    for (int i = 0; i < values.length; i++) {
        serie.add(i, Precision.round(values[i], 2));
    }/* www .j a  va 2s .  c om*/
    collectionDataset.addSeries(serie);
}

From source file:gov.sandia.umf.platform.ui.jobs.Raster.java

public void parsePrnFile(File f) {
    dataset = new XYSeriesCollection();
    XYSeries series = new XYSeries("Spikes");
    dataset.addSeries(series);/*  w  ww . ja v  a  2s  .  co  m*/
    int columns = 1;

    try {
        int row = 0;
        int timeColumn = -1; // It's possible that there might not be a time column. In that case, we use raw row index;

        BufferedReader br = new BufferedReader(new FileReader(f));
        while (true) {
            String line = br.readLine();
            if (line == null)
                break; // indicates end of stream

            line = line.trim();
            if (line.length() == 0)
                continue;
            if (line.startsWith("End of"))
                continue;

            String[] parts = line.split("\t"); // TODO: does Xyce output tabs or spaces? May have to switch regexp here, depending on source.
            columns = Math.max(columns, parts.length);

            char firstCharacter = parts[0].charAt(0);
            if (firstCharacter < '0' || firstCharacter > '9') // column header
            {
                if (timeColumn >= 0)
                    continue;

                int timeMatch = 0; // goodness of match
                for (int p = 0; p < parts.length; p++) {
                    int potentialMatch = 0;
                    String columnName = parts[p];
                    if (columnName.equals("TIME"))
                        potentialMatch = 1;
                    else if (columnName.equals("$t"))
                        potentialMatch = 2;
                    if (potentialMatch > timeMatch) {
                        timeMatch = potentialMatch;
                        timeColumn = p;
                    }
                }
            } else {
                int p = timeColumn;
                double time = row;
                if (p >= 0)
                    time = Double.parseDouble(parts[timeColumn]);
                p++;
                for (; p < parts.length; p++) {
                    if (!parts[p].isEmpty() && Double.parseDouble(parts[p]) != 0)
                        series.add(time, p);
                }
                row++;
            }
        }
        br.close();
    } catch (IOException e) {
    }

    availableHeight = Math.min(20, Math.max(1, Math.round((float) availableHeight / columns)));
}

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: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);
            }/*ww  w.ja  va  2  s. c  o m*/
            if (y != Double.NaN) {
                xySerie.add(x, y);
            }
        }
        dataset.addSeries(xySerie);
    }
    return dataset;
}

From source file:org.kurento.test.latency.ChartWriter.java

public ChartWriter(Map<Long, LatencyRegistry> latencyMap, String seriesTitle, String chartTitle,
        String xAxisLabel, String yAxisLabel) {

    // Convert latencyMap to XYDataset
    XYSeries series = new XYSeries(seriesTitle);
    for (long time : latencyMap.keySet()) {
        series.add(time, Math.abs(latencyMap.get(time).getLatency()));
    }//from   w w w.j  av a  2s .  co m
    dataset = new XYSeriesCollection();
    ((XYSeriesCollection) dataset).addSeries(series);

    this.xAxisLabel = xAxisLabel;
    this.yAxisLabel = yAxisLabel;
    this.chartTitle = chartTitle;
}

From source file:mt.DisplayHistogram.java

public static IntervalXYDataset createDataset(final List<Double> values, final int numBins,
        final String title) {
    final XYSeries series = new XYSeries(title);

    final ValuePair<Double, Double> minmax = getMinMax(values);
    min = minmax.getA();/*from w  ww  .  j a  v  a2 s . c om*/
    max = minmax.getB();

    final List<ValuePair<Double, Integer>> hist = binData(values, min, max, numBins);

    for (final ValuePair<Double, Integer> pair : hist)
        series.add(pair.getA(), pair.getB());

    final XYSeriesCollection dataset = new XYSeriesCollection(series);
    dataset.setAutoWidth(true);

    return dataset;
}

From source file:com.spotify.heroic.http.render.RenderUtils.java

public static JFreeChart createChart(final List<ShardedResultGroup> groups, final String title,
        Map<String, String> highlight, Double threshold, int height) {
    final XYLineAndShapeRenderer lineAndShapeRenderer = new XYLineAndShapeRenderer(true, true);
    final DeviationRenderer intervalRenderer = new DeviationRenderer();

    final XYSeriesCollection regularData = new XYSeriesCollection();
    final YIntervalSeriesCollection intervalData = new YIntervalSeriesCollection();

    int lineAndShapeCount = 0;
    int intervalCount = 0;

    for (final ShardedResultGroup resultGroup : groups) {
        final MetricCollection group = resultGroup.getMetrics();

        if (group.getType() == MetricType.POINT) {
            final XYSeries series = new XYSeries(resultGroup.getMetrics().toString());

            final List<Point> data = group.getDataAs(Point.class);

            for (final Point d : data) {
                series.add(d.getTimestamp(), d.getValue());
            }//ww w  . j  a  v a  2s.  c  o  m

            lineAndShapeRenderer.setSeriesPaint(lineAndShapeCount, Color.BLUE);
            lineAndShapeRenderer.setSeriesShapesVisible(lineAndShapeCount, false);
            lineAndShapeRenderer.setSeriesStroke(lineAndShapeCount, new BasicStroke(2.0f));
            regularData.addSeries(series);
            ++lineAndShapeCount;
        }

        if (group.getType() == MetricType.SPREAD) {
            final YIntervalSeries series = new YIntervalSeries(resultGroup.getMetrics().toString());

            final List<Spread> data = group.getDataAs(Spread.class);

            for (final Spread d : data) {
                series.add(d.getTimestamp(), d.getSum() / d.getCount(), d.getMin(), d.getMax());
            }

            intervalRenderer.setSeriesPaint(intervalCount, Color.GREEN);
            intervalRenderer.setSeriesStroke(intervalCount, new BasicStroke(2.0f));
            intervalRenderer.setSeriesFillPaint(intervalCount, new Color(200, 255, 200));
            intervalRenderer.setSeriesShapesVisible(intervalCount, false);
            intervalData.addSeries(series);
            ++intervalCount;
        }
    }

    final JFreeChart chart = buildChart(title, regularData, intervalData, lineAndShapeRenderer,
            intervalRenderer);

    chart.setAntiAlias(true);
    chart.setBackgroundPaint(Color.WHITE);

    final XYPlot plot = chart.getXYPlot();

    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.BLACK);
    plot.setRangeGridlinePaint(Color.BLACK);

    if (threshold != null) {
        final ValueMarker marker = new ValueMarker(threshold, Color.RED,
                new BasicStroke(Math.max(Math.min(height / 20, 6), 1)), Color.RED, null, 0.5f);
        plot.addRangeMarker(marker);
    }

    plot.setRenderer(lineAndShapeRenderer);

    // final DateAxis rangeAxis = (DateAxis) plot.getRangeAxis();
    // rangeAxis.setStandardTickUnits(DateAxis.createStandardDateTickUnits());

    return chart;
}

From source file:fr.ign.cogit.simplu3d.rjmcmc.generic.visitor.StatsVisitor.java

public StatsVisitor(String title) {

    aF = new ApplicationFrame(title);

    this.series = new XYSeries("U Total");
    this.seriesUnary = new XYSeries("U Unaire");
    this.seriesBinary = new XYSeries("U Binaire");
    this.seriesBest = new XYSeries("Meilleur candidat");
    final XYSeriesCollection dataset = new XYSeriesCollection(this.series);
    dataset.addSeries(seriesUnary);// www  .ja v a 2 s . c  o m
    dataset.addSeries(seriesBinary);
    dataset.addSeries(seriesBest);

    final JFreeChart chart = createChart(dataset);

    final ChartPanel chartPanel = new ChartPanel(chart);

    final JPanel content = new JPanel(new BorderLayout());
    content.add(chartPanel);
    chartPanel.setPreferredSize(new java.awt.Dimension(800, (int) (0.8 * 540)));
    aF.setContentPane(content);
    aF.pack();
    aF.setVisible(true);

    CHARTSINGLETON = chartPanel;
}