Java 类javax.swing.tree.MutableTreeNode 实例源码

项目:VASSAL-src    文件:ServerStatusView.java   
private void refresh(DefaultTreeModel m,
                     ServerStatus.ModuleSummary[] modules) {
  final MutableTreeNode root = (MutableTreeNode) m.getRoot();
  totalPlayers = 0;

  while (root.getChildCount() > 0) {
    m.removeNodeFromParent((MutableTreeNode) root.getChildAt(0));
  }

  if (modules.length == 0) {
    final DefaultMutableTreeNode n = new DefaultMutableTreeNode(
      Resources.getString("Chat.no_connections")); //$NON-NLS-1$
    n.setAllowsChildren(false);
  }
  else {
    for (ServerStatus.ModuleSummary s : modules) {
      m.insertNodeInto(createNode(s), root, root.getChildCount());
    }
  }

  // append total number of players on server to root node
  root.setUserObject(
    Resources.getString(Resources.VASSAL) + " (" + totalPlayers + ")");
}
项目:AgentWorkbench    文件:ThreadInfoStorageTree.java   
/**
 * Sort nodes descending.
 *
 * @param node the node
 * @param treeModel the tree model
 */
private void sortNodesDescending(DefaultMutableTreeNode node, DefaultTreeModel treeModel) {
    boolean unsorted = true;

    while (unsorted) {
        unsorted = false;
        for (int i = 0; i < node.getChildCount() - 1; i++) {
            ThreadInfoStorageAgent tiaFirst = (ThreadInfoStorageAgent) ((DefaultMutableTreeNode) node.getChildAt(i)).getUserObject();
            ThreadInfoStorageAgent tiaSecond = (ThreadInfoStorageAgent) ((DefaultMutableTreeNode) node.getChildAt(i+1)).getUserObject();

            if (tiaFirst.getXYSeriesMap().get("TOTAL_CPU_SYSTEM_TIME").getMaxY() < tiaSecond.getXYSeriesMap().get("TOTAL_CPU_SYSTEM_TIME").getMaxY()) {
                treeModel.insertNodeInto((MutableTreeNode) node.getChildAt(i+1), node, i);
                unsorted = true;
            }
        }
    }
}
项目:rapidminer    文件:PlotConfigurationTreeModel.java   
private void rangeAxisConfigAdded(int index, RangeAxisConfig rangeAxis) {
    RangeAxisConfigTreeNode newChild = new RangeAxisConfigTreeNode(rangeAxis);
    insertNodeInto(newChild, (MutableTreeNode) root, index + NUMBER_OF_PERMANENT_DIMENSIONS);

    List<ValueSource> rangeAxisValueSources = rangeAxis.getValueSources();
    if (rangeAxis.getValueSources().size() > 0) {
        int idx = 0;
        // add new value source child nodes
        for (ValueSource source : rangeAxisValueSources) {
            valueSourceAdded(idx, source, rangeAxis);
            ++idx;
        }
    } else {

        // change selection path
        TreePath pathToNewChild = new TreePath(getPathToRoot(newChild));
        makeVisibleAndSelect(pathToNewChild);

    }
}
项目:rapidminer    文件:PlotConfigurationTreeModel.java   
private void rangeAxisConfigRemoved(int index, RangeAxisConfig rangeAxis) {
    removeNodeFromParent((MutableTreeNode) root.getChildAt(index + NUMBER_OF_PERMANENT_DIMENSIONS));

    reload();
    plotConfigTree.expandAll();

    // Acquire new selection element
    int childCount = root.getChildCount();
    Object newSelection = null;

    if (childCount > NUMBER_OF_PERMANENT_DIMENSIONS) {
        newSelection = root.getChildAt(childCount - 1);
    } else {
        newSelection = root;
    }

    // change selection path
    TreePath path = new TreePath(getPathToRoot((TreeNode) newSelection));
    makeVisibleAndSelect(path);
}
项目:call-IDE    文件:Parser.java   
/**
 * A method to check whether the file has a main method in it or not
 * @param file a parameter to take the file to check
 * @return true if the file has a main method; false, if it hasn't
 */
public boolean hasMain( File file) {
    int index = getRow( file);
    if (index != -1) {
        MutableTreeNode node = ((MutableTreeNode) rootNode.getChildAt(index));
        if (node instanceof ClassNode) {
            for (int i = 0; i < ((ClassNode) node).getChildCount(); i++) {
                TreeNode treeNode = (((ClassNode) node).getChildAt(i));
                if (treeNode instanceof MethodNode) {
                    MethodDeclaration metDec = ((MethodNode) treeNode).metDec;
                    if (metDec.getNameAsString().equals("main") &&
                        metDec.isPublic() && metDec.isStatic()) {
                        ArrayList<Parameter> parameters = new ArrayList<Parameter>(metDec.getParameters());
                        if (parameters.size() == 1 && parameters.get(0).toString().startsWith("String[]"))
                            return true;
                    }
                }
            }
        }
    }
    return false;
}
项目:ISO8583    文件:SortTreeHelper.java   
public static void sort(DefaultMutableTreeNode parent) {
    int n = parent.getChildCount();
    for (int i = 0; i < n - 1; i++) {
        int min = i;
        for (int j = i + 1; j < n; j++) {
            if (tnc.compare((DefaultMutableTreeNode) parent.getChildAt(min), (DefaultMutableTreeNode) parent.getChildAt(j)) > 0) {
                min = j;
            }
        }
        if (i != min) {
            MutableTreeNode a = (MutableTreeNode) parent.getChildAt(i);
            MutableTreeNode b = (MutableTreeNode) parent.getChildAt(min);
            parent.insert(b, i);
            parent.insert(a, min);

            updateTree = true;
        }
    }
}
项目:JavaGraph    文件:DisplayTreeNode.java   
/**
 * Insert child node using a sorting based on the name of the child node (toString)
 * Uses a natural ordering sort
 * @param child Child node to insert.
 */
public void insertSorted(MutableTreeNode child) {
    Comparator<TreeNode> comparator = this.comparator;
    // binary search for the right position to insert
    int lower = 0;
    int upper = getChildCount();
    while (lower < upper) {
        int mid = (lower + upper) / 2;
        TreeNode midChild = getChildAt(mid);
        if (comparator.compare(child, midChild) < 0) {
            upper = mid;
        } else {
            lower = mid + 1;
        }
    }
    insert(child, lower);
}
项目:Equella    文件:BrowseFinder.java   
@SuppressWarnings("unchecked")
public void insertInOrder(MutableTreeNode newChild)
{
    if( !Check.isEmpty(children) )
    {
        List<MutableTreeNode> mtns = new ArrayList<MutableTreeNode>(children);
        mtns.add(newChild);
        Collections.sort(mtns, new NumberStringComparator<MutableTreeNode>());

        removeAllChildren();
        for( MutableTreeNode mtn : mtns )
        {
            add(mtn);
        }
    }
    else
    {
        add(newChild);
    }
}
项目:ISO8583    文件:SortTreeHelper.java   
public static void sort(DefaultMutableTreeNode parent) {
    int n = parent.getChildCount();
    for (int i = 0; i < n - 1; i++) {
        int min = i;
        for (int j = i + 1; j < n; j++) {
            if (tnc.compare((DefaultMutableTreeNode) parent.getChildAt(min), (DefaultMutableTreeNode) parent.getChildAt(j)) > 0) {
                min = j;
            }
        }
        if (i != min) {
            MutableTreeNode a = (MutableTreeNode) parent.getChildAt(i);
            MutableTreeNode b = (MutableTreeNode) parent.getChildAt(min);
            parent.insert(b, i);
            parent.insert(a, min);

            updateTree = true;
        }
    }
}
项目:spmf    文件:ShowTrie.java   
/**
 * Method to display graphically the Trie by means of a TreeModel
 * @param model TreeModel when we want to insert the Trie nodes
 * @param p TreeNode for the TreeModel
 */
private static void display(Trie frequentAtomsTrie, DefaultTreeModel model, MutableTreeNode p) {
    List<TrieNode> nodes = frequentAtomsTrie.nodes;
    if (nodes != null) {
        //For each node
        for (int i = 0; i < nodes.size(); i++) {
            TrieNode node = nodes.get(i);
            Trie child = node.getChild();

            //We create a new TreeNode composed of the pair and the list of appearances
            DefaultMutableTreeNode currentNode = new DefaultMutableTreeNode(node.getPair().toString()+" ("+child.getSupport()+")");
            //And we insert it in the TreeModel
            model.insertNodeInto(currentNode, p, i);
            //And we go on doing the same process with the child
            j++;
            if(j <3) {
                display(child, model, currentNode);
            }
            j--;
        }
    }
}
项目:spmf    文件:Trie.java   
/**
 * Method to display graphically the Trie by means of a TreeModel
 * @param model TreeModel when we want to insert the Trie nodes
 * @param p TreeNode for the TreeModel
 */
private void display(DefaultTreeModel model, MutableTreeNode p) {

    if (nodes != null) {
        //For each node
        for (int i = 0; i < nodes.size(); i++) {
            TrieNode node = nodes.get(i);
            Trie child = node.getChild();

            //We create a new TreeNode composed of the pair and the list of appearances
            DefaultMutableTreeNode currentNode = new DefaultMutableTreeNode(node.getPair().toString() + child.appearingIn);
            //And we insert it in the TreeModel
            model.insertNodeInto(currentNode, p, i);
            //And we go on doing the same process with the child
            child.display(model, currentNode);
        }
    }
}
项目:XM-Miner    文件:ServerDirectoryTreeModel.java   
public ServerDirectoryTreeModel (MutableTreeNode root, DirectoryType[] dList)
       {
               super(root);
               int currentIndex = 0;
               dirList = dList;
/*
  System.out.println("create directory list .................");
  for (int i=0; i<dList.length; i++) {
      System.out.print("[ " + i + " ] " + dList[i].nodeName);
      for (int j=0; j<dList[i].childnodeNames.length; j++)
        System.out.print(":" + dList[i].childnodeNames[j]);
      System.out.println("");
  }
*/
               for (int i=0; i<dirList[0].childnodeNames.length; i++) {
                 currentIndex = addNewNode(root, dirList[0].childnodeNames[i], currentIndex);
               }
       }
项目:taxonaut    文件:UnitedNameTreeNode.java   
public void insert(MutableTreeNode newChild, int childIndex)
   {
if(newChild == null)
    return;

if(mappedNodes == null) {
    mappedNodes = createNodeMap();
}
else if(mappedNodes.indexOf(newChild) != -1)
    return;

super.insert(newChild, childIndex);

if (newChild instanceof NameTreeNode)
    mappedNodes.add((NameTreeNode)newChild);
   }
项目:taxonaut    文件:AbstractNameTreeNode.java   
public void setParent(MutableTreeNode newParent)
   {
super.setParent(newParent);
setToolTipText(null);
if(isLeaf())
    return;

Enumeration<?> descendants = breadthFirstEnumeration();
while(descendants.hasMoreElements()) {
    MutableTreeNode descendant = 
    (MutableTreeNode)descendants.nextElement();
    if(descendant instanceof AbstractNameTreeNode) {
    ((AbstractNameTreeNode<?>)descendant).setToolTipText(null);
    }
}
   }
项目:taxonaut    文件:UnitedNameTreeModel.java   
protected void removeAllChildren(MutableTreeNode parentNode,
                 DefaultTreeModel tree)
   {
Enumeration<?> enm = parentNode.children();
MutableTreeNode[] toRemove =
    new MutableTreeNode[parentNode.getChildCount()];

int i = 0;
while(enm.hasMoreElements()) {
    toRemove[i++] =
    (MutableTreeNode)enm.nextElement();
}
for(i = 0; i < toRemove.length; i++) {
    tree.removeNodeFromParent(toRemove[i]);
    toRemove[i] = null;
}
toRemove = null;
   }
项目:tda    文件:SunJDKParser.java   
private boolean checkForDuplicateThreadItem(Map directChildMap, DefaultMutableTreeNode node1) {
    ThreadInfo mi1 = (ThreadInfo) node1.getUserObject();
    String name1 = mi1.getName();

    for (Iterator iter2 = directChildMap.entrySet().iterator(); iter2.hasNext();) {
        DefaultMutableTreeNode node2 = (DefaultMutableTreeNode) ((Map.Entry) iter2.next()).getValue();
        if (node1 == node2) {
            continue;
        }

        ThreadInfo mi2 = (ThreadInfo) node2.getUserObject();
        if (name1.equals(mi2.getName()) && node2.getChildCount() > 0) {
            node1.add((MutableTreeNode) node2.getFirstChild());
            iter2.remove();
            return true;
        }
    }

    return false;
}
项目:BlocktopographPC-GUI    文件:NBTNode.java   
@Override
public void remove(MutableTreeNode removedNode) {
    if (removedNode instanceof NBTNode) {
        Tag removedTag = ((NBTNode) removedNode).getTag();

        switch (selfTag.getType()) {
            case COMPOUND:
                ((CompoundTag) selfTag).getValue().remove(removedTag);
                break;
            case LIST:
                ((ListTag) selfTag).getValue().remove(removedTag);
                break;
        }
    }

    super.remove(removedNode);
}
项目:SporeModder    文件:TreeNode.java   
@Override
public MutableTreeNode fillHierarchyTree(DefaultTreeModel model, MutableTreeNode parent, int index) {
    super.fillHierarchyTree(model, parent, index);

    if (!childrenNodes.isEmpty()) {
        int ind = 0;

        for (int i = 0; i < childrenNodes.size(); i++) {
            if (childrenNodes.get(i) != null) {
                childrenNodes.get(i).fillHierarchyTree(model, node, ind++);
            }
        }
    }

    return node;
}
项目:SporeModder    文件:Window.java   
@Override
public MutableTreeNode fillHierarchyTree(DefaultTreeModel model, MutableTreeNode parent, int index) {
    if (isLayoutWindow) {
        node = new DefaultMutableTreeNode(this);
        model.setRoot(node);
    }
    else {
        super.fillHierarchyTree(model, parent, index);
    }

    int ind = 0;

    for (int i = 0; i < modifiers.size(); i++) {
        if (modifiers.get(i) != null) {
            modifiers.get(i).fillHierarchyTree(model, node, ind++);
        }
    }

    for (int i = 0; i < children.size(); i++) {
        if (children.get(i) != null) {
            children.get(i).fillHierarchyTree(model, node, ind++);
        }
    }

    return node;
}
项目:SporeModder    文件:WinTreeView.java   
@Override
public MutableTreeNode fillHierarchyTree(DefaultTreeModel model, MutableTreeNode parent, int index) {
    super.fillHierarchyTree(model, parent, index);

    if (!childrenNodes.isEmpty()) {
        int ind = 0;

        for (int i = 0; i < childrenNodes.size(); i++) {
            if (childrenNodes.get(i) != null) {
                childrenNodes.get(i).fillHierarchyTree(model, node, ind++);
            }
        }
    }

    return node;
}
项目:rapidminer-studio    文件:PlotConfigurationTreeModel.java   
private void rangeAxisConfigAdded(int index, RangeAxisConfig rangeAxis) {
    RangeAxisConfigTreeNode newChild = new RangeAxisConfigTreeNode(rangeAxis);
    insertNodeInto(newChild, (MutableTreeNode) root, index + NUMBER_OF_PERMANENT_DIMENSIONS);

    List<ValueSource> rangeAxisValueSources = rangeAxis.getValueSources();
    if (rangeAxis.getValueSources().size() > 0) {
        int idx = 0;
        // add new value source child nodes
        for (ValueSource source : rangeAxisValueSources) {
            valueSourceAdded(idx, source, rangeAxis);
            ++idx;
        }
    } else {

        // change selection path
        TreePath pathToNewChild = new TreePath(getPathToRoot(newChild));
        makeVisibleAndSelect(pathToNewChild);

    }
}
项目:rapidminer-studio    文件:PlotConfigurationTreeModel.java   
private void rangeAxisConfigRemoved(int index, RangeAxisConfig rangeAxis) {
    removeNodeFromParent((MutableTreeNode) root.getChildAt(index + NUMBER_OF_PERMANENT_DIMENSIONS));

    reload();
    plotConfigTree.expandAll();

    // Acquire new selection element
    int childCount = root.getChildCount();
    Object newSelection = null;

    if (childCount > NUMBER_OF_PERMANENT_DIMENSIONS) {
        newSelection = root.getChildAt(childCount - 1);
    } else {
        newSelection = root;
    }

    // change selection path
    TreePath path = new TreePath(getPathToRoot((TreeNode) newSelection));
    makeVisibleAndSelect(path);
}
项目:tinyMediaManager    文件:TvShowSeasonTreeNode.java   
@SuppressWarnings("unchecked")
@Override
public void insert(MutableTreeNode newChild, int childIndex) {
  if (this.children != null) {
    int index = Collections.binarySearch(this.children, newChild, nodeComparator);
    if (index < 0) {
      super.insert(newChild, -index - 1);
    }
    else if (index >= 0) {
      super.insert(newChild, index);
    }
  }
  else {
    super.insert(newChild, childIndex);
  }
}
项目:ultimate-pastebin-intellij-plugin    文件:PasteNodeUtil.java   
/**
 * <p>Creates a {@link MutableTreeNode} representing a {@link Paste} and its infos, wrapping the data in {@link PasteNode} and {@link PasteInfoNode}</p>
 *
 * @param paste The {@link Paste} used to create the nodes.
 * @return a {@link MutableTreeNode} with the info.
 */
public static MutableTreeNode createNodeForPaste(Paste paste) {
  Objects.requireNonNull(paste);

  final DefaultMutableTreeNode pasteNode = new DefaultMutableTreeNode(new PasteNode(paste));

  pasteNode.add(new DefaultMutableTreeNode(new PasteInfoNode(getMessage("ultimatepastebin.paste.key", paste.getKey()))));
  pasteNode.add(new DefaultMutableTreeNode(new PasteInfoNode(getMessage("ultimatepastebin.paste.url", paste.getUrl()))));
  pasteNode.add(new DefaultMutableTreeNode(new PasteInfoNode(getMessage("ultimatepastebin.paste.visibility", paste.getVisibility().name()))));
  pasteNode.add(new DefaultMutableTreeNode(new PasteInfoNode(getMessage("ultimatepastebin.paste.createddate", formatDateTime(paste.getLocalPasteDate())))));
  pasteNode.add(new DefaultMutableTreeNode(new PasteInfoNode(getMessage("ultimatepastebin.paste.expiration", paste.getExpiration().name()))));
  pasteNode.add(new DefaultMutableTreeNode(new PasteInfoNode(getMessage("ultimatepastebin.paste.expirationdate", paste.getExpiration() == NEVER ? getMessage("ultimatepastebin.paste.expiration.never") : formatDateTime(paste.getLocalExpirationDate())))));
  pasteNode.add(new DefaultMutableTreeNode(new PasteInfoNode(getMessage("ultimatepastebin.paste.views", paste.getHits()))));
  pasteNode.add(new DefaultMutableTreeNode(new PasteInfoNode(getMessage("ultimatepastebin.paste.highlight", paste.getHighLight().name()))));

  return pasteNode;
}
项目:ultimate-pastebin-intellij-plugin    文件:PasteTreeRenderer.java   
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
  Component component = super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);

  if (component instanceof WrappingIconPanel && value instanceof MutableTreeNode) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;

    // When is the root, i return, because there is no need
    // to do anything, the root isn't being shown anyway
    if (node.isRoot())
      return component;

    updateIcon((WrappingIconPanel) component, node);
  }

  return component;
}
项目:bigtable-sql    文件:HelpViewerWindow.java   
public void add(MutableTreeNode node)
{
    super.add(node);
    if (node instanceof DocumentNode)
    {
        final DocumentNode dn = (DocumentNode) node;
        final URL docURL = dn.getURL();
        if (docURL != null)
        {
            String docTitle = dn.toString();
            if (StringUtils.isEmpty(docTitle))
            {
                docTitle = docURL.toExternalForm();
            }
            _docTitles.add(docTitle);
            _docURLs.add(docURL);
        }
    }
}
项目:thread-dump-analysis    文件:SunJDKParser.java   
private boolean checkForDuplicateThreadItem(Map directChildMap, DefaultMutableTreeNode node1) {
    ThreadInfo mi1 = (ThreadInfo) node1.getUserObject();
    String name1 = mi1.getName();

    for (Iterator iter2 = directChildMap.entrySet().iterator(); iter2.hasNext();) {
        DefaultMutableTreeNode node2 = (DefaultMutableTreeNode) ((Map.Entry) iter2.next()).getValue();
        if (node1 == node2) {
            continue;
        }

        ThreadInfo mi2 = (ThreadInfo) node2.getUserObject();
        if (name1.equals(mi2.getName()) && node2.getChildCount() > 0) {
            node1.add((MutableTreeNode) node2.getFirstChild());
            iter2.remove();
            return true;
        }
    }

    return false;
}
项目:swingx    文件:PainterDemo.java   
private MutableTreeNode createGlossPainterDemos() {
    DefaultMutableTreeNode node = createInfoNode("Gloss Painter Demos",
            null);

    RectanglePainter rp = new RectanglePainter(20, 20, 20,
            20, 20, 20);
    rp.setFillPaint(Color.RED);
    rp.setBorderPaint(Color.RED.darker());
    rp.setStyle(RectanglePainter.Style.BOTH);
    rp.setBorderWidth(5);
    rp.setAntialiasing(true);
    CompoundPainter<Object> cp = new CompoundPainter<Object>(rp, new GlossPainter());
    node.add(createInfoNode("Gloss on top of rectangle", cp));

    rp = new RectanglePainter(20, 20, 20, 20, 20, 20, true,
            Color.RED, 5f, Color.RED.darker());
    rp.setAntialiasing(true);
    cp = new CompoundPainter<Object>(rp, new GlossPainter(GlossPosition.BOTTOM));
    node.add(createInfoNode("Gloss on bottom of rectangle", cp));

    return node;
}
项目:incubator-taverna-engine    文件:AbstractIterationStrategyNode.java   
@Override
public synchronized void insert(MutableTreeNode child, int index) {
    if (!getAllowsChildren())
        throw new IllegalStateException("Node does not allow children");
    if (!(child instanceof IterationStrategyNode))
        throw new IllegalArgumentException(
                "Child not an instance of IterationStrategyNode: " + child);
    if (child == this)
        throw new IllegalArgumentException("Can't be it's own parent");

    // Check if it is already there (in case we'll just move it)
    int alreadyExistsIndex = children.indexOf(child);

    children.add(index, (IterationStrategyNode) child);

    if (alreadyExistsIndex > -1) {
        // Remove it from the old position
        if (index < alreadyExistsIndex
                && alreadyExistsIndex + 1 < children.size())
            alreadyExistsIndex++;
        children.remove(alreadyExistsIndex);
    }
    if (child.getParent() != this)
        child.setParent(this);
}
项目:mindraider    文件:TrashJPanel.java   
/**
 * Remove the currently selected node.
 */
public void removeCurrentNode() {
    TreePath currentSelection = tree.getSelectionPath();
    if (currentSelection != null) {
        DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) (currentSelection
                .getLastPathComponent());
        MutableTreeNode parent = (MutableTreeNode) (currentNode.getParent());
        if (parent != null) {
            treeModel.removeNodeFromParent(currentNode);
            return;
        }
    }

    // Either there was no selection, or the root was selected.
    toolkit.beep();
}
项目:aibench-project    文件:ClassBrowser.java   
MutableTreeNode makeNode(Map map, String nodeName) {
        DefaultMutableTreeNode root = new DefaultMutableTreeNode(nodeName);
        Iterator it = map.keySet().iterator();
        while (it.hasNext()) {
                String name = (String) it.next();
                Map val = (Map) map.get(name);
                if (val.size() == 0) {
                        DefaultMutableTreeNode leaf = new DefaultMutableTreeNode(name);
                        root.add(leaf);
                } else {
                        MutableTreeNode node = makeNode(val, name);
                        root.add(node);
                }
        }
        return root;
}
项目:HTML5_WebSite    文件:ChartTree.java   
private MutableTreeNode createGanttChartsNode() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode(
        "Gantt Charts"
    );

    DefaultMutableTreeNode n1 = new DefaultMutableTreeNode(
        new DemoDescription("edu.ucla.stat.SOCR.chart.demo.GanttDemo1", "GanttDemo1")
    );
    DefaultMutableTreeNode n2 = new DefaultMutableTreeNode(
        new DemoDescription("edu.ucla.stat.SOCR.chart.demo.GanttDemo2", "GanttDemo2")
    );

    root.add(n1);
    root.add(n2);

    return root;
}
项目:HTML5_WebSite    文件:ChartTree.java   
private MutableTreeNode createCrosshairChartsNode() {
      DefaultMutableTreeNode root = new DefaultMutableTreeNode("Crosshairs");

      DefaultMutableTreeNode n1 = new DefaultMutableTreeNode(
              new DemoDescription("edu.ucla.stat.SOCR.chart.demo.CrosshairDemo1", 
              "CrosshairDemo1"));
      DefaultMutableTreeNode n2 = new DefaultMutableTreeNode(
              new DemoDescription("edu.ucla.stat.SOCR.chart.demo.CrosshairDemo2", 
              "CrosshairDemo2"));
      DefaultMutableTreeNode n3 = new DefaultMutableTreeNode(
              new DemoDescription("edu.ucla.stat.SOCR.chart.demo.CrosshairDemo3", 
              "CrosshairDemo3"));
      DefaultMutableTreeNode n4 = new DefaultMutableTreeNode(
              new DemoDescription("edu.ucla.stat.SOCR.chart.demo.CrosshairDemo4", 
              "CrosshairDemo4"));

      root.add(n1);
//        root.add(n2);
      root.add(n3);
      root.add(n4);

      return root;
  }
项目:tinyMediaManager    文件:TvShowRootTreeNode.java   
@SuppressWarnings("unchecked")
@Override
public synchronized void insert(MutableTreeNode newChild, int childIndex) {
  if (this.children != null) {
    int index = Collections.binarySearch(this.children, newChild, nodeComparator);
    if (index < 0) {
      super.insert(newChild, -index - 1);
    }
    else if (index >= 0) {
      super.insert(newChild, index);
    }
  }
  else {
    super.insert(newChild, childIndex);
  }
}
项目:HTML5_WebSite    文件:ChartTree.java   
private MutableTreeNode createMarkersNode() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("Markers");
    DefaultMutableTreeNode n1 = new DefaultMutableTreeNode(
        new DemoDescription("edu.ucla.stat.SOCR.chart.demo.CategoryMarkerDemo1", 
        "CategoryMarkerDemo1"));
    DefaultMutableTreeNode n2 = new DefaultMutableTreeNode(
        new DemoDescription("edu.ucla.stat.SOCR.chart.demo.CategoryMarkerDemo2", 
        "CategoryMarkerDemo2"));
    DefaultMutableTreeNode n3 = new DefaultMutableTreeNode(
        new DemoDescription("edu.ucla.stat.SOCR.chart.demo.MarkerDemo1", "MarkerDemo1"));
    DefaultMutableTreeNode n4 = new DefaultMutableTreeNode(
        new DemoDescription("edu.ucla.stat.SOCR.chart.demo.MarkerDemo2", "MarkerDemo2"));
    root.add(n1);
    root.add(n2);
    root.add(n3);
    root.add(n4);
    return root;
}
项目:HTML5_WebSite    文件:ChartTree.java   
private MutableTreeNode createOrientationNode() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode(
        "Plot Orientation"
    );

    DefaultMutableTreeNode n1 = new DefaultMutableTreeNode(
        new DemoDescription(
            "edu.ucla.stat.SOCR.chart.demo.PlotOrientationDemo1", "PlotOrientationDemo1"
        )
    );
    DefaultMutableTreeNode n2 = new DefaultMutableTreeNode(
        new DemoDescription(
            "edu.ucla.stat.SOCR.chart.demo.PlotOrientationDemo2", "PlotOrientationDemo2"
        )
    );

    root.add(n1);
    root.add(n2);

    return root;
}
项目:tinyMediaManager    文件:TvShowTreeNode.java   
@SuppressWarnings("unchecked")
@Override
public void insert(MutableTreeNode newChild, int childIndex) {
  if (this.children != null) {
    int index = Collections.binarySearch(this.children, newChild, nodeComparator);
    if (index < 0) {
      super.insert(newChild, -index - 1);
    }
    else if (index >= 0) {
      super.insert(newChild, index);
    }
  }
  else {
    super.insert(newChild, childIndex);
  }
}
项目:incubator-netbeans    文件:HintsPanel.java   
public HintMetadata getSelectedHint() {
        TreePath selectionPath = errorTree.getSelectionModel().getSelectionPath();
        if (selectionPath==null) {
            return null;
}
        DefaultMutableTreeNode lastPathComponent = (DefaultMutableTreeNode) (MutableTreeNode) (TreeNode) selectionPath.getLastPathComponent();
        if (lastPathComponent!= null && lastPathComponent.getUserObject() instanceof HintMetadata)
            return (HintMetadata) lastPathComponent.getUserObject();
        return null;
    }
项目:incubator-netbeans    文件:PathsCustomizer.java   
@Override
public void intervalAdded(ListDataEvent e) {
    for (int i = e.getIndex1(); i >= e.getIndex0(); i--) {
        Object obj = listModel.getElementAt(i);
        if (obj instanceof ClassPathSupport.Item) {
            DefaultMutableTreeNode node = toTreeNode(obj);
            treeModel.insertNodeInto(node, (MutableTreeNode)treeModel.getRoot(), e.getIndex0());
            TreePath path = new TreePath(node.getPath());
            tree.setSelectionPath(path);
            tree.makeVisible(path);
        }
    }
}
项目:incubator-netbeans    文件:PathsCustomizer.java   
@Override
public void intervalAdded(ListDataEvent e) {
    for (int i = e.getIndex1(); i >= e.getIndex0(); i--) {
        Object obj = listModel.getElementAt(i);
        if (obj instanceof ClassPathSupport.Item) {
            DefaultMutableTreeNode node = toTreeNode(obj);
            treeModel.insertNodeInto(node, (MutableTreeNode)treeModel.getRoot(), e.getIndex0());
            TreePath path = new TreePath(node.getPath());
            tree.setSelectionPath(path);
            tree.makeVisible(path);
        }
    }
}