public void removeHighlights(CompoundModel mdl) { for (int i = 0; i < mdl.getChildren().size(); i++) { NodeModel node = (NodeModel) mdl.getChildren().get(i); node.setHighlight(false); if (node instanceof CompoundModel) { removeHighlights((CompoundModel) node); } } }
private void updateMarginSize(CompoundModel root) { for (Object o : root.getChildren()) { GraphObject child = (GraphObject) o; if (child instanceof CompoundModel) { updateMarginSize((CompoundModel) child); } } root.calculateSizeUp(); }
public boolean isAncestorofNode(NodeModel node) { CompoundModel root = node.getParentModel(); while (root != null) { if (root == this) { return true; } else { root = root.getParentModel(); } } return false; }
public void setMarginSize(int margin) { this.MARGIN_SIZE = margin; CompoundModel root = this; while (root.getParentModel() != null) { root = root.getParentModel(); } for (Object o : root.getChildren()) { if (o instanceof CompoundModel) { updateMarginSize((CompoundModel) o); } } }
public void setParentModel(CompoundModel parent) { super.setParentModel(parent); // if a parent of a model is set as null, do not update ClusterManager if (parent != null) { setClusterManager(parent.getClusterManager()); } }
public void execute() { child.setHighlight(false); if (child instanceof CompoundModel) { removeHighlights((CompoundModel) child); } primExecute(); parent.calculateSizeUp(); }
/** This method calculates sizes of children recursively and then calculates its own size. */ public void calculateSizeDown() { // First, recursively calculate sizes of children compounds Iterator iter = this.children.iterator(); while (iter.hasNext()) { NodeModel child = (NodeModel) iter.next(); if (child instanceof CompoundModel) { ((CompoundModel) child).calculateSizeDown(); } } if (getParentModel() != null && !isRoot) { // Second, calculate size of this compound model if (this.children.size() == 0) { setSize(CompoundModel.DEFAULT_SIZE); } else { Rectangle bound = calculateBounds(); Dimension diff = getLocationAbs().getDifference(bound.getLocation()); setLocationAbs(new Point(bound.x - this.MARGIN_SIZE, bound.y - this.MARGIN_SIZE)); setSize( new Dimension( bound.width + (2 * this.MARGIN_SIZE), bound.height + (2 * this.MARGIN_SIZE) + this.labelHeight)); iter = this.children.iterator(); while (iter.hasNext()) { NodeModel child = (NodeModel) iter.next(); child.setLocationAbs( child .getLocationAbs() .translate(diff.width + this.MARGIN_SIZE, diff.height + this.MARGIN_SIZE)); } } } }
public void undo() { parent.addChild(child); child.setParentModel(parent); restoreConnections(); }
protected void primExecute() { deleteConnections(child); parent.removeChild(child); }