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(XYSeries series) 

Source Link

Document

Constructs a dataset and populates it with a single series.

Usage

From source file:org.radargun.reporting.BarPlotGenerator.java

/**
 * @param operation Name of the plotted operation
 * @param ranges ranges[0] = min, ranges[ranges.length - 1] = max
 * @param counts counts[i] is number of entries with value >= ranges[i - 1] and < ranges[i]
 * @param reportDir//from w  ww  .  j av  a2s  . c  om
 * @param filename
 * @throws IOException
 */
public static void generate(String operation, long[] ranges, long[] counts, String reportDir, String filename)
        throws IOException {
    XYSeries series = new XYSeries(operation + " response times");
    long totalCount = 0;
    for (long count : counts) {
        totalCount += count;
    }
    double left = Math.log10(ranges[0]);
    double right = Math.log10(ranges[ranges.length - 1]);

    for (int i = 0; i < counts.length; i++) {
        series.add(Math.log10(ranges[i]), (double) counts[i] / totalCount);
    }
    series.add(right, 0d);
    XYDataset dataset = new XYSeriesCollection(series);
    JFreeChart chart = ChartFactory.createXYStepAreaChart(operation + " response time histogram",
            "Response time", "Percentage", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis d = (NumberAxis) plot.getDomainAxis();
    d.setRange(left, right);
    d.setStandardTickUnits(new HistoTickUnitSource());
    plot.setDomainAxis(d);
    FileOutputStream output = new FileOutputStream(new File(reportDir + File.separator + filename));
    ChartUtilities.writeChartAsPNG(output, chart, 1024, 768);
    output.close();
}

From source file:org.portico.pgauge.gui.LatencyChart.java

public LatencyChart(LatencyDataset rawdata, PGConfiguration configuration) {
    this.rawdata = rawdata;
    this.series = new XYSeries("Iterations");
    this.dataset = new XYSeriesCollection(series);
    backfill(); // will initialize dataset

    // create the chart
    String title = "Round-Trip Latency (" + configuration.getPayloadSizeAsString() + " packets)";
    this.chart = ChartFactory.createXYLineChart(title, "Iterations", "Latency (microseconds)", dataset,
            PlotOrientation.VERTICAL, false, // legend
            true, // tooltips
            false); // urls

    // set max at 3 standard deviations from mean
    long max = rawdata.getAverage() + (long) (3 * rawdata.getStandardDeviation());
    chart.getXYPlot().getRangeAxis().setRange(0, max);

    this.panel = new ChartPanel(this.chart);
    getContentPane().add(this.panel);
    this.pack();//  w  w  w .ja v  a2s. co m
    this.setVisible(true);
}

From source file:ufmotionsuite.SpiralGraph.java

public void Graph() {
    XYSeries series = new XYSeries("X vs Y");
    for (int i = 0; i < arrLength; i++) {
        //System.out.println("Run");
        series.add(theta[i], r[i]);/*from  w  ww.ja v a  2  s.  c  o m*/
    }
    XYDataset dataset = new XYSeriesCollection(series);
    JFreeChart chart = ChartFactory.createXYLineChart("Distance from Origin over Angle", "Theta",
            "R (Distance)", dataset, org.jfree.chart.plot.PlotOrientation.VERTICAL, true, false, false);
    BufferedImage image = chart.createBufferedImage(600, 600);
    jLabel1.setIcon(new ImageIcon(image));
    this.setSize(800, 800);
}

From source file:com.wattzap.view.graphs.GenericScatterGraph.java

public GenericScatterGraph(XYSeries series, String xAxis, String yAxis) {
    super();/*from   ww  w  .  jav  a  2 s  . c  o  m*/

    XYDataset xyDataset = new XYSeriesCollection(series);

    JFreeChart chart = ChartFactory.createScatterPlot("", // chart title
            xAxis, // x axis label
            yAxis, // y axis label
            null, PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.darkGray);
    plot = chart.getXYPlot();
    plot.setDataset(0, xyDataset);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    // Shape cross = ShapeUtilities.createDiamond(0.5f);
    Shape cross = ShapeUtilities.createDiagonalCross(0.5f, 0.5f);
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, new Color(252, 141, 89));
    renderer.setSeriesShape(0, cross);

    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickLabelPaint(Color.white);
    domainAxis.setLabelPaint(Color.white);

    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setTickLabelPaint(Color.white);
    rangeAxis.setLabelPaint(Color.white);

    chartPanel = new ChartPanel(chart);
    chartPanel.setSize(100, 800);

    setLayout(new BorderLayout());
    add(chartPanel, BorderLayout.CENTER);
    setBackground(Color.black);

    chartPanel.revalidate();
    setVisible(true);
}

From source file:org.portico.pgauge.gui.ThroughputChart.java

public ThroughputChart(ThroughputDataset rawdata, PGConfiguration configuration) {
    this.rawdata = rawdata;
    this.series = new XYSeries("Iterations");
    this.dataset = new XYSeriesCollection(series);
    backfill();/*  w  w w.j  a  v a  2 s  .  c o  m*/

    // create the chart
    String title = "Attribute Updates for " + configuration.getFederateName() + " ("
            + configuration.getPayloadSizeAsString() + " packets)";
    this.chart = ChartFactory.createXYLineChart(title, "Iterations", "Time to Complete (ms)", dataset,
            PlotOrientation.VERTICAL, false, // legend
            true, // tooltips
            false); // urls

    this.panel = new ChartPanel(this.chart);
    getContentPane().add(this.panel);
    this.pack();
    this.setVisible(true);
}

From source file:net.relet.freimap.NodeInfo.java

public void setLinkCountProfile(LinkedList<LinkCount> lcp) {
    if (lcp.size() == 0) {
        minLinks = 0;/*www  . ja  v  a  2 s . co  m*/
        maxLinks = 0;
        return;
    }

    XYSeries data = new XYSeries("links");
    XYSeries avail = new XYSeries("avail");
    XYSeriesCollection datac = new XYSeriesCollection(data);
    datac.addSeries(avail);
    linkCountChart = ChartFactory.createXYLineChart("average incoming link count\r\nincoming link availability",
            "time", "count", datac, PlotOrientation.VERTICAL, false, false, false);
    sexupLayout(linkCountChart);

    long first = lcp.getFirst().time, last = lcp.getLast().time, lastClock = first, count = 0, maxCount = 0;
    long aggregate = (last - first) / CHART_WIDTH;
    double sum = 0;

    /* ok, this ain't effective, we do it just to pre-calculate maxCount */
    ListIterator<LinkCount> li = lcp.listIterator();
    while (li.hasNext()) {
        LinkCount lc = li.next();
        count++;
        if (lc.time - lastClock > aggregate) {
            if (maxCount < count)
                maxCount = count;
            lastClock = lc.time;
            count = 0;
        }
    }

    //reset for second iteration
    count = 0;
    lastClock = first;

    //iterate again
    li = lcp.listIterator();
    while (li.hasNext()) {
        LinkCount lc = li.next();
        if (minLinks > lc.count)
            minLinks = lc.count;
        if (maxLinks < lc.count)
            maxLinks = lc.count;

        sum += lc.count;
        count++;

        if (aggregate == 0)
            aggregate = 1000;//dirty hack
        if (lc.time - lastClock > aggregate) {
            for (long i = lastClock; i < lc.time - aggregate; i += aggregate) {
                data.add(i * 1000, (i == lastClock) ? sum / count : Double.NaN);
                avail.add(i * 1000, (i == lastClock) ? ((double) count / maxCount) : 0);
            }

            count = 0;
            sum = 0;
            lastClock = lc.time;
        }
    }

    status = STATUS_AVAILABLE;
}

From source file:udpserver.UDPui.java

/**
 * Creates new form UDPui/*from   w  ww . j a  va  2s . c o  m*/
 */
public UDPui() {
    // <editor-fold defaultstate="collapsed" desc="Graph">
    series = new XYSeries("ECG Reading");
    series.setMaximumItemCount(50);
    XYSeriesCollection dataset = new XYSeriesCollection(series);
    JFreeChart chart = ChartFactory.createXYLineChart("ECG Reading", "Time (seconds)", "Voltage (volt)",
            dataset);

    final XYPlot plot = chart.getXYPlot();
    NumberAxis domain = (NumberAxis) plot.getDomainAxis();

    JPanel jPanel1 = new JPanel();
    jPanel1.setLayout(new java.awt.BorderLayout());
    jPanel1.setVisible(true);
    jPanel1.setSize(600, 500);
    jPanel1.add(new ChartPanel(chart), BorderLayout.CENTER);
    jPanel1.validate();
    add(jPanel1);
    // </editor-fold>
    initComponents();
    receiveUDP();
    //        tempReceiveUDP();
    //        new UDPServer(valuePane);
}

From source file:cpsControllers.LineChartController.java

/**
 * Method for create line chart./*from w  ww .java 2  s.c  o m*/
 * 
 * @param t
 * @param values
 * @return 
 */
public JFreeChart printChart2(ArrayList<Double> t, ArrayList<Double> values) {

    // Prepare the data set
    XYSeries xySeries = new XYSeries("Number & Square Chart");

    double[] val = new double[values.size()];
    for (int i = 0; i < val.length; i++) {
        xySeries.add(i, values.get(i));
    }

    XYDataset xyDataset = new XYSeriesCollection(xySeries);

    //Create the chart
    JFreeChart chart = ChartFactory.createXYLineChart("Wykres liniowy", "Czas (t)", "Aplituda (A)", xyDataset,
            PlotOrientation.VERTICAL, false, true, false);

    //    //Render the frame
    //    ChartFrame chartFrame = new ChartFrame("Wykres sygnalu ", chart);
    //    chartFrame.setVisible(true);
    //    chartFrame.setSize(800, 600);

    return chart;
}

From source file:com.ivli.roim.controls.VOILUTPanel.java

private XYSeriesCollection makeLUTCurve() {
    double min = iLUT.getView().getMin();
    double max = iLUT.getView().getMax();

    Curve c = iLUT.getView().getWindowCurve();

    return new XYSeriesCollection(XYSeriesUtilities.getSeriesRebinned(iCurveName, c, NO_OF_BINS, min, max));
}

From source file:endrov.typeTimeRemap.TimeRemapWindow.java

/**
 * Make a new window/*  ww  w  .  j  ava  2 s .  c o  m*/
 */
public TimeRemapWindow() {
    bAdd.addActionListener(this);
    bRefresh.addActionListener(this);
    objectCombo.addActionListener(this);

    XYDataset xyDataset = new XYSeriesCollection(frametimeSeries);

    JFreeChart chart = ChartFactory.createXYLineChart("", "New time", "Original time", xyDataset,
            PlotOrientation.HORIZONTAL, false/*legend*/, false/*tooltips*/, false/*urls*/);
    ChartPanel graphpanel = new ChartPanel(chart);

    //Put GUI together
    JPanel datapanel = new JPanel(new BorderLayout());
    JPanel dataparto = new JPanel(new BorderLayout());
    dataparto.add(datapart, BorderLayout.NORTH);
    JScrollPane datapartscroll = new JScrollPane(dataparto, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

    JPanel buttonpanel = new JPanel(new GridLayout(1, 2));
    buttonpanel.add(bAdd);
    buttonpanel.add(bRefresh);
    datapanel.add(buttonpanel, BorderLayout.SOUTH);
    datapanel.add(datapartscroll, BorderLayout.CENTER);
    setLayout(new BorderLayout());
    add(datapanel, BorderLayout.EAST);

    JPanel leftPanel = new JPanel(new BorderLayout());
    leftPanel.add(graphpanel, BorderLayout.CENTER);
    leftPanel.add(objectCombo, BorderLayout.SOUTH);
    add(leftPanel, BorderLayout.CENTER);

    loadData();

    //Window overall things
    setTitleEvWindow("Time remapper");
    packEvWindow();
    setBoundsEvWindow(new Rectangle(100, 100, 1000, 600));
    setVisibleEvWindow(true);
}