當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultMutableTreeNode.depthFirstEnumeration方法代碼示例

本文整理匯總了Java中javax.swing.tree.DefaultMutableTreeNode.depthFirstEnumeration方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultMutableTreeNode.depthFirstEnumeration方法的具體用法?Java DefaultMutableTreeNode.depthFirstEnumeration怎麽用?Java DefaultMutableTreeNode.depthFirstEnumeration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.tree.DefaultMutableTreeNode的用法示例。


在下文中一共展示了DefaultMutableTreeNode.depthFirstEnumeration方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: filterNode

import javax.swing.tree.DefaultMutableTreeNode; //導入方法依賴的package包/類
/**
 * Removes non-agents from DefaultMutableTreeNode.
 *
 * @param node the node
 * @param key the key
 */
private void filterNode(DefaultMutableTreeNode node){
	
	Vector<DefaultMutableTreeNode> toDeleteVect= new Vector<DefaultMutableTreeNode>();
	
	@SuppressWarnings("unchecked")
	Enumeration<DefaultMutableTreeNode> e = node.depthFirstEnumeration();
	if(e != null){
		while (e.hasMoreElements()){
			DefaultMutableTreeNode actualElement = e.nextElement();
			if (actualElement.isLeaf() == true && matchAgentClass(actualElement) == false) {
				//--- immediate removal invalidates the enumeration ---
//				actualElement.removeFromParent();
				// --- remember for later removal ---
				toDeleteVect.add(actualElement); 
			}
		}
	}
	//--- delete nodes ---
	for( int i=0; i < toDeleteVect.size(); i++){
		toDeleteVect.get(i).removeFromParent();
	}
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:29,代碼來源:ThreadInfoStorageTree.java

示例2: getAllItems

import javax.swing.tree.DefaultMutableTreeNode; //導入方法依賴的package包/類
private List<Item> getAllItems() {
    List<Item> result = new LinkedList<FmtSpaces.Item>();
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) ((FmtSpaces) panel).model.getRoot();
    Enumeration children = root.depthFirstEnumeration();
    while( children.hasMoreElements() ) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) children.nextElement();
        Object o = node.getUserObject();
        if (o instanceof Item) {
            Item item = (Item) o;
            if ( item.items == null || item.items.length == 0 ) {
                result.add( item );
            }
        }
    }            
    return result;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:FmtSpaces.java

示例3: sortTree

import javax.swing.tree.DefaultMutableTreeNode; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public static void sortTree(PnlGuiConfig pnlGuiConfig, DefaultMutableTreeNode root, JTree treeTypes) {
	if (root != null) {
		Enumeration e = root.depthFirstEnumeration();
		while (e.hasMoreElements()) {
			DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement();
			if (!node.isLeaf()) {
				sort(node);   //selection sort
			}
		}
		
		//Atualizando a arvore
		if (updateTree) {
			TreePath treePath = treeTypes.getSelectionPath();
			DefaultTreeModel model = (DefaultTreeModel) treeTypes.getModel();
			model.reload();
			treeTypes.setSelectionPath(treePath);
			updateTree = false;
		}

		pnlGuiConfig.getPnlFieldCondition().ckDynamicClick();
	}
}
 
開發者ID:adelbs,項目名稱:ISO8583,代碼行數:24,代碼來源:SortTreeHelper.java

示例4: findNode

import javax.swing.tree.DefaultMutableTreeNode; //導入方法依賴的package包/類
public DefaultMutableTreeNode findNode(DefaultMutableTreeNode root, int id) {
    Enumeration<DefaultMutableTreeNode> e = root.depthFirstEnumeration();
    while (e.hasMoreElements()) {
        DefaultMutableTreeNode node = e.nextElement();
        if (node.getUserObject() instanceof HTTP2SampleResult){
      HTTP2SampleResult http2NodeResult= (HTTP2SampleResult) node.getUserObject();
      if (http2NodeResult.getId()==id) {
          return node;
      }
        }
    }
    return null;
}
 
開發者ID:Blazemeter,項目名稱:jmeter-bzm-plugins,代碼行數:14,代碼來源:ViewResultsFullVisualizer.java

示例5: buildTree

import javax.swing.tree.DefaultMutableTreeNode; //導入方法依賴的package包/類
/**
 * Builds the JTree which represents the navigation menu and then returns it
 *
 * @return The navigation tree.
 */
private JTree buildTree() {
    String name = Messages.message("colopedia");
    DefaultMutableTreeNode root
        = new DefaultMutableTreeNode(new ColopediaTreeItem(null, null, name, null));

    FreeColClient fcc = getFreeColClient();
    new TerrainDetailPanel(fcc, this).addSubTrees(root);
    new ResourcesDetailPanel(fcc, this).addSubTrees(root);
    new GoodsDetailPanel(fcc, this).addSubTrees(root);
    new UnitDetailPanel(fcc, this).addSubTrees(root);
    new BuildingDetailPanel(fcc, this).addSubTrees(root);
    new FatherDetailPanel(fcc, this).addSubTrees(root);
    new NationDetailPanel(fcc, this).addSubTrees(root);
    new NationTypeDetailPanel(fcc, this).addSubTrees(root);
    new ConceptDetailPanel(fcc, this).addSubTrees(root);

    DefaultTreeModel treeModel = new DefaultTreeModel(root);
    tree = new JTree(treeModel) {
            @Override
            public Dimension getPreferredSize() {
                return new Dimension(
                    (int)(200 * getImageLibrary().getScaleFactor()),
                    super.getPreferredSize().height);
            }
        };
    tree.setRootVisible(false);
    tree.setCellRenderer(new ColopediaTreeCellRenderer());
    tree.setOpaque(false);
    tree.addTreeSelectionListener(this);

    listPanel.add(tree);
    Enumeration allNodes = root.depthFirstEnumeration();
    while (allNodes.hasMoreElements()) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) allNodes.nextElement();
        ColopediaTreeItem item = (ColopediaTreeItem) node.getUserObject();
        nodeMap.put(item.getId(), node);
    }
    return tree;
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:45,代碼來源:ColopediaPanel.java

示例6: select

import javax.swing.tree.DefaultMutableTreeNode; //導入方法依賴的package包/類
private boolean select(DefaultMutableTreeNode parent, Predicate<IEntity> selectionPredicate) {
  if (parent.getChildCount() == 0) {
    return false;
  }

  Enumeration en = parent.depthFirstEnumeration();
  while (en.hasMoreElements()) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) en.nextElement();
    IEntity ent = null;
    if (node.getUserObject() instanceof IconTreeListItem) {
      IconTreeListItem iconItem = (IconTreeListItem) node.getUserObject();
      if (iconItem.getUserObject() instanceof IEntity) {
        ent = (IEntity) iconItem.getUserObject();
      }
    } else if (node.getUserObject() instanceof IEntity) {
      ent = (IEntity) node.getUserObject();
    }

    if (ent == null) {
      continue;
    }

    if (selectionPredicate.test(ent)) {
      final TreePath newSelection = new TreePath(node.getPath());
      if (this.tree.getSelectionPath() != null && this.tree.getSelectionPath().equals(newSelection)) {
        continue;
      }

      this.tree.setSelectionPath(newSelection);
      TreePath path = this.tree.getSelectionPath();
      if (path == null || !this.tree.isVisible()) {
        return false;
      }

      Rectangle bounds = this.tree.getPathBounds(path);
      if (bounds == null) {
        return false;
      }
      // set the height to the visible height to force the node to top 
      bounds.height = this.tree.getVisibleRect().height;
      this.tree.scrollRectToVisible(bounds);
      return true;
    }
  }

  return false;
}
 
開發者ID:gurkenlabs,項目名稱:litiengine,代碼行數:48,代碼來源:MapSelectionPanel.java


注:本文中的javax.swing.tree.DefaultMutableTreeNode.depthFirstEnumeration方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。