From 38cce5e9c7164fce7f14d594f0a07f8945a59b4c Mon Sep 17 00:00:00 2001 From: fros4943 Date: Mon, 11 Feb 2008 15:17:30 +0000 Subject: [PATCH] added icon interface --- .../se/sics/cooja/mspmote/ESBMoteType.java | 25 ++++++++++++++++++- .../se/sics/cooja/mspmote/MspMoteType.java | 16 ++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/ESBMoteType.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/ESBMoteType.java index d8fd902da..e1e05c123 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/ESBMoteType.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/ESBMoteType.java @@ -26,13 +26,18 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ESBMoteType.java,v 1.1 2008/02/07 14:53:29 fros4943 Exp $ + * $Id: ESBMoteType.java,v 1.2 2008/02/11 15:17:30 fros4943 Exp $ */ package se.sics.cooja.mspmote; +import java.awt.Image; +import java.awt.MediaTracker; +import java.awt.Toolkit; +import java.net.URL; import javax.swing.*; import org.apache.log4j.Logger; + import se.sics.cooja.*; @ClassDescription("ESB Mote Type") @@ -51,6 +56,24 @@ public class ESBMoteType extends MspMoteType { setDescription(targetNice + " Mote Type #" + identifier); } + public Icon getMoteTypeIcon() { + Toolkit toolkit = Toolkit.getDefaultToolkit(); + URL imageURL = this.getClass().getClassLoader().getResource("images/esb.jpg"); + Image image = toolkit.getImage(imageURL); + MediaTracker tracker = new MediaTracker(GUI.frame); + tracker.addImage(image, 1); + try { + tracker.waitForAll(); + } catch (InterruptedException ex) { + } + if (image.getHeight(GUI.frame) > 0 && image.getWidth(GUI.frame) > 0) { + image = image.getScaledInstance((100*image.getWidth(GUI.frame)/image.getHeight(GUI.frame)), 100, Image.SCALE_DEFAULT); + return new ImageIcon(image); + } + + return null; + } + public Mote generateMote(Simulation simulation) { return new ESBMote(this, simulation); } diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java index 13d16c108..768670426 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMoteType.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: MspMoteType.java,v 1.2 2008/02/08 14:30:28 fros4943 Exp $ + * $Id: MspMoteType.java,v 1.3 2008/02/11 15:17:30 fros4943 Exp $ */ package se.sics.cooja.mspmote; @@ -420,7 +420,8 @@ public abstract class MspMoteType implements MoteType { sourceFile.getName().length() - 2); final String command = getCompileCommand(filenameNoExtension); - logger.info("Compile command: " + command); + logger.info("-- Compiling MSP430 Firmware --"); + logger.info("command: " + command); compilationOutput.clearMessages(); @@ -880,10 +881,21 @@ public abstract class MspMoteType implements MoteType { smallPane.add(BorderLayout.EAST, label); panel.add(smallPane); + // Icon (if available) + Icon moteTypeIcon = getMoteTypeIcon(); + if (moteTypeIcon != null) { + smallPane = new JPanel(new BorderLayout()); + label = new JLabel(moteTypeIcon); + smallPane.add(BorderLayout.CENTER, label); + panel.add(smallPane); + } + panel.add(Box.createRigidArea(new Dimension(0, 5))); return panel; } + public abstract Icon getMoteTypeIcon(); + public ProjectConfig getConfig() { logger.warn("Msp mote type project config not implemented"); return null;