set default location and size

This commit is contained in:
fros4943 2008-10-03 14:30:51 +00:00
parent 4db4a211bf
commit 4f5ff657d4
2 changed files with 30 additions and 26 deletions

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: LogListener.java,v 1.11 2008/10/03 10:39:49 fros4943 Exp $ * $Id: LogListener.java,v 1.12 2008/10/03 14:30:51 fros4943 Exp $
*/ */
package se.sics.cooja.plugins; package se.sics.cooja.plugins;
@ -50,7 +50,7 @@ import se.sics.cooja.interfaces.Log;
* @author Fredrik Osterlind, Niclas Finne * @author Fredrik Osterlind, Niclas Finne
*/ */
@ClassDescription("Log Listener") @ClassDescription("Log Listener")
@PluginType(PluginType.SIM_PLUGIN) @PluginType(PluginType.SIM_STANDARD_PLUGIN)
public class LogListener extends VisPlugin { public class LogListener extends VisPlugin {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(LogListener.class); private static Logger logger = Logger.getLogger(LogListener.class);
@ -166,7 +166,7 @@ public class LogListener extends VisPlugin {
if (!filterText.equals(oldFilterText) && logCache.length > 1) { if (!filterText.equals(oldFilterText) && logCache.length > 1) {
// Update from log cache // Update from log cache
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
synchronized(logCache) { synchronized(logCache) {
int pos = logPos; int pos = logPos;
int count; int count;
if(logCache[pos] != null) { if(logCache[pos] != null) {
@ -247,6 +247,8 @@ public class LogListener extends VisPlugin {
setTitle("Log Listener - Listening on " + nrLogs + " mote logs"); setTitle("Log Listener - Listening on " + nrLogs + " mote logs");
pack(); pack();
setSize(gui.getDesktopPane().getWidth(), getHeight());
setLocation(0, gui.getDesktopPane().getHeight() - getHeight());
try { try {
setSelected(true); setSelected(true);

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: VisState.java,v 1.4 2007/01/09 09:49:24 fros4943 Exp $ * $Id: VisState.java,v 1.5 2008/10/03 14:30:51 fros4943 Exp $
*/ */
package se.sics.cooja.plugins; package se.sics.cooja.plugins;
@ -41,21 +41,21 @@ import se.sics.cooja.Mote.State;
/** /**
* A State Visualizer indicates mote states by painting them in different colors. * A State Visualizer indicates mote states by painting them in different colors.
* Active motes are green, sleeping motes are gray and dead motes are read. * Active motes are green, sleeping motes are gray and dead motes are read.
* *
* The inner color indicates the mote type. * The inner color indicates the mote type.
* *
* A VisState observes both the simulation and all mote states. * A VisState observes both the simulation and all mote states.
* *
* @author Fredrik Osterlind * @author Fredrik Osterlind
*/ */
@ClassDescription("State Visualizer") @ClassDescription("State Visualizer")
@PluginType(PluginType.SIM_PLUGIN) @PluginType(PluginType.SIM_STANDARD_PLUGIN)
public class VisState extends Visualizer2D { public class VisState extends Visualizer2D {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(VisState.class); private static Logger logger = Logger.getLogger(VisState.class);
private Simulation simulation; private Simulation simulation;
private static final Color moteTypeColors[] = new Color[] { private static final Color moteTypeColors[] = new Color[] {
Color.MAGENTA, Color.MAGENTA,
Color.CYAN, Color.CYAN,
@ -71,15 +71,15 @@ public class VisState extends Visualizer2D {
/** /**
* Creates a new state visualizer. * Creates a new state visualizer.
* *
* @param simulationToVisualize Simulation to visualize * @param simulationToVisualize Simulation to visualize
*/ */
public VisState(Simulation simulationToVisualize, GUI gui) { public VisState(Simulation simulationToVisualize, GUI gui) {
super(simulationToVisualize, gui); super(simulationToVisualize, gui);
setTitle("State Visualizer"); setTitle("State Visualizer");
simulation = simulationToVisualize; simulation = simulationToVisualize;
// Always observe all motes in simulation // Always observe all motes in simulation
stateObserver = new Observer() { stateObserver = new Observer() {
public void update(Observable obs, Object obj) { public void update(Observable obs, Object obj) {
@ -98,35 +98,37 @@ public class VisState extends Visualizer2D {
} }
}); });
simObserver.update(null, null); simObserver.update(null, null);
setLocation(
gui.getDesktopPane().getWidth() - getWidth(),
0);
} }
public Color[] getColorOf(Mote mote) { public Color[] getColorOf(Mote mote) {
Color[] returnColors = new Color[2]; Color[] returnColors = new Color[2];
// If mote is sleeping, make outer circle blue // If mote is sleeping, make outer circle blue
if (mote.getState() == Mote.State.LPM) if (mote.getState() == Mote.State.LPM) {
returnColors[1] = Color.GRAY; returnColors[1] = Color.GRAY;
} else if (mote.getState() == State.DEAD) {
// If mote is dead, make outer circle red
else if (mote.getState() == State.DEAD)
returnColors[1] = Color.RED; returnColors[1] = Color.RED;
} else {
else
returnColors[1] = Color.GREEN; // make outer circle green returnColors[1] = Color.GREEN; // make outer circle green
}
// Associate different colors with different mote types // Associate different colors with different mote types
Vector<MoteType> allTypes = simulation.getMoteTypes(); Vector<MoteType> allTypes = simulation.getMoteTypes();
int numberOfTypes = allTypes.size(); int numberOfTypes = allTypes.size();
for (int colCounter=0; colCounter < numberOfTypes && colCounter < moteTypeColors.length; colCounter++) { for (int colCounter=0; colCounter < numberOfTypes && colCounter < moteTypeColors.length; colCounter++) {
if (mote.getType() == allTypes.get(colCounter)) { if (mote.getType() == allTypes.get(colCounter)) {
returnColors[0] = moteTypeColors[colCounter]; returnColors[0] = moteTypeColors[colCounter];
return returnColors; return returnColors;
} }
} }
returnColors[0] = Color.WHITE; returnColors[0] = Color.WHITE;
return returnColors; return returnColors;
} }