protected void handleBoundaryEvents() { for (BoundaryEvent boundaryEvent : boundaryEvents) { mxGeometry geometry = new mxGeometry(0.8, 1.0, eventSize, eventSize); geometry.setOffset(new mxPoint(-(eventSize / 2), -(eventSize / 2))); geometry.setRelative(true); mxCell boundaryPort = new mxCell(null, geometry, "shape=ellipse;perimter=ellipsePerimeter"); boundaryPort.setId("boundary-event-" + boundaryEvent.getId()); boundaryPort.setVertex(true); Object portParent = null; if (boundaryEvent.getAttachedToRefId() != null) { portParent = generatedVertices.get(boundaryEvent.getAttachedToRefId()); } else if (boundaryEvent.getAttachedToRef() != null) { portParent = generatedVertices.get(boundaryEvent.getAttachedToRef().getId()); } else { throw new RuntimeException("Could not generate DI: boundaryEvent '" + boundaryEvent.getId() + "' has no attachedToRef"); } graph.addCell(boundaryPort, portParent); generatedVertices.put(boundaryEvent.getId(), boundaryPort); } }
newGraph.clearSelection(); newGraph.selectAll(); Object[] cells = newGraph.getSelectionCells(); //here you have all cells for (Object c : cells) { mxCell cell = (mxCell) c; //cast if (cell.isVertex()) { //isVertex //todo }else{ //is not a vertex, so u can get source and target //todo cell.getChildCount(); //Returns the number of child cells. (edges) cell.getChildAt(x); //Returns the child at the specified index. (target) }
/** * Returns a clone of the cell. */ public Object clone() throws CloneNotSupportedException { mxCell clone = (mxCell) super.clone(); clone.setValue(cloneValue()); clone.setStyle(getStyle()); clone.setCollapsed(isCollapsed()); clone.setConnectable(isConnectable()); clone.setEdge(isEdge()); clone.setVertex(isVertex()); clone.setVisible(isVisible()); clone.setParent(null); clone.setSource(null); clone.setTarget(null); clone.children = null; clone.edges = null; mxGeometry geometry = getGeometry(); if (geometry != null) { clone.setGeometry((mxGeometry) geometry.clone()); } return clone; }
private final mxCell createFilter(final MIFilter plugin, final int c) { final mxCell vertex = new mxCell("<<Filter>>\n" + plugin.getName() + " : " + KaxVizFrame.getShortClassName(plugin), new mxGeometry(FILTER_SPACE, FILTER_SPACE + (c * (FILTER_HEIGHT + FILTER_SPACE)), FILTER_WIDTH, FILTER_HEIGHT), STYLE_FILTER); vertex.setVertex(true); this.graph.addCell(vertex); return vertex; }
public mxCell addJGraphTEdge( final DefaultWeightedEdge edge ) { if ( edgeToCellMap.containsKey( edge ) ) { // cell for edge already existed, skip creation and return original // cell. return edgeToCellMap.get( edge ); } mxCell cell = null; getModel().beginUpdate(); try { final Spot source = tmm.getTrackModel().getEdgeSource( edge ); final Spot target = tmm.getTrackModel().getEdgeTarget( edge ); cell = new mxCell( edge ); cell.setEdge( true ); cell.setId( null ); cell.setValue( String.format( "%.1f", tmm.getTrackModel().getEdgeWeight( edge ) ) ); cell.setGeometry( new mxGeometry() ); cell.getGeometry().setRelative( true ); addEdge( cell, defaultParent, vertexToCellMap.get( source ), vertexToCellMap.get( target ), null ); edgeToCellMap.put( edge, cell ); cellToEdgeMap.put( cell, edge ); } finally { getModel().endUpdate(); } return cell; }
public mxCell addJGraphTVertex( final Spot vertex ) { if ( vertexToCellMap.containsKey( vertex ) ) { // cell for Spot already existed, skip creation and return original // cell. return vertexToCellMap.get( vertex ); } mxCell cell = null; getModel().beginUpdate(); try { cell = new mxCell( vertex, new mxGeometry(), "" ); cell.setVertex( true ); cell.setId( null ); cell.setValue( vertex.getName() ); addCell( cell, defaultParent ); vertexToCellMap.put( vertex, cell ); cellToVertexMap.put( cell, vertex ); } finally { getModel().endUpdate(); } return cell; }
/** * Hook method that creates the new vertex for insertVertex. * * @param parent Cell that specifies the parent of the new vertex. * @param id Optional string that defines the Id of the new vertex. * @param value Object to be used as the user object. * @param x Integer that defines the x coordinate of the vertex. * @param y Integer that defines the y coordinate of the vertex. * @param width Integer that defines the width of the vertex. * @param height Integer that defines the height of the vertex. * @param style Optional string that defines the cell style. * @param relative Specifies if the geometry should be relative. * @return Returns the new vertex to be inserted. */ public Object createVertex(Object parent, String id, Object value, double x, double y, double width, double height, String style, boolean relative) { mxGeometry geometry = new mxGeometry(x, y, width, height); geometry.setRelative(relative); mxCell vertex = new mxCell(value, geometry, style); vertex.setId(id); vertex.setVertex(true); vertex.setConnectable(true); return vertex; }
/** * Hook method that creates the new edge for insertEdge. This * implementation does not set the source and target of the edge, these * are set when the edge is added to the model. * * @param parent Cell that specifies the parent of the new edge. * @param id Optional string that defines the Id of the new edge. * @param value Object to be used as the user object. * @param source Cell that defines the source of the edge. * @param target Cell that defines the target of the edge. * @param style Optional string that defines the cell style. * @return Returns the new edge to be inserted. */ public Object createEdge(Object parent, String id, Object value, Object source, Object target, String style) { mxCell edge = new mxCell(value, new mxGeometry(), style); edge.setId(id); edge.setEdge(true); edge.getGeometry().setRelative(true); return edge; }
int edgeCount = currVertex.getEdgeCount(); mxCell currEdge = new mxCell(); ArrayList<mxCell> neighborVertexes = new ArrayList<mxCell>(); currEdge = (mxCell) currVertex.getEdgeAt(j); mxCell source = (mxCell) currEdge.getSource(); mxCell destination = (mxCell) currEdge.getTarget();
/** * Hook for creating the group cell to hold the given array of <mxCells> if * no group cell was given to the <group> function. The children are just * for informational purpose, they will be added to the returned group * later. Note that the returned group should have a geometry. The * coordinates of which are later overridden. * * @param cells * @return Returns a new group cell. */ public Object createGroupCell(Object[] cells) { mxCell group = new mxCell("", new mxGeometry(), null); group.setVertex(true); group.setConnectable(false); return group; }
/** * Recursively finds the visual elements. * * @param parent The parent node. * @param nodes List of thre nodes. * @param edges List of the edges. */ protected static final void getVisualElements(mxCell parent, List<VNode> nodes, List<VEdge> edges) { if (parent instanceof VNode) { if (!(parent instanceof VInParameter) && !(parent instanceof VOutParameter)) { nodes.add((VNode) parent); } } else if (parent instanceof VEdge) { edges.add((VEdge) parent); } for (int i = 0; i < parent.getChildCount(); ++i) { getVisualElements((mxCell) parent.getChildAt(i), nodes, edges); } } }
/** * Constructs a new cell codec. */ public mxCellCodec() { this(new mxCell(), null, new String[] { "parent", "source", "target" }, null); }
cell.setVertex(true); mxRectangle bounds = new mxRectangle(); bounds.setHeight(80);
public mxICell insert(mxICell child) { int index = getChildCount(); if (child.getParent() == this) { index--; } return insert(child, index); }
public mxICell remove(int index) { mxICell child = null; if (children != null && index >= 0) { child = getChildAt(index); remove(child); } return child; }