From c15c38bb1a148effeb9764c56f24d15bbebb1349 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Wed, 30 May 2007 10:51:14 +0000 Subject: [PATCH] added mote highlight functionality --- tools/cooja/java/se/sics/cooja/GUI.java | 47 ++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/tools/cooja/java/se/sics/cooja/GUI.java b/tools/cooja/java/se/sics/cooja/GUI.java index 2ae4d0eac..7c29aa2da 100644 --- a/tools/cooja/java/se/sics/cooja/GUI.java +++ b/tools/cooja/java/se/sics/cooja/GUI.java @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: GUI.java,v 1.54 2007/05/28 09:37:01 fros4943 Exp $ + * $Id: GUI.java,v 1.55 2007/05/30 10:51:14 fros4943 Exp $ */ package se.sics.cooja; @@ -190,6 +190,15 @@ public class GUI { private Vector> positionerClasses = new Vector>(); + // Mote highlight observable + private class HighlightObservable extends Observable { + private void highlightMote(Mote mote) { + setChanged(); + notifyObservers(mote); + } + } + private HighlightObservable moteHighlightObservable = new HighlightObservable(); + /** * Creates a new COOJA Simulator GUI. * @@ -238,6 +247,29 @@ public class GUI { } } + + /** + * Add mote highlight observer. + * + * @see #deleteTickObserver(Observer) + * @param newObserver + * New observer + */ + public void addMoteHighligtObserver(Observer newObserver) { + moteHighlightObservable.addObserver(newObserver); + } + + /** + * Delete an mote highlight observer. + * + * @see #addTickObserver(Observer) + * @param observer + * Observer to delete + */ + public void deleteMoteHighligtObserver(Observer observer) { + moteHighlightObservable.deleteObserver(observer); + } + /** * @return True if simulator is visualized */ @@ -3256,4 +3288,17 @@ public class GUI { return false; } + /** + * This method can be used by various different modules in the simulator to + * indicate for example that a mote has been selected. All mote highlight + * listeners will be notified. An example application of mote highlightinh is + * a simulator visualizer that highlights the mote. + * + * @see #addMoteHighligtObserver(Observer) + * @param m + * Mote to highlight + */ + public void signalMoteHighlight(Mote m) { + moteHighlightObservable.highlightMote(m); + } }