/** * Inserts the specified vertex into the graph model. This method does in * fact nothing, it calls insert edge with the vertex and the source and * target port set to null. This example shows how to add a vertex with a * port and a black border: * * <pre> * DefaultGraphCell vertex = new DefaultGraphCell("Hello, world!"); * Map attrs = vertex.getAttributes(); * GraphConstants.setOpaque(attrs, false); * GraphConstants.setBorderColor(attrs, Color.black); * DefaultPort port = new DefaultPort(); * vertex.add(port); * port.setParent(vertex); * graph.getGraphLayoutCache().insert(vertex); * </pre> * * @param cell * inserts the specified cell in the cache */ public void insert(Object cell) { insert(new Object[] { cell }); }
public void run() { graph.getGraphLayoutCache().insert(cell); } });
/** * Inserts the specified edge into the graph model. This method does in fact * nothing, it calls insert with a default connection set. * * @param edge * the edge to be inserted * @param source * the source port this edge is connected to * @param target * the target port this edge is connected to */ public void insertEdge(Object edge, Object source, Object target) { insert(new Object[] { edge }, new Hashtable(), new ConnectionSet(edge, source, target), new ParentMap()); }
/** * Inserts the specified cells into the graph model. This method is a * general implementation of cell insertion. If the source and target port * are null, then no connection set is created. The method uses the * attributes from the specified edge and the egdge's children to construct * the insert call. This example shows how to insert an edge with a special * arrow between two known vertices: * * <pre> * Object source = graph.getDefaultPortForCell(sourceVertex).getCell(); * Object target = graph.getDefaultPortForCell(targetVertex).getCell(); * DefaultEdge edge = new DefaultEdge("Hello, world!"); * edge.setSource(source); * edge.setTarget(target); * Map attrs = edge.getAttributes(); * GraphConstants.setLineEnd(attrs, GraphConstants.ARROW_TECHNICAL); * graph.getGraphLayoutCache().insert(edge); * </pre> */ public void insert(Object[] cells) { insert(cells, new Hashtable(), new ConnectionSet(), new ParentMap()); }
public void run() { ConnectionSet cs = new ConnectionSet(); cs.connect(newEdge, otherextreme.getFirstChild(), vertex.getFirstChild()); Hashtable edgeprops = new Hashtable(); Hashtable elements = new Hashtable(); GraphConstants.setDashPattern(edgeprops, new float[] { 3, 3 }); elements.put(newEdge, edgeprops); glc.insert(new Object[] { newEdge }, elements, cs, null); // to conenct port with port } };
newCells[i] = clones.get(cells[i]); insert(newCells, nested, cs, pm, null); return newCells;
private void createArrow(K source, K target) { if (!arrowAlreadyExist(source, target)) { DefaultGraphCell[] arrowCell = new DefaultGraphCell[1]; DefaultEdge edge = new DefaultEdge(); edge.setSource(stateCells.get(source).getChildAt(0)); edge.setTarget(stateCells.get(target).getChildAt(0)); arrowCell[0] = edge; int arrow = GraphConstants.ARROW_TECHNICAL; GraphConstants.setLineEnd(edge.getAttributes(), arrow); GraphConstants.setEndFill(edge.getAttributes(), true); graph.getGraphLayoutCache().insert(arrowCell); Set<K> targetSet = arrows.get(source); if (targetSet == null) { targetSet = EnumSet.noneOf(keyType); arrows.put(source, targetSet); } targetSet.add(target); } }
edit(nested, null, pm, null); else insert(newCells.toArray(), nested, null, pm);
public void objEntityChanged(EntityEvent e) { remapEntity(e); updateEntityCell(e.getEntity()); // maybe super entity was changed ObjEntity entity = (ObjEntity) e.getEntity(); DefaultEdge inheritanceEdge = inheritanceEdges.get(entity); if (inheritanceEdge != null) { if (entity.getSuperEntity() == null) { graph.getGraphLayoutCache().remove(new Object[] { inheritanceEdge }); inheritanceEdges.remove(entity); } else { inheritanceEdge.setTarget(entityCells.get( entity.getSuperEntity().getName()).getChildAt(0)); Map nested = new HashMap(); nested.put(inheritanceEdge, inheritanceEdge.getAttributes()); graph.getGraphLayoutCache().edit(nested); } } else { if (entity.getSuperEntity() != null) { DefaultEdge edge = createInheritanceEdge(entity); graph.getGraphLayoutCache().insert(edge); } } }
insert(cells, nested, cs, pm, null);
private void initializeJPanel() { initiate = true; graph.setGraphLayoutCache(new GraphLayoutCache(new DefaultGraphModel(), new DefaultCellViewFactory(), true)); graph.setEditable(false); for (K key : stateKeys) stateCells.put(key, createCell(key, new Point2D(0, 0))); for (K key : stateKeys) createStateTransitionDiagram(key); graph.getGraphLayoutCache().insert(stateCells.values().toArray()); JGraphFacade facade = new JGraphFacade(graph.getGraphLayoutCache()); facade.setEdgePromotion(false); JGraphTreeLayout layout = new JGraphTreeLayout(); layout.run(facade); Map<?, ?> map = facade.createNestedMap(true, true); graph.getGraphLayoutCache().edit(map); }
private void createArrow(int source, int target) { if (!arrowAlreadyExist(source, target)) { DefaultGraphCell[] arrowCell = new DefaultGraphCell[1]; DefaultEdge edge = new DefaultEdge(); edge.setSource(stateCells[source].getChildAt(0)); edge.setTarget(stateCells[target].getChildAt(0)); arrowCell[0] = edge; int arrow = GraphConstants.ARROW_TECHNICAL; GraphConstants.setLineEnd(edge.getAttributes(), arrow); GraphConstants.setEndFill(edge.getAttributes(), true); graph.getGraphLayoutCache().insert(arrowCell); sourceArrows[sourceArrowIndex] = source; sourceArrowIndex++; targetArrows[targetArrowIndex] = target; targetArrowIndex++; } }
private void createArrow(int source, int target) { if (!arrowAlreadyExist(source, target)) { DefaultGraphCell[] arrowCell = new DefaultGraphCell[1]; DefaultEdge edge = new DefaultEdge(); edge.setSource(stateCells[source].getChildAt(0)); edge.setTarget(stateCells[target].getChildAt(0)); arrowCell[0] = edge; int arrow = GraphConstants.ARROW_TECHNICAL; GraphConstants.setLineEnd(edge.getAttributes(), arrow); GraphConstants.setEndFill(edge.getAttributes(), true); graph.getGraphLayoutCache().insert(arrowCell); sourceArrows[sourceArrowIndex] = source; sourceArrowIndex++; targetArrows[targetArrowIndex] = target; targetArrowIndex++; } }
private void initializeJPanel() { initiate = true; graph.setGraphLayoutCache(new GraphLayoutCache(new DefaultGraphModel(), new DefaultCellViewFactory(), true)); graph.setEditable(false); for (int i = 0; i < numberOfStates; i++) { isStateEmpty(stateMachine.states.get(i)); } stateCells = new DefaultGraphCell[numberOfStates]; State<E> parent = getParentState(); stateCells[stateCellIndex] = createCell(parent.getStateEnum().toString(), new Point2D(0, 0), stateCellIndex); stateCellIndex++; createStateMachineDiagram(parent); graph.getGraphLayoutCache().insert(stateCells); JGraphFacade facade = new JGraphFacade(graph.getGraphLayoutCache()); facade.setEdgePromotion(false); JGraphTreeLayout layout = new JGraphTreeLayout(); layout.run(facade); Map<?, ?> map = facade.createNestedMap(true, true); graph.getGraphLayoutCache().edit(map); createDefaultArrows(); createArrowsForStateTransitions(); }
private void initializeJPanel() { initiate = true; graph.setGraphLayoutCache(new GraphLayoutCache(new DefaultGraphModel(), new DefaultCellViewFactory(), true)); graph.setEditable(false); for (int i = 0; i < numberOfStates; i++) { isStateEmpty(stateMachine.states.get(i)); } stateCells = new DefaultGraphCell[numberOfStates]; State<E> parent = getParentState(); stateCells[stateCellIndex] = createCell(parent.getStateEnum().toString(), new Point2d(0, 0), stateCellIndex); stateCellIndex++; createStateMachineDiagram(parent); graph.getGraphLayoutCache().insert(stateCells); JGraphFacade facade = new JGraphFacade(graph.getGraphLayoutCache()); facade.setEdgePromotion(false); JGraphTreeLayout layout = new JGraphTreeLayout(); layout.run(facade); Map<?, ?> map = facade.createNestedMap(true, true); graph.getGraphLayoutCache().edit(map); createDefaultArrows(); createArrowsForStateTransitions(); }
cs = cs.clone(cellMap); Object[] cells = cellMap.values().toArray(); graph.getGraphLayoutCache().insert(cells, nested, cs, null, null); } else {