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:cz.cuni.mff.d3s.spl.demo.libselection.JFreeChartPlotter.java

private static XYDataset getDatasetFromPairList(List<Pair<Long, Long>> input) {
    XYSeries result = new XYSeries("");

    for (Pair<Long, Long> p : input) {
        result.add(p.first, p.second);/* w w w.java2 s  . c om*/
    }

    return new XYSeriesCollection(result);
}

From source file:FindHullWindowLogic.java

static void drawPointsOnChart(JPanel panelWhenInside, ArrayList<Point2D> convexHull) {
    panelWhenInside.removeAll();/*from  ww w . j  a v  a2  s .  c  o  m*/
    panelWhenInside.setLayout(new java.awt.BorderLayout());
    XYSeries seriersAllPoints = new XYSeries("All points");
    addPointsToSeries(seriersAllPoints);

    int pairsNumber = 0;
    if (convexHull != null)
        pairsNumber = convexHull.size() - 1;
    XYSeries covnexHullDivideOnPiars[] = new XYSeries[pairsNumber];

    for (int i = 0; i < covnexHullDivideOnPiars.length; i++) {
        covnexHullDivideOnPiars[i] = new XYSeries("Convex hull pair " + i);
    }

    if (convexHull != null) {
        divideOnPairsAndConvertConvexHullIntoSeries(covnexHullDivideOnPiars, convexHull);
    }

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

    for (int i = 0; i < covnexHullDivideOnPiars.length; i++) {
        dataset.addSeries(covnexHullDivideOnPiars[i]);
    }

    // Generate the graph
    JFreeChart chart = ChartFactory.createXYLineChart(null, // Title
            null, // x-axis Label
            null, // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            false, // Show Legend
            false, // Use tooltips
            false // Configure chart to generate URLs?
    );

    final XYPlot plot = chart.getXYPlot();
    ChartPanel chartPanel = new ChartPanel(chart);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShape(0, ShapeUtilities.createDiamond(3));

    for (int i = 1; i <= covnexHullDivideOnPiars.length; i++) {
        renderer.setSeriesPaint(i, Color.red);
        renderer.setSeriesLinesVisible(i, true);
        renderer.setSeriesStroke(i, new BasicStroke(1.0f));
    }

    plot.setRenderer(renderer);

    panelWhenInside.add(chartPanel, BorderLayout.CENTER);
    panelWhenInside.validate();
}

From source file:GUI.Data.java

/**
 * Creates new form Data// w  w  w.  j ava  2s  .  c om
 */
public Data() {

    XYSeries Goals = new XYSeries("Goals Scored");
    Goals.add(1, 1.0);
    Goals.add(2, 3.0);
    Goals.add(3, 2.0);
    Goals.add(4, 0.0);
    Goals.add(5, 3.0);
    XYDataset xyDataset = new XYSeriesCollection(Goals);
    JFreeChart chart = ChartFactory.createXYLineChart("Goals Scored Over Time", "Fixture Number", "Goals",
            xyDataset, PlotOrientation.VERTICAL, true, true, false);
    ChartPanel cp = new ChartPanel(chart) {

        @Override
        public Dimension getPreferredSize() {
            return new Dimension(320, 240);
        }
    };
    cp.setMouseWheelEnabled(true);
    add(cp);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    pack();
    initComponents();
}

From source file:signalanalysis.Graphs.java

public Graphs(final String title, ArrayList<Float> lags, String x, String y, String name) {

    super(title);
    final XYSeries series = new XYSeries(name);
    for (int i = 0; i < lags.size(); i++) {
        series.add(i, lags.get(i));/*from  w w  w .  j  ava2s .c  om*/
    }

    final XYSeriesCollection data = new XYSeriesCollection(series);
    final JFreeChart chart = ChartFactory.createXYLineChart(title, x, y, data, PlotOrientation.VERTICAL, true,
            true, false);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);
}

From source file:utlis.HistogramPlot.java

public JFreeChart plotGrayChart(int[] histogram) {

    XYSeries xysBrightnes = new XYSeries("Brightnes");

    for (int i = 0; i < histogram.length; i++) {

        xysBrightnes.add(i, histogram[i]);
    }/*w  w w  .j a  v  a2 s  .  co  m*/

    XYSeriesCollection collection = new XYSeriesCollection();
    collection.addSeries(xysBrightnes);

    JFreeChart chart = ChartFactory.createXYLineChart("Histogram", "Color Value", "Pixel count", collection);
    try {
        ChartUtilities.saveChartAsJPEG(new File("chart.jpg"), chart, 500, 300);
    } catch (IOException ex) {
        Logger.getLogger(HistogramPlot.class.getName()).log(Level.SEVERE, null, ex);
    }
    return chart;
}

From source file:org.jfree.chart.demo.ScatterCanvas.java

public ScatterCanvas(int width, int height, int xArea, int yArea) {

    xEffectiveArea = xArea;/*from w  w w. jav a  2s .  co m*/
    yEffectiveArea = yArea;
    this.series = new XYSeries("series");

    final XYSeriesCollection dataset = new XYSeriesCollection(this.series);

    final JFreeChart chart = createChart(dataset);

    final ChartPanel chartPanel = new ChartPanel(chart);

    this.add(chartPanel);

    chartPanel.setPreferredSize(new java.awt.Dimension(width - padding, height - padding));

}

From source file:org.chocosolver.gui.panels.DepthPanel.java

public DepthPanel(GUI frame) {
    super(frame);
    depth = new XYSeries("Depth");
    XYSeriesCollection scoll = new XYSeriesCollection();
    scoll.addSeries(depth);/* w  w  w.j av  a 2s. co m*/
    JFreeChart chart = ChartFactory.createXYLineChart("Depth", "Nodes", "Depth", scoll);
    this.setChart(chart);
    solver.plugMonitor(this);
}

From source file:Graphic.Poids.java

public Poids(List<Float> valeurs, List<String> date) {
    dataset = new XYSeriesCollection();
    XYSeries serie = new XYSeries("Courbe");
    for (int i = 0; i < valeurs.size(); i++) {
        serie.add(i, valeurs.get(i));//from w w  w  . ja v a  2 s. c  om
    }
    dataset.addSeries(serie);
    diagramme = ChartFactory.createXYLineChart("Graphe de Poids", "Date", "Poids", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(diagramme);
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setPreferredSize(new Dimension(1200, 600));
    add(chartPanel);
}

From source file:com.oracle.cch.swingtest.ChartJFrame.java

/**
 * Creates new form ChartJFrame/*from   w ww . java2s  .  c  o  m*/
 */
public ChartJFrame() {
    initComponents();
    XYSeries Goals = new XYSeries("Goals Scored");
    Goals.add(1, 1.0);
    Goals.add(2, 3.0);
    Goals.add(3, 2.0);
    Goals.add(4, 0.0);
    Goals.add(5, 3.0);
    XYDataset xyDataset = new XYSeriesCollection(Goals);
    chart = ChartFactory.createXYLineChart("Goals Scored Over Time", "Fixture Number", "Goals", xyDataset,
            PlotOrientation.VERTICAL, true, true, false);
    ChartPanel cp = new ChartPanel(chart) {

        @Override
        public Dimension getPreferredSize() {
            return new Dimension(320, 240);
        }
    };
    FlowLayout fl = new FlowLayout();
    this.setLayout(fl);
    this.add(cp);

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    pack();
}

From source file:org.chocosolver.gui.panels.FreeVarsPanel.java

public FreeVarsPanel(GUI frame) {
    super(frame);
    series = new XYSeries("Free variables");
    XYSeriesCollection scoll = new XYSeriesCollection();
    scoll.addSeries(series);/*from  w  w  w .  ja v a 2  s  . c om*/
    JFreeChart chart = ChartFactory.createXYLineChart("Free variables", "Nodes", "free vars", scoll);
    this.setChart(chart);
    solver.plugMonitor(this);
}