/** * Returns <code>true</code> if <code>vertex</code> is a valid vertex. * * @return <code>true</code> if <code>vertex</code> is a valid vertex. */ public static boolean isVertex(GraphModel model, Object vertex) { return (vertex != null && !model.isEdge(vertex) && !model.isPort(vertex)); }
/** * @param model * @return all edges in the model */ public static Set getAllEdges(GraphModel model) { List cells = DefaultGraphModel.getDescendants(model, (DefaultGraphModel.getRoots(model))); if (cells != null) { Set result = new HashSet(); for (int index = 0; index < cells.size(); index++) if (model.isEdge(cells.get(index))) result.add(cells.get(index)); return result; } return null; }
public org.jgraph.graph.CellView createView(GraphModel model, Object cell) { org.jgraph.graph.CellView view = null; if (model.isPort(cell)) view = new PortView(cell); else if (model.isEdge(cell)) view = createEdgeView(cell); else view = createVertexView(cell); return view; }
public org.jgraph.graph.CellView createView(GraphModel model, Object cell) { org.jgraph.graph.CellView view = null; if (model.isPort(cell)) view = new PortView(cell); else if (model.isEdge(cell)) view = createEdgeView(cell); else view = createVertexView(cell); return view; }
public org.jgraph.graph.CellView createView(GraphModel model, Object cell) { org.jgraph.graph.CellView view = null; if (model.isPort(cell)) view = new PortView(cell); else if (model.isEdge(cell)) view = createEdgeView(cell); else view = createVertexView(cell); return view; }
public org.jgraph.graph.CellView createView(GraphModel model, Object cell) { org.jgraph.graph.CellView view = null; if (model.isPort(cell)) view = new PortView(cell); else if (model.isEdge(cell)) view = createEdgeView(cell); else view = createVertexView(cell); return view; }
public org.jgraph.graph.CellView createView(GraphModel model, Object cell) { org.jgraph.graph.CellView view = null; if (model.isPort(cell)) view = new PortView(cell); else if (model.isEdge(cell)) view = createEdgeView(cell); else view = createVertexView(cell); return view; }
public org.jgraph.graph.CellView createView(GraphModel model, Object cell) { org.jgraph.graph.CellView view = null; if (model.isPort(cell)) view = new PortView(cell); else if (model.isEdge(cell)) view = createEdgeView(cell); else view = createVertexView(cell); return view; }
public org.jgraph.graph.CellView createView(GraphModel model, Object cell) { org.jgraph.graph.CellView view = null; if (model.isPort(cell)) view = new PortView(cell); else if (model.isEdge(cell)) view = createEdgeView(cell); else view = createVertexView(cell); return view; }
public org.jgraph.graph.CellView createView(GraphModel model, Object cell) { org.jgraph.graph.CellView view = null; if (model.isPort(cell)) view = new PortView(cell); else if (model.isEdge(cell)) view = createEdgeView(cell); else view = createVertexView(cell); return view; }
public org.jgraph.graph.CellView createView(GraphModel model, Object cell) { org.jgraph.graph.CellView view = null; if (model.isPort(cell)) view = new PortView(cell); else if (model.isEdge(cell)) view = createEdgeView(cell); else view = createVertexView(cell); return view; }
/** * A helper method to return various arrays of cells that are visible in * this cache. For example, to get all selected vertices in a graph, do * <code>graph.getSelectionCells(graph.getGraphLayoutCache().getCells(false, true, false, false));</code> */ public Object[] getCells(boolean groups, boolean vertices, boolean ports, boolean edges) { CellView[] views = getCellViews(); List result = new ArrayList(views.length); GraphModel model = getModel(); for (int i = 0; i < views.length; i++) { Object cell = views[i].getCell(); boolean isEdge = model.isEdge(cell); if ((ports || !model.isPort(cell))) { if (((((ports || vertices) && !isEdge) || (edges && isEdge)) && views[i] .isLeaf()) || (groups && !views[i].isLeaf())) result.add(views[i].getCell()); } } return result.toArray(); }
Rectangle2D ret = null; for (int i = 0; i < cells.length; i++) { if (graphModel != null && graphModel.isEdge(cells[i])) { CellView cellView = graphLayoutCache.getMapping( cells[i], false);
/** * Constructs a view for the specified cell and associates it with the * specified object using the specified CellMapper. This calls refresh on * the created CellView to create all dependent views. * <p> * Note: The mapping needs to be available before the views of child cells * and ports are created. * <b>Note: This method must return new instances!</b> * * @param cell * reference to the object in the model */ public CellView createView(GraphModel model, Object cell) { CellView view = null; if (model.isPort(cell)) view = createPortView(cell); else if (model.isEdge(cell)) view = createEdgeView(cell); else view = createVertexView(cell); return view; }
translate(childCell, dx, dy); hasChildren = true; } else if (model.isEdge(childCell) && cell != childCell) { hasChildren = true;
/** * Returns a connection set that represents the connection or disconnection * of <code>cells</code> in <code>model</code> based on * <code>disconnect</code>. */ public static ConnectionSet create(GraphModel m, Object[] cells, boolean disconnect) { ConnectionSet cs = new ConnectionSet(); for (int i = 0; i < cells.length; i++) { Object cell = cells[i]; // Edge if (m.isEdge(cell)) { if (disconnect) cs.disconnect(cell); else cs.connect(cell, m.getSource(cell), m.getTarget(cell)); } // Port Iterator it = m.edges(cell); while (it.hasNext()) { // Edge At Port Object edge = it.next(); if (m.getSource(edge) == cell) connect(cs, edge, cell, true, disconnect); else if (m.getTarget(edge) == cell) connect(cs, edge, cell, false, disconnect); } } return cs; }
/** * Hook for subclassers to return the port to be used for edges that have * been connected to the group. This is called from expand. This returns the * first port of the first or last vertex depending on <code>source</code>. */ protected Object getChildPort(Object edge, boolean source) { GraphModel model = getModel(); // Contains the parent of the port, eg. the group Object parent = (source) ? DefaultGraphModel.getSourceVertex(model, edge) : DefaultGraphModel.getTargetVertex(model, edge); // Finds a vertex in the group int c = model.getChildCount(parent); for (int i = (source) ? c - 1 : 0; i < c && i >= 0; i += (source) ? -1 : +1) { Object child = model.getChild(parent, i); if (!model.isEdge(child) && !model.isPort(child)) { // Finds a port in the vertex for (int j = 0; j < model.getChildCount(child); j++) { Object port = model.getChild(child, j); if (model.isPort(port)) { return port; } } } } return null; }
/** * Returns the default portview for the specified cell. The default * implementation returns the first floating port (ie. the first port that * does not define an offset) or <b>the </b> port, if there is only one * port. * * @param cell * the cell whose port is to be obtained * @return the port view of the specified cell */ public PortView getDefaultPortForCell(Object cell) { if (cell != null && !getModel().isEdge(cell)) { int childCount = getModel().getChildCount(cell); for (int i = 0; i < childCount; i++) { Object childCell = getModel().getChild(cell, i); CellView child = getGraphLayoutCache().getMapping(childCell, false); if (child instanceof PortView) { Point2D offset = GraphConstants.getOffset(child .getAllAttributes()); if (offset == null || childCount == 1) return (PortView) child; } } } return null; }