[cooja] plugins/Visualizer: Replaced multiple if-string with switch over
strings
This commit is contained in:
parent
cef3c4079d
commit
ad0e192d84
|
@ -1477,14 +1477,13 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
|
||||||
showMoteToMoteRelations = false;
|
showMoteToMoteRelations = false;
|
||||||
|
|
||||||
for (Element element : configXML) {
|
for (Element element : configXML) {
|
||||||
if (element.getName().equals("skin")) {
|
switch (element.getName()) {
|
||||||
|
case "skin":
|
||||||
String wanted = element.getText();
|
String wanted = element.getText();
|
||||||
/* Backwards compatibility: se.sics -> org.contikios */
|
/* Backwards compatibility: se.sics -> org.contikios */
|
||||||
if (wanted.startsWith("se.sics")) {
|
if (wanted.startsWith("se.sics")) {
|
||||||
wanted = wanted.replaceFirst("se\\.sics", "org.contikios");
|
wanted = wanted.replaceFirst("se\\.sics", "org.contikios");
|
||||||
}
|
} for (Class<? extends VisualizerSkin> skinClass : visualizerSkins) {
|
||||||
|
|
||||||
for (Class<? extends VisualizerSkin> skinClass : visualizerSkins) {
|
|
||||||
if (wanted.equals(skinClass.getName())
|
if (wanted.equals(skinClass.getName())
|
||||||
/* Backwards compatibility */
|
/* Backwards compatibility */
|
||||||
|| wanted.equals(Cooja.getDescriptionOf(skinClass))) {
|
|| wanted.equals(Cooja.getDescriptionOf(skinClass))) {
|
||||||
|
@ -1498,15 +1497,13 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
|
||||||
wanted = null;
|
wanted = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} if (wanted != null) {
|
||||||
if (wanted != null) {
|
|
||||||
logger.warn("Could not load visualizer: " + element.getText());
|
logger.warn("Could not load visualizer: " + element.getText());
|
||||||
}
|
} break;
|
||||||
}
|
case "moterelations":
|
||||||
else if (element.getName().equals("moterelations")) {
|
|
||||||
showMoteToMoteRelations = true;
|
showMoteToMoteRelations = true;
|
||||||
}
|
break;
|
||||||
else if (element.getName().equals("viewport")) {
|
case "viewport":
|
||||||
try {
|
try {
|
||||||
String[] matrix = element.getText().split(" ");
|
String[] matrix = element.getText().split(" ");
|
||||||
viewportTransform.setTransform(
|
viewportTransform.setTransform(
|
||||||
|
@ -1522,11 +1519,11 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
|
||||||
catch (NumberFormatException e) {
|
catch (NumberFormatException e) {
|
||||||
logger.warn("Bad viewport: " + e.getMessage());
|
logger.warn("Bad viewport: " + e.getMessage());
|
||||||
resetViewport();
|
resetViewport();
|
||||||
}
|
} break;
|
||||||
}
|
case "hidden":
|
||||||
else if (element.getName().equals("hidden")) {
|
|
||||||
BasicInternalFrameUI ui = (BasicInternalFrameUI) getUI();
|
BasicInternalFrameUI ui = (BasicInternalFrameUI) getUI();
|
||||||
ui.getNorthPane().setPreferredSize(new Dimension(0, 0));
|
ui.getNorthPane().setPreferredSize(new Dimension(0, 0));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue