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;
}
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");
}
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;
}
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;
}
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();
}
Aggregations