use of org.jfree.chart.plot.RingPlot in project i2p.i2p-bote by i2p.
the class PeerInfoTag method createRelayChart.
private String createRelayChart(RelayPeer[] relayPeers) throws IOException {
RingPlot plot;
if (relayPeers.length == 0) {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("", 100);
plot = new RingPlot(dataset);
plot.setSectionPaint("", Color.gray);
} else {
int good = 0;
int untested = 0;
for (RelayPeer relayPeer : relayPeers) {
int reachability = relayPeer.getReachability();
if (reachability == 0)
untested += 1;
else if (reachability > 80)
good += 1;
}
int bad = relayPeers.length - good - untested;
DefaultPieDataset dataset = new DefaultPieDataset();
if (good > 0)
dataset.setValue(_t("Good"), good);
if (bad > 0)
dataset.setValue(_t("Unreliable"), bad);
if (untested > 0)
dataset.setValue(_t("Untested"), untested);
plot = new RingPlot(dataset);
plot.setSectionPaint(_t("Good"), Color.green);
plot.setSectionPaint(_t("Unreliable"), Color.red);
plot.setSectionPaint(_t("Untested"), Color.orange);
}
plot.setLabelGenerator(null);
plot.setShadowGenerator(null);
JFreeChart chart = new JFreeChart(_t("Relay Peers:"), JFreeChart.DEFAULT_TITLE_FONT, plot, relayPeers.length == 0 ? false : true);
return ServletUtilities.saveChartAsPNG(chart, 400, 300, null);
}
use of org.jfree.chart.plot.RingPlot in project cytoscape-impl by cytoscape.
the class RingLayer method createChart.
private JFreeChart createChart(final PieDataset dataset, final double sectionDepth, final double interiorGap) {
JFreeChart chart = ChartFactory.createRingChart(// chart title
null, // data
dataset, // include legend
false, // tooltips
false, // urls
false);
chart.setAntiAlias(true);
chart.setBorderVisible(false);
chart.setBackgroundPaint(TRANSPARENT_COLOR);
chart.setBackgroundImageAlpha(0.0f);
chart.setPadding(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
final RingPlot plot = (RingPlot) chart.getPlot();
plot.setCircular(true);
plot.setStartAngle(startAngle);
plot.setDirection(rotation == Rotation.ANTICLOCKWISE ? org.jfree.util.Rotation.ANTICLOCKWISE : org.jfree.util.Rotation.CLOCKWISE);
plot.setOutlineVisible(false);
plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
plot.setBackgroundPaint(TRANSPARENT_COLOR);
plot.setBackgroundAlpha(0.0f);
plot.setShadowPaint(TRANSPARENT_COLOR);
plot.setShadowXOffset(0);
plot.setShadowYOffset(0);
plot.setInnerSeparatorExtension(0);
plot.setOuterSeparatorExtension(0);
plot.setSectionDepth(sectionDepth);
plot.setInteriorGap(interiorGap);
// Labels don't look good if it has multiple rings, so only show them when there's only one ring
plot.setLabelGenerator(showItemLabels && datasetList.size() == 1 ? new CustomPieSectionLabelGenerator(labels) : null);
plot.setSimpleLabels(true);
plot.setLabelBackgroundPaint(TRANSPARENT_COLOR);
plot.setLabelOutlinePaint(TRANSPARENT_COLOR);
plot.setLabelShadowPaint(TRANSPARENT_COLOR);
plot.setLabelFont(plot.getLabelFont().deriveFont(itemFontSize));
final BasicStroke stroke = new BasicStroke(borderWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
plot.setSeparatorStroke(stroke);
plot.setSeparatorPaint(borderWidth > 0 ? borderColor : TRANSPARENT_COLOR);
final List<?> keys = dataset.getKeys();
for (int i = 0; i < keys.size(); i++) {
final String k = (String) keys.get(i);
final Color c = colors.size() > i ? colors.get(i) : DEFAULT_ITEM_BG_COLOR;
plot.setSectionPaint(k, c);
plot.setSectionOutlinePaint(k, borderWidth > 0 ? borderColor : TRANSPARENT_COLOR);
plot.setSectionOutlineStroke(k, stroke);
}
return chart;
}
use of org.jfree.chart.plot.RingPlot in project i2p.i2p-bote by i2p.
the class PeerInfoTag method createDhtChart.
private String createDhtChart(DhtPeerStats dhtStats) throws IOException {
RingPlot plot;
int numDhtPeers = dhtStats.getData().size();
if (numDhtPeers == 0) {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("", 100);
plot = new RingPlot(dataset);
plot.setSectionPaint("", Color.gray);
} else {
int reachable = 0;
for (DhtPeerStatsRow row : dhtStats.getData()) {
if (row.isReachable())
reachable += 1;
}
int unreachable = numDhtPeers - reachable;
DefaultPieDataset dataset = new DefaultPieDataset();
if (reachable > 0)
dataset.setValue(_t("Reachable"), reachable);
if (unreachable > 0)
dataset.setValue(_t("Unreachable"), unreachable);
plot = new RingPlot(dataset);
plot.setSectionPaint(_t("Reachable"), Color.green);
plot.setSectionPaint(_t("Unreachable"), Color.red);
}
plot.setLabelGenerator(null);
plot.setShadowGenerator(null);
JFreeChart dhtChart = new JFreeChart(_t("Kademlia Peers:"), JFreeChart.DEFAULT_TITLE_FONT, plot, numDhtPeers == 0 ? false : true);
return ServletUtilities.saveChartAsPNG(dhtChart, 400, 300, null);
}
Aggregations