[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;
|
||||
|
||||
for (Element element : configXML) {
|
||||
if (element.getName().equals("skin")) {
|
||||
switch (element.getName()) {
|
||||
case "skin":
|
||||
String wanted = element.getText();
|
||||
/* Backwards compatibility: se.sics -> org.contikios */
|
||||
if (wanted.startsWith("se.sics")) {
|
||||
wanted = wanted.replaceFirst("se\\.sics", "org.contikios");
|
||||
}
|
||||
|
||||
for (Class<? extends VisualizerSkin> skinClass : visualizerSkins) {
|
||||
} for (Class<? extends VisualizerSkin> skinClass : visualizerSkins) {
|
||||
if (wanted.equals(skinClass.getName())
|
||||
/* Backwards compatibility */
|
||||
|| wanted.equals(Cooja.getDescriptionOf(skinClass))) {
|
||||
@ -1498,15 +1497,13 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
|
||||
wanted = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (wanted != null) {
|
||||
} if (wanted != null) {
|
||||
logger.warn("Could not load visualizer: " + element.getText());
|
||||
}
|
||||
}
|
||||
else if (element.getName().equals("moterelations")) {
|
||||
} break;
|
||||
case "moterelations":
|
||||
showMoteToMoteRelations = true;
|
||||
}
|
||||
else if (element.getName().equals("viewport")) {
|
||||
break;
|
||||
case "viewport":
|
||||
try {
|
||||
String[] matrix = element.getText().split(" ");
|
||||
viewportTransform.setTransform(
|
||||
@ -1522,11 +1519,11 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
|
||||
catch (NumberFormatException e) {
|
||||
logger.warn("Bad viewport: " + e.getMessage());
|
||||
resetViewport();
|
||||
}
|
||||
}
|
||||
else if (element.getName().equals("hidden")) {
|
||||
} break;
|
||||
case "hidden":
|
||||
BasicInternalFrameUI ui = (BasicInternalFrameUI) getUI();
|
||||
ui.getNorthPane().setPreferredSize(new Dimension(0, 0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user