[cooja] apps/mrm: Adapted MRM visualizer skin to show adequate

information for multi-selections
This commit is contained in:
Enrico Joerns 2014-04-10 18:33:26 +02:00
parent e69b08f5fd
commit 8e648bcece

View File

@ -81,15 +81,14 @@ public class MRMVisualizerSkin implements VisualizerSkin {
public void paintBeforeMotes(Graphics g) { public void paintBeforeMotes(Graphics g) {
Set<Mote> selectedMotes = visualizer.getSelectedMotes(); Set<Mote> selectedMotes = visualizer.getSelectedMotes();
if (simulation == null || selectedMotes == null || selectedMotes.isEmpty()) { if (simulation == null || selectedMotes == null) {
return; return;
} }
final Mote selectedMote = visualizer.getSelectedMotes().iterator().next(); for (final Mote selectedMote : selectedMotes) {
if (selectedMote.getInterfaces().getRadio() == null) { if (selectedMote.getInterfaces().getRadio() == null) {
return; continue;
} }
final Position sPos = selectedMote.getInterfaces().getPosition(); final Position sPos = selectedMote.getInterfaces().getPosition();
/* Paint transmission and interference range for selected mote */ /* Paint transmission and interference range for selected mote */
@ -110,12 +109,12 @@ public class MRMVisualizerSkin implements VisualizerSkin {
String msg = "No edges"; String msg = "No edges";
int msgWidth = fm.stringWidth(msg); int msgWidth = fm.stringWidth(msg);
g.setColor(Color.BLACK); g.setColor(Color.BLACK);
g.drawString(msg, x - msgWidth/2, y + 2*Visualizer.MOTE_RADIUS + 3); g.drawString(msg, x - msgWidth / 2, y + 2 * Visualizer.MOTE_RADIUS + 3);
return; return;
} }
g.setColor(Color.BLACK); g.setColor(Color.BLACK);
int edges = 0; int edges = 0;
for (Mote d: dests) { for (Mote d : dests) {
if (d == selectedMote) { if (d == selectedMote) {
continue; continue;
} }
@ -153,6 +152,7 @@ public class MRMVisualizerSkin implements VisualizerSkin {
g.setColor(Color.BLACK); g.setColor(Color.BLACK);
g.drawString(msg, x - msgWidth/2, y + 2*Visualizer.MOTE_RADIUS + 3); g.drawString(msg, x - msgWidth/2, y + 2*Visualizer.MOTE_RADIUS + 3);
} }
}
public void paintAfterMotes(Graphics g) { public void paintAfterMotes(Graphics g) {
} }