public Vector getAssociatedLevelLists() { Vector levelLists = new Vector(); Vector endPts = CollectionHelper.makeVector("Keyword"); Hashtable keywordParents = oncotcap.Oncotcap.getDataSource() .getParentTree( "Keyword", endPts, CollectionHelper.makeVector(this), TreeDisplayModePanel.ROOT); // Take each of the parents and get the associated level lists if (keywordParents.size() <= 0) return levelLists; Hashtable levelListsHashtable = oncotcap.Oncotcap.getDataSource() .getInstanceTree( "EnumLevelList", new Vector(), makeLevelListFilter(keywordParents), TreeDisplayModePanel.ROOT); for (Enumeration e = keywordParents.keys(); e.hasMoreElements(); ) { System.out.println("Keyword.getAssociatedLevelLists: " + e.nextElement()); } // Collect all the level lists from the hashtable Vector selectedItems = CollectionHelper.makeVector(keyword); for (Enumeration e = levelListsHashtable.keys(); e.hasMoreElements(); ) { Object obj = e.nextElement(); if (obj instanceof EnumLevelList) { levelLists.addElement(obj); } } return levelLists; }
/** Draws the edge structure of the tree */ public void drawEdges(Graphics2D gg) { gg.setPaint(Color.black); Enumeration nodeList = argument.getBreadthFirstTraversal().elements(); // For each vertex... while (nodeList.hasMoreElements()) { // Get its edge list... TreeVertex vertex = (TreeVertex) nodeList.nextElement(); Enumeration edges = vertex.getEdgeList().elements(); // For each edge in the list... while (edges.hasMoreElements()) { TreeEdge edge = (TreeEdge) edges.nextElement(); // If we have several vertices on layer 0, only draw // edges for layers below that if (!(argument.isMultiRoots() && vertex.getLayer() == 0)) { // If the edge has been selected with the mouse, // use a thick line if (edge.isSelected()) { gg.setStroke(selectStroke); } gg.draw(edge.getShape(this)); // If we used a thick line, reset the stroke to normal // line for next edge. if (edge.isSelected()) { gg.setStroke(solidStroke); } TreeVertex edgeSource = edge.getDestVertex(); } } } }
/** * Update the layouts tree. * * @param current The name of the current layout or <CODE>null</CODE> if none. */ public void updateLayouts(Path current) throws PipelineException { DefaultMutableTreeNode root = null; { root = new DefaultMutableTreeNode(new TreeData(), true); { Path path = new Path(PackageInfo.getSettingsPath(), "layouts"); rebuildTreeModel(path, new Path("/"), root); } DefaultTreeModel model = (DefaultTreeModel) pTree.getModel(); model.setRoot(root); { Enumeration e = root.depthFirstEnumeration(); if (e != null) { while (e.hasMoreElements()) { DefaultMutableTreeNode tnode = (DefaultMutableTreeNode) e.nextElement(); pTree.expandPath(new TreePath(tnode.getPath())); } } } } pTree.clearSelection(); if (current != null) { TreePath tpath = null; DefaultMutableTreeNode tnode = root; for (String comp : current.getComponents()) { DefaultMutableTreeNode next = null; Enumeration e = tnode.children(); if (e != null) { while (e.hasMoreElements()) { DefaultMutableTreeNode child = (DefaultMutableTreeNode) e.nextElement(); TreeData data = (TreeData) child.getUserObject(); if (data.toString().equals(comp)) { tpath = new TreePath(child.getPath()); next = child; break; } } } if (next == null) break; tnode = next; } if (tpath != null) { pTree.setSelectionPath(tpath); pTree.makeVisible(tpath); } } }
protected void restoreTree() { Pair<ElementNode, List<ElementNode>> selection = storeSelection(); DefaultMutableTreeNode root = getRootNode(); if (!myShowClasses || myContainerNodes.isEmpty()) { List<ParentNode> otherObjects = new ArrayList<ParentNode>(); Enumeration<ParentNode> children = getRootNodeChildren(); ParentNode newRoot = new ParentNode( null, new MemberChooserObjectBase(getAllContainersNodeName()), new Ref<Integer>(0)); while (children.hasMoreElements()) { final ParentNode nextElement = children.nextElement(); if (nextElement instanceof ContainerNode) { final ContainerNode containerNode = (ContainerNode) nextElement; Enumeration<MemberNode> memberNodes = containerNode.children(); List<MemberNode> memberNodesList = new ArrayList<MemberNode>(); while (memberNodes.hasMoreElements()) { memberNodesList.add(memberNodes.nextElement()); } for (MemberNode memberNode : memberNodesList) { newRoot.add(memberNode); } } else { otherObjects.add(nextElement); } } replaceChildren(root, otherObjects); sortNode(newRoot, myComparator); if (newRoot.children().hasMoreElements()) root.add(newRoot); } else { Enumeration<ParentNode> children = getRootNodeChildren(); while (children.hasMoreElements()) { ParentNode allClassesNode = children.nextElement(); Enumeration<MemberNode> memberNodes = allClassesNode.children(); ArrayList<MemberNode> arrayList = new ArrayList<MemberNode>(); while (memberNodes.hasMoreElements()) { arrayList.add(memberNodes.nextElement()); } Collections.sort(arrayList, myComparator); for (MemberNode memberNode : arrayList) { myNodeToParentMap.get(memberNode).add(memberNode); } } replaceChildren(root, myContainerNodes); } myTreeModel.nodeStructureChanged(root); defaultExpandTree(); restoreSelection(selection); }
private void jButtonRequireSelectedStreamActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButtonRequireSelectedStreamActionPerformed try { int index = jComboBoxRemoteServices.getSelectedIndex(); if (index != -1) { final ServiceResponse service = availableServices.elementAt(index); final String stream = jComboBoxFileList.getSelectedItem().toString(); System.out.println( "StreamClientJFrame.jButtonRequireSelectedFileActionPerformed stream " + stream); JRadioButton jrbStreamProtocol = null; for (Enumeration<?> e = buttonGroupStreamProtocol.getElements(); e.hasMoreElements(); ) { JRadioButton b = (JRadioButton) e.nextElement(); if (b.getModel() == buttonGroupStreamProtocol.getSelection()) { jrbStreamProtocol = b; } } final String streamProtocol = jrbStreamProtocol.getText(); JRadioButton jrbRampProtocol = null; for (Enumeration<?> e = buttonGroupRampProtocol.getElements(); e.hasMoreElements(); ) { JRadioButton b = (JRadioButton) e.nextElement(); if (b.getModel() == buttonGroupRampProtocol.getSelection()) { jrbRampProtocol = b; } } final String rampProtocol = jrbRampProtocol.getText(); // sc.getStream(service, stream, streamProtocol, rampProtocol); Thread t = new Thread( new Runnable() { @Override public void run() { try { sc.getStream(service, stream, streamProtocol, rampProtocol); } catch (Exception ex) { ex.printStackTrace(); } } }); t.start(); } } catch (Exception e) { e.printStackTrace(); } } // GEN-LAST:event_jButtonRequireSelectedStreamActionPerformed
private void restorePath(ArrayList<Object> newPath, int idx) { if (idx >= myPath.length) return; InspectionTreeNode oldNode = (InspectionTreeNode) myPath[idx]; InspectionTreeNode newRoot = (InspectionTreeNode) newPath.get(idx - 1); InspectionResultsViewComparator comparator = InspectionResultsViewComparator.getInstance(); Enumeration children = newRoot.children(); while (children.hasMoreElements()) { InspectionTreeNode child = (InspectionTreeNode) children.nextElement(); if (comparator.compare(child, oldNode) == 0) { newPath.add(child); restorePath(newPath, idx + 1); return; } } // Exactly same element not found. Trying to select somewhat near. int count = newRoot.getChildCount(); if (count > 0) { if (myIndicies[idx] < count) { newPath.add(newRoot.getChildAt(myIndicies[idx])); } else { newPath.add(newRoot.getChildAt(count - 1)); } } }
public DefaultMutableTreeNode findNode(DefaultMutableTreeNode parent, String match) { if (parent == null) return null; // Commented by Balan on 15/03/03 // String treename = (String)parent.getUserObject (); // Comment Ends // Added by Balan on 15/03/03 String treename = "" + ((Hashtable) parent.getUserObject()).get("TREE-NAME"); // Add Ends if (treename != null) { if (treename.equals(match)) return parent; } if (frame.model.isLeaf(parent)) return null; Enumeration en = parent.children(); if ((en == null) || (!en.hasMoreElements())) return null; for (; en.hasMoreElements(); ) { DefaultMutableTreeNode child = (DefaultMutableTreeNode) en.nextElement(); DefaultMutableTreeNode returnNode = findNode(child, match); if (returnNode != null) return returnNode; } return null; }
// ------------------------------------------------------------------------ // SCREEN PAINTER // Put some function here to paint whatever you want over the screen before and after // all edges and nodes have been painted. public void PaintScreenBefore(Graphics g) { Dimension d = MainClass.mainFrame.GetGraphDisplayPanel().getSize(); NodeInfo nodeInfo; int x = 0; int y = 0; int step = 10; for (; x < d.width; x += step) { for (y = 0; y < d.height; y += step) { double val = 0; double sum = 0; double total = 0; double min = 10000000; for (Enumeration nodes = proprietaryNodeInfo.elements(); nodes.hasMoreElements(); ) { nodeInfo = (NodeInfo) nodes.nextElement(); double dist = distance(x, y, nodeInfo.centerX, nodeInfo.centerY); if (nodeInfo.value != -1 && nodeInfo.nodeNumber.intValue() != 1) { // 121 if (dist < min) min = dist; val += ((double) nodeInfo.value) / dist / dist; sum += (1 / dist / dist); } } int reading = (int) (val / sum); reading = reading >> 2; if (reading > 255) reading = 255; g.setColor(new Color(reading, reading, reading)); g.fillRect(x, y, step, step); } } }
private void checkNodeValidity(@NotNull DefaultMutableTreeNode node) { Enumeration enumeration = node.children(); while (enumeration.hasMoreElements()) { checkNodeValidity((DefaultMutableTreeNode) enumeration.nextElement()); } if (node instanceof Node && node != getModelRoot()) ((Node) node).update(this); }
/** Description of the Method */ public void removeAllElements() { for (Enumeration<BPM_Element> e = listModel.elements(); e.hasMoreElements(); ) { BPM_Element elm = e.nextElement(); elm.stopMonitor(); } listModel.removeAllElements(); }
void drawboard(Graphics g) { g.setColor(Color.black); g.fillRect(0, 0, getWidth(), getHeight()); sqw = getWidth() / xdim; sqh = getHeight() / ydim; // draw background panels if (def != null) { for (int y = 0; y < ydim; y++) { for (int x = 0; x < xdim; x++) def.drawObject(g, x, y, sqw, sqh, this); } } if (USEVEC) { // draw each element in the vector for (Enumeration e = boardVec.elements(); e.hasMoreElements(); ) { boardContainer c = (boardContainer) e.nextElement(); c.o.drawObject(g, c.d.width, c.d.height, sqw, sqh, this); } } else { // draw from grid for (int y = 0; y < ydim; y++) { for (int x = 0; x < xdim; x++) if (board[x][y] != null) board[x][y].drawObject(g, x, y, sqw, sqh, this); } } }
protected final void loadChildren(DynamicNode node) throws DbException { if (node.hasLoaded() || node.isLeaf()) return; node.setHasLoaded(); Object userObject = node.getUserObject(); if (userObject == ROOT) return; SrVector children = new SrVector(10); boolean isSorted = true; DbObject dbParent = null; if (userObject == DB_RAM) { Db[] dbs = Db.getDbs(); for (int i = 0; i < dbs.length; i++) { if (dbs[i] instanceof DbRAM) insertProjects(children, dbs[i]); } } else if (userObject instanceof Db) { insertProjects(children, (Db) userObject); } else { dbParent = (DbObject) userObject; dbParent.getDb().beginTrans(Db.READ_TRANS); insertComponents(children, dbParent); isSorted = childrenAreSorted(dbParent); dbParent.getDb().commitTrans(); } if (isSorted) { children.sort(getComparator(dbParent)); } ArrayList groupNodeList = new ArrayList(); DynamicNode groupNode = null; Enumeration enumeration = children.elements(); while (enumeration.hasMoreElements()) { DynamicNode childNode = (DynamicNode) enumeration.nextElement(); GroupParams group = childNode.getGroupParams(); if (group.name == null) { node.add(childNode); } else { if (groupNode == null) { groupNode = createGroupNode(group); node.add(groupNode); groupNodeList.add(groupNode); } else if (!groupNode.toString().equals(group.name)) { boolean groupFound = false; for (int i = 0; i < groupNodeList.size(); i++) { groupNode = (DynamicNode) groupNodeList.get(i); if (groupNode.toString().equals(group.name)) { groupFound = true; break; } } if (!groupFound) { groupNode = createGroupNode(group); node.add(groupNode); groupNodeList.add(groupNode); } } groupNode.add(childNode); } } groupNodeList.clear(); }
public HierarchyBrowserBaseEx(@NotNull Project project, @NotNull PsiElement element) { super(project); setHierarchyBase(element); myCardLayout = new CardLayout(); myTreePanel = new JPanel(myCardLayout); createTrees(myType2TreeMap); final HierarchyBrowserManager.State state = HierarchyBrowserManager.getInstance(project).getState(); for (String type : myType2TreeMap.keySet()) { myType2ScopeMap.put(type, state.SCOPE != null ? state.SCOPE : SCOPE_ALL); } final Enumeration<String> keys = myType2TreeMap.keys(); while (keys.hasMoreElements()) { final String key = keys.nextElement(); final JTree tree = myType2TreeMap.get(key); myOccurrenceNavigators.put( key, new OccurenceNavigatorSupport(tree) { @Override @Nullable protected Navigatable createDescriptorForNode(DefaultMutableTreeNode node) { final HierarchyNodeDescriptor descriptor = getDescriptor(node); if (descriptor == null) return null; PsiElement psiElement = getOpenFileElementFromDescriptor(descriptor); if (psiElement == null || !psiElement.isValid()) return null; final VirtualFile virtualFile = psiElement.getContainingFile().getVirtualFile(); if (virtualFile == null) return null; return new OpenFileDescriptor( psiElement.getProject(), virtualFile, psiElement.getTextOffset()); } @Override public String getNextOccurenceActionName() { return getNextOccurenceActionNameImpl(); } @Override public String getPreviousOccurenceActionName() { return getPrevOccurenceActionNameImpl(); } }); myTreePanel.add(ScrollPaneFactory.createScrollPane(tree), key); } final JPanel legendPanel = createLegendPanel(); final JPanel contentPanel; if (legendPanel != null) { contentPanel = new JPanel(new BorderLayout()); contentPanel.add(myTreePanel, BorderLayout.CENTER); contentPanel.add(legendPanel, BorderLayout.SOUTH); } else { contentPanel = myTreePanel; } buildUi(createToolbar(getActionPlace(), HELP_ID).getComponent(), contentPanel); }
/** * notify listeners of a popup selection * * @param popStr popup selection string */ void popNotify(String popStr) { Enumeration en = popListeners.elements(); for (; en.hasMoreElements(); ) { PopListener listener = (PopListener) en.nextElement(); listener.popHappened(popStr); } } // popNotify()
private void traverseToLeaves( final PackageDependenciesNode treeNode, final StringBuffer denyRules, final StringBuffer allowRules) { final Enumeration enumeration = treeNode.breadthFirstEnumeration(); while (enumeration.hasMoreElements()) { PsiElement childPsiElement = ((PackageDependenciesNode) enumeration.nextElement()).getPsiElement(); if (myIllegalDependencies.containsKey(childPsiElement)) { final Map<DependencyRule, Set<PsiFile>> illegalDeps = myIllegalDependencies.get(childPsiElement); for (final DependencyRule rule : illegalDeps.keySet()) { if (rule.isDenyRule()) { if (denyRules.indexOf(rule.getDisplayText()) == -1) { denyRules.append(rule.getDisplayText()); denyRules.append("\n"); } } else { if (allowRules.indexOf(rule.getDisplayText()) == -1) { allowRules.append(rule.getDisplayText()); allowRules.append("\n"); } } } } } }
private static void expand(JTree tree, TreePath path, int levels) { if (levels == 0) return; tree.expandPath(path); TreeNode node = (TreeNode) path.getLastPathComponent(); Enumeration children = node.children(); while (children.hasMoreElements()) { expand(tree, path.pathByAddingChild(children.nextElement()), levels - 1); } }
// {{{ traverseNodes() method public static boolean traverseNodes( DefaultMutableTreeNode node, HyperSearchTreeNodeCallback callbackInterface) { if (!callbackInterface.processNode(node)) return false; for (Enumeration e = node.children(); e.hasMoreElements(); ) { DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) e.nextElement(); if (!traverseNodes(childNode, callbackInterface)) return false; } return true; } // }}}
@Override public void actionPerformed(ActionEvent evt) { TreePath path = resultTree.getSelectionPath(); DefaultMutableTreeNode operNode = (DefaultMutableTreeNode) path.getLastPathComponent(); for (Enumeration e = operNode.children(); e.hasMoreElements(); ) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement(); resultTree.collapsePath(new TreePath(node.getPath())); } resultTree.scrollPathToVisible(new TreePath(operNode.getPath())); }
/* * Applet is no longer displayed */ public void stop() { // Tell all pages to stop talking to the server Enumeration e = pages.elements(); while (e.hasMoreElements()) { SOAPMonitorPage pg = (SOAPMonitorPage) e.nextElement(); if (pg != null) { pg.stop(); } } }
private int getChildIndex(InspectionTreeNode node, InspectionTreeNode child) { int idx = 0; Enumeration children = node.children(); while (children.hasMoreElements()) { InspectionTreeNode ch = (InspectionTreeNode) children.nextElement(); if (ch == child) break; idx++; } return idx; }
private void step() { myNext = null; while (myEnum.hasMoreElements()) { final Object o = myEnum.nextElement(); if (o instanceof FileTreeNode) { myNext = ((FileTreeNode) o).getFilePointer(); break; } } }
/** * Writes all of the edge comments to the writer to create the comment file and whether a datamap * entry is generated or not. Each line represents an entry of the datamap. Each line contains a 1 * or a 0 that signifies if generates or not and is followed by a comment if there is one. */ public void writeComments(Writer commentWriter) throws IOException { // Write out all the edge comments Enumeration e = rep.edges(); while (e.hasMoreElements()) { NamedEdge edge = (NamedEdge) e.nextElement(); if (edge.isGenerated()) { commentWriter.write("1 " + edge.getComment() + '\n'); } else commentWriter.write("0 " + edge.getComment() + '\n'); } }
protected final void updateInsertIndexInChildrenOfNode(DynamicNode parentNode) throws DbException { Enumeration childrenEnum = parentNode.children(); while (childrenEnum.hasMoreElements()) { DynamicNode node = (DynamicNode) childrenEnum.nextElement(); DbObject dbo = (DbObject) node.getRealObject(); DbObject dbParent = dbo.getComposite(); node.insertIndex = getSequence(dbParent, dbo); } }
private static void sortNode(ParentNode node, final Comparator<ElementNode> sortComparator) { ArrayList<MemberNode> arrayList = new ArrayList<MemberNode>(); Enumeration<MemberNode> children = node.children(); while (children.hasMoreElements()) { arrayList.add(children.nextElement()); } Collections.sort(arrayList, sortComparator); replaceChildren(node, arrayList); }
/** * Writes out information for the datamap file (.dm file) .dm datamap file is in the format of: * number of vertices <br> * write out all vertices: |vertex type| |vertex id int| * |number of enumerations| |enumeration strings .....| <br> * number of edges <br> * write out all edges: | left vertex | |name of edge| * |right vertex| * * @param graphWriter the file to be written too - .dm file */ public void write(Writer graphWriter) throws IOException { // Write out the number of Vertices graphWriter.write("" + rep.numberOfVertices() + '\n'); // Write out all the vertices Enumeration v = rep.vertices(); while (v.hasMoreElements()) { SoarVertex vertex = (SoarVertex) v.nextElement(); if (vertex != null) vertex.write(graphWriter); } // Write out the number of edges graphWriter.write("" + rep.numberOfEdges() + '\n'); // Write out all the edges Enumeration e = rep.edges(); while (e.hasMoreElements()) { NamedEdge edge = (NamedEdge) e.nextElement(); edge.write(graphWriter); } }
private Set<Object> addPaths(Enumeration elements) { ArrayList<Object> elementArray = new ArrayList<Object>(); if (elements != null) { while (elements.hasMoreElements()) { Object each = elements.nextElement(); elementArray.add(each); } } return addPaths(elementArray); }
// Get what the user selects as the answer public String getSelection() { String selectedChoice = null; Enumeration<AbstractButton> buttons = bg.getElements(); while (buttons.hasMoreElements()) { JRadioButton temp = (JRadioButton) buttons.nextElement(); if (temp.isSelected()) { selectedChoice = temp.getText(); } } return (selectedChoice); }
@Override public JComponent getPreferredFocusedComponent() { final Enumeration<AbstractButton> enumeration = myGroup.getElements(); while (enumeration.hasMoreElements()) { final AbstractButton button = enumeration.nextElement(); if (button.isSelected()) { return button; } } return myPanel; }
/** * Returns the bPM attribute of the BPMsTable object * * @param name The Parameter * @return The bPM value */ public BPM_Element getBPM(String name) { BPM_Element bpmElm = null; Enumeration<BPM_Element> bpm_enum = listModel.elements(); while (bpm_enum.hasMoreElements()) { BPM_Element bpmElm1 = bpm_enum.nextElement(); if (bpmElm1.getName().equals(name)) { bpmElm = bpmElm1; } } return bpmElm; }
public void save(PrintStream stream) { saved = true; stream.println("<?xml version=\"1.0\"?>"); stream.println("<scale>"); stream.println(" <name>" + nameTF.getText() + "</name>"); for (Enumeration en = sp.notes.elements(); en.hasMoreElements(); ) { ScalePanel.Notik cur = (ScalePanel.Notik) en.nextElement(); stream.println(" <note>" + cur.n + "</note>"); } stream.println("</scale>"); }