Search in sources :

Example 11 with XYSeries

use of org.jfree.data.xy.XYSeries in project n2a by frothga.

the class Raster method parsePrnFile.

public void parsePrnFile(File f) {
    dataset = new XYSeriesCollection();
    XYSeries series = new XYSeries("Spikes");
    dataset.addSeries(series);
    try {
        int row = 0;
        // It's possible that there might not be a time column. In that case, we use raw row index;
        int timeColumn = -1;
        BufferedReader br = new BufferedReader(new FileReader(f));
        while (true) {
            String line = br.readLine();
            // indicates end of stream
            if (line == null)
                break;
            line = line.trim();
            if (line.length() == 0)
                continue;
            if (line.startsWith("End of"))
                continue;
            // TODO: does Xyce output tabs or spaces? May have to switch regexp here, depending on source.
            String[] parts = line.split("\t");
            char firstCharacter = parts[0].charAt(0);
            if (// column header
            firstCharacter < '0' || firstCharacter > '9') {
                if (timeColumn < 0) {
                    // goodness of match
                    int timeMatch = 0;
                    for (int p = 0; p < parts.length; p++) {
                        int potentialMatch = 0;
                        String columnName = parts[p];
                        if (columnName.equals("TIME"))
                            potentialMatch = 1;
                        else if (columnName.equals("$t"))
                            potentialMatch = 2;
                        if (potentialMatch > timeMatch) {
                            timeMatch = potentialMatch;
                            timeColumn = p;
                        }
                    }
                }
                // These should never be accessed.
                for (int p = columns.size(); p <= timeColumn; p++) columns.add(p, 0);
                for (int p = columns.size(); p < parts.length; p++) {
                    try {
                        int c = Integer.parseInt(parts[p]);
                        if (c < 0)
                            throw new NumberFormatException();
                        columns.add(p, c);
                    } catch (NumberFormatException e) {
                        columns.add(p, nextColumn--);
                    }
                }
                continue;
            }
            // It is unlikely that column headers will show up later if they don't come first.
            for (int p = columns.size(); p < parts.length; p++) columns.add(p, nextColumn--);
            int p = timeColumn;
            double time = row;
            if (p >= 0)
                time = Double.parseDouble(parts[timeColumn]);
            p++;
            for (; p < parts.length; p++) {
                if (!parts[p].isEmpty() && Double.parseDouble(parts[p]) != 0)
                    series.add(time, columns.get(p));
            }
            row++;
        }
        br.close();
    } catch (IOException e) {
    }
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) IOException(java.io.IOException) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection)

Example 12 with XYSeries

use of org.jfree.data.xy.XYSeries in project gephi by gephi.

the class Degree method getReport.

/**
     *
     * @return
     */
@Override
public String getReport() {
    String report = "";
    if (isDirected) {
        report = getDirectedReport();
    } else {
        //Distribution series
        XYSeries dSeries = ChartUtils.createXYSeries(degreeDist, "Degree Distribution");
        XYSeriesCollection dataset1 = new XYSeriesCollection();
        dataset1.addSeries(dSeries);
        JFreeChart chart1 = ChartFactory.createXYLineChart("Degree Distribution", "Value", "Count", dataset1, PlotOrientation.VERTICAL, true, false, false);
        chart1.removeLegend();
        ChartUtils.decorateChart(chart1);
        ChartUtils.scaleChart(chart1, dSeries, false);
        String degreeImageFile = ChartUtils.renderChart(chart1, "degree-distribution.png");
        NumberFormat f = new DecimalFormat("#0.000");
        report = "<HTML> <BODY> <h1>Degree Report </h1> " + "<hr>" + "<br> <h2> Results: </h2>" + "Average Degree: " + f.format(avgDegree) + "<br /><br />" + degreeImageFile + "</BODY></HTML>";
    }
    return report;
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) DecimalFormat(java.text.DecimalFormat) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) JFreeChart(org.jfree.chart.JFreeChart) NumberFormat(java.text.NumberFormat)

Example 13 with XYSeries

use of org.jfree.data.xy.XYSeries in project gephi by gephi.

the class Degree method getDirectedReport.

public String getDirectedReport() {
    //Distribution series
    XYSeries dSeries = ChartUtils.createXYSeries(degreeDist, "Degree Distribution");
    XYSeries idSeries = ChartUtils.createXYSeries(inDegreeDist, "In-Degree Distribution");
    XYSeries odSeries = ChartUtils.createXYSeries(outDegreeDist, "Out-Degree Distribution");
    XYSeriesCollection dataset1 = new XYSeriesCollection();
    dataset1.addSeries(dSeries);
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(idSeries);
    XYSeriesCollection dataset3 = new XYSeriesCollection();
    dataset3.addSeries(odSeries);
    JFreeChart chart1 = ChartFactory.createXYLineChart("Degree Distribution", "Value", "Count", dataset1, PlotOrientation.VERTICAL, true, false, false);
    chart1.removeLegend();
    ChartUtils.decorateChart(chart1);
    ChartUtils.scaleChart(chart1, dSeries, false);
    String degreeImageFile = ChartUtils.renderChart(chart1, "degree-distribution.png");
    JFreeChart chart2 = ChartFactory.createXYLineChart("In-Degree Distribution", "Value", "Count", dataset2, PlotOrientation.VERTICAL, true, false, false);
    chart2.removeLegend();
    ChartUtils.decorateChart(chart2);
    ChartUtils.scaleChart(chart2, dSeries, false);
    String indegreeImageFile = ChartUtils.renderChart(chart2, "indegree-distribution.png");
    JFreeChart chart3 = ChartFactory.createXYLineChart("Out-Degree Distribution", "Value", "Count", dataset3, PlotOrientation.VERTICAL, true, false, false);
    chart3.removeLegend();
    ChartUtils.decorateChart(chart3);
    ChartUtils.scaleChart(chart3, dSeries, false);
    String outdegreeImageFile = ChartUtils.renderChart(chart3, "outdegree-distribution.png");
    NumberFormat f = new DecimalFormat("#0.000");
    String report = "<HTML> <BODY> <h1>Degree Report </h1> " + "<hr>" + "<br> <h2> Results: </h2>" + "Average Degree: " + f.format(avgDegree) + "<br /><br />" + degreeImageFile + "<br /><br />" + indegreeImageFile + "<br /><br />" + outdegreeImageFile + "</BODY></HTML>";
    return report;
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) DecimalFormat(java.text.DecimalFormat) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) JFreeChart(org.jfree.chart.JFreeChart) NumberFormat(java.text.NumberFormat)

Example 14 with XYSeries

use of org.jfree.data.xy.XYSeries in project gephi by gephi.

the class DynamicDegree method getReport.

@Override
public String getReport() {
    //Time series
    XYSeries dSeries = ChartUtils.createXYSeries(averages, "Degree Time Series");
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(dSeries);
    JFreeChart chart = ChartFactory.createXYLineChart("Degree Time Series", "Time", "Average Degree", dataset, PlotOrientation.VERTICAL, true, false, false);
    chart.removeLegend();
    ChartUtils.decorateChart(chart);
    ChartUtils.scaleChart(chart, dSeries, false);
    String degreeImageFile = ChartUtils.renderChart(chart, "degree-ts.png");
    NumberFormat f = new DecimalFormat("#0.000000");
    String report = "<HTML> <BODY> <h1>Dynamic Degree Report </h1> " + "<hr>" + "<br> Bounds: from " + f.format(bounds.getLow()) + " to " + f.format(bounds.getHigh()) + "<br> Window: " + window + "<br> Tick: " + tick + "<br><br><h2> Average degrees over time: </h2>" + "<br /><br />" + degreeImageFile;
    /*for (Interval<Double> averages : averages) {
         report += averages.toString(dynamicModel.getTimeFormat().equals(DynamicModel.TimeFormat.DOUBLE)) + "<br />";
         }*/
    report += "<br /><br /></BODY></HTML>";
    return report;
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) DecimalFormat(java.text.DecimalFormat) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) JFreeChart(org.jfree.chart.JFreeChart) NumberFormat(java.text.NumberFormat)

Example 15 with XYSeries

use of org.jfree.data.xy.XYSeries in project gephi by gephi.

the class DynamicNbNodes method getReport.

@Override
public String getReport() {
    //Time series
    XYSeries dSeries = ChartUtils.createXYSeries(counts, "Nb Nodes Time Series");
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(dSeries);
    JFreeChart chart = ChartFactory.createXYLineChart("# Nodes Time Series", "Time", "# Nodes", dataset, PlotOrientation.VERTICAL, true, false, false);
    chart.removeLegend();
    ChartUtils.decorateChart(chart);
    ChartUtils.scaleChart(chart, dSeries, false);
    String imageFile = ChartUtils.renderChart(chart, "nb-nodes-ts.png");
    NumberFormat f = new DecimalFormat("#0.000");
    String report = "<HTML> <BODY> <h1>Dynamic Number of Nodes 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 nodes 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;
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) DecimalFormat(java.text.DecimalFormat) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) JFreeChart(org.jfree.chart.JFreeChart) NumberFormat(java.text.NumberFormat)

Aggregations

XYSeries (org.jfree.data.xy.XYSeries)25 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)24 JFreeChart (org.jfree.chart.JFreeChart)17 DecimalFormat (java.text.DecimalFormat)11 NumberFormat (java.text.NumberFormat)11 HashMap (java.util.HashMap)6 Map (java.util.Map)2 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Node (org.gephi.graph.api.Node)1 XYPlot (org.jfree.chart.plot.XYPlot)1 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)1 XYSplineRenderer (org.jfree.chart.renderer.xy.XYSplineRenderer)1 XYDataItem (org.jfree.data.xy.XYDataItem)1