Changed graphs to be non-static.
Updated itoopie.i2p to reflect actual version.
This commit is contained in:
@ -48,8 +48,8 @@ public class OverviewTab extends TabLogoPanel {
|
||||
super(imageName);
|
||||
super.setLayout(null);
|
||||
|
||||
Chart2D bwChart = BandwidthChart.getChart();
|
||||
Chart2D partTunnelChart = ParticipatingTunnelsChart.getChart();
|
||||
final BandwidthChart bwChart = new BandwidthChart();
|
||||
Chart2D partTunnelChart = new ParticipatingTunnelsChart();
|
||||
ChartPanel pt = new ChartPanel(partTunnelChart);
|
||||
pt.setSize(300, 135);
|
||||
pt.setLocation(15, 10);
|
||||
|
@ -244,7 +244,7 @@ public class SettingsFrame extends RegisteredFrame{
|
||||
}
|
||||
|
||||
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);
|
||||
networkPanel.add(lblI2PControl);
|
||||
lblI2PControl.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
|
@ -28,19 +28,24 @@ import net.i2p.itoopie.gui.component.chart.ObjRecorder2Trace2DAdapter;
|
||||
import net.i2p.itoopie.i18n.Transl;
|
||||
|
||||
|
||||
public class BandwidthChart {
|
||||
public class BandwidthChart extends Chart2D{
|
||||
private static ConfigurationManager _conf = ConfigurationManager.getInstance();
|
||||
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 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 graphInterval = _conf.getConf("graph.graphinterval", DEFAULT_GRAPH_INTERVAL);
|
||||
|
||||
Chart2D chart = new Chart2D();
|
||||
chart.setUseAntialiasing(true);
|
||||
chart.setMinPaintLatency(20);
|
||||
setUseAntialiasing(true);
|
||||
setMinPaintLatency(20);
|
||||
ITrace2D dataBWIn = new Trace2DLtd( graphInterval/updateInterval );
|
||||
dataBWIn.setStroke(new BasicStroke(1));
|
||||
dataBWIn.setColor(new Color(255, 0, 0, 255));
|
||||
@ -48,7 +53,7 @@ public class BandwidthChart {
|
||||
|
||||
ITracePainter<?> dotPainter = new TracePainterPolyline();
|
||||
dataBWIn.setTracePainter(dotPainter);
|
||||
chart.addTrace(dataBWIn);
|
||||
addTrace(dataBWIn);
|
||||
|
||||
ITrace2D dataBWOut = new Trace2DLtd( graphInterval/updateInterval );
|
||||
dataBWOut.setStroke(new BasicStroke(1));
|
||||
@ -56,32 +61,35 @@ public class BandwidthChart {
|
||||
dataBWOut.setName(Transl._("Bandwidth Out [KB/s]"));
|
||||
|
||||
dataBWOut.setTracePainter(dotPainter);
|
||||
chart.addTrace(dataBWOut);
|
||||
addTrace(dataBWOut);
|
||||
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
|
||||
|
||||
chart.getAxisX().setFormatter(new LabelFormatterDate(sdf));
|
||||
chart.getAxisX().setPaintGrid(true);
|
||||
chart.getAxisX().setAxisTitle(new AxisTitle(Transl._("Time")));
|
||||
getAxisX().setFormatter(new LabelFormatterDate(sdf));
|
||||
getAxisX().setPaintGrid(true);
|
||||
getAxisX().setAxisTitle(new AxisTitle(Transl._("Time")));
|
||||
|
||||
DecimalFormat df = new DecimalFormat("0 ; 0");
|
||||
chart.getAxisY().setFormatter(new LabelFormatterNumber(df));
|
||||
chart.getAxisY().setPaintGrid(true);
|
||||
chart.getAxisY().setAxisTitle(new AxisTitle(""));
|
||||
getAxisY().setFormatter(new LabelFormatterNumber(df));
|
||||
getAxisY().setPaintGrid(true);
|
||||
getAxisY().setAxisTitle(new AxisTitle(""));
|
||||
|
||||
// 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);
|
||||
new ObjRecorder2Trace2DAdapter(dataBWOut, new OutboundBandwidthTracker(), "m_value", updateInterval);
|
||||
return chart;
|
||||
bwInTracker = new InboundBandwidthTracker();
|
||||
bwOutTracker = new OutboundBandwidthTracker();
|
||||
|
||||
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();
|
||||
Container contentPane = frame.getContentPane();
|
||||
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.setLocation(200, 300);
|
||||
frame.setSize(700, 210);
|
||||
|
@ -27,19 +27,21 @@ import net.i2p.itoopie.gui.component.chart.ObjRecorder2Trace2DAdapter;
|
||||
import net.i2p.itoopie.i18n.Transl;
|
||||
|
||||
|
||||
public class ParticipatingTunnelsChart {
|
||||
public class ParticipatingTunnelsChart extends Chart2D {
|
||||
private static ConfigurationManager _conf = ConfigurationManager.getInstance();
|
||||
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 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 graphInterval = _conf.getConf("graph.graphinterval", DEFAULT_GRAPH_INTERVAL);
|
||||
|
||||
Chart2D chart = new Chart2D();
|
||||
chart.setUseAntialiasing(true);
|
||||
chart.setMinPaintLatency(20);
|
||||
setUseAntialiasing(true);
|
||||
setMinPaintLatency(20);
|
||||
ITrace2D dataPartTunnels = new Trace2DLtd( graphInterval/updateInterval );
|
||||
dataPartTunnels.setStroke(new BasicStroke(1));
|
||||
dataPartTunnels.setColor(new Color(255, 0, 0, 255));
|
||||
@ -47,32 +49,31 @@ public class ParticipatingTunnelsChart {
|
||||
|
||||
ITracePainter<?> dotPainter = new TracePainterPolyline();
|
||||
dataPartTunnels.setTracePainter(dotPainter);
|
||||
chart.addTrace(dataPartTunnels);
|
||||
addTrace(dataPartTunnels);
|
||||
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
|
||||
|
||||
chart.getAxisX().setFormatter(new LabelFormatterDate(sdf));
|
||||
chart.getAxisX().setPaintGrid(true);
|
||||
chart.getAxisX().setAxisTitle(new AxisTitle(Transl._("Time")));
|
||||
getAxisX().setFormatter(new LabelFormatterDate(sdf));
|
||||
getAxisX().setPaintGrid(true);
|
||||
getAxisX().setAxisTitle(new AxisTitle(Transl._("Time")));
|
||||
|
||||
DecimalFormat df = new DecimalFormat("0 ; 0");
|
||||
chart.getAxisY().setFormatter(new LabelFormatterNumber(df));
|
||||
chart.getAxisY().setPaintGrid(true);
|
||||
chart.getAxisY().setAxisTitle(new AxisTitle(""));
|
||||
getAxisY().setFormatter(new LabelFormatterNumber(df));
|
||||
getAxisY().setPaintGrid(true);
|
||||
getAxisY().setAxisTitle(new AxisTitle(""));
|
||||
|
||||
// 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);
|
||||
//new ObjRecorder2Trace2DAdapter(dataPartTunnels, new DummyDataCollector(0.5, 1000), "m_number", updateInterval);
|
||||
return chart;
|
||||
partTunnelTracker = new ParticipatingTunnelsTracker();
|
||||
partTunnelAdapter = new ObjRecorder2Trace2DAdapter(dataPartTunnels, partTunnelTracker, "m_value", updateInterval/2);
|
||||
}
|
||||
|
||||
public static void main(final String[] args) {
|
||||
JFrame frame = new JFrame();
|
||||
Container contentPane = frame.getContentPane();
|
||||
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.setLocation(200, 300);
|
||||
frame.setSize(700, 210);
|
||||
|
@ -36,16 +36,10 @@ public class InboundBandwidthTracker extends Thread {
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
EnumMap<ROUTER_INFO, Object> em;
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
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) {
|
||||
}
|
||||
|
||||
|
||||
runOnce();
|
||||
try {
|
||||
Thread.sleep(updateInterval);
|
||||
} 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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,16 +36,10 @@ public class OutboundBandwidthTracker extends Thread {
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
EnumMap<ROUTER_INFO, Object> em;
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
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) {
|
||||
}
|
||||
|
||||
|
||||
runOnce();
|
||||
try {
|
||||
Thread.sleep(updateInterval);
|
||||
} 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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,16 +36,9 @@ public class ParticipatingTunnelsTracker extends Thread {
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
EnumMap<ROUTER_INFO, Object> em;
|
||||
while (true) {
|
||||
try {
|
||||
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) {
|
||||
}
|
||||
|
||||
|
||||
runOnce();
|
||||
try {
|
||||
Thread.sleep(updateInterval);
|
||||
} 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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ entering <tt>http://itoopie.i2p/files/I2PControl.xpi2p</tt> in the 'Plugin Insta
|
||||
<img src="images/itoopie-settings.png">
|
||||
</figure>
|
||||
|
||||
<p>Version 0.1</p>
|
||||
<p>Version 0.0.1</p>
|
||||
<tt>Added graphs.</tt>
|
||||
<tt>Added support for changing the port of I2PControl</tt>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user