mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-23 01:29:33 +00:00
made mote-to-mote relations optional, reordered how skins are painted to more easily decide which skin is
painted first
This commit is contained in:
parent
21a901ad26
commit
11d124882c
@ -550,7 +550,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
|
|||||||
try {
|
try {
|
||||||
VisualizerSkin newSkin = skinClass.newInstance();
|
VisualizerSkin newSkin = skinClass.newInstance();
|
||||||
newSkin.setActive(Visualizer.this.simulation, Visualizer.this);
|
newSkin.setActive(Visualizer.this.simulation, Visualizer.this);
|
||||||
currentSkins.add(newSkin);
|
currentSkins.add(0, newSkin);
|
||||||
} catch (InstantiationException e1) {
|
} catch (InstantiationException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
} catch (IllegalAccessException e1) {
|
} catch (IllegalAccessException e1) {
|
||||||
@ -700,7 +700,26 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
|
|||||||
menu.setVisible(true);
|
menu.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean showMoteToMoteRelations = true;
|
||||||
private void populateSkinMenu(MenuElement menu) {
|
private void populateSkinMenu(MenuElement menu) {
|
||||||
|
/* Mote-to-mote relations */
|
||||||
|
JCheckBoxMenuItem moteRelationsItem = new JCheckBoxMenuItem("Mote relations", showMoteToMoteRelations);
|
||||||
|
moteRelationsItem.addItemListener(new ItemListener() {
|
||||||
|
public void itemStateChanged(ItemEvent e) {
|
||||||
|
JCheckBoxMenuItem menuItem = ((JCheckBoxMenuItem)e.getItem());
|
||||||
|
showMoteToMoteRelations = menuItem.isSelected();
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (menu instanceof JMenu) {
|
||||||
|
((JMenu)menu).add(moteRelationsItem);
|
||||||
|
((JMenu)menu).add(new JSeparator());
|
||||||
|
}
|
||||||
|
if (menu instanceof JPopupMenu) {
|
||||||
|
((JPopupMenu)menu).add(moteRelationsItem);
|
||||||
|
((JPopupMenu)menu).add(new JSeparator());
|
||||||
|
}
|
||||||
|
|
||||||
for (Class<? extends VisualizerSkin> skinClass: visualizerSkins) {
|
for (Class<? extends VisualizerSkin> skinClass: visualizerSkins) {
|
||||||
/* Should skin be enabled in this simulation? */
|
/* Should skin be enabled in this simulation? */
|
||||||
if (!isSkinCompatible(skinClass)) {
|
if (!isSkinCompatible(skinClass)) {
|
||||||
@ -998,16 +1017,18 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
|
|||||||
Mote[] allMotes = simulation.getMotes();
|
Mote[] allMotes = simulation.getMotes();
|
||||||
|
|
||||||
/* Paint mote relations */
|
/* Paint mote relations */
|
||||||
MoteRelation[] relations = simulation.getGUI().getMoteRelations();
|
if (showMoteToMoteRelations) {
|
||||||
for (MoteRelation r: relations) {
|
MoteRelation[] relations = simulation.getGUI().getMoteRelations();
|
||||||
Position sourcePos = r.source.getInterfaces().getPosition();
|
for (MoteRelation r: relations) {
|
||||||
Position destPos = r.dest.getInterfaces().getPosition();
|
Position sourcePos = r.source.getInterfaces().getPosition();
|
||||||
|
Position destPos = r.dest.getInterfaces().getPosition();
|
||||||
|
|
||||||
Point sourcePoint = transformPositionToPixel(sourcePos);
|
Point sourcePoint = transformPositionToPixel(sourcePos);
|
||||||
Point destPoint = transformPositionToPixel(destPos);
|
Point destPoint = transformPositionToPixel(destPos);
|
||||||
|
|
||||||
g.setColor(r.color == null ? Color.black : r.color);
|
g.setColor(r.color == null ? Color.black : r.color);
|
||||||
drawArrow(g, sourcePoint.x, sourcePoint.y, destPoint.x, destPoint.y, MOTE_RADIUS + 1);
|
drawArrow(g, sourcePoint.x, sourcePoint.y, destPoint.x, destPoint.y, MOTE_RADIUS + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Mote mote: allMotes) {
|
for (Mote mote: allMotes) {
|
||||||
@ -1264,11 +1285,19 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
|
|||||||
ArrayList<Element> config = new ArrayList<Element>();
|
ArrayList<Element> config = new ArrayList<Element>();
|
||||||
Element element;
|
Element element;
|
||||||
|
|
||||||
|
/* Show mote-to-mote relations */
|
||||||
|
if (showMoteToMoteRelations) {
|
||||||
|
element = new Element("moterelations");
|
||||||
|
element.setText("" + true);
|
||||||
|
config.add(element);
|
||||||
|
}
|
||||||
|
|
||||||
/* Skins */
|
/* Skins */
|
||||||
for (VisualizerSkin skin: currentSkins) {
|
for (int i=currentSkins.size()-1; i >= 0; i--) {
|
||||||
element = new Element("skin");
|
VisualizerSkin skin = currentSkins.get(i);
|
||||||
element.setText(skin.getClass().getName());
|
element = new Element("skin");
|
||||||
config.add(element);
|
element.setText(skin.getClass().getName());
|
||||||
|
config.add(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Viewport */
|
/* Viewport */
|
||||||
@ -1298,6 +1327,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
|
|||||||
|
|
||||||
public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) {
|
public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) {
|
||||||
loadedConfig = true;
|
loadedConfig = true;
|
||||||
|
showMoteToMoteRelations = false;
|
||||||
|
|
||||||
for (Element element : configXML) {
|
for (Element element : configXML) {
|
||||||
if (element.getName().equals("skin")) {
|
if (element.getName().equals("skin")) {
|
||||||
@ -1319,6 +1349,8 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
|
|||||||
if (wanted != null) {
|
if (wanted != null) {
|
||||||
logger.warn("Could not load visualizer: " + element.getText());
|
logger.warn("Could not load visualizer: " + element.getText());
|
||||||
}
|
}
|
||||||
|
} else if (element.getName().equals("moterelations")) {
|
||||||
|
showMoteToMoteRelations = true;
|
||||||
} else if (element.getName().equals("viewport")) {
|
} else if (element.getName().equals("viewport")) {
|
||||||
try {
|
try {
|
||||||
String[] matrix = element.getText().split(" ");
|
String[] matrix = element.getText().split(" ");
|
||||||
|
Loading…
Reference in New Issue
Block a user