[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()) {
|
||||||
String wanted = element.getText();
|
case "skin":
|
||||||
/* Backwards compatibility: se.sics -> org.contikios */
|
String wanted = element.getText();
|
||||||
if (wanted.startsWith("se.sics")) {
|
/* Backwards compatibility: se.sics -> org.contikios */
|
||||||
wanted = wanted.replaceFirst("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())
|
if (wanted.equals(skinClass.getName())
|
||||||
/* Backwards compatibility */
|
/* Backwards compatibility */
|
||||||
|| wanted.equals(Cooja.getDescriptionOf(skinClass))) {
|
|| wanted.equals(Cooja.getDescriptionOf(skinClass))) {
|
||||||
|
@ -1498,35 +1497,33 @@ 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;
|
||||||
}
|
case "viewport":
|
||||||
else if (element.getName().equals("viewport")) {
|
try {
|
||||||
try {
|
String[] matrix = element.getText().split(" ");
|
||||||
String[] matrix = element.getText().split(" ");
|
viewportTransform.setTransform(
|
||||||
viewportTransform.setTransform(
|
Double.parseDouble(matrix[0]),
|
||||||
Double.parseDouble(matrix[0]),
|
|
||||||
Double.parseDouble(matrix[1]),
|
Double.parseDouble(matrix[1]),
|
||||||
Double.parseDouble(matrix[2]),
|
Double.parseDouble(matrix[2]),
|
||||||
Double.parseDouble(matrix[3]),
|
Double.parseDouble(matrix[3]),
|
||||||
Double.parseDouble(matrix[4]),
|
Double.parseDouble(matrix[4]),
|
||||||
Double.parseDouble(matrix[5])
|
Double.parseDouble(matrix[5])
|
||||||
);
|
);
|
||||||
resetViewport = 0;
|
resetViewport = 0;
|
||||||
}
|
}
|
||||||
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