Beispiel #1
0
  public synchronized void elementInserted(
      Object source, ElementType element, int pos, int newSize) {

    LinearElement parent = root;
    LinearElement previousChild = pos - 1 >= 0 ? root.getVector().get(pos - 1) : null;

    LinearElement newElement = visualizer.initElement(element, parent, previousChild);

    if (pos + 1 < newSize) // if there is a child after us
      // use pos not pos + 1 because the element has not been
      // added to the vector yet, so pos + 1 in the user's
      // vector is pos in the roots vector.
      root.getVector().get(pos).setPreviousChild(newElement);

    parent.getVector().insertElementAt(newElement, pos);
    root.focusPosition();
  }