コード例 #1
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());
  }