Search in sources :

Example 1 with SummaryListener

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" + "&amp;c=" + (3 * _periodCount) + "&amp;w=" + (3 * _width) + "&amp;h=" + (3 * _height) + "\">");
            String title = _t("Combined bandwidth graph");
            _out.write("<img class=\"statimage\"" + " src=\"viewstat.jsp?stat=bw.combined" + "&amp;periodCount=" + _periodCount + "&amp;width=" + _width);
            if (!hideLegend) {
                // bw.combined graph has two entries in its legend
                // -26 pixels equalizes its height with the other images
                _out.write("&amp;height=" + (_height - 26));
            } else {
                // no legend, no height difference needed
                _out.write("&amp;height=" + (_height));
            }
            _out.write("&amp;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() + "&amp;c=" + (3 * _periodCount) + "&amp;w=" + (3 * _width) + "&amp;h=" + (3 * _height) + (_showEvents ? "&amp;showEvents=1" : "") + "\">");
            _out.write("<img class=\"statimage\" border=\"0\"" + " src=\"viewstat.jsp?stat=" + r.getRateStat().getName() + "&amp;showEvents=" + _showEvents + "&amp;period=" + r.getPeriod() + "&amp;periodCount=" + _periodCount + "&amp;width=" + _width + "&amp;height=" + _height + "&amp;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 "";
}
Also used : SummaryListener(net.i2p.router.web.SummaryListener) TreeSet(java.util.TreeSet) Rate(net.i2p.stat.Rate) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 TreeSet (java.util.TreeSet)1 SummaryListener (net.i2p.router.web.SummaryListener)1 Rate (net.i2p.stat.Rate)1