updated plugin constructors

This commit is contained in:
fros4943 2007-01-09 09:49:24 +00:00
parent bf7ed8eb41
commit 18d9c94222
11 changed files with 71 additions and 57 deletions

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: LogListener.java,v 1.3 2006/12/07 14:26:48 fros4943 Exp $
* $Id: LogListener.java,v 1.4 2007/01/09 09:49:24 fros4943 Exp $
*/
package se.sics.cooja.plugins;
@ -52,7 +52,7 @@ import se.sics.cooja.interfaces.Log;
* @author Fredrik Osterlind
*/
@ClassDescription("Log Listener")
@VisPluginType(VisPluginType.SIM_PLUGIN)
@PluginType(PluginType.SIM_PLUGIN)
public class LogListener extends VisPlugin {
private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(LogListener.class);
@ -69,8 +69,8 @@ public class LogListener extends VisPlugin {
*
* @param simulationToControl Simulation to control
*/
public LogListener(final Simulation simulationToControl) {
super("Log Listener - Listening on ?? mote logs");
public LogListener(final Simulation simulationToControl, GUI gui) {
super("Log Listener - Listening on ?? mote logs", gui);
simulation = simulationToControl;
int nrLogs = 0;
@ -159,7 +159,7 @@ public class LogListener extends VisPlugin {
return config;
}
public boolean setConfigXML(Collection<Element> configXML) {
public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) {
for (Element element : configXML) {
if (element.getName().equals("filter")) {

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: MoteInformation.java,v 1.2 2006/09/26 13:08:05 fros4943 Exp $
* $Id: MoteInformation.java,v 1.3 2007/01/09 09:49:24 fros4943 Exp $
*/
package se.sics.cooja.plugins;
@ -47,7 +47,7 @@ import se.sics.cooja.Mote.State;
* @author Fredrik Osterlind
*/
@ClassDescription("Mote Information")
@VisPluginType(VisPluginType.MOTE_PLUGIN)
@PluginType(PluginType.MOTE_PLUGIN)
public class MoteInformation extends VisPlugin {
private static Logger logger = Logger.getLogger(MoteInformation.class);
@ -63,16 +63,19 @@ public class MoteInformation extends VisPlugin {
private Observer stateObserver;
private Vector<JPanel> visibleMoteInterfaces = new Vector<JPanel>();
private Simulation mySimulation;
/**
* Create a new mote information window.
*
* @param moteToView Mote to view
*/
public MoteInformation(Mote moteToView) {
super("Mote Information (" + moteToView + ")");
public MoteInformation(Mote moteToView, Simulation simulation, GUI gui) {
super("Mote Information (" + moteToView + ")", gui);
mote = moteToView;
mySimulation = simulation;
JLabel label;
JPanel mainPane = new JPanel();
mainPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
@ -89,7 +92,7 @@ public class MoteInformation extends VisPlugin {
button.setActionCommand("removeMote");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
GUI.currentSimulation.removeMote(mote);
mySimulation.removeMote(mote);
dispose();
}
});

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: MoteInterfaceViewer.java,v 1.2 2006/11/30 14:25:59 fros4943 Exp $
* $Id: MoteInterfaceViewer.java,v 1.3 2007/01/09 09:49:24 fros4943 Exp $
*/
package se.sics.cooja.plugins;
@ -46,7 +46,7 @@ import se.sics.cooja.*;
* @author Fredrik Osterlind
*/
@ClassDescription("Mote Interface Viewer")
@VisPluginType(VisPluginType.MOTE_PLUGIN)
@PluginType(PluginType.MOTE_PLUGIN)
public class MoteInterfaceViewer extends VisPlugin {
private static final long serialVersionUID = 1L;
@ -60,8 +60,8 @@ public class MoteInterfaceViewer extends VisPlugin {
*
* @param moteToView Mote to view
*/
public MoteInterfaceViewer(Mote moteToView) {
super("Mote Interface Viewer (" + moteToView + ")");
public MoteInterfaceViewer(Mote moteToView, Simulation simulation, GUI gui) {
super("Mote Interface Viewer (" + moteToView + ")", gui);
mote = moteToView;
JLabel label;
@ -147,12 +147,27 @@ public class MoteInterfaceViewer extends VisPlugin {
}
/**
* Tries to select the interface with the given class name.
* @param description Interface description
* @return True if selected, false otherwise
*/
public boolean setSelectedInterface(String description) {
for (int i=0; i < selectInterfaceComboBox.getItemCount(); i++) {
if (selectInterfaceComboBox.getItemAt(i).equals(description)) {
selectInterfaceComboBox.setSelectedIndex(i);
return true;
}
}
return false;
}
public void closePlugin() {
// Release old interface visualizer if any
if (selectedMoteInterface != null && currentInterfaceVisualizer != null)
selectedMoteInterface.releaseInterfaceVisualizer(currentInterfaceVisualizer);
}
public Collection<Element> getConfigXML() {
Vector<Element> config = new Vector<Element>();
@ -165,15 +180,11 @@ public class MoteInterfaceViewer extends VisPlugin {
return config;
}
public boolean setConfigXML(Collection<Element> configXML) {
public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) {
for (Element element : configXML) {
if (element.getName().equals("interface")) {
for (int i=0; i < selectInterfaceComboBox.getItemCount(); i++) {
if (selectInterfaceComboBox.getItemAt(i).equals(element.getText())) {
selectInterfaceComboBox.setSelectedIndex(i);
}
}
setSelectedInterface(element.getText());
}
}
return true;

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: MoteTypeInformation.java,v 1.1 2006/08/21 12:13:08 fros4943 Exp $
* $Id: MoteTypeInformation.java,v 1.2 2007/01/09 09:49:24 fros4943 Exp $
*/
package se.sics.cooja.plugins;
@ -43,7 +43,7 @@ import se.sics.cooja.*;
* @author Fredrik Osterlind
*/
@ClassDescription("Mote Type Information")
@VisPluginType(VisPluginType.SIM_PLUGIN)
@PluginType(PluginType.SIM_PLUGIN)
public class MoteTypeInformation extends VisPlugin {
private static Logger logger = Logger.getLogger(MoteTypeInformation.class);
@ -59,8 +59,8 @@ public class MoteTypeInformation extends VisPlugin {
*
* @param simulation Simulation
*/
public MoteTypeInformation(Simulation simulation) {
super("Mote Type Information *frozen*");
public MoteTypeInformation(Simulation simulation, GUI gui) {
super("Mote Type Information *frozen*", gui);
mySimulation = simulation;

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: SimControl.java,v 1.2 2006/12/13 11:55:06 fros4943 Exp $
* $Id: SimControl.java,v 1.3 2007/01/09 09:49:24 fros4943 Exp $
*/
package se.sics.cooja.plugins;
@ -49,7 +49,7 @@ import se.sics.cooja.*;
* @author Fredrik Osterlind
*/
@ClassDescription("Control Panel")
@VisPluginType(VisPluginType.SIM_STANDARD_PLUGIN)
@PluginType(PluginType.SIM_STANDARD_PLUGIN)
public class SimControl extends VisPlugin {
private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(SimControl.class);
@ -75,8 +75,8 @@ public class SimControl extends VisPlugin {
*
* @param simulationToControl Simulation to control
*/
public SimControl(Simulation simulationToControl) {
super("Control Panel - " + simulationToControl.getTitle());
public SimControl(Simulation simulationToControl, GUI gui) {
super("Control Panel - " + simulationToControl.getTitle(), gui);
simulation = simulationToControl;

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: SimInformation.java,v 1.2 2006/09/05 14:12:48 fros4943 Exp $
* $Id: SimInformation.java,v 1.3 2007/01/09 09:49:24 fros4943 Exp $
*/
package se.sics.cooja.plugins;
@ -43,7 +43,7 @@ import se.sics.cooja.*;
* @author Fredrik Osterlind
*/
@ClassDescription("Simulation Information")
@VisPluginType(VisPluginType.SIM_PLUGIN)
@PluginType(PluginType.SIM_PLUGIN)
public class SimInformation extends VisPlugin {
private static final long serialVersionUID = 1L;
private Simulation simulation;
@ -64,8 +64,8 @@ public class SimInformation extends VisPlugin {
*
* @param simulationToView Simulation to view
*/
public SimInformation(Simulation simulationToView) {
super("Simulation Information");
public SimInformation(Simulation simulationToView, GUI gui) {
super("Simulation Information", gui);
simulation = simulationToView;

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: VariableWatcher.java,v 1.2 2006/11/30 14:25:59 fros4943 Exp $
* $Id: VariableWatcher.java,v 1.3 2007/01/09 09:49:24 fros4943 Exp $
*/
package se.sics.cooja.plugins;
@ -51,7 +51,7 @@ import se.sics.cooja.*;
* @author Fredrik Osterlind
*/
@ClassDescription("Variable Watcher")
@VisPluginType(VisPluginType.MOTE_PLUGIN)
@PluginType(PluginType.MOTE_PLUGIN)
public class VariableWatcher extends VisPlugin {
private static final long serialVersionUID = 1L;
@ -79,8 +79,8 @@ public class VariableWatcher extends VisPlugin {
*
* @param moteToView Mote to view
*/
public VariableWatcher(Mote moteToView) {
super("Variable Watcher (" + moteToView + ")");
public VariableWatcher(Mote moteToView, Simulation simulation, GUI gui) {
super("Variable Watcher (" + moteToView + ")", gui);
moteMemory = (SectionMoteMemory) moteToView.getMemory();
@ -343,7 +343,7 @@ public class VariableWatcher extends VisPlugin {
return config;
}
public boolean setConfigXML(Collection<Element> configXML) {
public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) {
lengthPane.setVisible(false);
setNumberOfValues(1);
varLength.setValue(1);

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: VisBattery.java,v 1.3 2006/10/23 16:15:12 fros4943 Exp $
* $Id: VisBattery.java,v 1.4 2007/01/09 09:49:24 fros4943 Exp $
*/
package se.sics.cooja.plugins;
@ -49,7 +49,7 @@ import se.sics.cooja.interfaces.Battery;
* @author Fredrik Osterlind
*/
@ClassDescription("Battery Visualizer")
@VisPluginType(VisPluginType.SIM_PLUGIN)
@PluginType(PluginType.SIM_PLUGIN)
public class VisBattery extends Visualizer2D {
private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(VisBattery.class);
@ -65,8 +65,8 @@ public class VisBattery extends Visualizer2D {
* @param simulationToVisualize
* Simulation to visualize
*/
public VisBattery(Simulation simulationToVisualize) {
super(simulationToVisualize);
public VisBattery(Simulation simulationToVisualize, GUI gui) {
super(simulationToVisualize, gui);
setTitle("Battery Visualizer");
simulation = simulationToVisualize;

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: VisState.java,v 1.3 2006/10/23 16:15:16 fros4943 Exp $
* $Id: VisState.java,v 1.4 2007/01/09 09:49:24 fros4943 Exp $
*/
package se.sics.cooja.plugins;
@ -49,7 +49,7 @@ import se.sics.cooja.Mote.State;
* @author Fredrik Osterlind
*/
@ClassDescription("State Visualizer")
@VisPluginType(VisPluginType.SIM_PLUGIN)
@PluginType(PluginType.SIM_PLUGIN)
public class VisState extends Visualizer2D {
private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(VisState.class);
@ -74,8 +74,8 @@ public class VisState extends Visualizer2D {
*
* @param simulationToVisualize Simulation to visualize
*/
public VisState(Simulation simulationToVisualize) {
super(simulationToVisualize);
public VisState(Simulation simulationToVisualize, GUI gui) {
super(simulationToVisualize, gui);
setTitle("State Visualizer");
simulation = simulationToVisualize;

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: VisTraffic.java,v 1.4 2006/10/11 10:38:26 fros4943 Exp $
* $Id: VisTraffic.java,v 1.5 2007/01/09 09:49:24 fros4943 Exp $
*/
package se.sics.cooja.plugins;
@ -48,7 +48,7 @@ import se.sics.cooja.interfaces.Position;
* @author Fredrik Osterlind
*/
@ClassDescription("Traffic Visualizer")
@VisPluginType(VisPluginType.SIM_PLUGIN)
@PluginType(PluginType.SIM_PLUGIN)
public class VisTraffic extends Visualizer2D {
protected boolean USE_ALPHA = false;
@ -74,8 +74,8 @@ public class VisTraffic extends Visualizer2D {
* @param simulationToVisualize
* Simulation to visualize
*/
public VisTraffic(Simulation simulationToVisualize) {
super(simulationToVisualize);
public VisTraffic(Simulation simulationToVisualize, GUI gui) {
super(simulationToVisualize, gui);
setTitle("Traffic Visualizer");
simulation = simulationToVisualize;

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: Visualizer2D.java,v 1.2 2006/09/07 09:54:37 fros4943 Exp $
* $Id: Visualizer2D.java,v 1.3 2007/01/09 09:49:24 fros4943 Exp $
*/
package se.sics.cooja.plugins;
@ -57,7 +57,7 @@ import se.sics.cooja.interfaces.*;
* @author Fredrik Osterlind
*/
@ClassDescription("2D Mote Visualizer")
@VisPluginType(VisPluginType.SIM_PLUGIN)
@PluginType(PluginType.SIM_PLUGIN)
public abstract class Visualizer2D extends VisPlugin {
private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(Visualizer2D.class);
@ -107,8 +107,8 @@ public abstract class Visualizer2D extends VisPlugin {
* @param simulationToVisualize
* Simulation to visualize
*/
public Visualizer2D(Simulation simulationToVisualize) {
super("Visualizer2D");
public Visualizer2D(Simulation simulationToVisualize, GUI gui) {
super("Visualizer2D", gui);
myPlugin = this;
@ -257,7 +257,7 @@ public abstract class Visualizer2D extends VisPlugin {
JMenuItem menuItem = new JMenuItem("Open mote plugin for " + mote);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
GUI.currentGUI.showMotePluginsMenu(canvas, mote, pos);
simulation.getGUI().showMotePluginsMenu(canvas, mote, pos);
}
});
pickMoteMenu.add(menuItem);