コード例 #1
0
ファイル: EntityPallet.java プロジェクト: mchudleigh/jaamsim
    @Override
    public Component getTreeCellRendererComponent(
        JTree tree,
        Object value,
        boolean selected,
        boolean expanded,
        boolean leaf,
        int row,
        boolean hasFocus) {

      super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);

      // If not a leaf, just return
      if (!leaf) return this;

      // If we don't find an ObjectType (likely we will) just return
      Object userObj = ((DefaultMutableTreeNode) value).getUserObject();
      if (!(userObj instanceof ObjectType)) return this;

      ObjectType type = (ObjectType) userObj;
      this.setText(type.getName());

      if (!RenderManager.isGood()) return this;

      if (type.getIconImage() == null) return this;

      icon.setImage(type.getIconImage());
      this.setIcon(icon);
      return this;
    }
コード例 #2
0
ファイル: EntityPallet.java プロジェクト: mchudleigh/jaamsim
  private void updateTree() {

    // Create a tree that allows one selection at a time
    top.removeAllChildren();
    HashMap<String, DefaultMutableTreeNode> paletteNodes = new HashMap<>();
    for (ObjectType type : ObjectType.getAll()) {
      if (!type.isDragAndDrop()) continue;

      String pName = type.getPaletteName();
      DefaultMutableTreeNode palNode = paletteNodes.get(pName);
      if (palNode == null) {
        palNode = new DefaultMutableTreeNode(pName, true);
        paletteNodes.put(pName, palNode);
        top.add(palNode);
      }

      DefaultMutableTreeNode classNode = new DefaultMutableTreeNode(type, true);
      palNode.add(classNode);
    }
    treeModel.reload(top);
  }
コード例 #3
0
ファイル: EntityPallet.java プロジェクト: mchudleigh/jaamsim
    /*
     * override getToolTipText to control what to display
     */
    @Override
    public String getToolTipText(MouseEvent e) {

      if (this.getPathForLocation(e.getX(), e.getY()) == null) {
        return null;
      }

      // Obtain the node under the mouse
      DefaultMutableTreeNode node =
          (DefaultMutableTreeNode)
              this.getPathForLocation(e.getX(), e.getY()).getLastPathComponent();
      if (node == null) {
        return null;
      }

      Object object = node.getUserObject();

      // It is a leaf node
      if (!(object instanceof ObjectType)) {
        return null;
      }
      ObjectType ot = (ObjectType) object;
      return GUIFrame.formatToolTip(ot.getName(), ot.getDescription());
    }
コード例 #4
0
ファイル: ExpParser.java プロジェクト: altal22/jaamsim
 private static String unitToString(Class<? extends Unit> unit) {
   ObjectType type = ObjectType.getObjectTypeForClass(unit);
   if (type == null) return "Unknown Unit";
   return type.getName();
 }