Esempio n. 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);
      }
    }
  }
Esempio n. 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();
  }
Esempio n. 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;
  }
Esempio n. 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);
      }
    }
  }
Esempio n. 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());
    }
  }
Esempio n. 6
0
  public void execute() {
    child.setHighlight(false);

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

    primExecute();
    parent.calculateSizeUp();
  }
Esempio n. 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));
        }
      }
    }
  }
Esempio n. 8
0
 public void undo() {
   parent.addChild(child);
   child.setParentModel(parent);
   restoreConnections();
 }
Esempio n. 9
0
 protected void primExecute() {
   deleteConnections(child);
   parent.removeChild(child);
 }