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:br.usp.icmc.gazetteer.SemanticSearchTest.Grafico.java

private XYDataset createDataset2() {
    XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
    XYSeries team1_xy_data = new XYSeries("MAP2");
    int k = 126;//ww  w  .  j  a va2  s. c  o  m
    for (BigDecimal d : cm.getFire()) {
        team1_xy_data.add(k, d.floatValue());
        k++;
    }
    xySeriesCollection.addSeries(team1_xy_data);
    return xySeriesCollection;
}

From source file:org.fhcrc.cpl.toolbox.gui.chart.PanelWithHeatMap.java

protected void init() {
    dataset = new XYSeriesCollection();
    renderer = new XYBlockRenderer();
    //set all possible series to the default shape

    //        init(chart.getXYPlot());
}

From source file:ch.zhaw.init.walj.projectmanagement.util.chart.LineChart.java

/**
 * creates a dataset with the booked effort (in hours) of a specific employee
 * @param employeeID ID of an employee //from  w ww .j a  va 2  s. c o m
 * @return dataset with booked hours
 */
private XYSeriesCollection createDataset(int employeeID) {

    // initialize variables
    Effort effort = new Effort(tasks, path);
    double bookedEffort;
    XYSeries booked = new XYSeries("Booked");
    int projectMonths = project.getNumberOfMonths();

    // get booked effort for every month
    for (double i = 1; i <= projectMonths; i++) {

        if (effort.getBookedEffortPerMonth(i, employeeID) != 0) {
            bookedEffort = effort.getBookedEffortPerMonth(i, employeeID);
            booked.add(i, bookedEffort);
        }

    }

    // add booked effort to dataset
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(booked);

    return dataset;
}

From source file:se.lnu.cs.doris.metrics.SLOC.java

private void generateImage(ImageType type) throws Exception {
    if (this.m_mainDir == null) {
        throw new Exception("Base directory not set.");
    }/*  w  w w .  j a  v  a 2 s  .  c  o  m*/

    XYSeries linesOfCodeTotal = new XYSeries("Total lines");
    XYSeries linesOfCode = new XYSeries("Lines of code");
    XYSeries linesOfComments = new XYSeries("Lines of comments");
    XYSeries baseLine = new XYSeries("index 100");

    for (File f : this.m_mainDir.listFiles()) {
        if (f.isDirectory() && !f.getName().contains(this.m_avoid)) {

            int commitNumber = Utilities.parseInt(f.getName());
            int slocd = 0;
            int slocmt = 0;
            int sloct = 0;

            for (File sd : f.listFiles()) {
                if (!sd.getName().toLowerCase().contains(this.m_avoid)) {
                    slocd += this.countLines(sd, false);
                    slocmt += this.countLines(sd, true);
                    sloct += slocd + slocmt;
                }
            }

            if (this.m_baseValueTotal < 0) {
                this.m_baseValueTotal = sloct;
                this.m_baseValueComments = slocmt;
                this.m_baseValueCode = slocd;

                sloct = 100;
                slocmt = 100;
                slocd = 100;
            } else {
                sloct = (int) ((double) sloct / (double) this.m_baseValueTotal * 100);
                slocmt = (int) ((double) slocmt / (double) this.m_baseValueComments * 100);
                slocd = (int) ((double) slocd / (double) this.m_baseValueCode * 100);
            }

            linesOfCodeTotal.add(commitNumber, sloct);
            linesOfCode.add(commitNumber, slocd);
            linesOfComments.add(commitNumber, slocmt);
            baseLine.add(commitNumber, 100);

        }
    }

    XYSeriesCollection collection = new XYSeriesCollection();

    collection.addSeries(linesOfCodeTotal);
    collection.addSeries(linesOfCode);
    collection.addSeries(linesOfComments);
    collection.addSeries(baseLine);

    JFreeChart chart = ChartFactory.createXYLineChart(
            "Source lines of code change for " + this.m_projectName + " \nBase value code: "
                    + this.m_baseValueCode + "\nBase value comments: " + this.m_baseValueComments,
            "Commit", "SLOC change %", collection, PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = chart.getXYPlot();

    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setTickUnit(new NumberTickUnit(2));

    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setTickUnit(new NumberTickUnit(10));

    switch (type) {
    case JPEG:
        ChartUtilities.saveChartAsJPEG(new File(this.m_mainDir.getAbsolutePath(), "sloc_chart.jpg"), chart,
                1000, 720);
        break;
    case PNG:
        ChartUtilities.saveChartAsPNG(new File(this.m_mainDir.getAbsolutePath(), "sloc_chart.png"), chart, 1000,
                720);
        break;
    default:
        break;
    }
}

From source file:XYPlotter.java

/**
 * Creates the dataset.//from w  w w .j a v  a 2  s . c  o  m
 * 
 * @return a sample dataset.
 */
private XYSeriesCollection createDataset(String legendTxt) {

    series1 = new XYSeries("f(x)");
    series2 = new XYSeries("g(x)");

    final XYSeriesCollection dataset = new XYSeriesCollection();

    dataset.addSeries(series1);
    dataset.addSeries(series2);

    return dataset;
}

From source file:com.itemanalysis.jmetrik.graph.nicc.NonparametricCurvePanel.java

private void createChart(String name, String title, String xLabel, String yLabel, double minScore,
        double maxScore) {
    XYSeriesCollection dataset = new XYSeriesCollection();
    final JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title
            xLabel, // x axis label
            yLabel, // y axis label
            dataset, // data
            chartOrientation, // chart orientation
            showLegend, // include legend
            true, // tooltips
            false // urls
    );/*from  www .  ja  va  2s . c  om*/

    if (showLegend) {
        LegendTitle chartTitle = chart.getLegend();
        chartTitle.setPosition(legendPosition);
    }

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);

    //        //can use this code to fix the number of tick marks on the y-axis
    //        NumberFormat myFormatter = new DecimalFormat("#.0");
    //        NumberAxis yaxis = (NumberAxis)plot.getRangeAxis();
    //        yaxis.setTickUnit(new NumberTickUnit(.1, myFormatter));

    ChartPanel panel = new ChartPanel(chart);
    panel.getPopupMenu().addSeparator();
    panel.setPreferredSize(new Dimension(width, height));

    //        this.addLocalEPSMenuItem(this, panel.getPopupMenu(), chart);//remove this line for public release versions

    chart.setPadding(new RectangleInsets(20.0, 5.0, 20.0, 5.0));
    charts.put(name, chart);

    JPanel subPanel = new JPanel();//additional panel needed to prevent gridlayout from stretching graph
    subPanel.add(panel);
    subPanel.setBackground(Color.WHITE);
    this.add(subPanel);

}

From source file:dla_franctal.LineChart.java

public XYDataset createBBAreaRationDataset(ArrayList<Double> bbAreaRatio,
        ArrayList<Integer> staticParticlesAtCurrentTick) {
    final XYSeries currentBBAreaRatio = new XYSeries("");
    for (int i = 0; i < bbAreaRatio.size(); i++) {
        currentBBAreaRatio.add(staticParticlesAtCurrentTick.get(i), bbAreaRatio.get(i));
    }/*from w  w  w .java  2s.  c o  m*/
    final XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(currentBBAreaRatio);
    return dataset;
}

From source file:Result3.java

public void createGraphs() {
    XYSeries a_data = new XYSeries("A");
    XYSeries c_data = new XYSeries("C");
    XYSeries g_data = new XYSeries("G");
    XYSeries t_data = new XYSeries("T");
    for (int i = 0; i < a.length; i++) {
        a_data.add(i, a[i]);/*from  www  . j  a v a  2s .  c  o  m*/
        c_data.add(i, c[i]);
        g_data.add(i, g[i]);
        t_data.add(i, t[i]);
    }

    XYSeriesCollection my_data_series = new XYSeriesCollection();
    my_data_series.addSeries(a_data);
    my_data_series.addSeries(c_data);
    my_data_series.addSeries(g_data);
    my_data_series.addSeries(t_data);

    JFreeChart XYLineChart = ChartFactory.createXYLineChart("Frequency Table", "Position", "No. of Occurences",
            my_data_series, PlotOrientation.VERTICAL, true, true, false);
    bImage1 = (BufferedImage) XYLineChart.createBufferedImage(690, 337);
    ImageIcon imageIcon1 = new ImageIcon(bImage1);
    jLabel1.setIcon(imageIcon1);

}

From source file:com.joey.software.plottingToolkit.PlotingToolkit.java

public static JFreeChart getPlot(float[] yData, String title, String xlabel, String ylabel) {
    float[] xData = getXDataFloat(yData.length);
    XYSeriesCollection datCol = getCollection(xData, yData, "Data");

    // Create the chart

    JFreeChart chart = ChartFactory.createXYLineChart(title, // Title
            xlabel, // X-Axis label
            ylabel, // Y-Axis label
            new XYSeriesCollection(), // Dataset
            PlotOrientation.VERTICAL, true, // Show legend
            true, true);//from w  w  w .j  ava 2 s.c  o m

    // Add the series
    chart.getXYPlot().setDataset(0, datCol);

    // Set the rendering
    XYLineAndShapeRenderer rend1 = new XYLineAndShapeRenderer(true, true);

    chart.getXYPlot().setRenderer(0, rend1);

    return chart;
}

From source file:org.gephi.statistics.plugin.dynamic.DynamicNbEdges.java

public String getReport() {
    //Transform to Map
    Map<Double, Integer> map = new HashMap<Double, Integer>();
    for (Interval<Integer> interval : counts.getIntervals()) {
        map.put(interval.getLow(), interval.getValue());
    }/*from  www  . j  a  v a  2 s  .c o m*/

    //Time series
    XYSeries dSeries = ChartUtils.createXYSeries(map, "Nb Edges Time Series");

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(dSeries);

    JFreeChart chart = ChartFactory.createXYLineChart("# Edges Time Series", "Time", "# Edges", dataset,
            PlotOrientation.VERTICAL, true, false, false);

    chart.removeLegend();
    ChartUtils.decorateChart(chart);
    ChartUtils.scaleChart(chart, dSeries, false);
    String imageFile = ChartUtils.renderChart(chart, "nb-edges-ts.png");

    NumberFormat f = new DecimalFormat("#0.000");

    String report = "<HTML> <BODY> <h1>Dynamic Number of Edges Report </h1> " + "<hr>" + "<br> Bounds: from "
            + f.format(bounds.getLow()) + " to " + f.format(bounds.getHigh()) + "<br> Window: " + window
            + "<br> Tick: " + tick + "<br><br><h2> Number of edges over time: </h2>" + "<br /><br />"
            + imageFile;

    /*for (Interval<Integer> count : counts) {
    report += count.toString(dynamicModel.getTimeFormat().equals(DynamicModel.TimeFormat.DOUBLE)) + "<br />";
    }*/
    report += "<br /><br /></BODY></HTML>";
    return report;
}