当前位置: 首页>>代码示例>>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;未经允许,请勿转载。