Пример #1
0
  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);
      }
    }
  }
Пример #2
0
  private void updateMarginSize(CompoundModel root) {
    for (Object o : root.getChildren()) {
      GraphObject child = (GraphObject) o;

      if (child instanceof CompoundModel) {
        updateMarginSize((CompoundModel) child);
      }
    }

    root.calculateSizeUp();
  }
Пример #3
0
  public boolean isAncestorofNode(NodeModel node) {
    CompoundModel root = node.getParentModel();

    while (root != null) {
      if (root == this) {
        return true;
      } else {
        root = root.getParentModel();
      }
    }

    return false;
  }
Пример #4
0
  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);
      }
    }
  }
Пример #5
0
  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());
    }
  }
Пример #6
0
  public void execute() {
    child.setHighlight(false);

    if (child instanceof CompoundModel) {
      removeHighlights((CompoundModel) child);
    }

    primExecute();
    parent.calculateSizeUp();
  }
Пример #7
0
  /** 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));
        }
      }
    }
  }
Пример #8
0
 public void undo() {
   parent.addChild(child);
   child.setParentModel(parent);
   restoreConnections();
 }
Пример #9
0
 protected void primExecute() {
   deleteConnections(child);
   parent.removeChild(child);
 }