minor update in highlighted motes

This commit is contained in:
fros4943 2007-05-30 20:57:58 +00:00
parent 490bc06de2
commit fc056f97f9

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: Visualizer2D.java,v 1.10 2007/05/30 10:54:22 fros4943 Exp $ * $Id: Visualizer2D.java,v 1.11 2007/05/30 20:57:58 fros4943 Exp $
*/ */
package se.sics.cooja.plugins; package se.sics.cooja.plugins;
@ -88,6 +88,7 @@ public abstract class Visualizer2D extends VisPlugin {
private Observer moteHighligtObserver = null; private Observer moteHighligtObserver = null;
private Mote highlightedMote = null; private Mote highlightedMote = null;
private Color highlightColor = Color.GRAY; private Color highlightColor = Color.GRAY;
private Timer highlightTimer = null;
public interface MoteMenuAction { public interface MoteMenuAction {
public boolean isEnabled(Mote mote); public boolean isEnabled(Mote mote);
@ -189,14 +190,17 @@ public abstract class Visualizer2D extends VisPlugin {
public void update(Observable obs, Object obj) { public void update(Observable obs, Object obj) {
if (!(obj instanceof Mote)) if (!(obj instanceof Mote))
return; return;
if (highlightTimer != null && highlightTimer.isRunning())
highlightTimer.stop();
highlightTimer = new Timer(100, null);
highlightedMote = (Mote) obj; highlightedMote = (Mote) obj;
final Timer timer = new Timer(100, null); highlightTimer.addActionListener(new ActionListener() {
timer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// Decrease delay // Decrease delay
if (timer.getDelay() < 90) { if (highlightTimer.getDelay() < 90) {
timer.stop(); highlightTimer.stop();
highlightedMote = null; highlightedMote = null;
repaint(); repaint();
return; return;
@ -207,11 +211,11 @@ public abstract class Visualizer2D extends VisPlugin {
highlightColor = Color.CYAN; highlightColor = Color.CYAN;
else else
highlightColor = Color.GRAY; highlightColor = Color.GRAY;
timer.setDelay(timer.getDelay()-1); highlightTimer.setDelay(highlightTimer.getDelay()-1);
repaint(); repaint();
} }
}); });
timer.start(); highlightTimer.start();
} }
}); });