protected void layout(FlowElementsContainer flowElementsContainer) { graph = new mxGraph(); cellParent = graph.getDefaultParent(); graph.getModel().beginUpdate(); layout.execute(graph.getDefaultParent()); graph.getModel().endUpdate();
parent = model.getParent(root); parent = model.getParent(parent); model.beginUpdate(); mxGeometry g = model.getGeometry(root); if (g.isRelative()) { g = model.getGeometry(model.getParent(root)); mxGeometry g = model.getGeometry(parent); model.setGeometry(parent, g); if (model.getParent(node.cell) != graph.getCurrentRoot() && model.getParent(node.cell) != graph.getDefaultParent()) { moveNode(node, dx, dy); model.endUpdate();
model.beginUpdate(); try String style = setStyle(model.getStyle(cells[i]), key, value); model.setStyle(cells[i], style); model.endUpdate();
model.beginUpdate(); try model.setStyle(cells[i], style); model.endUpdate();
/** * Sets the source and target of the given edge in a single atomic change. * * @param edge Cell that specifies the edge. * @param source Cell that specifies the new source terminal. * @param target Cell that specifies the new target terminal. */ public static void setTerminals(mxIGraphModel model, Object edge, Object source, Object target) { model.beginUpdate(); try { model.setTerminal(edge, source, true); model.setTerminal(edge, target, false); } finally { model.endUpdate(); } }
/** * Resets the control points of the given edge. */ public Object resetEdge(Object edge) { mxGeometry geo = model.getGeometry(edge); if (geo != null) { // Resets the control points List<mxPoint> points = geo.getPoints(); if (points != null && !points.isEmpty()) { geo = (mxGeometry) geo.clone(); geo.setPoints(null); model.setGeometry(edge, geo); } } return edge; }
mxGeometry geometry = model.getGeometry(edge); Object parent = graph.getModel().getParent(edge); model.setGeometry(edge, geometry);
public void actionPerformed(ActionEvent e1) { if (e1 != null) { EdgeDragContextMenu edcm = edcmc[0]; ((mxCell) connectPreview.getPreviewState().getCell()).setTarget(edcm.getTarget()); } reallycommit = true; EdgeController.super.mouseReleased(e); graphComponent.getGraph().getModel().endUpdate(); reallycommit = false; } };
mxGeometry geo = model.getGeometry(cell); geo.translate(dx, dy); if (!geo.isRelative() && model.isVertex(cell) && !isAllowNegativeCoordinates()) if (geo.isRelative() && !model.isEdge(cell)) model.setGeometry(cell, geo);
/** * Returns the cells with the same parent as the first cell * in the given array. */ public Object[] getCellsForGroup(Object[] cells) { List<Object> result = new ArrayList<Object>(cells.length); if (cells.length > 0) { Object parent = model.getParent(cells[0]); result.add(cells[0]); // Filters selection cells with the same parent for (int i = 1; i < cells.length; i++) { if (model.getParent(cells[i]) == parent) { result.add(cells[i]); } } } return result.toArray(); }
public mxPoint getParentOffset(Object parent) { mxPoint result = new mxPoint(); if (parent != null && parent != this.parent) { mxIGraphModel model = graph.getModel(); if (model.isAncestor(this.parent, parent)) { mxGeometry parentGeo = model.getGeometry(parent); while (parent != this.parent) { result.setX(result.getX() + parentGeo.getX()); result.setY(result.getY() + parentGeo.getY()); parent = model.getParent(parent);; parentGeo = model.getGeometry(parent); } } } return result; }
/** * 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; }
/** * Creates a collection of cells using the visitor pattern. */ public static Collection<Object> filterDescendants(mxIGraphModel model, Filter filter) { return filterDescendants(model, filter, model.getRoot()); }
/** * Returns true if the given cell should be kept inside the bounds of its * parent according to the rules defined by getOverlap and * isAllowOverlapParent. This implementation returns false for all children * of edges and isConstrainChildren() otherwise. */ public boolean isConstrainChild(Object cell) { return isConstrainChildren() && !getModel().isEdge(getModel().getParent(cell)); }
private void setVertexStyle(final mxICell vertex, final String colorstr) { String targetStyle = vertex.getStyle(); targetStyle = mxStyleUtils.removeAllStylenames(targetStyle); targetStyle = mxStyleUtils.setStyle(targetStyle , mxConstants.STYLE_STROKECOLOR, colorstr ); // Style specifics int width, height; if (globalStyle.equals(SIMPLE_STYLE_NAME)) { targetStyle = mxStyleUtils.setStyle(targetStyle, mxConstants.STYLE_FILLCOLOR, colorstr); width = DEFAULT_CELL_HEIGHT; height = width; } else { targetStyle = mxStyleUtils.setStyle(targetStyle, mxConstants.STYLE_FILLCOLOR, "white"); width = DEFAULT_CELL_WIDTH; height = DEFAULT_CELL_HEIGHT; } targetStyle = globalStyle + ";" + targetStyle; graphx.getModel().setStyle(vertex, targetStyle); graphx.getModel().getGeometry(vertex).setWidth(width); graphx.getModel().getGeometry(vertex).setHeight(height); }
/** * Returns true if the label bounds of the state should be used for the * editor. */ protected boolean useLabelBounds(mxCellState state) { mxIGraphModel model = state.getView().getGraph().getModel(); mxGeometry geometry = model.getGeometry(state.getCell()); return ((geometry != null && geometry.getOffset() != null && !geometry.isRelative() && (geometry.getOffset().getX() != 0 || geometry .getOffset().getY() != 0)) || model.isEdge(state.getCell())); }
/** * Returns whether or not the specified parent is a valid * ancestor of the specified cell, either direct or indirectly * based on whether ancestor recursion is enabled. * @param cell the possible child cell * @param parent the possible parent cell * @param recurse whether or not to recurse the child ancestors * @return whether or not the specified parent is a valid * ancestor of the specified cell, either direct or indirectly * based on whether ancestor recursion is enabled. */ public boolean isValidAncestor(Object cell, Object parent, boolean recurse) { return (recurse ? model.isAncestor(parent, cell) : model .getParent(cell) == parent); }
/** * Returns true if the given cell may not be moved, sized, bended, * disconnected, edited or selected. This implementation returns true for * all vertices with a relative geometry if cellsLocked is false. * * @param cell Cell whose locked state should be returned. * @return Returns true if the given cell is locked. */ public boolean isCellLocked(Object cell) { mxGeometry geometry = model.getGeometry(cell); return isCellsLocked() || (geometry != null && model.isVertex(cell) && geometry .isRelative()); }
/** * Returns the first child of the root in the model, that is, the first or * default layer of the diagram. * * @return Returns the default parent for new cells. */ public Object getDefaultParent() { Object parent = defaultParent; if (parent == null) { parent = view.getCurrentRoot(); if (parent == null) { Object root = model.getRoot(); parent = model.getChildAt(root, 0); } } return parent; }