Search in sources :

Example 16 with XYSeriesCollection

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

the class EigenvectorCentrality method getReport.

/**
     *
     * @return
     */
@Override
public String getReport() {
    //distribution of values
    Map<Double, Integer> dist = new HashMap<>();
    for (int i = 0; i < centralities.length; i++) {
        Double d = centralities[i];
        if (dist.containsKey(d)) {
            Integer v = dist.get(d);
            dist.put(d, v + 1);
        } else {
            dist.put(d, 1);
        }
    }
    //Distribution series
    XYSeries dSeries = ChartUtils.createXYSeries(dist, "Eigenvector Centralities");
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(dSeries);
    JFreeChart chart = ChartFactory.createScatterPlot("Eigenvector Centrality Distribution", "Score", "Count", dataset, PlotOrientation.VERTICAL, true, false, false);
    chart.removeLegend();
    ChartUtils.decorateChart(chart);
    ChartUtils.scaleChart(chart, dSeries, true);
    String imageFile = ChartUtils.renderChart(chart, "eigenvector-centralities.png");
    String report = "<HTML> <BODY> <h1>Eigenvector Centrality Report</h1> " + "<hr>" + "<h2> Parameters: </h2>" + "Network Interpretation:  " + (isDirected ? "directed" : "undirected") + "<br>" + "Number of iterations: " + numRuns + "<br>" + "Sum change: " + sumChange + "<br> <h2> Results: </h2>" + imageFile + "</BODY></HTML>";
    return report;
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) HashMap(java.util.HashMap) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) JFreeChart(org.jfree.chart.JFreeChart)

Example 17 with XYSeriesCollection

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

the class GraphDistance method createImageFile.

private String createImageFile(TempDir tempDir, double[] pVals, String pName, String pX, String pY) {
    //distribution of values
    Map<Double, Integer> dist = new HashMap<>();
    for (int i = 0; i < N; i++) {
        Double d = pVals[i];
        if (dist.containsKey(d)) {
            Integer v = dist.get(d);
            dist.put(d, v + 1);
        } else {
            dist.put(d, 1);
        }
    }
    //Distribution series
    XYSeries dSeries = ChartUtils.createXYSeries(dist, pName);
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(dSeries);
    JFreeChart chart = ChartFactory.createXYLineChart(pName, pX, pY, dataset, PlotOrientation.VERTICAL, true, false, false);
    chart.removeLegend();
    ChartUtils.decorateChart(chart);
    ChartUtils.scaleChart(chart, dSeries, isNormalized);
    return ChartUtils.renderChart(chart, pName + ".png");
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) HashMap(java.util.HashMap) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) JFreeChart(org.jfree.chart.JFreeChart)

Example 18 with XYSeriesCollection

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

the class WeightedDegree method getReport.

@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, "w-degree-distribution.png");
        NumberFormat f = new DecimalFormat("#0.000");
        report = "<HTML> <BODY> <h1>Weighted Degree Report </h1> " + "<hr>" + "<br> <h2> Results: </h2>" + "Average Weighted Degree: " + f.format(avgWDegree) + "<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 19 with XYSeriesCollection

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

the class DynamicClusteringCoefficient method getReport.

@Override
public String getReport() {
    //Time series
    XYSeries dSeries = ChartUtils.createXYSeries(averages, "Clustering Coefficient Time Series");
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(dSeries);
    JFreeChart chart = ChartFactory.createXYLineChart("Clustering Coefficient", "Time", "Average Clustering Coefficient", dataset, PlotOrientation.VERTICAL, true, false, false);
    chart.removeLegend();
    ChartUtils.decorateChart(chart);
    ChartUtils.scaleChart(chart, dSeries, false);
    String coefficientImageFile = ChartUtils.renderChart(chart, "coefficient-ts.png");
    NumberFormat f = new DecimalFormat("#0.000000");
    String report = "<HTML> <BODY> <h1>Dynamic Clustering Coefficient 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 clustering cloefficient over time: </h2>" + "<br /><br />" + coefficientImageFile;
    /*for (Interval<Double> average : averages) {
        report += average.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 20 with XYSeriesCollection

use of org.jfree.data.xy.XYSeriesCollection in project openblocks by mikaelhg.

the class CLineGraph method getCSV.

public String getCSV() {
    lock = true;
    int max = 0;
    List<List<String>> columns = new ArrayList<List<String>>();
    for (int i = 0; i < chartData.getSeriesNum(); i++) {
        if (i == 0) {
            //{name, v1, v2, v3}
            List<String> time = new ArrayList<String>();
            XYSeries s = ((XYSeriesCollection) chart.getXYPlot().getDataset()).getSeries(i);
            max = Math.max(max, s.getItemCount());
            time.add("TIME,");
            for (Object o : s.getItems()) {
                XYDataItem item = (XYDataItem) o;
                time.add(item.getX() + ",");
            }
            columns.add(time);
        }
        //{name, v1, v2, v3}
        List<String> values = new ArrayList<String>();
        XYSeries s = ((XYSeriesCollection) chart.getXYPlot().getDataset()).getSeries(i);
        max = Math.max(max, s.getItemCount());
        values.add(s.getKey().toString() + ",");
        for (Object o : s.getItems()) {
            XYDataItem item = (XYDataItem) o;
            values.add(item.getY() + ",");
        }
        columns.add(values);
    }
    StringBuilder output = new StringBuilder();
    for (int i = 0; i < max; i++) {
        for (int j = 0; j < columns.size(); j++) {
            if (i < columns.get(j).size()) {
                output.append(columns.get(j).get(i));
            } else {
                output.append(",");
            }
        }
        output.append("\n");
    }
    lock = false;
    return output.toString();
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) XYDataItem(org.jfree.data.xy.XYDataItem)

Aggregations

XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)23 XYSeries (org.jfree.data.xy.XYSeries)22 JFreeChart (org.jfree.chart.JFreeChart)17 DecimalFormat (java.text.DecimalFormat)11 NumberFormat (java.text.NumberFormat)11 HashMap (java.util.HashMap)6 XYPlot (org.jfree.chart.plot.XYPlot)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Node (org.gephi.graph.api.Node)1 StandardXYItemRenderer (org.jfree.chart.renderer.xy.StandardXYItemRenderer)1 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)1 XYSplineRenderer (org.jfree.chart.renderer.xy.XYSplineRenderer)1 XYDataItem (org.jfree.data.xy.XYDataItem)1