private void setAnimationStatesForInstanceChildrenContainer(
      IFigure figure, Rectangle rect1, Rectangle rect2) {
    Rectangle instanceFigBounds = getInstanceOfDeclFigure().getInstanceBox().getBounds().getCopy();

    if (rect2.x + rect2.width < instanceFigBounds.x + instanceFigBounds.width)
      rect2.width = instanceFigBounds.width;
    rect2.height = LayoutUtil.getHeightToContainAllChildren(figure);

    Rectangle invocationFigBounds = getInvocationFigure().getBounds().getCopy();
    rect1.x = invocationFigBounds.x;
    rect1.y = rect2.y;
    rect1.width = rect2.width + rect2.x - invocationFigBounds.x;
    rect1.height = rect2.height;
  }
  private void setAnimationStatesForNewDecl(Rectangle rect1, Rectangle rect2) {
    if (isCallToDifferentClass()) {
      Rectangle invocationFigBounds = getInvocationFigure().getBounds().getCopy();

      rect1.x = invocationFigBounds.x;
      rect1.y = invocationFigBounds.y;
      rect1.width = rect2.width;
      rect1.height = rect2.height;

      rect2.y = invocationFigBounds.y;
    } else if (isCallToSameClass()) {
      rect1.x = rect2.x;
      rect1.y = rect2.height / 2 + rect2.y;
      rect1.width = rect2.width;
      rect1.height = 0;
    }
  }
  private void setAnimationStatesForOtherMethods(
      MethodBoxFigure figure, Rectangle rect1, Rectangle rect2) {
    Rectangle invocationBounds = figure.getPartner().getBounds().getCopy();
    rect1.y = invocationBounds.y;
    rect2.y = invocationBounds.y;

    rect1.x = rect2.x - 1; // kluge to avoid the rect1==rect2 continue in animation playback
    rect1.height = rect2.height;
    rect1.width = rect2.width;
  }
  public void relocate(CellEditor celleditor) {
    if (celleditor == null) return;
    Text text = (Text) celleditor.getControl();

    Rectangle rect = fig.getClientArea(Rectangle.SINGLETON);
    if (fig instanceof Label) rect = ((Label) fig).getTextBounds().intersect(rect);
    fig.translateToAbsolute(rect);

    org.eclipse.swt.graphics.Rectangle trim = text.computeTrim(0, 0, 0, 0);
    rect.translate(trim.x, trim.y);
    rect.width += trim.width;
    rect.height += trim.height;

    text.setBounds(rect.x, rect.y, rect.width, rect.height);
  }
 @Override
 public void setAnimationStates(IFigure figure, Rectangle rect1, Rectangle rect2) {
   if (figure.equals(getDeclarationFigure())) {
     setAnimationStatesForNewDecl(rect1, rect2);
   } else if (isCallToDifferentClass()
       && figure.equals(getInstanceOfDeclFigure().getChildrenContainer())) {
     setAnimationStatesForInstanceChildrenContainer(figure, rect1, rect2);
   } else if (isCallToDifferentClass()
       && figure instanceof MethodBoxFigure
       && MethodBoxModel.declaration == ((MethodBoxFigure) figure).getType()
       && ((MethodBoxFigure) figure).getPartner() != null) {
     setAnimationStatesForOtherMethods((MethodBoxFigure) figure, rect1, rect2);
   } else {
     rect1.x = rect2.x;
     rect1.y = rect2.y;
     rect1.width = rect2.width;
     rect1.height = rect2.height;
   }
 }