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
* Support i2pcontrol HTTP Java console webapp at port 7657
* Layout fixes and adjustments
* Fixes for long translated strings
* Fixes for i2pd
* Graph adjustments
* Localize time format on graphs
@ -11,6 +12,7 @@
* Rename Configuration tab to "I2P Control"
* Remove "Settings read from I2P router" message
* 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
* Remove debug output
* README updates

View File

@ -81,7 +81,7 @@ public class Main {
root.add(tabbedPane);
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.addChangeListener(new TabChangeListener(overviewTab));
@ -92,7 +92,8 @@ public class Main {
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.addChangeListener(new TabChangeListener(settingsTab));

View File

@ -5,6 +5,7 @@ import java.awt.EventQueue;
import java.util.EnumMap;
import info.monitorenter.gui.chart.Chart2D;
import info.monitorenter.gui.chart.ITrace2D;
import info.monitorenter.gui.chart.views.ChartPanel;
import javax.swing.BorderFactory;
@ -34,22 +35,24 @@ public class OverviewTab extends TabLogoPanel {
private static ConfigurationManager _conf = ConfigurationManager.getInstance();
private final static int DEFAULT_INFO_UPDATE_INTERVAL = 30*1000; // Milliseconds.
JLabel lblI2P;
JLabel lblVersion;
JLabel lblVersionSpecified;
MultiLineLabel lblStatus;
MultiLineLabel lblStatusSpecified;
MultiLineLabel lblUptime;
JLabel lblUptimeSpecified;
MultiLineLabel lblNetworkStatus;
MultiLineLabel lblNetworkStatusSpecified;
private final JLabel lblI2P;
private final JLabel lblVersion;
private final JLabel lblVersionSpecified;
private final MultiLineLabel lblStatus;
private final MultiLineLabel lblStatusSpecified;
private final MultiLineLabel lblUptime;
private final JLabel lblUptimeSpecified;
private final MultiLineLabel lblNetworkStatus;
private final MultiLineLabel lblNetworkStatusSpecified;
private final BandwidthChart bwChart;
private final ParticipatingTunnelsChart partTunnelChart;
public OverviewTab(String imageName) {
super(imageName);
super.setLayout(null);
final BandwidthChart bwChart = new BandwidthChart();
Chart2D partTunnelChart = new ParticipatingTunnelsChart();
bwChart = new BandwidthChart();
partTunnelChart = new ParticipatingTunnelsChart();
ChartPanel pt = new ChartPanel(partTunnelChart);
pt.setSize(300, 135);
pt.setLocation(5, 10);
@ -143,6 +146,18 @@ public class OverviewTab extends TabLogoPanel {
}).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(){
try {
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 ConfigurationManager _conf;
private final ConfigurationManager _conf;
private final OverviewTab _otab;
/**
* Create the application.
*/
public SettingsFrame(String imageName) {
public SettingsFrame(String imageName, OverviewTab otab) {
super(imageName);
setLayout(null);
_conf = ConfigurationManager.getInstance();
_otab = otab;
initialize();
}
@ -390,6 +392,8 @@ public class SettingsFrame extends TabLogoPanel {
_conf.setConf("server.port", port);
_conf.setConf("server.password", pwText);
JSONRPC2Interface.testSettings();
if (!oldIP.equals(ipText) || oldPort != port)
_otab.clearGraphs();
} catch (InvalidPasswordException e) {
_conf.setConf("server.password", oldPW);
JOptionPane.showConfirmDialog(