use of net.i2p.router.web.SummaryListener in project i2p.i2p by i2p.
the class GraphHelper method getImages.
public String getImages() {
if (StatSummarizer.isDisabled())
return "";
try {
List<SummaryListener> listeners = StatSummarizer.instance().getListeners();
TreeSet<SummaryListener> ordered = new TreeSet<SummaryListener>(new AlphaComparator());
ordered.addAll(listeners);
// go to some trouble to see if we have the data for the combined bw graph
boolean hasTx = false;
boolean hasRx = false;
for (SummaryListener lsnr : ordered) {
String title = lsnr.getRate().getRateStat().getName();
if (title.equals("bw.sendRate"))
hasTx = true;
else if (title.equals("bw.recvRate"))
hasRx = true;
}
boolean hideLegend = _context.getProperty(PROP_LEGEND, DEFAULT_LEGEND);
if (hasTx && hasRx && !_showEvents) {
_out.write("<a href=\"graph?stat=bw.combined" + "&c=" + (3 * _periodCount) + "&w=" + (3 * _width) + "&h=" + (3 * _height) + "\">");
String title = _t("Combined bandwidth graph");
_out.write("<img class=\"statimage\"" + " src=\"viewstat.jsp?stat=bw.combined" + "&periodCount=" + _periodCount + "&width=" + _width);
if (!hideLegend) {
// bw.combined graph has two entries in its legend
// -26 pixels equalizes its height with the other images
_out.write("&height=" + (_height - 26));
} else {
// no legend, no height difference needed
_out.write("&height=" + (_height));
}
_out.write("&hideLegend=" + hideLegend + "\" alt=\"" + title + "\" title=\"" + title + "\"></a>\n");
}
for (SummaryListener lsnr : ordered) {
Rate r = lsnr.getRate();
// e.g. "statname for 60m"
String title = _t("{0} for {1}", r.getRateStat().getName(), DataHelper.formatDuration2(_periodCount * r.getPeriod()));
_out.write("<a href=\"graph?stat=" + r.getRateStat().getName() + '.' + r.getPeriod() + "&c=" + (3 * _periodCount) + "&w=" + (3 * _width) + "&h=" + (3 * _height) + (_showEvents ? "&showEvents=1" : "") + "\">");
_out.write("<img class=\"statimage\" border=\"0\"" + " src=\"viewstat.jsp?stat=" + r.getRateStat().getName() + "&showEvents=" + _showEvents + "&period=" + r.getPeriod() + "&periodCount=" + _periodCount + "&width=" + _width + "&height=" + _height + "&hideLegend=" + hideLegend + "\" alt=\"" + title + "\" title=\"" + title + "\"></a>\n");
}
// FIXME jrobin doesn't support setting the timezone, will have to mod TimeAxis.java
// 0.9.1 - all graphs currently state UTC on them, so this text blurb is unnecessary,
// _out.write("<p><i>" + _t("All times are UTC.") + "</i></p>\n");
} catch (IOException ioe) {
ioe.printStackTrace();
}
return "";
}
Aggregations