当前位置: 首页>>代码示例>>Java>>正文


Java DefaultMutableTreeNode.isLeaf方法代码示例

本文整理汇总了Java中javax.swing.tree.DefaultMutableTreeNode.isLeaf方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultMutableTreeNode.isLeaf方法的具体用法?Java DefaultMutableTreeNode.isLeaf怎么用?Java DefaultMutableTreeNode.isLeaf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.tree.DefaultMutableTreeNode的用法示例。


在下文中一共展示了DefaultMutableTreeNode.isLeaf方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: filterNodeByKey

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
 * Filter node by key.
 *
 * @param node the node
 * @param key the key
 */
private void filterNodeByKey(DefaultMutableTreeNode node, String key){
		
		Vector<DefaultMutableTreeNode> toDeleteVect= new Vector<DefaultMutableTreeNode>();
		
		@SuppressWarnings("unchecked")
		Enumeration<DefaultMutableTreeNode> e = node.breadthFirstEnumeration();
		if(e != null){
			while (e.hasMoreElements()){
				DefaultMutableTreeNode actualElement = e.nextElement();
				if (actualElement.isLeaf() == true && key.isEmpty() == false && actualElement.toString().toLowerCase().contains(key.toLowerCase()) == false) {
					//--- immediate removal invalidates the enumeration ---
	//				actualElement.removeFromParent();
					// --- remember for later removal ---
					toDeleteVect.add(actualElement); 
				}
				if(actualElement.isLeaf() == true && actualElement.toString().toLowerCase().contains(key.toLowerCase()) == true){
					//--- (re)expand collapsed parent if search string matches ---
					int level = actualElement.getLevel() -1;
					StringBuilder sb = new StringBuilder();
					sb.append(level -1).append(",");
					String levelString = sb.toString();
					if(expansionState.contains(levelString) == false){
						levelString = sb.append(level).append(",").toString();
						expansionState = expansionState.concat(levelString);
					}
				}
			}
		}
		//--- delete nodes ---
		for( int i=0; i < toDeleteVect.size(); i++){
			toDeleteVect.get(i).removeFromParent();
		}
	}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:40,代码来源:ThreadInfoStorageTree.java

示例3: sortThreads

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
public void sortThreads() {
	DefaultMutableTreeNode tempNode = (DefaultMutableTreeNode) copyNode((DefaultMutableTreeNode) getModel().getRoot());

	// --- save expansion state ---
	expansionState = saveExpansionState();

	// --- sort and update ---
	@SuppressWarnings("rawtypes")
	Enumeration e = tempNode.breadthFirstEnumeration();
	while (e.hasMoreElements()) {
		DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement();
		if (node.isLeaf() == true) {
			sortNodesDescending((DefaultMutableTreeNode) node.getParent(),
					(DefaultTreeModel) getModel());
		}
	}

	((DefaultTreeModel) getModel()).setRoot(tempNode);

	// --- restore expansion ---
	restoreExpansionState(expansionState);
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:23,代码来源:ThreadInfoStorageTree.java

示例4: itemSelected

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
 * @param e
 */
protected void itemSelected(MouseEvent e) {
 if (e.getClickCount() == 2) {
    	DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
     
     if (node != null) {
         if (node.isLeaf())
         	if (node.getParent() != null) {
          	if (node.getParent().toString().equals("graphs")) {
                  for (int i=0 ; i<observers.size() ; i++)
                      (observers.get(i)).graphSelected(node.toString());
              }
              else if (node.getParent().toString().equals("animations")) {
                  for (int i=0 ; i<observers.size() ; i++)
                      (observers.get(i)).animationSelected(node.toString());
              }
              else if (node.getParent().toString().equals("algorithms")) {
                  for (int i=0 ; i<observers.size() ; i++)
                      (observers.get(i)).algorithmSelected(node.toString());
              }
          }
  }
	}
}
 
开发者ID:guilhebl,项目名称:routerapp,代码行数:27,代码来源:NavigationView.java

示例5: valueChanged

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/** Required by TreeSelectionListener interface. */
public void valueChanged(TreeSelectionEvent e) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();

    if (node == null)
        return;

    Object nodeInfo = node.getUserObject();
    if (node.isLeaf()) {
        BookInfo book = (BookInfo) nodeInfo;
        displayURL(book.bookURL);
        if (DEBUG) {
            System.out.print(book.bookURL + ":  \n    ");
        }
    } else {
        displayURL(helpURL);
    }
    if (DEBUG) {
        System.out.println(nodeInfo.toString());
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:22,代码来源:TreeDemo.java

示例6: valueChanged

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/** Required by TreeSelectionListener interface. */
public void valueChanged(TreeSelectionEvent e) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode)
                       tree.getLastSelectedPathComponent();

    if (node == null) return;

    Object nodeInfo = node.getUserObject();
    if (node.isLeaf()) {
        BookInfo book = (BookInfo)nodeInfo;
        displayURL(book.bookURL);
        if (DEBUG) {
            System.out.print(book.bookURL + ":  \n    ");
        }
    } else {
        displayURL(helpURL); 
    }
    if (DEBUG) {
        System.out.println(nodeInfo.toString());
    }
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:22,代码来源:TreeDemo.java

示例7: 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

示例8: valueChanged

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
 * This function analyses a tree selection event and calls the
 * right methods to take care of building the requested unit's
 * details.
 *
 * @param event The incoming TreeSelectionEvent.
 */
@Override
public void valueChanged(TreeSelectionEvent event) {
    detailPanel.removeAll();
    DefaultMutableTreeNode node
        = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
    if (node != null) {
        if (node.isLeaf()) {
            OptionGroup group = (OptionGroup) node.getUserObject();
            for (Option option : group.getOptions()) {
                addOptionUI(option, editable && group.isEditable());
            }
        } else {
            tree.expandPath(event.getPath());
        }
    }
    detailPanel.revalidate();
    detailPanel.repaint();
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:26,代码来源:OptionGroupUI.java

示例9: copyNode

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
 * Gets a copy of DefaultMutableTreeNode.
 *
 * @param OriginNode the origin node
 * @return the object
 */
private Object copyNode(DefaultMutableTreeNode OriginNode){
    DefaultMutableTreeNode Copy = new DefaultMutableTreeNode(OriginNode.getUserObject());
    if(OriginNode.isLeaf()){
        return Copy;
    }else{
        int cc = OriginNode.getChildCount();
        for(int i=0;i<cc;i++){
            Copy.add((MutableTreeNode) copyNode((DefaultMutableTreeNode)OriginNode.getChildAt(i)));
        }
        return Copy;
    }
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:19,代码来源:ThreadInfoStorageTree.java

示例10: valueChanged

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/** Required by TreeSelectionListener interface. */
@Override
public void valueChanged(TreeSelectionEvent e) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();

    if (node != null && node.isLeaf()) {
        int pos = workspace.getDividerLocation();
        workspace.setTopComponent((JPanel) node.getUserObject());
        workspace.setDividerLocation(pos);
    }
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:12,代码来源:SmileDemo.java

示例11: expandTree

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private void expandTree(JTree tree) {
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getModel()
            .getRoot();
    Enumeration e = root.breadthFirstEnumeration();
    while (e.hasMoreElements()) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement();
        if (node.isLeaf()) {
            continue;
        }
        int row = tree.getRowForPath(new TreePath(node.getPath()));
        tree.expandRow(row);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:LastNodeLowerHalfDrop.java

示例12: traverseTree

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
public void traverseTree(DefaultMutableTreeNode root, JMenu rootMenu) {
	for (Enumeration e = root.children(); e.hasMoreElements(); ) {
		DefaultMutableTreeNode child = (DefaultMutableTreeNode)e.nextElement();
		if ( child.isLeaf() ) {
			JMenuItem childMI = new JMenuItem(child.toString());
			rootMenu.add(childMI);
			childMI.addActionListener(this);
		} else {
			JMenu nextRootMenu = new JMenu(child.toString());
			traverseTree(child, nextRootMenu);
			rootMenu.add(nextRootMenu);
		}
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:15,代码来源:AccessAllData.java


注:本文中的javax.swing.tree.DefaultMutableTreeNode.isLeaf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。