From 9866684f5ec9b37edf6650da49dcf7d5e5ebc4e6 Mon Sep 17 00:00:00 2001 From: amaehrle <amaehrle@mail.uni-paderborn.de> Date: Fri, 21 Apr 2017 16:31:58 +0200 Subject: [PATCH] Add debugging tweaks for mobility models Javadoc and comments might follow later --- src/gui/DTNSimGUI.java | 4 ++++ src/gui/EventLogPanel.java | 2 ++ src/gui/MainWindow.java | 1 + src/gui/NodeChooser.java | 1 + src/gui/SimMenuBar.java | 2 +- src/gui/playfield/PlayField.java | 10 +++++++--- 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/gui/DTNSimGUI.java b/src/gui/DTNSimGUI.java index 61a418d0..59cb0395 100644 --- a/src/gui/DTNSimGUI.java +++ b/src/gui/DTNSimGUI.java @@ -257,6 +257,10 @@ public class DTNSimGUI extends DTNSimUI { infoPanel.showInfo(host); } + public void highlightHost(DTNHost host) { + field.highlightHost(host); + } + /** * Shows a path on the playfield * @param path The path to show diff --git a/src/gui/EventLogPanel.java b/src/gui/EventLogPanel.java index c851d949..d1b75ee7 100644 --- a/src/gui/EventLogPanel.java +++ b/src/gui/EventLogPanel.java @@ -252,6 +252,7 @@ public class EventLogPanel extends JPanel gui.setPaused(true); if (host1 != null) { gui.setFocus(host1); + gui.highlightHost(host1); } } @@ -316,6 +317,7 @@ public class EventLogPanel extends JPanel if (source.getClientProperty(HOST_PROP) != null) { // button was a host button -> focus it on GUI gui.setFocus((DTNHost)source.getClientProperty(HOST_PROP)); + gui.highlightHost((DTNHost)source.getClientProperty(HOST_PROP)); } else if (source.getClientProperty(MSG_PROP) != null) { // was a message button -> show information about the message diff --git a/src/gui/MainWindow.java b/src/gui/MainWindow.java index d03cd9f5..30cf2ef1 100644 --- a/src/gui/MainWindow.java +++ b/src/gui/MainWindow.java @@ -73,6 +73,7 @@ public class MainWindow extends JFrame { hostListScroll = new JScrollPane(chooser); hostListScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + hostListScroll.getVerticalScrollBar().setUnitIncrement(20); logControlSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(elp.getControls()),new JScrollPane(elp)); diff --git a/src/gui/NodeChooser.java b/src/gui/NodeChooser.java index 2af26327..d76e7e76 100644 --- a/src/gui/NodeChooser.java +++ b/src/gui/NodeChooser.java @@ -200,6 +200,7 @@ public class NodeChooser extends JPanel implements ActionListener { JButton source = (JButton)e.getSource(); DTNHost host = (DTNHost)source.getClientProperty(HOST_KEY); gui.setFocus(host); + gui.highlightHost(host); } else if (e.getSource() == this.groupChooser) { setNodes(groupChooser.getSelectedIndex() * MAX_NODE_COUNT); diff --git a/src/gui/SimMenuBar.java b/src/gui/SimMenuBar.java index a4e89911..396db893 100644 --- a/src/gui/SimMenuBar.java +++ b/src/gui/SimMenuBar.java @@ -121,7 +121,7 @@ public class SimMenuBar extends JMenuBar implements ActionListener { showBuffer = createCheckItem(pfMenu, "Show message buffer", true, SHOW_BUFFER_S); focusOnClick = createCheckItem(pfMenu, - "Focus to closest node on mouse click", false,FOCUS_ON_CLICK_S); + "Focus to closest node on mouse click", true,FOCUS_ON_CLICK_S); enableMapGraphic = createCheckItem(pfMenu,"Show map graphic", true, null); diff --git a/src/gui/playfield/PlayField.java b/src/gui/playfield/PlayField.java index 743c2a13..85889581 100644 --- a/src/gui/playfield/PlayField.java +++ b/src/gui/playfield/PlayField.java @@ -341,12 +341,16 @@ public class PlayField extends JPanel implements VhmListener { closestDist = dist; } } - highlightedHosts.clear(); - highlightedHosts.add(closest); - NodeGraphic.setHighlightedNodes(highlightedHosts); gui.setFocus(closest); + highlightHost(closest); + } + + public void highlightHost(DTNHost host) { + highlightedHosts.clear(); + highlightedHosts.add(host); + NodeGraphic.setHighlightedNodes(highlightedHosts); this.updateField(); } -- GitLab