/** * Returns all edges connected to the given cells or their descendants. */ public Object[] getAllEdges(Object[] cells) { List<Object> edges = new ArrayList<Object>(); if (cells != null) { for (int i = 0; i < cells.length; i++) { int edgeCount = model.getEdgeCount(cells[i]); for (int j = 0; j < edgeCount; j++) { edges.add(model.getEdgeAt(cells[i], j)); } // Recurses Object[] children = mxGraphModel.getChildren(model, cells[i]); edges.addAll(Arrays.asList(getAllEdges(children))); } } return edges.toArray(); }
/** * Returns all edges connected to the given cells or their descendants. */ public Object[] getAllEdges(Object[] cells) { List<Object> edges = new ArrayList<Object>(); if (cells != null) { for (int i = 0; i < cells.length; i++) { int edgeCount = model.getEdgeCount(cells[i]); for (int j = 0; j < edgeCount; j++) { edges.add(model.getEdgeAt(cells[i], j)); } // Recurses Object[] children = mxGraphModel.getChildren(model, cells[i]); edges.addAll(Arrays.asList(getAllEdges(children))); } } return edges.toArray(); }
/** * Returns all distinct edges connected to this cell. * * @param model Model that contains the connection information. * @param cell Cell whose connections should be returned. * @param incoming Specifies if incoming edges should be returned. * @param outgoing Specifies if outgoing edges should be returned. * @param includeLoops Specifies if loops should be returned. * @return Returns the array of connected edges for the given cell. */ public static Object[] getEdges(mxIGraphModel model, Object cell, boolean incoming, boolean outgoing, boolean includeLoops) { int edgeCount = model.getEdgeCount(cell); List<Object> result = new ArrayList<Object>(edgeCount); for (int i = 0; i < edgeCount; i++) { Object edge = model.getEdgeAt(cell, i); Object source = model.getTerminal(edge, true); Object target = model.getTerminal(edge, false); if ((includeLoops && source == target) || ((source != target) && ((incoming && target == cell) || (outgoing && source == cell)))) { result.add(edge); } } return result.toArray(); }
/** * Returns all distinct edges connected to this cell. * * @param model Model that contains the connection information. * @param cell Cell whose connections should be returned. * @param incoming Specifies if incoming edges should be returned. * @param outgoing Specifies if outgoing edges should be returned. * @param includeLoops Specifies if loops should be returned. * @return Returns the array of connected edges for the given cell. */ public static Object[] getEdges(mxIGraphModel model, Object cell, boolean incoming, boolean outgoing, boolean includeLoops) { int edgeCount = model.getEdgeCount(cell); List<Object> result = new ArrayList<Object>(edgeCount); for (int i = 0; i < edgeCount; i++) { Object edge = model.getEdgeAt(cell, i); Object source = model.getTerminal(edge, true); Object target = model.getTerminal(edge, false); if ((includeLoops && source == target) || ((source != target) && ((incoming && target == cell) || (outgoing && source == cell)))) { result.add(edge); } } return result.toArray(); }
/** * Returns the number of incoming or outgoing edges, ignoring the given * edge. * * @param model Graph model that contains the connection data. * @param cell Cell whose edges should be counted. * @param outgoing Boolean that specifies if the number of outgoing or * incoming edges should be returned. * @param ignoredEdge Object that represents an edge to be ignored. * @return Returns the number of incoming or outgoing edges. */ public static int getDirectedEdgeCount(mxIGraphModel model, Object cell, boolean outgoing, Object ignoredEdge) { int count = 0; int edgeCount = model.getEdgeCount(cell); for (int i = 0; i < edgeCount; i++) { Object edge = model.getEdgeAt(cell, i); if (edge != ignoredEdge && model.getTerminal(edge, outgoing) == cell) { count++; } } return count; }
/** * Returns the number of incoming or outgoing edges, ignoring the given * edge. * * @param model Graph model that contains the connection data. * @param cell Cell whose edges should be counted. * @param outgoing Boolean that specifies if the number of outgoing or * incoming edges should be returned. * @param ignoredEdge Object that represents an edge to be ignored. * @return Returns the number of incoming or outgoing edges. */ public static int getDirectedEdgeCount(mxIGraphModel model, Object cell, boolean outgoing, Object ignoredEdge) { int count = 0; int edgeCount = model.getEdgeCount(cell); for (int i = 0; i < edgeCount; i++) { Object edge = model.getEdgeAt(cell, i); if (edge != ignoredEdge && model.getTerminal(edge, outgoing) == cell) { count++; } } return count; }
Object edge = model.getEdgeAt(terminal, i); Object src = model.getTerminal(edge, true); Object trg = model.getTerminal(edge, false);
Object edge = model.getEdgeAt(terminal, i); Object src = model.getTerminal(edge, true); Object trg = model.getTerminal(edge, false);
Object e = model.getEdgeAt(vertex, i); boolean isSource = view.getVisibleTerminal(e, true) == vertex;
Object e = model.getEdgeAt(vertex, i); boolean isSource = view.getVisibleTerminal(e, true) == vertex;
Object e = model.getEdgeAt(vertex, i); boolean isSource = model.getTerminal(e, true) == vertex;
Object e = model.getEdgeAt(vertex, i); boolean isSource = model.getTerminal(e, true) == vertex;
/** * */ public void addEdges(mxCellState state) { mxGraph graph = graphComponent.getGraph(); mxIGraphModel model = graph.getModel(); Object cell = state.getCell(); int edgeCount = model.getEdgeCount(cell); for (int i = 0; i < edgeCount; i++) { mxCellState state2 = graph.getView().getState( model.getEdgeAt(cell, i)); if (state2 != null) { moveState(state2, 0, 0); } } }
/** * */ public void addEdges(mxCellState state) { mxGraph graph = graphComponent.getGraph(); mxIGraphModel model = graph.getModel(); Object cell = state.getCell(); int edgeCount = model.getEdgeCount(cell); for (int i = 0; i < edgeCount; i++) { mxCellState state2 = graph.getView().getState( model.getEdgeAt(cell, i)); if (state2 != null) { moveState(state2, 0, 0); } } }
/** * Invalidates the state of the given cell, all its descendants and * connected edges. */ public void invalidate(Object cell) { mxIGraphModel model = graph.getModel(); cell = (cell != null) ? cell : model.getRoot(); mxCellState state = getState(cell); if (state == null || !state.isInvalid()) { if (state != null) { state.setInvalid(true); } // Recursively invalidates all descendants int childCount = model.getChildCount(cell); for (int i = 0; i < childCount; i++) { Object child = model.getChildAt(cell, i); invalidate(child); } // Propagates invalidation to all connected edges int edgeCount = model.getEdgeCount(cell); for (int i = 0; i < edgeCount; i++) { invalidate(model.getEdgeAt(cell, i)); } } }
/** * Invalidates the state of the given cell, all its descendants and * connected edges. */ public void invalidate(Object cell) { mxIGraphModel model = graph.getModel(); cell = (cell != null) ? cell : model.getRoot(); mxCellState state = getState(cell); if (state == null || !state.isInvalid()) { if (state != null) { state.setInvalid(true); } // Recursively invalidates all descendants int childCount = model.getChildCount(cell); for (int i = 0; i < childCount; i++) { Object child = model.getChildAt(cell, i); invalidate(child); } // Propagates invalidation to all connected edges int edgeCount = model.getEdgeCount(cell); for (int i = 0; i < edgeCount; i++) { invalidate(model.getEdgeAt(cell, i)); } } }