Refine search
public void execute(Object parent) { mxIGraphModel model = graph.getModel(); List<Object> roots = graph.findTreeRoots(parent, true, invert); layout(node); double x0 = graph.getGridSize(); double y0 = x0; if (!moveTree || parent == graph.getDefaultParent() || parent == graph.getCurrentRoot()) { mxGeometry g = model.getGeometry(root); if (g.isRelative()) { mxRectangle size = graph.getStartSize(parent); dx += size.getWidth(); dy += size.getHeight(); if (resizeParent && !graph.isCellCollapsed(parent)) { mxGeometry g = model.getGeometry(parent); if (model.getParent(node.cell) != graph.getCurrentRoot() && model.getParent(node.cell) != graph.getDefaultParent()) { moveNode(node, dx, dy);
protected void layout(FlowElementsContainer flowElementsContainer) { graph = new mxGraph(); cellParent = graph.getDefaultParent(); graph.getModel().beginUpdate(); layout.setDisableEdgeStyle(false); layout.setUseBoundingBox(true); layout.execute(graph.getDefaultParent()); graph.getModel().endUpdate();
protected void handleAssociations() { Hashtable<String, Object> edgeStyle = new Hashtable<String, Object>(); edgeStyle.put(mxConstants.STYLE_ORTHOGONAL, true); edgeStyle.put(mxConstants.STYLE_EDGE, mxEdgeStyle.ElbowConnector); edgeStyle.put(mxConstants.STYLE_ENTRY_X, 0.0); edgeStyle.put(mxConstants.STYLE_ENTRY_Y, 0.5); graph.getStylesheet().putCellStyle(STYLE_SEQUENCEFLOW, edgeStyle); Hashtable<String, Object> boundaryEdgeStyle = new Hashtable<String, Object>(); boundaryEdgeStyle.put(mxConstants.STYLE_EXIT_X, 0.5); boundaryEdgeStyle.put(mxConstants.STYLE_EXIT_Y, 1.0); boundaryEdgeStyle.put(mxConstants.STYLE_ENTRY_X, 0.5); boundaryEdgeStyle.put(mxConstants.STYLE_ENTRY_Y, 1.0); boundaryEdgeStyle.put(mxConstants.STYLE_EDGE, mxEdgeStyle.OrthConnector); graph.getStylesheet().putCellStyle(STYLE_BOUNDARY_SEQUENCEFLOW, boundaryEdgeStyle); for (Association association : associations.values()) { Object sourceVertex = generatedVertices.get(association.getSourceRef()); Object targetVertex = generatedVertices.get(association.getTargetRef()); String style = null; if (handledFlowElements.get(association.getSourceRef()) instanceof BoundaryEvent) { // Sequence flow out of boundary events are handled in a different way, // to make them visually appealing for the eye of the dear end user. style = STYLE_BOUNDARY_SEQUENCEFLOW; } else { style = STYLE_SEQUENCEFLOW; } Object associationEdge = graph.insertEdge(cellParent, association.getId(), "", sourceVertex, targetVertex, style); generatedAssociationEdges.put(association.getId(), associationEdge); } }
/** * Returns a boolean indicating if the given <em>mxCell</em> should be ignored as a vertex. This returns true if the cell has no connections. * * @param vertex * Object that represents the vertex to be tested. * @return Returns true if the vertex should be ignored. */ public boolean isVertexIgnored(Object vertex) { return super.isVertexIgnored(vertex) || graph.isSwimlane(vertex) || graph.getModel().getGeometry(vertex).isRelative() || graph.getConnections(vertex).length == 0; }
protected void createEventVertex(FlowElement flowElement) { // Add styling for events if needed if (!graph.getStylesheet().getStyles().containsKey(STYLE_EVENT)) { Hashtable<String, Object> eventStyle = new Hashtable<String, Object>(); eventStyle.put(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_ELLIPSE); graph.getStylesheet().putCellStyle(STYLE_EVENT, eventStyle); } // Add vertex representing event to graph Object eventVertex = graph.insertVertex(cellParent, flowElement.getId(), "", 0, 0, eventSize, eventSize, STYLE_EVENT); generatedVertices.put(flowElement.getId(), eventVertex); }
/** * Returns true if the given cells should be removed from the parent for the specified * mousereleased event. */ protected boolean shouldRemoveCellFromParent(Object parent, Object[] cells, MouseEvent e) { if (graphComponent.getGraph().getModel().isVertex(parent)) { mxCellState pState = graphComponent.getGraph().getView() .getState(parent); return pState != null && !pState.contains(e.getX(), e.getY()); } return false; }
/** * Returns an mxPoint representing the given event in the unscaled, * non-translated coordinate space and applies the grid. */ public mxPoint getPointForEvent(MouseEvent e, boolean addOffset) { double s = graph.getView().getScale(); mxPoint tr = graph.getView().getTranslate(); double off = (addOffset) ? graph.getGridSize() / 2 : 0; double x = graph.snap(e.getX() / s - tr.getX() - off); double y = graph.snap(e.getY() / s - tr.getY() - off); return new mxPoint(x, y); }
/** * */ public Rectangle getFoldingIconBounds(mxCellState state, ImageIcon icon) { mxIGraphModel model = graph.getModel(); boolean isEdge = model.isEdge(state.getCell()); double scale = getGraph().getView().getScale(); int x = (int) Math.round(state.getX() + 4 * scale); int y = (int) Math.round(state.getY() + 4 * scale); int w = (int) Math.max(8, icon.getIconWidth() * scale); int h = (int) Math.max(8, icon.getIconHeight() * scale); if (isEdge) { mxPoint pt = graph.getView().getPoint(state); x = (int) pt.getX() - w / 2; y = (int) pt.getY() - h / 2; } return new Rectangle(x, y, w, h); }
@Override public void mouseReleased(MouseEvent ev) { if (nodeExploder != null && !ev.isConsumed() && isEditEvent(ev)) { Object cell = getCellAt(ev.getX(), ev.getY(), false); if (cell != null && getGraph().isCellEditable(cell)) { String nodeLabel = (String) graph.getModel().getValue(cell); if (nodeLabel != null) { nodeExploder.explode(nodeLabel); } } } } });
/** * Returns the folding icon bounds. */ public Rectangle getFoldingIconBounds(mxCellState state, ImageIcon icon) { if (state.getCell() instanceof VSubProcess) { double scale = getGraph().getView().getScale(); int w = (int) Math.max(8, icon.getIconWidth() * scale); int h = (int) Math.max(8, icon.getIconHeight() * scale); int x = (int) Math.round(state.getX() + state.getWidth() * 0.5 - w * 0.5); int y = (int) Math.round(state.getY() + state.getHeight() - h * 1.25); return new Rectangle(x, y, w, h); } return super.getFoldingIconBounds(state, icon); }
Object target, MouseEvent e) mxGraph graph = graphComponent.getGraph(); boolean clone = e.isControlDown() && isCloneEnabled(); cells = graph.getCloneableCells(cells); && isRemoveCellsFromParent() && shouldRemoveCellFromParent( graph.getModel().getParent(initialCell), cells, e)) target = graph.getDefaultParent(); Object[] tmp = graph.moveCells(cells, dx, dy, clone, target, e.getPoint()); graph.setSelectionCells(tmp);
/** * */ public Object[] stop(boolean commit, MouseEvent e, double dx, double dy, boolean clone, Object target) { Object[] cells = movingCells; reset(); mxGraph graph = graphComponent.getGraph(); graph.getModel().beginUpdate(); try { if (commit) { double s = graph.getView().getScale(); cells = graph.moveCells(cells, dx / s, dy / s, clone, target, e.getPoint()); } fireEvent(new mxEventObject(mxEvent.STOP, "event", e, "commit", commit)); } finally { graph.getModel().endUpdate(); } return cells; }
/** * */ public void start(MouseEvent e) { if (isLivePreview()) { movePreview.start(e, graphComponent.getGraph().getView().getState(initialCell)); } else { mxGraph graph = graphComponent.getGraph(); // Constructs an array with cells that are indeed movable cells = getCells(initialCell); cellBounds = graph.getView().getBounds(cells); if (cellBounds != null) { // Updates the size of the graph handler that is in // charge of painting all other handlers bbox = graph.getView().getBoundingBox(cells); Rectangle bounds = cellBounds.getRectangle(); bounds.width += 1; bounds.height += 1; setPreviewBounds(bounds); } } first = e.getPoint(); }
/** * */ public boolean hitFoldingIcon(Object cell, int x, int y) { if (cell != null) { mxIGraphModel model = graph.getModel(); // Draws the collapse/expand icons boolean isEdge = model.isEdge(cell); if (foldingEnabled && (model.isVertex(cell) || isEdge)) { mxCellState state = graph.getView().getState(cell); if (state != null) { ImageIcon icon = getFoldingIcon(state); if (icon != null) { return getFoldingIconBounds(state, icon).contains(x, y); } } } } return false; }
/** * */ public void mouseReleased(MouseEvent e) { if (graphComponent.isEnabled() && isEnabled() && !e.isConsumed() && current != null) { mxGraph graph = graphComponent.getGraph(); double scale = graph.getView().getScale(); mxPoint tr = graph.getView().getTranslate(); current.setX(current.getX() / scale - tr.getX()); current.setY(current.getY() / scale - tr.getY()); current.setWidth(current.getWidth() / scale); current.setHeight(current.getHeight() / scale); Object cell = insertCell(current); eventSource.fireEvent(new mxEventObject(mxEvent.INSERT, "cell", cell)); e.consume(); } reset(); }
Rectangle[] h = new Rectangle[4]; mxPoint p0 = state.getAbsolutePoint(0); mxPoint pe = state.getAbsolutePoint(state.getAbsolutePointCount() - 1); mxGeometry geometry = graphComponent.getGraph().getModel().getGeometry( state.getCell()); List<mxPoint> points = geometry.getPoints(); mxGraphView view = graphComponent.getGraph().getView(); pt = view.transformControlPoint(state, points.get(0)) .getPoint(); if (isHandleVisible(3) && h[1].intersects(h[3]))
public static mxGraph makeHelloWorldGraph() { mxGraph graph = new mxGraph(); Object parent = graph.getDefaultParent(); graph.getModel().beginUpdate(); try { Object v1 = graph.insertVertex(parent, null, "", 20, 20, 80, 30,"opacity=0"); Object v2 = graph.insertVertex(parent, null, "World!", 240, 150, 80, 30); graph.insertEdge(parent, null, "Edge", v1, v2); } finally { graph.getModel().endUpdate(); } return graph; }
private FileEntry createNetworkTopologyGraph(CubeDockerConfiguration cubeDockerConfiguration, DockerClientExecutor executor, ReporterConfiguration reporterConfiguration) { mxGraph graph = new mxGraph(); Object parent = graph.getDefaultParent(); graph.setAutoSizeCells(true); graph.getModel().beginUpdate(); try { DockerCompositions dockerCompositions = cubeDockerConfiguration.getDockerContainersContent(); for (Map.Entry<String, CubeContainer> container: containers.entrySet()) { final String containerId = container.getKey(); Object containerName = graph.insertVertex(parent, null, containerId, 0, 0, 80, 30); final CubeContainer cubeContainer = container.getValue(); if (!cubeContainer.isManual()) { nwName = insertedVertex.get(nw); } else { nwName = graph.insertVertex(parent, null, nw, 0, 0, 60, 20); graph.setCellStyles(mxConstants.STYLE_FILLCOLOR, "#00FF00", new Object[]{nwName}); graph.updateCellSize(nwName); graph.insertEdge(parent, null, nw, containerName, nwName); insertedVertex.put(nw, nwName); graph.getModel().endUpdate(); layout.execute(graph.getDefaultParent());