diff --git a/tools/cooja/java/se/sics/cooja/contikimote/ContikiMoteType.java b/tools/cooja/java/se/sics/cooja/contikimote/ContikiMoteType.java index f7d3bad1b..42f02f98c 100644 --- a/tools/cooja/java/se/sics/cooja/contikimote/ContikiMoteType.java +++ b/tools/cooja/java/se/sics/cooja/contikimote/ContikiMoteType.java @@ -31,9 +31,7 @@ package se.sics.cooja.contikimote; -import java.awt.BorderLayout; import java.awt.Container; -import java.awt.Dimension; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -50,12 +48,13 @@ import java.util.Random; import java.util.Vector; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.swing.Box; -import javax.swing.BoxLayout; + +import javax.swing.JComponent; import javax.swing.JLabel; -import javax.swing.JPanel; + import org.apache.log4j.Logger; import org.jdom.Element; + import se.sics.cooja.AbstractionLevelDescription; import se.sics.cooja.ClassDescription; import se.sics.cooja.CoreComm; @@ -1194,98 +1193,52 @@ public class ContikiMoteType implements MoteType { * * @return Mote type visualizer */ - public JPanel getTypeVisualizer() { - JPanel panel = new JPanel(); - JLabel label = new JLabel(); - JPanel smallPane; + public JComponent getTypeVisualizer() { + StringBuilder sb = new StringBuilder(); + // Identifier + sb.append(""); - panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); - - /* Identifier */ - smallPane = new JPanel(new BorderLayout()); - label = new JLabel("Identifier"); - smallPane.add(BorderLayout.WEST, label); - label = new JLabel(identifier); - smallPane.add(BorderLayout.EAST, label); - panel.add(smallPane); - - /* Description */ - smallPane = new JPanel(new BorderLayout()); - label = new JLabel("Description"); - smallPane.add(BorderLayout.WEST, label); - label = new JLabel(description); - smallPane.add(BorderLayout.EAST, label); - panel.add(smallPane); + // Description + sb.append(""); /* Contiki application */ - smallPane = new JPanel(new BorderLayout()); - label = new JLabel("Contiki application"); - smallPane.add(BorderLayout.WEST, label); - label = new JLabel(getContikiSourceFile().getName()); - label.setToolTipText(getContikiSourceFile().getAbsolutePath()); - smallPane.add(BorderLayout.EAST, label); - panel.add(smallPane); - - panel.add(Box.createVerticalStrut(15)); + sb.append(""); /* Contiki firmware */ - smallPane = new JPanel(new BorderLayout()); - label = new JLabel("Contiki firmware"); - smallPane.add(BorderLayout.WEST, label); - label = new JLabel(getContikiFirmwareFile().getName()); - label.setToolTipText(getContikiFirmwareFile().getAbsolutePath()); - smallPane.add(BorderLayout.EAST, label); - panel.add(smallPane); + sb.append(""); - /* JNI Class */ - smallPane = new JPanel(new BorderLayout()); - label = new JLabel("Java class (JNI)"); - smallPane.add(BorderLayout.WEST, label); - label = new JLabel(this.javaClassName); - smallPane.add(BorderLayout.EAST, label); - panel.add(smallPane); + /* JNI class */ + sb.append(""); - /* Sensors */ - smallPane = new JPanel(new BorderLayout()); - label = new JLabel("Sensors"); - smallPane.add(BorderLayout.WEST, label); - panel.add(smallPane); - - for (String sensor : sensors) { - smallPane = new JPanel(new BorderLayout()); - label = new JLabel(sensor); - smallPane.add(BorderLayout.EAST, label); - panel.add(smallPane); + /* Contiki sensors */ + sb.append(""); - /* Mote Interfaces */ - smallPane = new JPanel(new BorderLayout()); - label = new JLabel("Mote interfaces"); - smallPane.add(BorderLayout.WEST, label); - panel.add(smallPane); - - for (Class intf : moteInterfacesClasses) { - smallPane = new JPanel(new BorderLayout()); - label = new JLabel(intf.getSimpleName()); - smallPane.add(BorderLayout.EAST, label); - panel.add(smallPane); + /* Mote interfaces */ + sb.append(""); - /* Core Interfaces */ - smallPane = new JPanel(new BorderLayout()); - label = new JLabel("Core interfaces"); - smallPane.add(BorderLayout.WEST, label); - panel.add(smallPane); - - for (String intf : getCoreInterfaces()) { - smallPane = new JPanel(new BorderLayout()); - label = new JLabel(intf); - smallPane.add(BorderLayout.EAST, label); - panel.add(smallPane); + /* Contiki core mote interfaces */ + sb.append(""); - panel.add(Box.createRigidArea(new Dimension(0, 5))); - return panel; + JLabel label = new JLabel(sb.append("
Identifier") + .append(getIdentifier()).append("
Description") + .append(getDescription()).append("
Contiki application") + .append(getContikiSourceFile().getAbsolutePath()).append("
Contiki firmware") + .append(getContikiFirmwareFile().getAbsolutePath()).append("
JNI library") + .append(this.javaClassName).append("
Contiki sensors"); + for (String sensor: sensors) { + sb.append(sensor).append("
"); } + sb.append("
Mote interface"); + for (Class moteInterface: moteInterfacesClasses) { + sb.append(moteInterface.getSimpleName()).append("
"); } + sb.append("
Contiki's mote interface"); + for (String coreInterface: getCoreInterfaces()) { + sb.append(coreInterface).append("
"); } + sb.append("
").toString()); + label.setVerticalTextPosition(JLabel.TOP); + return label; } public Collection getConfigXML(Simulation simulation) { diff --git a/tools/cooja/java/se/sics/cooja/motes/AbstractApplicationMoteType.java b/tools/cooja/java/se/sics/cooja/motes/AbstractApplicationMoteType.java index 55375553f..2f6af8fc9 100644 --- a/tools/cooja/java/se/sics/cooja/motes/AbstractApplicationMoteType.java +++ b/tools/cooja/java/se/sics/cooja/motes/AbstractApplicationMoteType.java @@ -145,10 +145,11 @@ public abstract class AbstractApplicationMoteType implements MoteType { sb.append("Description") .append(getDescription()).append(""); + sb.append("Mote interface"); for (Class moteInterface : moteInterfaceClasses) { - sb.append("Mote interface") - .append(moteInterface.getSimpleName()).append(""); + sb.append(moteInterface.getSimpleName()).append("
"); } + sb.append(""); JLabel label = new JLabel(sb.append("").toString()); label.setVerticalTextPosition(JLabel.TOP);