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:grafica.Lineal.java

private void inicializar() {
    cjto_datos = new XYSeriesCollection();
    grafico = crearGrafico(cjto_datos);/* w  w  w.ja v a2 s.co m*/
    panel_grafico = new ChartPanel(grafico);
    panel_grafico.setFillZoomRectangle(true);
    panel_grafico.setMouseWheelEnabled(true);
}

From source file:br.com.ant.system.util.ChartUtil.java

public void createTempoTotalExecucao(Set<EstatisticaColetor> estatisticas) {

    // Create a simple XY chart
    XYSeries series = new XYSeries("Formiga");

    JFrame frame = new JFrame();

    for (EstatisticaColetor e : estatisticas) {
        series.add(e.getId(), e.getTempoExecucao());
    }//from ww  w .  j  a  va  2  s  .  c  o  m

    // Add the series to your data set
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);

    // Generate the graph
    JFreeChart chart = ChartFactory.createXYLineChart("Tempo total de Execuo", "Execuo", "Tempo (ms)",
            dataset, PlotOrientation.VERTICAL, true, true, false);
    frame.getContentPane().add(new ChartPanel(chart));

    frame.setPreferredSize(new Dimension(600, 600));
    frame.setMinimumSize(new Dimension(600, 600));
    frame.setMaximumSize(new Dimension(600, 600));
    frame.setVisible(true);

    try {
        ChartUtilities.saveChartAsJPEG(new File("chart.jpg"), chart, 500, 300);
    } catch (IOException e) {
        System.err.println("Problem occurred creating chart.");
    }
}

From source file:statistics.distribution.CustomDistribution.java

private XYDataset getDataset() {
    XYSeriesCollection dataSet = new XYSeriesCollection();
    XYSeries xySeries = new XYSeries("PDF");
    double x = 1;
    for (int i = 0; i < lines.size(); i++) {
        int y = Integer.parseInt(lines.get(i).trim());
        x += y;/*from ww w  .j  a v a2 s.  c  om*/
        xySeries.add(x, y);
    }
    dataSet.addSeries(xySeries);
    return dataSet;
}

From source file:playground.yu.utils.charts.XYScatterLineChart.java

public XYScatterLineChart(String title, String xAxisLabel, String yAxisLabel) {
    super(title, xAxisLabel, yAxisLabel);
    this.dataset = new XYSeriesCollection();
    this.chart = createChart(title, xAxisLabel, yAxisLabel, this.dataset);
    addDefaultFormatting();/*from ww  w. ja  v a  2s . c o  m*/
}

From source file:org.gvsig.gui.beans.graphic.GraphicChartPanel.java

public GraphicChartPanel() {
    dataset = new XYSeriesCollection();

    createChart();//ww  w . ja  v a 2s.com

    initialize();

    Plot plot = this.jPanelChart.getChart().getPlot();
    plot.setOutlineStroke(new BasicStroke(1));
    plot.setOutlinePaint(Color.black);

    chart.setBackgroundPaint(Color.white);
    plot.setBackgroundPaint(new Color(245, 245, 245));
}

From source file:turtlekit.pvequalsnrt.PhysicsChecker.java

@Override
public void setupFrame(JFrame frame) {
    XYSeriesCollection dataset = new XYSeriesCollection();
    final ChartPanel chartPanel = ChartsUtil.createChartPanel(dataset, "PV = nRT", null, null);
    chartPanel.setPreferredSize(new java.awt.Dimension(550, 250));
    rightSide = new XYSeries("Gas on the right side");
    dataset.addSeries(rightSide);// www .j av  a  2 s  .c  om
    total = new XYSeries("Total");
    dataset.addSeries(total);
    frame.setContentPane(chartPanel);
    frame.setLocation(50, 0);
    XYSeries s = dataset.getSeries("Total");
}

From source file:api3.transform.PlotWave.java

public void plot(double[][] signal, String name, long samplerate) {

    frame.setTitle(name);//from ww w  .  ja va 2  s . c  o  m

    XYSeries[] soundWave = new XYSeries[signal.length];
    for (int j = 0; j < signal.length; ++j) {
        soundWave[j] = new XYSeries("sygnal" + j);
        for (int i = 0; i < signal[0].length; ++i) {
            double index = (samplerate == 0) ? i : 1000.0 * (double) i / (double) samplerate;
            soundWave[j].add(index, signal[j][i]);
        }
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    for (int j = 0; j < signal.length; ++j) {
        dataset.addSeries(soundWave[j]);
    }

    JFreeChart chart = //            (samplerate ==0 )?
            //            ChartFactory.createXYBarChart(
            //            name,
            //            "prbka",
            //            false,
            //            "warto",
            //            new XYBarDataset(dataset,0.0625),
            //            PlotOrientation.VERTICAL,
            //            true,false,false)
            //            :
            ChartFactory.createXYLineChart(name, "prbka", "warto", dataset,
                    PlotOrientation.VERTICAL, true, false, false);

    XYPlot plot = (XYPlot) chart.getPlot();

    final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();

    slider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent event) {
            int value = slider.getValue();
            double minimum = domainAxis.getRange().getLowerBound();
            double maximum = domainAxis.getRange().getUpperBound();
            double delta = (0.1f * (domainAxis.getRange().getLength()));
            if (value < lastValue) { // left
                minimum = minimum - delta;
                maximum = maximum - delta;
            } else { // right
                minimum = minimum + delta;
                maximum = maximum + delta;
            }
            DateRange range = new DateRange(minimum, maximum);
            domainAxis.setRange(range);
            lastValue = value;
            if (lastValue == slider.getMinimum() || lastValue == slider.getMaximum()) {
                slider.setValue(SLIDER_DEFAULT_VALUE);
            }
        }

    });

    plot.addRangeMarker(new ValueMarker(0, Color.BLACK, new BasicStroke(1)));

    ChartPanel chartPanel = new ChartPanel(chart);
    Border border = BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createEtchedBorder());
    chartPanel.setBorder(border);

    chartPanel.addMouseWheelListener(addZoomWheel());

    panel.add(chartPanel);
    JPanel dashboard = new JPanel(new BorderLayout());
    dashboard.setBorder(BorderFactory.createEmptyBorder(0, 4, 4, 4));
    dashboard.add(slider);
    panel.add(dashboard, BorderLayout.SOUTH);

    frame.getContentPane().add((JPanel) panel, BorderLayout.CENTER);

    frame.pack();
    frame.setVisible(true);
}

From source file:fr.ign.cogit.geoxygene.sig3d.gui.window.result.DissimilarityCalculationDialog.java

/**
 * Affiche un graphique  l'aide de 2 nuages de points
 * //from   w w w  .ja  v  a2 s  .c om
 * @param title the frame title.
 */
public DissimilarityCalculationDialog(final String title, IDirectPositionList dpl1, IDirectPositionList dpl2) {

    super();
    final XYSeries series = new XYSeries("Objet 1");
    int nbElem = dpl1.size();

    for (int i = 0; i < nbElem - 1; i++) {

        series.add((dpl1.get(i + 1).getX() + dpl1.get(i).getX()) / 2, dpl1.get(i).getY());

    }

    final XYSeries series2 = new XYSeries("Objet 2");
    int nbElem2 = dpl2.size();

    for (int i = 0; i < nbElem2 - 1; i++) {

        series2.add((dpl2.get(i + 1).getX() + dpl2.get(i).getX()) / 2, dpl2.get(i).getY());

    }

    double valeur = 0;
    // Affiche la diffrence en norme L2 des 2 graphiques
    for (int i = 0; i < nbElem; i++) {

        valeur = valeur + Math.pow(dpl1.get(i).getY() - dpl2.get(i).getY(), 2);

    }

    valeur = Math.sqrt(valeur) / (1024 * 512);

    final XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);
    dataset.addSeries(series2);

    final JFreeChart chart = ChartFactory.createXYLineChart("XY Series Demo", "Distance : " + valeur,
            Messages.getString("Result.PointFD"), dataset, PlotOrientation.VERTICAL, true, true, false);

    final ChartPanel chartPanel = new ChartPanel(chart);

    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    this.setContentPane(chartPanel);

}

From source file:AsymptoticFreedom.GraphViewPanel.java

public JFreeChart getResultChart() {
    // XY ?//from  ww  w . j  av a 2s .  co m
    int quark_size = ViewPanel.quark_list.size();
    if (quark_size < 2)
        return new JFreeChart(new XYPlot());

    // XY Dataset  
    XYSeriesCollection data = new XYSeriesCollection();
    //System.out.println(series.get(0).getY(30));
    for (XYSeries s : series) {
        data.addSeries(s);
    }

    final JFreeChart chart = ChartFactory.createXYLineChart("Potential", "Distance", "Potential", data,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setTitle("Potential of quarks"); //  ?
    XYPlot plot = (XYPlot) chart.getPlot();
    //plot.addRangeMarker(new ValueMarker(15,Color.RED,new BasicStroke(2.0f)));
    for (int i = 0; i < quark_size; i++) {
        for (int j = i + 1; j < quark_size; j++) {
            Quark quark1 = ViewPanel.quark_list.get(i);
            Quark quark2 = ViewPanel.quark_list.get(j);
            double distance = quark1.pos.distance(quark2.pos);
            double value = quark1.calculatePotential(quark2);
            String anno_title = String.format("V_ %c-%c", quark1.color.charAt(0), quark2.color.charAt(0));
            //System.out.println(anno_title);
            XYPointerAnnotation pointer = new XYPointerAnnotation(anno_title, distance, value,
                    3.0 * Math.PI / 4.0);
            plot.addAnnotation(pointer);
        }
    }
    plot.getRangeAxis().setRange(-500, 4000);
    return chart;
}