From 59ed193e582e622de1332c772a8bace096345fe4 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Tue, 28 Oct 2008 16:22:35 +0000 Subject: [PATCH] updated example plugin --- .../examples/project_new_plugin/build.xml | 23 +++++++++++++++ .../java/MyDummyPlugin.java | 29 +++++++++---------- 2 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 tools/cooja/examples/project_new_plugin/build.xml diff --git a/tools/cooja/examples/project_new_plugin/build.xml b/tools/cooja/examples/project_new_plugin/build.xml new file mode 100644 index 000000000..57e6f4b6d --- /dev/null +++ b/tools/cooja/examples/project_new_plugin/build.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/cooja/examples/project_new_plugin/java/MyDummyPlugin.java b/tools/cooja/examples/project_new_plugin/java/MyDummyPlugin.java index 44ef48819..5baf53e5e 100644 --- a/tools/cooja/examples/project_new_plugin/java/MyDummyPlugin.java +++ b/tools/cooja/examples/project_new_plugin/java/MyDummyPlugin.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: MyDummyPlugin.java,v 1.1 2007/03/23 23:33:55 fros4943 Exp $ + * $Id: MyDummyPlugin.java,v 1.2 2008/10/28 16:22:35 fros4943 Exp $ */ import java.awt.event.*; @@ -37,28 +37,28 @@ import org.apache.log4j.Logger; import se.sics.cooja.*; /** - * This is an simple example plugin. - * It is a simulation plugin, which means that it depends on a single simulation. - * - * @author Fredrik Osterlind + * This is a simple example plugin. + * It is a simulation plugin (SIM_PLUGIN): it depends on a single simulation. + * + * @author Fredrik Österlind */ -@ClassDescription("Dummy Plugin") +@ClassDescription("Dummy Plugin") /* Description shown in menu */ @PluginType(PluginType.SIM_PLUGIN) public class MyDummyPlugin extends VisPlugin { private static final long serialVersionUID = 1L; private static Logger logger = Logger.getLogger(MyDummyPlugin.class); private Simulation mySimulation; private Observer tickObserver; - + /** * Creates a new dummy plugin. - * + * * @param simulationToVisualize Simulation to visualize */ public MyDummyPlugin(Simulation simulationToVisualize, GUI gui) { super("This is my title!", gui); mySimulation = simulationToVisualize; - + // Create and add a button JButton button = new JButton("dummy button"); button.addActionListener(new ActionListener() { @@ -67,27 +67,26 @@ public class MyDummyPlugin extends VisPlugin { } }); add(button); - + // Register as tickobserver mySimulation.addTickObserver(tickObserver = new Observer() { public void update(Observable obs, Object obj) { logger.info("Another tick loop completed - simulation time is now:\t" + mySimulation.getSimulationTime()); } }); - + setSize(300,100); // Set an initial size of this plugin - + // Tries to select this plugin try { setSelected(true); } catch (java.beans.PropertyVetoException e) { // Could not select } - } - + public void closePlugin() { mySimulation.deleteTickObserver(tickObserver); } - + }