Esempio n. 1
0
 public ALinearEventTrapper(
     yaas.visualizers.collection.tree.LinearVisualizer<ElementType> visualizer) {
   this.visualizer = visualizer;
   root = visualizer.getRoot();
   //
   //		boxWidth = ((ALinearLayoutManager<ElementType>) visualizer
   //				.getLayoutManager()).getBoxWidth();
   //		boxHeight = ((ALinearLayoutManager<ElementType>) visualizer
   //				.getLayoutManager()).getBoxHeight();
   //		dynamicWidth = ((ALinearLayoutManager<ElementType>) visualizer
   //				.getLayoutManager()).getDynamicWidth();
   //		dynamicHeight = ((ALinearLayoutManager<ElementType>) visualizer
   //				.getLayoutManager()).getDynamicHeight();
   shapes = visualizer.shapes();
 }
Esempio n. 2
0
  public synchronized void elementRemoved(Object source, int pos, int newSize) {

    LinearElement toBeRemoved = root.getVector().get(pos);
    shapes.getShapes().remove(toBeRemoved.getShape());
    visualizer.removeLine(toBeRemoved.getVerticalLine());
    visualizer.removeLine(toBeRemoved.getHorizontalLine());

    LinearElement parent = root;
    LinearElement previousChild = toBeRemoved.getPreviousChild();

    if (pos + 1 <= newSize) // If it is not the last element
    root.getVector().get(pos + 1).setPreviousChild(previousChild);

    parent.getVector().remove(toBeRemoved);

    root.focusPosition();
  }
Esempio n. 3
0
  public synchronized void elementChanged(Object source, ElementType element, int pos) {

    LinearElement node = root.getVector().get(pos);
    AnimationUtil.move(
        node,
        node.getX() + boxWidth / 3,
        node.getY(),
        true,
        ((ALinearLayoutManager<ElementType>)
                visualizer.getLayoutManagerOfBuffer((ListenableVector<ElementType>) source))
            .getHighlighting(),
        ((FlexibleShape)
                visualizer.getLayoutManagerOfBuffer((ListenableVector<ElementType>) source))
            .getColor());
    node.setObject(element);

    BoundedShape shape = node.getShape();

    try {
      double shapeStretchFactor = Double.parseDouble(element.toString());
      shape.setWidth((int) (boxWidth * (dynamicWidth ? shapeStretchFactor : 1)));
      shape.setHeight((int) (boxHeight * (dynamicHeight ? shapeStretchFactor : 1)));
    } catch (Exception e) {
      shape.setWidth((int) (boxWidth));
      shape.setHeight((int) (boxHeight));
    }

    if (shape instanceof TextShape) ((TextShape) shape).setText(element.toString());
    if (shape instanceof LabelShape) ((LabelShape) shape).setText(element.toString());

    AnimationUtil.move(
        node,
        node.getX() - boxWidth / 3,
        node.getY(),
        true,
        ((ALinearLayoutManager<ElementType>)
                visualizer.getLayoutManagerOfBuffer((ListenableVector<ElementType>) source))
            .getHighlighting(),
        ((FlexibleShape)
                visualizer.getLayoutManagerOfBuffer((ListenableVector<ElementType>) source))
            .getColor());
  }
Esempio n. 4
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();
  }