mirror of
https://github.com/oliverschmidt/contiki.git
synced 2025-01-08 12:30:40 +00:00
highlight several motes at the same time
This commit is contained in:
parent
d7dda45a96
commit
1cc78b180f
@ -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: Visualizer.java,v 1.1 2009/03/24 15:46:18 fros4943 Exp $
|
* $Id: Visualizer.java,v 1.2 2009/03/26 15:41:04 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.plugins;
|
package se.sics.cooja.plugins;
|
||||||
@ -119,10 +119,9 @@ public class Visualizer extends VisPlugin {
|
|||||||
private Observer simObserver = null;
|
private Observer simObserver = null;
|
||||||
private Observer posObserver = null;
|
private Observer posObserver = null;
|
||||||
private Observer moteHighligtObserver = null;
|
private Observer moteHighligtObserver = null;
|
||||||
|
private Vector<Mote> highlightedMotes = new Vector<Mote>();
|
||||||
|
private final static Color HIGHLIGHT_COLOR = Color.CYAN;
|
||||||
private Observer moteRelationsObserver = null;
|
private Observer moteRelationsObserver = null;
|
||||||
private Mote highlightedMote = null;
|
|
||||||
private Color highlightColor = Color.GRAY;
|
|
||||||
private Timer highlightTimer = null;
|
|
||||||
|
|
||||||
/* Popup menu */
|
/* Popup menu */
|
||||||
public static interface SimulationMenuAction {
|
public static interface SimulationMenuAction {
|
||||||
@ -203,33 +202,29 @@ public class Visualizer extends VisPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (highlightTimer != null && highlightTimer.isRunning()) {
|
final Timer timer = new Timer(100, null);
|
||||||
highlightTimer.stop();
|
final Mote mote = (Mote) obj;
|
||||||
}
|
timer.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
highlightTimer = new Timer(100, null);
|
|
||||||
highlightedMote = (Mote) obj;
|
|
||||||
highlightTimer.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
/* Count down */
|
/* Count down */
|
||||||
if (highlightTimer.getDelay() < 90) {
|
if (timer.getDelay() < 90) {
|
||||||
highlightTimer.stop();
|
timer.stop();
|
||||||
highlightedMote = null;
|
highlightedMotes.remove(mote);
|
||||||
repaint();
|
repaint();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Toggle colors */
|
/* Toggle highlight state */
|
||||||
if (highlightColor == Color.GRAY) {
|
if (highlightedMotes.contains(mote)) {
|
||||||
highlightColor = Color.CYAN;
|
highlightedMotes.remove(mote);
|
||||||
} else {
|
} else {
|
||||||
highlightColor = Color.GRAY;
|
highlightedMotes.add(mote);
|
||||||
}
|
}
|
||||||
highlightTimer.setDelay(highlightTimer.getDelay()-1);
|
timer.setDelay(timer.getDelay()-1);
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
highlightTimer.start();
|
timer.start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -689,8 +684,8 @@ public class Visualizer extends VisPlugin {
|
|||||||
int x = pixelCoord.x;
|
int x = pixelCoord.x;
|
||||||
int y = pixelCoord.y;
|
int y = pixelCoord.y;
|
||||||
|
|
||||||
if (mote == highlightedMote) {
|
if (!highlightedMotes.isEmpty() && highlightedMotes.contains(mote)) {
|
||||||
g.setColor(highlightColor);
|
g.setColor(HIGHLIGHT_COLOR);
|
||||||
g.fillOval(x - MOTE_RADIUS, y - MOTE_RADIUS, 2 * MOTE_RADIUS,
|
g.fillOval(x - MOTE_RADIUS, y - MOTE_RADIUS, 2 * MOTE_RADIUS,
|
||||||
2 * MOTE_RADIUS);
|
2 * MOTE_RADIUS);
|
||||||
} else if (mote == moteToMove) {
|
} else if (mote == moteToMove) {
|
||||||
|
Loading…
Reference in New Issue
Block a user