parent = model.getParent(root); parent = model.getParent(parent); mxGeometry g = model.getGeometry(root); if (g.isRelative()) { g = model.getGeometry(model.getParent(root)); if (model.getParent(node.cell) != graph.getCurrentRoot() && model.getParent(node.cell) != graph.getDefaultParent()) { moveNode(node, dx, dy);
/** * 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(); }
/** * Returns the terminal to be used for a given port. This implementation * always returns the parent cell. * * @param cell Cell that represents the port. * @param source If the cell is the source or target port. * @return Returns the terminal to be used for the given port. */ public Object getTerminalForPort(Object cell, boolean source) { return getModel().getParent(cell); }
/** * */ public static Object[] getParents(mxIGraphModel model, Object[] cells) { HashSet<Object> parents = new HashSet<Object>(); if (cells != null) { for (int i = 0; i < cells.length; i++) { Object parent = model.getParent(cells[i]); if (parent != null) { parents.add(parent); } } } return parents.toArray(); }
/** * */ public static Object[] getParents(mxIGraphModel model, Object[] cells) { HashSet<Object> parents = new HashSet<Object>(); if (cells != null) { for (int i = 0; i < cells.length; i++) { Object parent = model.getParent(cells[i]); if (parent != null) { parents.add(parent); } } } return parents.toArray(); }
/** * Returns the terminal to be used for a given port. This implementation * always returns the parent cell. * * @param cell Cell that represents the port. * @param source If the cell is the source or target port. * @return Returns the terminal to be used for the given port. */ public Object getTerminalForPort(Object cell, boolean source) { return getModel().getParent(cell); }
/** * 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 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); }
/** * Constructs a change of the current root in the given view. */ public mxCurrentRootChange(mxGraphView view, Object root) { this.view = view; this.root = root; this.previous = this.root; this.up = (root == null); if (!up) { Object tmp = view.getCurrentRoot(); mxIGraphModel model = view.graph.getModel(); while (tmp != null) { if (tmp == root) { up = true; break; } tmp = model.getParent(tmp); } } }
/** * 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)); }
/** * 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)); }
/** * */ protected void cellsMoved(Object[] cells, Point location) { if (cells != null && location != null) { mxIGraphModel model = getGraph().getModel(); // Checks if a layout exists to take care of the moving for (int i = 0; i < cells.length; i++) { mxIGraphLayout layout = getLayout(model.getParent(cells[i])); if (layout != null) { layout.moveCell(cells[i], location.x, location.y); } } } }
/** * */ protected void cellsMoved(Object[] cells, Point location) { if (cells != null && location != null) { mxIGraphModel model = getGraph().getModel(); // Checks if a layout exists to take care of the moving for (int i = 0; i < cells.length; i++) { mxIGraphLayout layout = getLayout(model.getParent(cells[i])); if (layout != null) { layout.moveCell(cells[i], location.x, location.y); } } } }
/** * Changes the root of the model. */ public void execute() { Object tmp = model.getParent(child); int tmp2 = getChildIndex(tmp, child); if (previous == null) { connect(child, false); } tmp = ((mxGraphModel) model).parentForCellChanged(child, previous, previousIndex); if (previous != null) { connect(child, true); } parent = previous; previous = tmp; index = previousIndex; previousIndex = tmp2; }
/** * Returns the drop target for the given transferable and location. */ protected Object getDropTarget(mxGraphComponent graphComponent, mxGraphTransferable gt) { Object[] cells = gt.getCells(); Object target = null; // Finds the target cell at the given location and checks if the // target is not already the parent of the first imported cell if (location != null) { target = graphComponent.getGraph().getDropTarget(cells, location, graphComponent.getCellAt(location.x, location.y)); if (cells.length > 0 && graphComponent.getGraph().getModel().getParent(cells[0]) == target) { target = null; } } return target; }
/** * Returns the drop target for the given transferable and location. */ protected Object getDropTarget(mxGraphComponent graphComponent, mxGraphTransferable gt) { Object[] cells = gt.getCells(); Object target = null; // Finds the target cell at the given location and checks if the // target is not already the parent of the first imported cell if (location != null) { target = graphComponent.getGraph().getDropTarget(cells, location, graphComponent.getCellAt(location.x, location.y)); if (cells.length > 0 && graphComponent.getGraph().getModel().getParent(cells[0]) == target) { target = null; } } return target; }
@SuppressWarnings( "unused" ) private void toggleBranchFolding() { Object parent; if ( trackScheme.getGraph().isCellFoldable( cell, true ) ) { parent = cell; } else { parent = trackScheme.getGraph().getModel().getParent( cell ); } trackScheme.getGraph().foldCells( !trackScheme.getGraph().isCellCollapsed( parent ), false, new Object[] { parent } ); }
@SuppressWarnings( "unused" ) private void toggleBranchFolding() { Object parent; if ( trackScheme.getGraph().isCellFoldable( cell, true ) ) { parent = cell; } else { parent = trackScheme.getGraph().getModel().getParent( cell ); } trackScheme.getGraph().foldCells( !trackScheme.getGraph().isCellCollapsed( parent ), false, new Object[] { parent } ); }
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; }
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; }