[cooja] Reformatted Visualizer and skins code

This commit is contained in:
Enrico Joerns 2014-04-10 19:03:43 +02:00
parent ea979fa027
commit cef3c4079d
4 changed files with 399 additions and 321 deletions

View file

@ -26,7 +26,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
package org.contikios.mrm;
import java.awt.Color;
@ -51,6 +50,7 @@ import org.contikios.mrm.ChannelModel.TxPair;
@ClassDescription("Radio environment (MRM)")
@SupportedArguments(radioMediums = {MRM.class})
public class MRMVisualizerSkin implements VisualizerSkin {
private static final Logger logger = Logger.getLogger(MRMVisualizerSkin.class);
private Simulation simulation = null;
@ -128,6 +128,7 @@ public class MRMVisualizerSkin implements VisualizerSkin {
public Radio getFromRadio() {
return selectedMote.getInterfaces().getRadio();
}
@Override
public Radio getToRadio() {
return dRadio;

View file

@ -27,7 +27,6 @@
* SUCH DAMAGE.
*
*/
package org.contikios.cooja.plugins;
import java.awt.BasicStroke;
@ -139,6 +138,7 @@ import org.contikios.cooja.plugins.skins.UDGMVisualizerSkin;
@ClassDescription("Network")
@PluginType(PluginType.SIM_STANDARD_PLUGIN)
public class Visualizer extends VisPlugin implements HasQuickHelp {
private static final long serialVersionUID = 1L;
private static final Logger logger = Logger.getLogger(Visualizer.class);
@ -186,8 +186,9 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
private Selection selection;
/* Visualizers */
private static final ArrayList<Class<? extends VisualizerSkin>> visualizerSkins =
new ArrayList<>();
private static final ArrayList<Class<? extends VisualizerSkin>> visualizerSkins
= new ArrayList<>();
static {
/* Register default visualizer skins */
registerVisualizerSkin(IDVisualizerSkin.class);
@ -213,20 +214,27 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
/* Popup menu */
public static interface SimulationMenuAction {
public boolean isEnabled(Visualizer visualizer, Simulation simulation);
public String getDescription(Visualizer visualizer, Simulation simulation);
public void doAction(Visualizer visualizer, Simulation simulation);
}
public static interface MoteMenuAction {
public boolean isEnabled(Visualizer visualizer, Mote mote);
public String getDescription(Visualizer visualizer, Mote mote);
public void doAction(Visualizer visualizer, Mote mote);
}
private ArrayList<Class<? extends SimulationMenuAction>> simulationMenuActions =
new ArrayList<>();
private ArrayList<Class<? extends MoteMenuAction>> moteMenuActions =
new ArrayList<>();
private ArrayList<Class<? extends SimulationMenuAction>> simulationMenuActions
= new ArrayList<>();
private ArrayList<Class<? extends MoteMenuAction>> moteMenuActions
= new ArrayList<>();
public Visualizer(Simulation simulation, Cooja gui) {
super("Network", gui);
@ -254,9 +262,11 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
viewMenu.removeAll();
populateSkinMenu(viewMenu);
}
@Override
public void menuDeselected(MenuEvent e) {
}
@Override
public void menuCanceled(MenuEvent e) {
}
@ -308,6 +318,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
/* Main canvas */
canvas = new JPanel() {
private static final long serialVersionUID = 1L;
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
@ -355,6 +366,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
});
}
}
@Override
public void moteWasRemoved(Mote mote) {
Position pos = mote.getInterfaces().getPosition();
@ -395,7 +407,8 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
/* Toggle highlight state */
if (highlightedMotes.contains(mote)) {
highlightedMotes.remove(mote);
} else {
}
else {
highlightedMotes.add(mote);
}
timer.setDelay(timer.getDelay() - 1);
@ -433,6 +446,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
handleMousePress(e);
}
}
@Override
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
@ -454,7 +468,8 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
if (rot > 0) {
zoomToFactor(zoomFactor() / 1.2, new Point(x, y));
} else {
}
else {
zoomToFactor(zoomFactor() * 1.2, new Point(x, y));
}
@ -478,29 +493,36 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
public void dragEnter(DropTargetDragEvent dtde) {
if (acceptOrRejectDrag(dtde)) {
dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
} else {
}
else {
dtde.rejectDrag();
}
}
@Override
public void dragExit(DropTargetEvent dte) {
}
@Override
public void dropActionChanged(DropTargetDragEvent dtde) {
if (acceptOrRejectDrag(dtde)) {
dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
} else {
}
else {
dtde.rejectDrag();
}
}
@Override
public void dragOver(DropTargetDragEvent dtde) {
if (acceptOrRejectDrag(dtde)) {
dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
} else {
}
else {
dtde.rejectDrag();
}
}
@Override
public void drop(DropTargetDropEvent dtde) {
Transferable transferable = dtde.getTransferable();
@ -537,6 +559,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
handleDropFile(file, dtde.getLocation());
}
private boolean acceptOrRejectDrag(DropTargetDragEvent dtde) {
Transferable transferable = dtde.getTransferable();
@ -564,7 +587,8 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
return false;
}
file = list.get(0);
} catch (UnsupportedFlavorException | IOException e) {
}
catch (UnsupportedFlavorException | IOException e) {
return false;
}
@ -601,7 +625,8 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
VisualizerSkin newSkin = skinClass.newInstance();
newSkin.setActive(Visualizer.this.simulation, Visualizer.this);
currentSkins.add(0, newSkin);
} catch (InstantiationException | IllegalAccessException e1) {
}
catch (InstantiationException | IllegalAccessException e1) {
e1.printStackTrace();
}
repaint();
@ -620,8 +645,8 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
if (skin.isEmpty()) {
continue;
}
Class<? extends VisualizerSkin> skinClass =
simulation.getCooja().tryLoadClass(this, VisualizerSkin.class, skin);
Class<? extends VisualizerSkin> skinClass
= simulation.getCooja().tryLoadClass(this, VisualizerSkin.class, skin);
generateAndActivateSkin(skinClass);
}
}
@ -703,7 +728,8 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
});
menu.add(menuItem);
}
} catch (InstantiationException | IllegalAccessException e1) {
}
catch (InstantiationException | IllegalAccessException e1) {
logger.fatal("Error: " + e1.getMessage(), e1);
}
}
@ -725,7 +751,8 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
});
menu.add(menuItem);
}
} catch (InstantiationException | IllegalAccessException e1) {
}
catch (InstantiationException | IllegalAccessException e1) {
logger.fatal("Error: " + e1.getMessage(), e1);
}
}
@ -748,6 +775,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
}
private boolean showMoteToMoteRelations = true;
private void populateSkinMenu(MenuElement menu) {
/* Mote-to-mote relations */
JCheckBoxMenuItem moteRelationsItem = new JCheckBoxMenuItem("Mote relations", showMoteToMoteRelations);
@ -795,8 +823,8 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
return;
}
Class<VisualizerSkin> skinClass =
(Class<VisualizerSkin>) menuItem.getClientProperty("skinclass");
Class<VisualizerSkin> skinClass
= (Class<VisualizerSkin>) menuItem.getClientProperty("skinclass");
if (skinClass == null) {
logger.fatal("Unknown visualizer skin class: " + skinClass);
return;
@ -805,7 +833,8 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
if (menuItem.isSelected()) {
/* Create and activate new skin */
generateAndActivateSkin(skinClass);
} else {
}
else {
/* Deactivate skin */
VisualizerSkin skinToDeactivate = null;
for (VisualizerSkin skin : currentSkins) {
@ -1014,7 +1043,8 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
private void beginMoveRequest(Mote motesToMove, boolean withTiming, boolean confirm) {
if (withTiming) {
moveStartTime = System.currentTimeMillis();
} else {
}
else {
moveStartTime = -1;
}
mouseActionState = MotesActionState.DEFAULT_PRESS;
@ -1157,11 +1187,13 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
g.setColor(MOVE_COLOR);
g.fillOval(x - MOTE_RADIUS, y - MOTE_RADIUS, 2 * MOTE_RADIUS,
2 * MOTE_RADIUS);
} else if (!highlightedMotes.isEmpty() && highlightedMotes.contains(mote)) {
}
else if (!highlightedMotes.isEmpty() && highlightedMotes.contains(mote)) {
g.setColor(HIGHLIGHT_COLOR);
g.fillOval(x - MOTE_RADIUS, y - MOTE_RADIUS, 2 * MOTE_RADIUS,
2 * MOTE_RADIUS);
} else if (moteColors.length >= 2) {
}
else if (moteColors.length >= 2) {
g.setColor(moteColors[0]);
g.fillOval(x - MOTE_RADIUS, y - MOTE_RADIUS, 2 * MOTE_RADIUS,
2 * MOTE_RADIUS);
@ -1170,7 +1202,8 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
g.fillOval(x - MOTE_RADIUS / 2, y - MOTE_RADIUS / 2, MOTE_RADIUS,
MOTE_RADIUS);
} else if (moteColors.length >= 1) {
}
else if (moteColors.length >= 1) {
g.setColor(moteColors[0]);
g.fillOval(x - MOTE_RADIUS, y - MOTE_RADIUS, 2 * MOTE_RADIUS,
2 * MOTE_RADIUS);
@ -1183,6 +1216,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
}
private Polygon arrowPoly = new Polygon();
private void drawArrow(Graphics g, int xSource, int ySource, int xDest, int yDest, int delta) {
double dx = xSource - xDest;
double dy = ySource - yDest;
@ -1245,12 +1279,14 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
/* Scale viewport */
if (smallX == bigX) {
scaleX = 1;
} else {
}
else {
scaleX = (bigX - smallX) / (canvas.getWidth());
}
if (smallY == bigY) {
scaleY = 1;
} else {
}
else {
scaleY = (bigY - smallY) / (canvas.getHeight());
}
@ -1266,8 +1302,8 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
Position viewMid =
transformPixelToPosition(canvas.getWidth()/2, canvas.getHeight()/2);
Position viewMid
= transformPixelToPosition(canvas.getWidth() / 2, canvas.getHeight() / 2);
double motesMidX = (smallXfinal + bigXfinal) / 2.0;
double motesMidY = (smallYfinal + bigYfinal) / 2.0;
@ -1325,6 +1361,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
public Position transformPixelToPosition(Point pixelPos) {
return transformPixelToPosition(pixelPos.x, pixelPos.y);
}
public Position transformPixelToPosition(int x, int y) {
Position position = new Position(null);
position.setCoordinates(
@ -1338,12 +1375,15 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
private int transformToPixelX(double x) {
return (int) (viewportTransform.getScaleX() * x + viewportTransform.getTranslateX());
}
private int transformToPixelY(double y) {
return (int) (viewportTransform.getScaleY() * y + viewportTransform.getTranslateY());
}
private double transformToPositionX(int x) {
return (x - viewportTransform.getTranslateX()) / viewportTransform.getScaleX();
}
private double transformToPositionY(int y) {
return (y - viewportTransform.getTranslateY()) / viewportTransform.getScaleY();
}
@ -1372,6 +1412,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
protected boolean isDropFileAccepted(File file) {
return true; /* TODO */
}
protected void handleDropFile(File file, Point point) {
@ -1410,19 +1451,19 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
double[] matrix = new double[6];
viewportTransform.getMatrix(matrix);
element.setText(
matrix[0] + " " +
matrix[1] + " " +
matrix[2] + " " +
matrix[3] + " " +
matrix[4] + " " +
matrix[5]
matrix[0] + " "
+ matrix[1] + " "
+ matrix[2] + " "
+ matrix[3] + " "
+ matrix[4] + " "
+ matrix[5]
);
config.add(element);
/* Hide decorations */
BasicInternalFrameUI ui = (BasicInternalFrameUI) getUI();
if (ui.getNorthPane().getPreferredSize() == null ||
ui.getNorthPane().getPreferredSize().height == 0) {
if (ui.getNorthPane().getPreferredSize() == null
|| ui.getNorthPane().getPreferredSize().height == 0) {
element = new Element("hidden");
config.add(element);
}
@ -1461,9 +1502,11 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
if (wanted != null) {
logger.warn("Could not load visualizer: " + element.getText());
}
} else if (element.getName().equals("moterelations")) {
}
else if (element.getName().equals("moterelations")) {
showMoteToMoteRelations = true;
} else if (element.getName().equals("viewport")) {
}
else if (element.getName().equals("viewport")) {
try {
String[] matrix = element.getText().split(" ");
viewportTransform.setTransform(
@ -1475,11 +1518,13 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
Double.parseDouble(matrix[5])
);
resetViewport = 0;
} catch (NumberFormatException e) {
}
catch (NumberFormatException e) {
logger.warn("Bad viewport: " + e.getMessage());
resetViewport();
}
} else if (element.getName().equals("hidden")) {
}
else if (element.getName().equals("hidden")) {
BasicInternalFrameUI ui = (BasicInternalFrameUI) getUI();
ui.getNorthPane().setPreferredSize(new Dimension(0, 0));
}
@ -1502,15 +1547,18 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
};
protected static class ButtonClickMoteMenuAction implements MoteMenuAction {
@Override
public boolean isEnabled(Visualizer visualizer, Mote mote) {
return mote.getInterfaces().getButton() != null
&& !mote.getInterfaces().getButton().isPressed();
}
@Override
public String getDescription(Visualizer visualizer, Mote mote) {
return "Click button on " + mote;
}
@Override
public void doAction(Visualizer visualizer, Mote mote) {
mote.getInterfaces().getButton().clickButton();
@ -1518,14 +1566,17 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
};
protected static class DeleteMoteMenuAction implements MoteMenuAction {
@Override
public boolean isEnabled(Visualizer visualizer, Mote mote) {
return true;
}
@Override
public String getDescription(Visualizer visualizer, Mote mote) {
return "Delete " + mote;
}
@Override
public void doAction(Visualizer visualizer, Mote mote) {
mote.getSimulation().removeMote(mote);
@ -1533,14 +1584,17 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
};
protected static class ShowLEDMoteMenuAction implements MoteMenuAction {
@Override
public boolean isEnabled(Visualizer visualizer, Mote mote) {
return mote.getInterfaces().getLED() != null;
}
@Override
public String getDescription(Visualizer visualizer, Mote mote) {
return "Show LEDs on " + mote;
}
@Override
public void doAction(Visualizer visualizer, Mote mote) {
Simulation simulation = mote.getSimulation();
@ -1552,8 +1606,8 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
/* Extract description (input to plugin) */
String desc = Cooja.getDescriptionOf(mote.getInterfaces().getLED());
MoteInterfaceViewer viewer =
(MoteInterfaceViewer) simulation.getCooja().tryStartPlugin(
MoteInterfaceViewer viewer
= (MoteInterfaceViewer) simulation.getCooja().tryStartPlugin(
MoteInterfaceViewer.class,
simulation.getCooja(),
simulation,
@ -1567,6 +1621,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
};
protected static class ShowSerialMoteMenuAction implements MoteMenuAction {
@Override
public boolean isEnabled(Visualizer visualizer, Mote mote) {
for (MoteInterface intf : mote.getInterfaces().getInterfaces()) {
@ -1576,10 +1631,12 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
}
return false;
}
@Override
public String getDescription(Visualizer visualizer, Mote mote) {
return "Show serial port on " + mote;
}
@Override
public void doAction(Visualizer visualizer, Mote mote) {
Simulation simulation = mote.getSimulation();
@ -1598,8 +1655,8 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
/* Extract description (input to plugin) */
String desc = Cooja.getDescriptionOf(serialPort);
MoteInterfaceViewer viewer =
(MoteInterfaceViewer) simulation.getCooja().tryStartPlugin(
MoteInterfaceViewer viewer
= (MoteInterfaceViewer) simulation.getCooja().tryStartPlugin(
MoteInterfaceViewer.class,
simulation.getCooja(),
simulation,
@ -1613,14 +1670,17 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
};
protected static class MoveMoteMenuAction implements MoteMenuAction {
@Override
public boolean isEnabled(Visualizer visualizer, Mote mote) {
return true;
}
@Override
public String getDescription(Visualizer visualizer, Mote mote) {
return "Move " + mote;
}
@Override
public void doAction(Visualizer visualizer, Mote mote) {
visualizer.beginMoveRequest(mote, false, false);
@ -1628,15 +1688,18 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
};
protected static class ResetViewportAction implements SimulationMenuAction {
@Override
public void doAction(Visualizer visualizer, Simulation simulation) {
visualizer.resetViewport = 1;
visualizer.repaint();
}
@Override
public String getDescription(Visualizer visualizer, Simulation simulation) {
return "Reset viewport";
}
@Override
public boolean isEnabled(Visualizer visualizer, Simulation simulation) {
return true;
@ -1644,6 +1707,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
};
protected static class ToggleDecorationsMenuAction implements SimulationMenuAction {
@Override
public void doAction(final Visualizer visualizer, Simulation simulation) {
if (!(visualizer.getUI() instanceof BasicInternalFrameUI)) {
@ -1651,11 +1715,12 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
}
BasicInternalFrameUI ui = (BasicInternalFrameUI) visualizer.getUI();
if (ui.getNorthPane().getPreferredSize() == null ||
ui.getNorthPane().getPreferredSize().height == 0) {
if (ui.getNorthPane().getPreferredSize() == null
|| ui.getNorthPane().getPreferredSize().height == 0) {
/* Restore window decorations */
ui.getNorthPane().setPreferredSize(null);
} else {
}
else {
/* Hide window decorations */
ui.getNorthPane().setPreferredSize(new Dimension(0, 0));
}
@ -1667,6 +1732,7 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
}
});
}
@Override
public String getDescription(Visualizer visualizer, Simulation simulation) {
if (!(visualizer.getUI() instanceof BasicInternalFrameUI)) {
@ -1674,12 +1740,13 @@ public class Visualizer extends VisPlugin implements HasQuickHelp {
}
BasicInternalFrameUI ui = (BasicInternalFrameUI) visualizer.getUI();
if (ui.getNorthPane().getPreferredSize() == null ||
ui.getNorthPane().getPreferredSize().height == 0) {
if (ui.getNorthPane().getPreferredSize() == null
|| ui.getNorthPane().getPreferredSize().height == 0) {
return "Restore window decorations";
}
return "Hide window decorations";
}
@Override
public boolean isEnabled(Visualizer visualizer, Simulation simulation) {
return visualizer.getUI() instanceof BasicInternalFrameUI;

View file

@ -27,7 +27,6 @@
* SUCH DAMAGE.
*
*/
package org.contikios.cooja.plugins.skins;
import java.awt.Color;
@ -53,6 +52,7 @@ import org.contikios.cooja.radiomediums.DirectedGraphMedium;
@ClassDescription("Radio environment (DGRM)")
@SupportedArguments(radioMediums = {DirectedGraphMedium.class})
public class DGRMVisualizerSkin implements VisualizerSkin {
private static final Logger logger = Logger.getLogger(DGRMVisualizerSkin.class);
private Simulation simulation = null;
@ -129,11 +129,19 @@ public class DGRMVisualizerSkin implements VisualizerSkin {
double pos_rssi = rssi + 100;
int lqi = ((DGRMDestinationRadio) r).lqi;
float red = (float) (1 - prob * pos_rssi / 90 * lqi / 100);
if(red > 1) red = 1;
if(red < 0) red = 0;
if (red > 1) {
red = 1;
}
if (red < 0) {
red = 0;
}
float green = (float) (prob * pos_rssi / 90 * lqi / 100);
if(green > 1) green = 1;
if(green < 0) green = 0;
if (green > 1) {
green = 1;
}
if (green < 0) {
green = 0;
}
if (prob == 0.0d) {
continue;
}

View file

@ -27,7 +27,6 @@
* SUCH DAMAGE.
*
*/
package org.contikios.cooja.plugins.skins;
import java.awt.BorderLayout;
@ -87,6 +86,7 @@ import org.contikios.cooja.radiomediums.UDGM;
@ClassDescription("Radio environment (UDGM)")
@SupportedArguments(radioMediums = {UDGM.class})
public class UDGMVisualizerSkin implements VisualizerSkin {
private static final Logger logger = Logger.getLogger(UDGMVisualizerSkin.class);
private static final Color COLOR_TX = new Color(0, 255, 0, 100);
@ -158,8 +158,8 @@ public class UDGMVisualizerSkin implements VisualizerSkin {
txRangeSpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
radioMedium.setTxRange(((SpinnerNumberModel)
txRangeSpinner.getModel()).getNumber().doubleValue());
radioMedium.setTxRange(((SpinnerNumberModel) txRangeSpinner.getModel())
.getNumber().doubleValue());
visualizer.repaint();
}
});
@ -167,8 +167,8 @@ public class UDGMVisualizerSkin implements VisualizerSkin {
interferenceRangeSpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
radioMedium.setInterferenceRange(((SpinnerNumberModel)
interferenceRangeSpinner.getModel()).getNumber().doubleValue());
radioMedium.setInterferenceRange(((SpinnerNumberModel) interferenceRangeSpinner.getModel())
.getNumber().doubleValue());
visualizer.repaint();
}
});
@ -176,8 +176,8 @@ public class UDGMVisualizerSkin implements VisualizerSkin {
successRatioTxSpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
radioMedium.SUCCESS_RATIO_TX = ((SpinnerNumberModel)
successRatioTxSpinner.getModel()).getNumber().doubleValue();
radioMedium.SUCCESS_RATIO_TX = ((SpinnerNumberModel) successRatioTxSpinner.getModel())
.getNumber().doubleValue();
visualizer.repaint();
}
});
@ -185,8 +185,8 @@ public class UDGMVisualizerSkin implements VisualizerSkin {
successRatioRxSpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
radioMedium.SUCCESS_RATIO_RX = ((SpinnerNumberModel)
successRatioRxSpinner.getModel()).getNumber().doubleValue();
radioMedium.SUCCESS_RATIO_RX = ((SpinnerNumberModel) successRatioRxSpinner.getModel())
.getNumber().doubleValue();
visualizer.repaint();
}
});
@ -375,8 +375,8 @@ public class UDGMVisualizerSkin implements VisualizerSkin {
if (m == selectedMote) {
continue;
}
double prob =
((UDGM) simulation.getRadioMedium()).getSuccessProbability(selectedRadio, m.getInterfaces().getRadio());
double prob
= ((UDGM) simulation.getRadioMedium()).getSuccessProbability(selectedRadio, m.getInterfaces().getRadio());
if (prob == 0.0d) {
continue;
}
@ -395,6 +395,7 @@ public class UDGMVisualizerSkin implements VisualizerSkin {
}
public static class RangeMenuAction implements SimulationMenuAction {
@Override
public boolean isEnabled(Visualizer visualizer, Simulation simulation) {
return true;
@ -420,6 +421,7 @@ public class UDGMVisualizerSkin implements VisualizerSkin {
};
public static class SuccessRatioMenuAction implements SimulationMenuAction {
@Override
public boolean isEnabled(Visualizer visualizer, Simulation simulation) {
return true;