Changed graphs to be non-static.

Updated itoopie.i2p to reflect actual version.
This commit is contained in:
dev
2011-08-01 14:02:47 +00:00
parent 6159f7390c
commit 8a2cc403e0
8 changed files with 87 additions and 67 deletions

View File

@ -48,8 +48,8 @@ public class OverviewTab extends TabLogoPanel {
super(imageName); super(imageName);
super.setLayout(null); super.setLayout(null);
Chart2D bwChart = BandwidthChart.getChart(); final BandwidthChart bwChart = new BandwidthChart();
Chart2D partTunnelChart = ParticipatingTunnelsChart.getChart(); Chart2D partTunnelChart = new ParticipatingTunnelsChart();
ChartPanel pt = new ChartPanel(partTunnelChart); ChartPanel pt = new ChartPanel(partTunnelChart);
pt.setSize(300, 135); pt.setSize(300, 135);
pt.setLocation(15, 10); pt.setLocation(15, 10);

View File

@ -244,7 +244,7 @@ public class SettingsFrame extends RegisteredFrame{
} }
private void setupConnectPanel(JPanel networkPanel){ private void setupConnectPanel(JPanel networkPanel){
JLabel lblI2PControl = new JLabel(Transl._("Connect to I2PControl")); JLabel lblI2PControl = new JLabel(Transl._("Connect to I2P node"));
lblI2PControl.setBounds(10, 10, 228, 15); lblI2PControl.setBounds(10, 10, 228, 15);
networkPanel.add(lblI2PControl); networkPanel.add(lblI2PControl);
lblI2PControl.setHorizontalAlignment(SwingConstants.RIGHT); lblI2PControl.setHorizontalAlignment(SwingConstants.RIGHT);

View File

@ -28,19 +28,24 @@ import net.i2p.itoopie.gui.component.chart.ObjRecorder2Trace2DAdapter;
import net.i2p.itoopie.i18n.Transl; import net.i2p.itoopie.i18n.Transl;
public class BandwidthChart { public class BandwidthChart extends Chart2D{
private static ConfigurationManager _conf = ConfigurationManager.getInstance(); private static ConfigurationManager _conf = ConfigurationManager.getInstance();
private final static int DEFAULT_UPDATE_INTERVAL = 10000; // Update every 2500th ms private final static int DEFAULT_UPDATE_INTERVAL = 10000; // Update every 2500th ms
private final static int DEFAULT_GRAPH_INTERVAL = 2*3600*1000; // The graph will cover a maximum of 2hrs private final static int DEFAULT_GRAPH_INTERVAL = 2*3600*1000; // The graph will cover a maximum of 2hrs
private final static String DATE_FORMAT = "HH:mm:ss"; private final static String DATE_FORMAT = "HH:mm:ss";
private ObjRecorder2Trace2DAdapter bwInAdapter;
private ObjRecorder2Trace2DAdapter bwOutAdapter;
private InboundBandwidthTracker bwInTracker;
private OutboundBandwidthTracker bwOutTracker;
public static Chart2D getChart(){ public BandwidthChart(){
super();
int updateInterval = _conf.getConf("graph.updateinterval", DEFAULT_UPDATE_INTERVAL); int updateInterval = _conf.getConf("graph.updateinterval", DEFAULT_UPDATE_INTERVAL);
int graphInterval = _conf.getConf("graph.graphinterval", DEFAULT_GRAPH_INTERVAL); int graphInterval = _conf.getConf("graph.graphinterval", DEFAULT_GRAPH_INTERVAL);
Chart2D chart = new Chart2D(); setUseAntialiasing(true);
chart.setUseAntialiasing(true); setMinPaintLatency(20);
chart.setMinPaintLatency(20);
ITrace2D dataBWIn = new Trace2DLtd( graphInterval/updateInterval ); ITrace2D dataBWIn = new Trace2DLtd( graphInterval/updateInterval );
dataBWIn.setStroke(new BasicStroke(1)); dataBWIn.setStroke(new BasicStroke(1));
dataBWIn.setColor(new Color(255, 0, 0, 255)); dataBWIn.setColor(new Color(255, 0, 0, 255));
@ -48,7 +53,7 @@ public class BandwidthChart {
ITracePainter<?> dotPainter = new TracePainterPolyline(); ITracePainter<?> dotPainter = new TracePainterPolyline();
dataBWIn.setTracePainter(dotPainter); dataBWIn.setTracePainter(dotPainter);
chart.addTrace(dataBWIn); addTrace(dataBWIn);
ITrace2D dataBWOut = new Trace2DLtd( graphInterval/updateInterval ); ITrace2D dataBWOut = new Trace2DLtd( graphInterval/updateInterval );
dataBWOut.setStroke(new BasicStroke(1)); dataBWOut.setStroke(new BasicStroke(1));
@ -56,32 +61,35 @@ public class BandwidthChart {
dataBWOut.setName(Transl._("Bandwidth Out [KB/s]")); dataBWOut.setName(Transl._("Bandwidth Out [KB/s]"));
dataBWOut.setTracePainter(dotPainter); dataBWOut.setTracePainter(dotPainter);
chart.addTrace(dataBWOut); addTrace(dataBWOut);
final SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); final SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
chart.getAxisX().setFormatter(new LabelFormatterDate(sdf)); getAxisX().setFormatter(new LabelFormatterDate(sdf));
chart.getAxisX().setPaintGrid(true); getAxisX().setPaintGrid(true);
chart.getAxisX().setAxisTitle(new AxisTitle(Transl._("Time"))); getAxisX().setAxisTitle(new AxisTitle(Transl._("Time")));
DecimalFormat df = new DecimalFormat("0 ; 0"); DecimalFormat df = new DecimalFormat("0 ; 0");
chart.getAxisY().setFormatter(new LabelFormatterNumber(df)); getAxisY().setFormatter(new LabelFormatterNumber(df));
chart.getAxisY().setPaintGrid(true); getAxisY().setPaintGrid(true);
chart.getAxisY().setAxisTitle(new AxisTitle("")); getAxisY().setAxisTitle(new AxisTitle(""));
// force ranges: // force ranges:
chart.getAxisY().setRangePolicy(new RangePolicyMinimumViewport(new Range(0, 5))); getAxisY().setRangePolicy(new RangePolicyMinimumViewport(new Range(0, 5)));
new ObjRecorder2Trace2DAdapter(dataBWIn, new InboundBandwidthTracker(), "m_value", updateInterval); bwInTracker = new InboundBandwidthTracker();
new ObjRecorder2Trace2DAdapter(dataBWOut, new OutboundBandwidthTracker(), "m_value", updateInterval); bwOutTracker = new OutboundBandwidthTracker();
return chart;
bwInAdapter = new ObjRecorder2Trace2DAdapter(dataBWIn, bwInTracker, "m_value", updateInterval/2);
bwOutAdapter = new ObjRecorder2Trace2DAdapter(dataBWOut, bwOutTracker, "m_value", updateInterval/2);
} }
public static void main(final String[] args) {
public static void main(final String[] args) {
JFrame frame = new JFrame(); JFrame frame = new JFrame();
Container contentPane = frame.getContentPane(); Container contentPane = frame.getContentPane();
contentPane.setLayout(new BorderLayout()); contentPane.setLayout(new BorderLayout());
contentPane.add(new ChartPanel(getChart()), BorderLayout.CENTER); contentPane.add(new ChartPanel(new BandwidthChart()), BorderLayout.CENTER);
//frame.add(new ChartPanel(getChart())); //frame.add(new ChartPanel(getChart()));
frame.setLocation(200, 300); frame.setLocation(200, 300);
frame.setSize(700, 210); frame.setSize(700, 210);

View File

@ -27,19 +27,21 @@ import net.i2p.itoopie.gui.component.chart.ObjRecorder2Trace2DAdapter;
import net.i2p.itoopie.i18n.Transl; import net.i2p.itoopie.i18n.Transl;
public class ParticipatingTunnelsChart { public class ParticipatingTunnelsChart extends Chart2D {
private static ConfigurationManager _conf = ConfigurationManager.getInstance(); private static ConfigurationManager _conf = ConfigurationManager.getInstance();
private final static int DEFAULT_UPDATE_INTERVAL = 10000; // Update every 1000th ms private final static int DEFAULT_UPDATE_INTERVAL = 10000; // Update every 1000th ms
private final static int DEFAULT_GRAPH_INTERVAL = 2*3600*1000; // The graph will cover a maximum of 2hrs private final static int DEFAULT_GRAPH_INTERVAL = 2*3600*1000; // The graph will cover a maximum of 2hrs
private final static String DATE_FORMAT = "HH:mm:ss"; private final static String DATE_FORMAT = "HH:mm:ss";
private ParticipatingTunnelsTracker partTunnelTracker;
private ObjRecorder2Trace2DAdapter partTunnelAdapter;
public static Chart2D getChart(){ public ParticipatingTunnelsChart(){
super();
int updateInterval = _conf.getConf("graph.updateinterval", DEFAULT_UPDATE_INTERVAL); int updateInterval = _conf.getConf("graph.updateinterval", DEFAULT_UPDATE_INTERVAL);
int graphInterval = _conf.getConf("graph.graphinterval", DEFAULT_GRAPH_INTERVAL); int graphInterval = _conf.getConf("graph.graphinterval", DEFAULT_GRAPH_INTERVAL);
Chart2D chart = new Chart2D(); setUseAntialiasing(true);
chart.setUseAntialiasing(true); setMinPaintLatency(20);
chart.setMinPaintLatency(20);
ITrace2D dataPartTunnels = new Trace2DLtd( graphInterval/updateInterval ); ITrace2D dataPartTunnels = new Trace2DLtd( graphInterval/updateInterval );
dataPartTunnels.setStroke(new BasicStroke(1)); dataPartTunnels.setStroke(new BasicStroke(1));
dataPartTunnels.setColor(new Color(255, 0, 0, 255)); dataPartTunnels.setColor(new Color(255, 0, 0, 255));
@ -47,32 +49,31 @@ public class ParticipatingTunnelsChart {
ITracePainter<?> dotPainter = new TracePainterPolyline(); ITracePainter<?> dotPainter = new TracePainterPolyline();
dataPartTunnels.setTracePainter(dotPainter); dataPartTunnels.setTracePainter(dotPainter);
chart.addTrace(dataPartTunnels); addTrace(dataPartTunnels);
final SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); final SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
chart.getAxisX().setFormatter(new LabelFormatterDate(sdf)); getAxisX().setFormatter(new LabelFormatterDate(sdf));
chart.getAxisX().setPaintGrid(true); getAxisX().setPaintGrid(true);
chart.getAxisX().setAxisTitle(new AxisTitle(Transl._("Time"))); getAxisX().setAxisTitle(new AxisTitle(Transl._("Time")));
DecimalFormat df = new DecimalFormat("0 ; 0"); DecimalFormat df = new DecimalFormat("0 ; 0");
chart.getAxisY().setFormatter(new LabelFormatterNumber(df)); getAxisY().setFormatter(new LabelFormatterNumber(df));
chart.getAxisY().setPaintGrid(true); getAxisY().setPaintGrid(true);
chart.getAxisY().setAxisTitle(new AxisTitle("")); getAxisY().setAxisTitle(new AxisTitle(""));
// force ranges: // force ranges:
chart.getAxisY().setRangePolicy(new RangePolicyMinimumViewport(new Range(0, 20))); getAxisY().setRangePolicy(new RangePolicyMinimumViewport(new Range(0, 20)));
new ObjRecorder2Trace2DAdapter(dataPartTunnels, new ParticipatingTunnelsTracker(), "m_value", updateInterval); partTunnelTracker = new ParticipatingTunnelsTracker();
//new ObjRecorder2Trace2DAdapter(dataPartTunnels, new DummyDataCollector(0.5, 1000), "m_number", updateInterval); partTunnelAdapter = new ObjRecorder2Trace2DAdapter(dataPartTunnels, partTunnelTracker, "m_value", updateInterval/2);
return chart;
} }
public static void main(final String[] args) { public static void main(final String[] args) {
JFrame frame = new JFrame(); JFrame frame = new JFrame();
Container contentPane = frame.getContentPane(); Container contentPane = frame.getContentPane();
contentPane.setLayout(new BorderLayout()); contentPane.setLayout(new BorderLayout());
contentPane.add(new ChartPanel(getChart()), BorderLayout.CENTER); contentPane.add(new ChartPanel(new ParticipatingTunnelsChart()), BorderLayout.CENTER);
//frame.add(new ChartPanel(getChart())); //frame.add(new ChartPanel(getChart()));
frame.setLocation(200, 300); frame.setLocation(200, 300);
frame.setSize(700, 210); frame.setSize(700, 210);

View File

@ -36,16 +36,10 @@ public class InboundBandwidthTracker extends Thread {
*/ */
@Override @Override
public void run() { public void run() {
EnumMap<ROUTER_INFO, Object> em;
while (true) { while (true) {
try {
em = GetRouterInfo.execute(ROUTER_INFO.BW_INBOUND_1S); runOnce();
double dbl = (Double) em.get(ROUTER_INFO.BW_INBOUND_1S);
m_value = dbl / 1024; //Bytes -> KBytes
} catch (InvalidPasswordException e) {
} catch (JSONRPC2SessionException e) {
}
try { try {
Thread.sleep(updateInterval); Thread.sleep(updateInterval);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -54,4 +48,14 @@ public class InboundBandwidthTracker extends Thread {
} }
} }
public synchronized void runOnce(){
try {
EnumMap<ROUTER_INFO, Object> em = GetRouterInfo.execute(ROUTER_INFO.BW_INBOUND_1S);
double dbl = (Double) em.get(ROUTER_INFO.BW_INBOUND_1S);
m_value = dbl / 1024; //Bytes -> KBytes
} catch (InvalidPasswordException e) {
} catch (JSONRPC2SessionException e) {
}
}
} }

View File

@ -36,16 +36,10 @@ public class OutboundBandwidthTracker extends Thread {
*/ */
@Override @Override
public void run() { public void run() {
EnumMap<ROUTER_INFO, Object> em;
while (true) { while (true) {
try {
em = GetRouterInfo.execute(ROUTER_INFO.BW_OUTBOUND_1S); runOnce();
double dbl = (Double) em.get(ROUTER_INFO.BW_OUTBOUND_1S);
m_value = dbl / 1024; //Bytes -> KBytes
} catch (InvalidPasswordException e) {
} catch (JSONRPC2SessionException e) {
}
try { try {
Thread.sleep(updateInterval); Thread.sleep(updateInterval);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -54,4 +48,14 @@ public class OutboundBandwidthTracker extends Thread {
} }
} }
public synchronized void runOnce(){
try {
EnumMap<ROUTER_INFO, Object> em = GetRouterInfo.execute(ROUTER_INFO.BW_OUTBOUND_1S);
double dbl = (Double) em.get(ROUTER_INFO.BW_OUTBOUND_1S);
m_value = dbl / 1024; //Bytes -> KBytes
} catch (InvalidPasswordException e) {
} catch (JSONRPC2SessionException e) {
}
}
} }

View File

@ -36,16 +36,9 @@ public class ParticipatingTunnelsTracker extends Thread {
*/ */
@Override @Override
public void run() { public void run() {
EnumMap<ROUTER_INFO, Object> em;
while (true) { while (true) {
try {
em = GetRouterInfo.execute(ROUTER_INFO.TUNNELS_PARTICIPATING); runOnce();
Long nbr = (Long) em.get(ROUTER_INFO.TUNNELS_PARTICIPATING);
m_value = nbr.doubleValue();
} catch (InvalidPasswordException e) {
} catch (JSONRPC2SessionException e) {
}
try { try {
Thread.sleep(updateInterval); Thread.sleep(updateInterval);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -54,4 +47,14 @@ public class ParticipatingTunnelsTracker extends Thread {
} }
} }
public synchronized void runOnce(){
try {
EnumMap<ROUTER_INFO, Object> em = GetRouterInfo.execute(ROUTER_INFO.TUNNELS_PARTICIPATING);
Long nbr = (Long) em.get(ROUTER_INFO.TUNNELS_PARTICIPATING);
m_value = nbr.doubleValue();
} catch (InvalidPasswordException e) {
} catch (JSONRPC2SessionException e) {
}
}
} }

View File

@ -125,7 +125,7 @@ entering <tt>http://itoopie.i2p/files/I2PControl.xpi2p</tt> in the 'Plugin Insta
<img src="images/itoopie-settings.png"> <img src="images/itoopie-settings.png">
</figure> </figure>
<p>Version 0.1</p> <p>Version 0.0.1</p>
<tt>Added graphs.</tt> <tt>Added graphs.</tt>
<tt>Added support for changing the port of I2PControl</tt> <tt>Added support for changing the port of I2PControl</tt>
</div> </div>