[cooja] skins/TrafficVisualizerSkin: Added @Override annotations and added some final modifiers

This commit is contained in:
Enrico Joerns 2014-06-11 00:27:33 +02:00
parent 01bd045570
commit 0e78bc67f9

View file

@ -60,7 +60,7 @@ import org.contikios.cooja.radiomediums.AbstractRadioMedium;
@ClassDescription("Radio traffic") @ClassDescription("Radio traffic")
@SupportedArguments(radioMediums = {AbstractRadioMedium.class}) @SupportedArguments(radioMediums = {AbstractRadioMedium.class})
public class TrafficVisualizerSkin implements VisualizerSkin { public class TrafficVisualizerSkin implements VisualizerSkin {
private static Logger logger = Logger.getLogger(TrafficVisualizerSkin.class); private static final Logger logger = Logger.getLogger(TrafficVisualizerSkin.class);
private final int MAX_HISTORY_SIZE = 200; private final int MAX_HISTORY_SIZE = 200;
@ -73,6 +73,7 @@ public class TrafficVisualizerSkin implements VisualizerSkin {
private RadioConnectionArrow[] history = null; private RadioConnectionArrow[] history = null;
private Observer radioMediumObserver = new Observer() { private Observer radioMediumObserver = new Observer() {
@Override
public void update(Observable obs, Object obj) { public void update(Observable obs, Object obj) {
RadioConnection last = radioMedium.getLastConnection(); RadioConnection last = radioMedium.getLastConnection();
if (last != null && historyList.size() < MAX_HISTORY_SIZE) { if (last != null && historyList.size() < MAX_HISTORY_SIZE) {
@ -82,7 +83,8 @@ public class TrafficVisualizerSkin implements VisualizerSkin {
} }
} }
}; };
private TimeEvent ageArrowsTimeEvent = new TimeEvent(0) { private final TimeEvent ageArrowsTimeEvent = new TimeEvent(0) {
@Override
public void execute(long t) { public void execute(long t) {
if (!active) { if (!active) {
return; return;
@ -118,6 +120,7 @@ public class TrafficVisualizerSkin implements VisualizerSkin {
} }
}; };
@Override
public void setActive(final Simulation simulation, Visualizer vis) { public void setActive(final Simulation simulation, Visualizer vis) {
this.radioMedium = (AbstractRadioMedium) simulation.getRadioMedium(); this.radioMedium = (AbstractRadioMedium) simulation.getRadioMedium();
this.simulation = simulation; this.simulation = simulation;
@ -125,6 +128,7 @@ public class TrafficVisualizerSkin implements VisualizerSkin {
this.active = true; this.active = true;
simulation.invokeSimulationThread(new Runnable() { simulation.invokeSimulationThread(new Runnable() {
@Override
public void run() { public void run() {
historyList.clear(); historyList.clear();
history = null; history = null;
@ -138,6 +142,7 @@ public class TrafficVisualizerSkin implements VisualizerSkin {
}); });
} }
@Override
public void setInactive() { public void setInactive() {
this.active = false; this.active = false;
if (simulation == null) { if (simulation == null) {
@ -149,11 +154,12 @@ public class TrafficVisualizerSkin implements VisualizerSkin {
radioMedium.deleteRadioMediumObserver(radioMediumObserver); radioMedium.deleteRadioMediumObserver(radioMediumObserver);
} }
@Override
public Color[] getColorOf(Mote mote) { public Color[] getColorOf(Mote mote) {
return null; return null;
} }
private Polygon arrowPoly = new Polygon(); private final Polygon arrowPoly = new Polygon();
private void drawArrow(Graphics g, int xSource, int ySource, int xDest, int yDest, int delta) { private void drawArrow(Graphics g, int xSource, int ySource, int xDest, int yDest, int delta) {
double dx = xSource - xDest; double dx = xSource - xDest;
double dy = ySource - yDest; double dy = ySource - yDest;
@ -183,6 +189,7 @@ public class TrafficVisualizerSkin implements VisualizerSkin {
return (int)(0.5 + len * Math.sin(dir)); return (int)(0.5 + len * Math.sin(dir));
} }
@Override
public void paintBeforeMotes(Graphics g) { public void paintBeforeMotes(Graphics g) {
RadioConnectionArrow[] historyCopy = history; RadioConnectionArrow[] historyCopy = history;
if (historyCopy == null) { if (historyCopy == null) {
@ -201,15 +208,17 @@ public class TrafficVisualizerSkin implements VisualizerSkin {
} }
} }
@Override
public void paintAfterMotes(Graphics g) { public void paintAfterMotes(Graphics g) {
} }
@Override
public Visualizer getVisualizer() { public Visualizer getVisualizer() {
return visualizer; return visualizer;
} }
private static class RadioConnectionArrow { private static class RadioConnectionArrow {
private RadioConnection conn; private final RadioConnection conn;
private int age; private int age;
private static final int MAX_AGE = 10; private static final int MAX_AGE = 10;
RadioConnectionArrow(RadioConnection conn) { RadioConnectionArrow(RadioConnection conn) {