コード例 #1
0
ファイル: ALinearEventTrapper.java プロジェクト: pdewan/YAAS
  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();
  }
コード例 #2
0
ファイル: ALinearEventTrapper.java プロジェクト: pdewan/YAAS
  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());
  }