From 8461beba1c6d9a787104a2bf92e808a7f50cc488 Mon Sep 17 00:00:00 2001 From: zzz Date: Thu, 17 Mar 2011 02:07:08 +0000 Subject: [PATCH] 1st cut --- apps/routerconsole/java/build.xml | 6 +- .../src/net/i2p/router/web/GraphHelper.java | 16 ++--- .../net/i2p/router/web/StatSummarizer.java | 60 +++++++++++------ .../net/i2p/router/web/SummaryRenderer.java | 66 +++++++++++++------ build.xml | 10 +-- 5 files changed, 100 insertions(+), 58 deletions(-) diff --git a/apps/routerconsole/java/build.xml b/apps/routerconsole/java/build.xml index dc686d29c..07c41d7de 100644 --- a/apps/routerconsole/java/build.xml +++ b/apps/routerconsole/java/build.xml @@ -26,7 +26,7 @@ - + @@ -58,7 +58,7 @@ - + @@ -92,7 +92,7 @@ diff --git a/apps/routerconsole/java/src/net/i2p/router/web/GraphHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/GraphHelper.java index 1b0e043e3..53cca47e9 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/GraphHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/GraphHelper.java @@ -23,8 +23,8 @@ public class GraphHelper extends FormHandler { private static final String PROP_REFRESH = "routerconsole.graphRefresh"; private static final String PROP_PERIODS = "routerconsole.graphPeriods"; private static final String PROP_EVENTS = "routerconsole.graphEvents"; - private static final int DEFAULT_X = 250; - private static final int DEFAULT_Y = 100; + public static final int DEFAULT_X = 250; + public static final int DEFAULT_Y = 100; private static final int DEFAULT_REFRESH = 60; private static final int DEFAULT_PERIODS = 60; static final int MAX_X = 2048; @@ -91,12 +91,11 @@ public class GraphHelper extends FormHandler { + "&height=" + (3 * _height) + "\" target=\"_blank\">"); String title = _("Combined bandwidth graph"); - _out.write("\""\n"); } @@ -113,9 +112,8 @@ public class GraphHelper extends FormHandler { + "&width=" + (3 * _width) + "&height=" + (3 * _height) + "\" target=\"_blank\">"); - _out.write("= 0 || name.indexOf("Bps") >= 0 || name.indexOf("memory") >= 0) && !showEvents) - def.setBaseValue(1024); + def.setBase(1024); if (!hideTitle) { String title; String p; @@ -109,11 +129,11 @@ class SummaryRenderer { descr = _(_listener.getRate().getRateStat().getDescription()); } def.datasource(plotName, path, plotName, "AVERAGE", "MEMORY"); - def.area(plotName, Color.BLUE, descr + "@r"); + def.area(plotName, Color.BLUE, descr + "\\r"); if (!hideLegend) { - def.gprint(plotName, "AVERAGE", _("avg") + ": @2@s"); - def.gprint(plotName, "MAX", ' ' + _("max") + ": @2@s"); - def.gprint(plotName, "LAST", ' ' + _("now") + ": @2@s@r"); + def.gprint(plotName, "AVERAGE", _("avg") + ": %.2f %s"); + def.gprint(plotName, "MAX", ' ' + _("max") + ": %.2f %S"); + def.gprint(plotName, "LAST", ' ' + _("now") + ": %.2f %S\\r"); } if (!showCredit) def.setShowSignature(false); @@ -126,24 +146,28 @@ class SummaryRenderer { def.line(dsNames[1], Color.RED, "Events per period"); */ if (hideLegend) - def.setShowLegend(false); + def.setNoLegend(true); if (hideGrid) { - def.setGridX(false); - def.setGridY(false); + def.setDrawXGrid(false); + def.setDrawYGrid(false); } //System.out.println("rendering: path=" + path + " dsNames[0]=" + dsNames[0] + " dsNames[1]=" + dsNames[1] + " lsnr.getName=" + _listener.getName()); def.setAntiAliasing(false); //System.out.println("Rendering: \n" + def.exportXmlTemplate()); //System.out.println("*****************\nData: \n" + _listener.getData().dump()); + def.setWidth(width); + def.setHeight(height); + RrdGraph graph = new RrdGraph(def); + int totalWidth = graph.getRrdGraphInfo().getWidth(); + int totalHeight = graph.getRrdGraphInfo().getHeight(); + BufferedImage img = new BufferedImage(totalWidth, totalHeight, BufferedImage.TYPE_USHORT_565_RGB); + Graphics gfx = img.getGraphics(); + graph.render(gfx); + ImageOutputStream ios = new MemoryCacheImageOutputStream(out); + ImageIO.write(img, "png", ios); //System.out.println("Graph created"); - byte data[] = null; - if ( (width <= 0) || (height <= 0) ) - data = graph.getPNGBytes(); - else - data = graph.getPNGBytes(width, height); - //long timeToPlot = System.currentTimeMillis() - begin; - out.write(data); + //File t = File.createTempFile("jrobinData", ".xml"); //_listener.getData().dumpXml(new FileOutputStream(t)); //System.out.println("plotted: " + (data != null ? data.length : 0) + " bytes in " + timeToPlot diff --git a/build.xml b/build.xml index 678abccf9..591a7dc31 100644 --- a/build.xml +++ b/build.xml @@ -293,7 +293,7 @@ - + @@ -462,7 +462,7 @@ - + @@ -665,7 +665,7 @@ - + @@ -824,7 +824,7 @@ - + @@ -1120,7 +1120,7 @@ - +