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
* 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;
@ -88,6 +88,7 @@ public abstract class Visualizer2D extends VisPlugin {
private Observer moteHighligtObserver = null;
private Mote highlightedMote = null;
private Color highlightColor = Color.GRAY;
private Timer highlightTimer = null;
public interface MoteMenuAction {
public boolean isEnabled(Mote mote);
@ -190,13 +191,16 @@ public abstract class Visualizer2D extends VisPlugin {
if (!(obj instanceof Mote))
return;
if (highlightTimer != null && highlightTimer.isRunning())
highlightTimer.stop();
highlightTimer = new Timer(100, null);
highlightedMote = (Mote) obj;
final Timer timer = new Timer(100, null);
timer.addActionListener(new ActionListener() {
highlightTimer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Decrease delay
if (timer.getDelay() < 90) {
timer.stop();
if (highlightTimer.getDelay() < 90) {
highlightTimer.stop();
highlightedMote = null;
repaint();
return;
@ -207,11 +211,11 @@ public abstract class Visualizer2D extends VisPlugin {
highlightColor = Color.CYAN;
else
highlightColor = Color.GRAY;
timer.setDelay(timer.getDelay()-1);
highlightTimer.setDelay(highlightTimer.getDelay()-1);
repaint();
}
});
timer.start();
highlightTimer.start();
}
});