List of usage examples for javax.swing.tree DefaultMutableTreeNode add
public void add(MutableTreeNode newChild)
newChild
from its parent and makes it a child of this node by adding it to the end of this node's child array. From source file:org.jfree.chart.demo.SuperDemo.java
private MutableTreeNode createMarkersNode() { DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode("Markers"); DefaultMutableTreeNode defaultmutabletreenode1 = new DefaultMutableTreeNode( new DemoDescription("CategoryMarkerDemo1", "CategoryMarkerDemo1.java")); DefaultMutableTreeNode defaultmutabletreenode2 = new DefaultMutableTreeNode( new DemoDescription("CategoryMarkerDemo2", "CategoryMarkerDemo2.java")); DefaultMutableTreeNode defaultmutabletreenode3 = new DefaultMutableTreeNode( new DemoDescription("MarkerDemo1", "MarkerDemo1.java")); DefaultMutableTreeNode defaultmutabletreenode4 = new DefaultMutableTreeNode( new DemoDescription("MarkerDemo2", "MarkerDemo2.java")); defaultmutabletreenode.add(defaultmutabletreenode1); defaultmutabletreenode.add(defaultmutabletreenode2); defaultmutabletreenode.add(defaultmutabletreenode3); defaultmutabletreenode.add(defaultmutabletreenode4); return defaultmutabletreenode; }
From source file:org.jfree.chart.demo.SuperDemo.java
private MutableTreeNode createMeterChartsNode() { DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode("Meter Charts"); DefaultMutableTreeNode defaultmutabletreenode1 = new DefaultMutableTreeNode( new DemoDescription("MeterChartDemo1", "MeterChartDemo1.java")); DefaultMutableTreeNode defaultmutabletreenode2 = new DefaultMutableTreeNode( new DemoDescription("MeterChartDemo2", "MeterChartDemo2.java")); DefaultMutableTreeNode defaultmutabletreenode3 = new DefaultMutableTreeNode( new DemoDescription("MeterChartDemo3", "MeterChartDemo3.java")); DefaultMutableTreeNode defaultmutabletreenode4 = new DefaultMutableTreeNode( new DemoDescription("ThermometerDemo1", "ThermometerDemo1.java")); defaultmutabletreenode.add(defaultmutabletreenode1); defaultmutabletreenode.add(defaultmutabletreenode2); defaultmutabletreenode.add(defaultmutabletreenode3); defaultmutabletreenode.add(defaultmutabletreenode4); return defaultmutabletreenode; }
From source file:gov.nih.nci.ncicb.cadsr.contexttree.service.impl.CDEBrowserTreeServiceImpl.java
/** * This method iterate all the classifications of a form and add * the corresponding branch of the cs tree to the root node * * @param currForm the Form that needs to be attached to the root node * @param currCSMap a Map to find a tree node given a cscsi id, this tree * node is used as a master copy for each protocol to create its own * cs tree/*from w w w . ja v a2 s. c om*/ * @param treeNodeMap a Map used to avoid copy the orginal node more than one * time. For each given Webnode id, this Map returns the corresponding * copy of that node that exist in the copy * @param newNode the form node to be added to the cs tree * @param rootNode the tree node for the branch to attach to * @param idGen the id genator used to get unique id when copy a node from * original tree */ private void copyCSTree(Form currForm, Map currCSMap, Map treeNodeMap, DefaultMutableTreeNode newNode, DefaultMutableTreeNode rootNode, TreeIdGenerator idGen) { //if the cs map does not exist for any reason, simplely add the new to the root if (currCSMap == null) rootNode.add(newNode); else { Iterator csIter = currForm.getClassifications().iterator(); while (csIter.hasNext()) { String cscsiId = ((ClassSchemeItem) csIter.next()).getCsCsiIdseq(); DefaultMutableTreeNode origTreeNode = (DefaultMutableTreeNode) currCSMap.get(cscsiId); WebNode origWebNode = (WebNode) origTreeNode.getUserObject(); DefaultMutableTreeNode treeNodeCopy = (DefaultMutableTreeNode) treeNodeMap.get(origWebNode.getId()); if (treeNodeCopy == null) { treeNodeCopy = new DefaultMutableTreeNode(origWebNode.copy(idGen.getNewId())); treeNodeMap.put(origWebNode.getId(), treeNodeCopy); } treeNodeCopy.add(newNode); DefaultMutableTreeNode pTreeNode = origTreeNode; DefaultMutableTreeNode cTreeNode = treeNodeCopy; //copy this branch of the cs tree all the way until one parent node is //found in the new tree while (pTreeNode.getParent() != null) { DefaultMutableTreeNode parentTreeNode = (DefaultMutableTreeNode) pTreeNode.getParent(); WebNode pWebNode = (WebNode) parentTreeNode.getUserObject(); DefaultMutableTreeNode pNodeCopy = (DefaultMutableTreeNode) treeNodeMap.get(pWebNode.getId()); if (pNodeCopy == null) { pNodeCopy = new DefaultMutableTreeNode(pWebNode.copy(idGen.getNewId())); treeNodeMap.put(pWebNode.getId(), pNodeCopy); pNodeCopy.add(cTreeNode); pTreeNode = parentTreeNode; cTreeNode = pNodeCopy; } else { // when one parent node is found in the new tree, attach the copy pNodeCopy.add(cTreeNode); return; } } rootNode.add(cTreeNode); } } }
From source file:edu.ku.brc.specify.tasks.subpane.security.SecurityAdminPane.java
/** * @param session//from w w w. ja va 2 s . c o m * @param instNode * @param institution */ private void addDivisionsRecursively(final DataProviderSessionIFace session, final DefaultMutableTreeNode instNode, final Institution institution) { // sort divisions TreeSet<Division> divisions = new TreeSet<Division>(institution.getDivisions()); for (Division division : divisions) { //log.debug("Adding Division "+division.getName()); for (Discipline discipline : division.getDisciplines()) { //log.debug(" Adding Discipline "+discipline.getName()); DataModelObjBaseWrapper dmob = new DataModelObjBaseWrapper(discipline); DefaultMutableTreeNode discNode = new DefaultMutableTreeNode(dmob); instNode.add(discNode); addCollectionsRecursively(session, discNode, discipline); addGroup(session, discNode, discipline); } } }
From source file:org.jfree.chart.demo.SuperDemo.java
private MutableTreeNode createOverlaidChartsNode() { DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode("Overlaid Charts"); DefaultMutableTreeNode defaultmutabletreenode1 = new DefaultMutableTreeNode( new DemoDescription("OverlaidBarChartDemo1", "OverlaidBarChartDemo1.java")); DefaultMutableTreeNode defaultmutabletreenode2 = new DefaultMutableTreeNode( new DemoDescription("OverlaidBarChartDemo2", "OverlaidBarChartDemo2.java")); DefaultMutableTreeNode defaultmutabletreenode3 = new DefaultMutableTreeNode( new DemoDescription("OverlaidXYPlotDemo1", "OverlaidXYPlotDemo1.java")); DefaultMutableTreeNode defaultmutabletreenode4 = new DefaultMutableTreeNode( new DemoDescription("OverlaidXYPlotDemo2", "OverlaidXYPlotDemo2.java")); defaultmutabletreenode.add(defaultmutabletreenode1); defaultmutabletreenode.add(defaultmutabletreenode2); defaultmutabletreenode.add(defaultmutabletreenode3); defaultmutabletreenode.add(defaultmutabletreenode4); return defaultmutabletreenode; }
From source file:it.isislab.dmason.tools.batch.BatchWizard.java
private void createNodes(DefaultMutableTreeNode top, ArrayList<Param> paramList) { //generalParams = new DefaultMutableTreeNode("General Params"); //simParams = new DefaultMutableTreeNode("Simulation Params"); top.add(generalParams); top.add(simParams);/*from ww w.j a v a 2 s. c om*/ generalParams.add(new DefaultMutableTreeNode(new ParamFixed("Width", "int", 1, "100"))); generalParams.add(new DefaultMutableTreeNode(new ParamFixed("Height", "int", 1, "100"))); generalParams.add(new DefaultMutableTreeNode(new ParamFixed("MaxDistance", "int", 1, "100"))); generalParams.add(new DefaultMutableTreeNode(new ParamFixed("NumAgents", "int", 1, "15"))); generalParams.add(new DefaultMutableTreeNode(new ParamFixed("Rows", "int", 1, "1"))); generalParams.add(new DefaultMutableTreeNode(new ParamFixed("Columns", "int", 1, "2"))); generalParams.add(new DefaultMutableTreeNode(new ParamFixed("MaxStep", "long", 1, "1000"))); for (Param param : paramList) { //p = new DefaultMutableTreeNode(param); // p.add(new DefaultMutableTreeNode(param)); simParams.add(new DefaultMutableTreeNode(param)); } }
From source file:edu.ku.brc.specify.tasks.subpane.security.SecurityAdminPane.java
/** * Adds all institutions as nodes to the navigation tree. Adds children nodes recursively (divisions, * disciplines, collections, user groups, and users). * @param session Data provider session to be used to retrieve data objects * @param root Root of the tree to add children (institutions) to *///from w ww. java 2s .c o m private void addInstitutionsRecursively(final DataProviderSessionIFace session, final DefaultMutableTreeNode root) { // initialize hash of users that will be used to avoid creation of multiple instances of the same persisted user spUsers = new HashSet<SpecifyUser>(); // XXX Room for performance improvement: fetch all tree in the same query using HQL with OUTER LEFT JOIN FETCH List<Institution> institutions = session.getDataList(Institution.class); Collections.sort(institutions, new ComparatorByStringRepresentation<Institution>()); for (Institution institution : institutions) { DefaultMutableTreeNode instNode = new DefaultMutableTreeNode(new DataModelObjBaseWrapper(institution)); root.add(instNode); addDivisionsRecursively(session, instNode, institution); addGroup(session, instNode, institution); } }
From source file:edu.ku.brc.af.tasks.subpane.formeditor.ViewSetSelectorPanel.java
/** * @param viewDefs//from ww w . j av a 2 s . c o m */ protected void buildTreeModel(Vector<ViewDefIFace> viewDefs) { DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); DefaultMutableTreeNode root = new DefaultMutableTreeNode("ViewDefs"); //$NON-NLS-1$ model.setRoot(root); for (ViewDefIFace vd : viewDefs) { DefaultMutableTreeNode vdNode = new DefaultMutableTreeNode(vd.getName()); vdNode.setUserObject(vd); if (vd instanceof FormViewDef) { root.add(vdNode); FormViewDef fvd = (FormViewDef) vd; for (FormRowIFace r : fvd.getRows()) { FormRow row = (FormRow) r; DefaultMutableTreeNode rowNode = new DefaultMutableTreeNode(row.getRowNumber()); rowNode.setUserObject(row); vdNode.add(rowNode); for (FormCellIFace c : row.getCells()) { FormCell cell = (FormCell) c; DefaultMutableTreeNode cellNode = new DefaultMutableTreeNode(cell.toString()); cellNode.setUserObject(cell); rowNode.add(cellNode); } } } } model.nodeStructureChanged(root); }
From source file:gov.nih.nci.ncicb.cadsr.contexttree.service.impl.CDEBrowserTreeServiceImpl.java
private Map getFormClassificationNodes(TreeFunctions treeFunctions, TreeIdGenerator idGen, String csType, String csiType) throws Exception { Map csiByContextMap = new HashMap(); FormDAO dao = daoFactory.getFormDAO(); List allCscsi = dao.getCSCSIHierarchyByType(csType, csiType); Map csMap = new HashMap(); //this map stores the webnode for cs given cs_idseq Map csiMap = new HashMap(); Iterator iter = allCscsi.iterator(); while (iter.hasNext()) { ClassSchemeItem cscsi = (ClassSchemeItem) iter.next(); String csContextId = cscsi.getCsConteIdseq(); Map currentCsiMap = (Map) csiByContextMap.get(csContextId); if (currentCsiMap == null) { //create a classification node for this context csiMap = new HashMap(); csiByContextMap.put(csContextId, csiMap); csMap.clear();// www. j av a2s . co m } String csId = cscsi.getCsIdseq(); // create classification scheme node if necessary DefaultMutableTreeNode csNode = (DefaultMutableTreeNode) csMap.get(csId); if (csNode == null) { csNode = getClassificationSchemeNode(idGen.getNewId(), cscsi, treeFunctions); csMap.put(csId, csNode); } // add csi node DefaultMutableTreeNode csiNode = getClassificationSchemeItemNode(idGen.getNewId(), cscsi, treeFunctions); String parentId = cscsi.getParentCscsiId(); DefaultMutableTreeNode parentNode = null; if (parentId != null) parentNode = (DefaultMutableTreeNode) csiMap.get(parentId); else parentNode = csNode; if (parentNode != null) parentNode.add(csiNode); csiMap.put(cscsi.getCsCsiIdseq(), csiNode); } return csiByContextMap; }
From source file:eu.crisis_economics.abm.dashboard.GASearchHandler.java
public boolean alterParameterTree(final IIntelliContext ctx) { // create initial population final DefaultMutableTreeNode root = ctx.getParameterTreeRootNode(); final DefaultMutableTreeNode newRoot = getAlteredParameterTreeRootNode(ctx); root.removeAllChildren();/*from ww w . j a va 2 s. c o m*/ final int count = newRoot.getChildCount(); for (int i = 0; i < count; ++i) root.add((DefaultMutableTreeNode) newRoot.getChildAt(0)); return true; }