use of org.jfree.chart.JFreeChart in project gephi by gephi.
the class Hits method getReport.
/**
*
* @return
*/
@Override
public String getReport() {
//distribution of hub values
Map<Double, Integer> distHubs = new HashMap<>();
for (int i = 0; i < hubs.length; i++) {
Double d = hubs[i];
if (distHubs.containsKey(d)) {
Integer v = distHubs.get(d);
distHubs.put(d, v + 1);
} else {
distHubs.put(d, 1);
}
}
//distribution of authority values
Map<Double, Integer> distAuthorities = new HashMap<>();
for (int i = 0; i < authority.length; i++) {
Double d = authority[i];
if (distAuthorities.containsKey(d)) {
Integer v = distAuthorities.get(d);
distAuthorities.put(d, v + 1);
} else {
distAuthorities.put(d, 1);
}
}
//Distribution of hub series
XYSeries dHubsSeries = ChartUtils.createXYSeries(distHubs, "Hubs");
//Distribution of authority series
XYSeries dAuthsSeries = ChartUtils.createXYSeries(distAuthorities, "Authority");
XYSeriesCollection datasetHubs = new XYSeriesCollection();
datasetHubs.addSeries(dHubsSeries);
XYSeriesCollection datasetAuths = new XYSeriesCollection();
datasetAuths.addSeries(dAuthsSeries);
JFreeChart chart = ChartFactory.createXYLineChart("Hubs Distribution", "Score", "Count", datasetHubs, PlotOrientation.VERTICAL, true, false, false);
chart.removeLegend();
ChartUtils.decorateChart(chart);
ChartUtils.scaleChart(chart, dHubsSeries, true);
String imageFile1 = ChartUtils.renderChart(chart, "hubs.png");
JFreeChart chart2 = ChartFactory.createXYLineChart("Authority Distribution", "Score", "Count", datasetAuths, PlotOrientation.VERTICAL, true, false, false);
chart2.removeLegend();
ChartUtils.decorateChart(chart2);
ChartUtils.scaleChart(chart2, dAuthsSeries, true);
String imageFile2 = ChartUtils.renderChart(chart2, "authorities.png");
String report = "<HTML> <BODY> <h1> HITS Metric Report </h1>" + "<hr>" + "<br />" + "<h2> Parameters: </h2> Ε = " + this.epsilon + "<br /> <h2> Results: </h2><br />" + imageFile1 + "<br />" + imageFile2 + "<br /><br />" + "<h2> Algorithm: </h2>" + "Jon M. Kleinberg, <i>Authoritative Sources in a Hyperlinked Environment</i>, in Journal of the ACM 46 (5): 604–632 (1999)<br />" + "</BODY> </HTML>";
return report;
}
use of org.jfree.chart.JFreeChart in project gephi by gephi.
the class ChartsUtils method buildScatterPlot.
/**
* Build new scatter plot from numbers array using a default title and xLabel.
* String dataName will be used for yLabel.
* Appearance can be changed later with the other methods of ChartsUtils.
* @param numbers Numbers for the scatter plot
* @param dataName Name of the numbers data
* @param useLines Indicates if lines have to be drawn instead of shapes
* @param useLinearRegression Indicates if the scatter plot has to have linear regreesion line drawn
* @return Scatter plot for the data and appearance options
*/
public static JFreeChart buildScatterPlot(final Number[] numbers, final String dataName, final boolean useLines, final boolean useLinearRegression) {
if (numbers == null || numbers.length == 0) {
return null;
}
XYSeriesCollection dataset = new XYSeriesCollection();
XYSeries series = new XYSeries(dataName);
for (int i = 0; i < numbers.length; i++) {
series.add(i, numbers[i]);
}
dataset.addSeries(series);
JFreeChart scatterPlot = buildScatterPlot(dataset, getMessage("ChartsUtils.report.scatter-plot.title"), getMessage("ChartsUtils.report.scatter-plot.xLabel"), dataName, useLines, useLinearRegression);
return scatterPlot;
}
use of org.jfree.chart.JFreeChart in project gephi by gephi.
the class ChartsUtils method buildScatterPlot.
/**
* Build new Scatter plot. Appearance can be changed later with the other methods of ChartsUtils.
* @param data Data for the plot
* @param title Title for the chart
* @param xLabel Text for x label
* @param yLabel Text for y label
* @param useLines Indicates if lines have to be drawn instead of shapes
* @param useLinearRegression Indicates if the scatter plot has to have linear regreesion line drawn
* @return Scatter plot for the data and appearance options
*/
public static JFreeChart buildScatterPlot(final XYSeriesCollection data, final String title, final String xLabel, final String yLabel, final boolean useLines, final boolean useLinearRegression) {
JFreeChart scatterPlot = ChartFactory.createXYLineChart(title, xLabel, yLabel, data, PlotOrientation.VERTICAL, true, true, false);
XYPlot plot = (XYPlot) scatterPlot.getPlot();
plot.setBackgroundPaint(java.awt.Color.WHITE);
plot.setDomainGridlinePaint(java.awt.Color.GRAY);
plot.setRangeGridlinePaint(java.awt.Color.GRAY);
setScatterPlotLinesEnabled(scatterPlot, useLines);
setScatterPlotLinearRegressionEnabled(scatterPlot, useLinearRegression);
return scatterPlot;
}
use of org.jfree.chart.JFreeChart in project gephi by gephi.
the class ChartsUtils method buildHistogram.
/**
* Build new histogram from the given numbers array using a default title and xLabel.
* String dataName will be used for yLabel.
* @param numbers Numbers for the histogram
* @param dataName Name of the numbers data
* @param divisions Divisions for the histogram
* @return Prepared histogram
*/
public static JFreeChart buildHistogram(final Number[] numbers, final String dataName, final int divisions) {
if (numbers == null || numbers.length == 0) {
return null;
}
HistogramDataset dataset = new HistogramDataset();
dataset.setType(HistogramType.FREQUENCY);
double[] doubleNumbers = new double[numbers.length];
for (int i = 0; i < doubleNumbers.length; i++) {
doubleNumbers[i] = numbers[i].doubleValue();
}
//Use 10 divisions if divisions number is invalid.
dataset.addSeries(dataName, doubleNumbers, divisions > 0 ? divisions : 10);
JFreeChart histogram = ChartFactory.createHistogram(getMessage("ChartsUtils.report.histogram.title"), dataName, getMessage("ChartsUtils.report.histogram.yLabel"), dataset, PlotOrientation.VERTICAL, true, true, false);
return histogram;
}
use of org.jfree.chart.JFreeChart in project zaproxy by zaproxy.
the class ScanProgressDialog method createChart.
private JFreeChart createChart(final XYDataset dataset) {
JFreeChart result = ChartFactory.createTimeSeriesChart(// No title - it just takes up space
null, Constant.messages.getString("ascan.progress.chart.time"), Constant.messages.getString("ascan.progress.chart.responses"), dataset, true, true, false);
XYPlot plot = result.getXYPlot();
ValueAxis daxis = plot.getDomainAxis();
daxis.setAutoRange(true);
daxis.setAutoRangeMinimumSize(60000.0);
plot.getRangeAxis().setAutoRangeMinimumSize(20);
return result;
}
Aggregations