/** * Sets the selected state to true for all Edges in the GraphPerspective. */ public Set selectAllEdges() { return setSelectedEdges(graph.edgesList(), true); }
adjacentEdges = myPerspective.getAdjacentEdgesList(node, true, false, true); } else if (target == TARGET) { adjacentEdges = myPerspective.getAdjacentEdgesList(node, true, true, false); } else { adjacentEdges = adjacentEdges = myPerspective.getAdjacentEdgesList(node, true, true, true);
public boolean setGraphPerspective(GraphPerspective gp) { if (gp.getRootGraph() != m_rootGraph) return false; final int[] nodeInx = gp.getNodeIndicesArray(); final int[] edgeInx = gp.getEdgeIndicesArray(); for (int i = 0; i < nodeInx.length; i++) m_rootGraph.addNodeMetaChild(m_rootGraphIndex, nodeInx[i]); for (int i = 0; i < edgeInx.length; i++) m_rootGraph.addEdgeMetaChild(m_rootGraphIndex, edgeInx[i]); return true; }
private static void printme(RootGraph root, GraphPerspective persp) { System.out.println("in RootGraph: " + root.getNodeCount() + " nodes and " + root.getEdgeCount() + " edges"); System.out.println("in GraphPerspective: " + persp.getNodeCount() + " nodes and " + persp.getEdgeCount() + " edges"); System.out.println(); }
if (persp.restoreNode(nodeInx[i]) != nodeInx[i]) throw new IllegalStateException("unable to restore node"); if (persp.restoreEdge(edgeInx[i]) != edgeInx[i]) throw new IllegalStateException("unable to restore edge"); persp.restoreNode(node2NotInPersp); persp.restoreEdge(edge3NotInPersp); persp.hideNode(node2NotInPersp); persp.hideEdge(edge3NotInPersp); final GraphPerspective persp2 = (GraphPerspective) persp.clone(); if ((persp2.getNodeCount() != persp.getNodeCount()) || (persp2.getEdgeCount() != persp.getEdgeCount())) throw new IllegalStateException("clone has different topology"); int[] edgeInxArr = persp2.getEdgeIndicesArray(); if (persp2.hideEdge(edgeInxArr[i]) != edgeInxArr[i]) throw new IllegalStateException("cannot hide edge in clone"); if (persp2.getEdgeCount() != 0) throw new IllegalStateException("some edges in clone remaining"); if (persp2.getNodeCount() != persp.getNodeCount()) throw new IllegalStateException("node counts should still be the same"); int[] nodeInxArr = persp2.getNodeIndicesArray();
GraphPerspective gp = graphView.getGraphPerspective(); int[] childrenNodeIndices = gp.getNodeMetaChildIndicesArray(rootIndex); if ((childGP == null) || (childGP.getNodeCount() == 0)) { throw new IllegalStateException("Node " + node.getIdentifier() + " has a non-empty array " List childrenNodeList = childGP.nodesList(); Iterator it = childrenNodeList.iterator(); double x = 0.0; Node childNode = (Node) it.next(); if (gp.containsNode(childNode, false)) { NodeView childNV = graphView.getNodeView(childNode.getRootGraphIndex());
/** * Shows all edges for "nodeView" found that are part of the network associated with "view". */ public static void showEdges(final GraphView view, final NodeView nodeView) { final int[] neighbours = view.getGraphPerspective().neighborsArray(nodeView.getGraphPerspectiveIndex()); for (int n = 0; n < neighbours.length; ++n) { final int[] edges = view.getGraphPerspective().getEdgeIndicesArray(nodeView.getGraphPerspectiveIndex(), neighbours[n], true, true); for (int j = 0; j < edges.length; ++j) view.showGraphObject(view.getEdgeView(edges[j])); } }
final int[] perspEdgeInxArr = perspective.getEdgeIndicesArray(); final int[] perspNodeInxArr = perspective.getNodeIndicesArray();
/** * DOCUMENT ME! * * @param args DOCUMENT ME! */ public static void main(String[] args) { final RootGraph root = FingRootGraphFactory.instantiateRootGraph(); final int n1 = root.createNode(); final int n2 = root.createNode(); final int e1 = root.createEdge(n1, n1, /* directed */ true); final GraphPerspective persp = root.createGraphPerspective((int[]) null, (int[]) null); if (persp.restoreEdge(e1) == 0) throw new IllegalStateException("could not restore valid edge"); final GraphPerspective persp2 = root.createGraphPerspective(null, new int[] { e1 }); if (!((persp2.getNodeCount() == 1) && (persp2.getEdgeCount() == 1))) throw new IllegalStateException("bad counts in perspective"); } }
Iterator ni = origView.getGraphPerspective().nodesIterator(); while (ni.hasNext()) { Node n = (Node) ni.next(); Iterator ei = origView.getGraphPerspective().edgesIterator(); while (ei.hasNext()) { Edge ee = (Edge) ei.next();
/** * DOCUMENT ME! * * @param view DOCUMENT ME! */ public static void selectFirstNeighbors(GraphView view) { if (view == null) { return; } GraphPerspective graphPerspective = view.getGraphPerspective(); Set nodeViewsToSelect = new HashSet(); for (Iterator i = view.getSelectedNodes().iterator(); i.hasNext();) { NodeView nview = (NodeView) i.next(); Node n = nview.getNode(); for (Iterator ni = graphPerspective.neighborsList(n).iterator(); ni.hasNext();) { Node neib = (Node) ni.next(); NodeView neibview = view.getNodeView(neib); nodeViewsToSelect.add(neibview); } } for (Iterator si = nodeViewsToSelect.iterator(); si.hasNext();) { NodeView nview = (NodeView) si.next(); nview.setSelected(true); } view.updateView(); }
/** * If the first argument is a Node in the referenced GraphPerspective, sets * its selected state to the value of the second argument. An event will be * fired iff the new state is different from the old state. * * @return true if an actual change was made, false otherwise */ public boolean setSelected(final Node node, final boolean newState) { boolean setChanged; if (newState == true) { // set flag to on // don't flag the node if it's not in the graph if (!graph.containsNode(node)) { return false; } setChanged = selectedNodes.add(node); if (setChanged) { fireEvent(node, true); } } else { // set flag to off // a node can't be selected unless it's in the graph setChanged = selectedNodes.remove(node); if (setChanged) { fireEvent(node, false); } } return setChanged; }
if (!graph.containsEdge(edge)) { continue;
/** * DOCUMENT ME! * * @return DOCUMENT ME! */ public List getNodeViewsList() { final List<NodeView> list = new ArrayList<NodeView>(getNodeViewCount()); final int[] gp_indices = getGraphPerspective().getNodeIndicesArray(); final int gpSize = gp_indices.length; for (int i = 0; i < gpSize; i++) list.add(getNodeView(gp_indices[i])); return list; }
/** * DOCUMENT ME! * * @param view DOCUMENT ME! */ public static void unHideNodesAndInterconnectingEdges(GraphView view) { if (view == null) { return; } for (Iterator i = view.getNodeViewsIterator(); i.hasNext();) { NodeView nview = (NodeView) i.next(); Node n = nview.getNode(); view.showGraphObject(nview); int[] na = view.getGraphPerspective().neighborsArray(nview.getGraphPerspectiveIndex()); for (int i2 = 0; i2 < na.length; ++i2) { int[] edges = view.getGraphPerspective() .getEdgeIndicesArray(nview.getGraphPerspectiveIndex(), na[i2], true); if (edges != null) for (int j = 0; j < edges.length; ++j) { EdgeView ev = view.getEdgeView(edges[j]); view.showGraphObject(ev); } } } view.updateView(); }
GraphPerspective graphPerspective = graph_view.getGraphPerspective(); IntArrayList gpNodeIndices = new IntArrayList(graphPerspective.getNodeIndicesArray()); IntArrayList gpEdgeIndices = new IntArrayList(graphPerspective.getEdgeIndicesArray());
/** * DOCUMENT ME! * * @param args DOCUMENT ME! */ public static void main(String[] args) { final RootGraph root = FingRootGraphFactory.instantiateRootGraph(); final int[] nodeInx = root.createNodes(10000); final int[] edgeInx = new int[100000]; for (int i = 0; i < edgeInx.length; i++) edgeInx[i] = root.createEdge(nodeInx[i % nodeInx.length], nodeInx[(i * 3) % nodeInx.length]); System.out.println("RootGraph node count: " + root.getNodeCount()); System.out.println("RootGraph edge count: " + root.getEdgeCount()); System.out.println(); for (int i = 0; i < 1000; i++) { GraphPerspective persp = root.createGraphPerspective(nodeInx, edgeInx); System.out.println("GraphPerspective node count: " + persp.getNodeCount()); System.out.println("GraphPerspective edge count: " + persp.getEdgeCount()); System.out.println(); } } }
java.util.List neighbors = myPerspective.neighborsList(currentNode); Iterator nodeIt = neighbors.iterator();
if (!graph.containsNode(node)) { continue;
/** * If the first argument is an Edge in the referenced GraphPerspective, sets * its selected state to the value of the second argument. An event will be * fired iff the new state is different from the old state. * * @return true if an actual change was made, false otherwise */ public boolean setSelected(final Edge edge, final boolean newState) { boolean setChanged; if (newState == true) { // set flag to on // don'tflagthe edge if it's not in the graph if (!graph.containsEdge(edge)) { return false; } setChanged = selectedEdges.add(edge); if (setChanged) { fireEvent(edge, true); } } else { // set flag to off // an edge can't be selected unless it's in the graph setChanged = selectedEdges.remove(edge); if (setChanged) { fireEvent(edge, false); } } return setChanged; }