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:celeste.Celeste.java

public void pintarPlaneta(int n_plat, double t) {
    XYSeriesCollection coleccion = new XYSeriesCollection();

    String name = planetas.get(n_plat)[0];
    double a = Double.parseDouble(planetas.get(n_plat)[1]);
    double epsilon = Double.parseDouble(planetas.get(n_plat)[2]);
    double p = Double.parseDouble(planetas.get(n_plat)[3]);
    Planeta planeta = new Planeta(a, epsilon, p);

    XYSeries serie = planeta.generarPosiciones();
    XYSeries serie2 = new XYSeries("posicion", false);

    serie.setKey(name);/*  w w w . ja  v  a 2  s .  c o m*/
    serie2.add(planeta.posicion(t).getX1(), planeta.posicion(t).getX2());

    coleccion.addSeries(serie);
    coleccion.addSeries(serie2);

    generarGrafica(coleccion, true);
}

From source file:eu.choreos.vv.chart.XYChart.java

public XYChart(String applicationTitle, String chartTitle, List<PlotData> reports, String xLabel,
        String yLabel) {/*from  www  .  j  a v  a 2 s .  com*/
    super(applicationTitle);

    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    XYSeriesCollection dataset = new XYSeriesCollection();

    for (PlotData report : reports) {
        createDataset(dataset, (LineData) report);
    }
    // based on the dataset we create the chart
    JFreeChart chart = createChart(dataset, chartTitle, xLabel, yLabel);
    // we put the chart into a panel
    ChartPanel chartPanel = new ChartPanel(chart);
    // default size
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    // add it to our application
    setContentPane(chartPanel);

}

From source file:pi.bestdeal.models.Charts.java

public XYSeriesCollection createDataset(String DateDebut, String DateFin, int idDeal) {
    XYSeries series = new XYSeries("volution des consultations");
    ChartDAO aO = ChartDAO.getInstance();
    for (int a : aO.daysvaluesConsultation(DateDebut, DateFin, idDeal)) {

        series.add(aO.daysvaluesConsultation(DateDebut, DateFin, idDeal).indexOf(a), a);
    }/*  w ww  .ja  va2 s. c  o  m*/
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);
    return dataset;

}

From source file:net.footballpredictions.footballstats.swing.GoalsGraph.java

/**
 * Plot goals scored and conceded against number of matches played.
 *//*from   w w w . j a  v a 2  s.com*/
public void updateGraph(String teamName, LeagueSeason data) {
    XYSeriesCollection dataSet = new XYSeriesCollection();

    XYSeries forSeries = new XYSeries(teamName + ' ' + messageResources.getString("graphs.scored"));
    XYSeries againstSeries = new XYSeries(teamName + ' ' + messageResources.getString("graphs.conceded"));

    int[][] goals = data.getTeam(teamName).getGoalsData();
    for (int i = 0; i < goals.length; i++) {
        forSeries.add(i, goals[i][0]);
        againstSeries.add(i, goals[i][1]);
    }

    dataSet.addSeries(forSeries);
    dataSet.addSeries(againstSeries);

    JFreeChart chart = ChartFactory.createXYLineChart(null, // Title
            messageResources.getString("graphs.matches"), messageResources.getString("combo.GraphType.GOALS"),
            dataSet, PlotOrientation.VERTICAL, true, // Legend.
            false, // Tooltips.
            false); // URLs.
    chart.getXYPlot().getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    chart.getXYPlot().getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    int max = Math.max(goals[goals.length - 1][0], goals[goals.length - 1][1]);
    chart.getXYPlot().getRangeAxis().setRange(0, max + 1);
    XYDifferenceRenderer renderer = new XYDifferenceRenderer();
    renderer.setSeriesPaint(0, Colours.POSITIVE); // Green.
    renderer.setPositivePaint(Colours.POSITIVE_FILL); // Translucent green.
    renderer.setSeriesPaint(1, Colours.NEGATIVE); // Red.
    renderer.setNegativePaint(Colours.NEGATIVE_FILL); // Translucent red.
    chart.getXYPlot().setRenderer(renderer);
    setChart(chart);
}

From source file:scatterplot1k.JFreeScatter2.java

private XYDataset createDataset() {
    XYSeriesCollection result = new XYSeriesCollection();
    result.addSeries(populateData());
    return result;
}

From source file:net.footballpredictions.footballstats.swing.PointsGraph.java

/**
 * Plot points earned against number of matches played.
 *///from ww  w.j av  a2s .co m
public void updateGraph(Object[] teams, LeagueSeason data) {
    assert teams.length > 0 : "Must be at least one team selected.";
    XYSeriesCollection dataSet = new XYSeriesCollection();
    int max = 0;
    for (Object team : teams) {
        String teamName = (String) team;
        XYSeries pointsSeries = new XYSeries(teamName);

        int[] points = data.getTeam(teamName).getPointsData(data.getMetaData().getPointsForWin(),
                data.getMetaData().getPointsForDraw());
        for (int i = 0; i < points.length; i++) {
            pointsSeries.add(i, points[i]);
        }
        max = Math.max(max, points[points.length - 1]);
        dataSet.addSeries(pointsSeries);
    }
    JFreeChart chart = ChartFactory.createXYLineChart(null, // Title
            messageResources.getString("graphs.matches"), messageResources.getString("combo.GraphType.POINTS"),
            dataSet, PlotOrientation.VERTICAL, true, // Legend.
            false, // Tooltips.
            false); // URLs.
    chart.getXYPlot().getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    chart.getXYPlot().getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    chart.getXYPlot().getRangeAxis().setRange(0, max + 1);
    setChart(chart);
}

From source file:es.bsc.autonomic.powermodeller.graphics.TotalPowerVsTotalPrediction.java

private static XYDataset dataSetToJFreeChartXYDataSet(DataSet ds) {

    XYSeriesCollection xyseriescollection = new XYSeriesCollection();

    for (String metric : ds.getHeader()) {
        List<Double> column = ds.getCol(metric);
        XYSeries xyseries = new XYSeries(metric);
        for (int i = 0; i < column.size(); i++) {
            xyseries.add(i, column.get(i));
        }/*from   w w w  . java2  s  .  c  o m*/
        xyseriescollection.addSeries(xyseries);
    }

    return xyseriescollection;
}

From source file:ui.FitnessGraph.java

/**
 * Creates a sample dataset./*w ww. j a  va  2s  .c om*/
 *
 * @return a sample dataset.
 */
private XYDataset createDataset(ArrayList<Double> data) {

    final XYSeries series1 = new XYSeries("fitness");
    for (int i = 0; i < data.size() - 1; i++) {

        double p = data.get(i);
        series1.add(i, p);
    }

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

    return dataset;

}

From source file:moviedatas.View.GlobalChart.java

@Override
public void movieListHasCHanged(ArrayList<Movie> movies) {
    XYSeries series = new XYSeries("Movie");
    for (int i = 0; i < movies.size(); i++) {
        Movie currentMovie = movies.get(i);
        series.add(currentMovie.getGross(), currentMovie.getScore());
    }/*from   w ww  .j a  va  2s  .  c o  m*/
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);
    JFreeChart scatterPlot = ChartFactory.createScatterPlot("", "Gross (in $)", "Score", dataset, VERTICAL,
            true, true, false);
    cPanel.setChart(scatterPlot);
    cPanel.updateUI();
}

From source file:tp2.FCFS.java

@Override
public void printGraph(String filename) {
    int i;//w w  w . jav  a2s  . c o m
    int y_axis = requestString.length * 10;

    XYSeries series = new XYSeries("FCFS");

    /* Adiciona o pontos XY do grfico de linhas. */
    series.add(y_axis, initCilindro);

    for (i = 0; i < requestString.length; i++) {
        series.add(y_axis - ((i + 1) * 10), requestString[i]);
    }

    /* Adiciona a serie criada a um SeriesCollection. */
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);

    /* Gera o grfico de linhas */
    JFreeChart chart = ChartFactory.createXYLineChart(
            /* Title */
            "FCFS Scheduler Algorithm",
            /* Title x*/
            "",
            /* Title y */
            "Cilindro", dataset,
            /* Plot Orientation */
            PlotOrientation.HORIZONTAL,
            /* Show Legend */
            false,
            /* Use tooltips */
            false,
            /* Configure chart to generate URLs? */
            false);

    /* Configura a espessura da linha do grfico  */
    XYPlot plot = chart.getXYPlot();

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    plot.setRenderer(renderer);

    /* Escreve o grfico para um arquivo indicado. */
    try {
        ChartUtilities.saveChartAsJPEG(new File(filename), chart, 500, 300);
    } catch (IOException ex) {
        Logger.getLogger(FCFS.class.getName()).log(Level.SEVERE, null, ex);
    }
}