Clear graphs when changing router hostname/port

finals
This commit is contained in:
zzz
2022-01-09 07:33:50 -05:00
parent 211583154e
commit b554c5b647
4 changed files with 37 additions and 15 deletions

View File

@ -3,6 +3,7 @@
* Build fixes * Build fixes
* Support i2pcontrol HTTP Java console webapp at port 7657 * Support i2pcontrol HTTP Java console webapp at port 7657
* Layout fixes and adjustments * Layout fixes and adjustments
* Fixes for long translated strings
* Fixes for i2pd * Fixes for i2pd
* Graph adjustments * Graph adjustments
* Localize time format on graphs * Localize time format on graphs
@ -11,6 +12,7 @@
* Rename Configuration tab to "I2P Control" * Rename Configuration tab to "I2P Control"
* Remove "Settings read from I2P router" message * Remove "Settings read from I2P router" message
* Set graph values to 0 when router is gone * Set graph values to 0 when router is gone
* Clear graph after changing router host/port
* Update to jchart2d 3.2.2 2011-09-25 * Update to jchart2d 3.2.2 2011-09-25
* Remove debug output * Remove debug output
* README updates * README updates

View File

@ -81,7 +81,7 @@ public class Main {
root.add(tabbedPane); root.add(tabbedPane);
tabbedPane.setBounds(0, 0, FRAME_WIDTH-9, TABBED_PANE_HEIGHT); tabbedPane.setBounds(0, 0, FRAME_WIDTH-9, TABBED_PANE_HEIGHT);
TabLogoPanel overviewTab = new OverviewTab("itoopie-opaque12"); OverviewTab overviewTab = new OverviewTab("itoopie-opaque12");
tabbedPane.addTab(' ' + Transl._t("Overview") + ' ', null, overviewTab, null); tabbedPane.addTab(' ' + Transl._t("Overview") + ' ', null, overviewTab, null);
tabbedPane.addChangeListener(new TabChangeListener(overviewTab)); tabbedPane.addChangeListener(new TabChangeListener(overviewTab));
@ -92,7 +92,8 @@ public class Main {
tabbedPane.addChangeListener(new TabChangeListener(configTab)); tabbedPane.addChangeListener(new TabChangeListener(configTab));
TabLogoPanel settingsTab = new SettingsFrame("itoopie-opaque12"); // pass overview tab to settingsframe to reset the charts on change
TabLogoPanel settingsTab = new SettingsFrame("itoopie-opaque12", overviewTab);
tabbedPane.addTab(' ' + Transl._t("Settings") + ' ', icon, settingsTab, null); tabbedPane.addTab(' ' + Transl._t("Settings") + ' ', icon, settingsTab, null);
tabbedPane.addChangeListener(new TabChangeListener(settingsTab)); tabbedPane.addChangeListener(new TabChangeListener(settingsTab));

View File

@ -5,6 +5,7 @@ import java.awt.EventQueue;
import java.util.EnumMap; import java.util.EnumMap;
import info.monitorenter.gui.chart.Chart2D; import info.monitorenter.gui.chart.Chart2D;
import info.monitorenter.gui.chart.ITrace2D;
import info.monitorenter.gui.chart.views.ChartPanel; import info.monitorenter.gui.chart.views.ChartPanel;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -34,22 +35,24 @@ public class OverviewTab extends TabLogoPanel {
private static ConfigurationManager _conf = ConfigurationManager.getInstance(); private static ConfigurationManager _conf = ConfigurationManager.getInstance();
private final static int DEFAULT_INFO_UPDATE_INTERVAL = 30*1000; // Milliseconds. private final static int DEFAULT_INFO_UPDATE_INTERVAL = 30*1000; // Milliseconds.
JLabel lblI2P; private final JLabel lblI2P;
JLabel lblVersion; private final JLabel lblVersion;
JLabel lblVersionSpecified; private final JLabel lblVersionSpecified;
MultiLineLabel lblStatus; private final MultiLineLabel lblStatus;
MultiLineLabel lblStatusSpecified; private final MultiLineLabel lblStatusSpecified;
MultiLineLabel lblUptime; private final MultiLineLabel lblUptime;
JLabel lblUptimeSpecified; private final JLabel lblUptimeSpecified;
MultiLineLabel lblNetworkStatus; private final MultiLineLabel lblNetworkStatus;
MultiLineLabel lblNetworkStatusSpecified; private final MultiLineLabel lblNetworkStatusSpecified;
private final BandwidthChart bwChart;
private final ParticipatingTunnelsChart partTunnelChart;
public OverviewTab(String imageName) { public OverviewTab(String imageName) {
super(imageName); super(imageName);
super.setLayout(null); super.setLayout(null);
final BandwidthChart bwChart = new BandwidthChart(); bwChart = new BandwidthChart();
Chart2D partTunnelChart = new ParticipatingTunnelsChart(); partTunnelChart = new ParticipatingTunnelsChart();
ChartPanel pt = new ChartPanel(partTunnelChart); ChartPanel pt = new ChartPanel(partTunnelChart);
pt.setSize(300, 135); pt.setSize(300, 135);
pt.setLocation(5, 10); pt.setLocation(5, 10);
@ -143,6 +146,18 @@ public class OverviewTab extends TabLogoPanel {
}).start(); }).start();
} }
/**
* @since 0.0.4
*/
public void clearGraphs() {
for (ITrace2D trace : bwChart.getTraces()) {
trace.removeAllPoints();
}
for (ITrace2D trace : partTunnelChart.getTraces()) {
trace.removeAllPoints();
}
}
private void populateInfo(){ private void populateInfo(){
try { try {
EnumMap<ROUTER_INFO, Object> em = GetRouterInfo.execute(ROUTER_INFO.VERSION, EnumMap<ROUTER_INFO, Object> em = GetRouterInfo.execute(ROUTER_INFO.VERSION,

View File

@ -88,15 +88,17 @@ public class SettingsFrame extends TabLogoPanel {
private JPasswordField txtRetypeNewPassword; private JPasswordField txtRetypeNewPassword;
*/ */
private ConfigurationManager _conf; private final ConfigurationManager _conf;
private final OverviewTab _otab;
/** /**
* Create the application. * Create the application.
*/ */
public SettingsFrame(String imageName) { public SettingsFrame(String imageName, OverviewTab otab) {
super(imageName); super(imageName);
setLayout(null); setLayout(null);
_conf = ConfigurationManager.getInstance(); _conf = ConfigurationManager.getInstance();
_otab = otab;
initialize(); initialize();
} }
@ -390,6 +392,8 @@ public class SettingsFrame extends TabLogoPanel {
_conf.setConf("server.port", port); _conf.setConf("server.port", port);
_conf.setConf("server.password", pwText); _conf.setConf("server.password", pwText);
JSONRPC2Interface.testSettings(); JSONRPC2Interface.testSettings();
if (!oldIP.equals(ipText) || oldPort != port)
_otab.clearGraphs();
} catch (InvalidPasswordException e) { } catch (InvalidPasswordException e) {
_conf.setConf("server.password", oldPW); _conf.setConf("server.password", oldPW);
JOptionPane.showConfirmDialog( JOptionPane.showConfirmDialog(