// (c) MIT 2003.  All rights reserved.

// -*-Mode: Java-*- 
// $Id: WMovementAnnotation.java,v 1.2 2003/03/06 00:40:43 moltmans Exp $
// WMovementAnnotation.java -- 
// Author: Michael Oltmans <moltmans@ai.mit.edu> 
// Created: <Fri Oct 29 15:21:25 1999> 
// Time-stamp: <2000-04-06 16:42:06 moltmans> 
package rec.annotate.widgets;

import java.awt.Color;
import rec.util.*;
import rec.sys.*;
import rec.core.widgets.*;
import rec.simulate.widgets.*;
import rec.annotate.*;


//  NEED to tie annotations to their source gestures so if the source is
//  deleted the annotation is deleted...  how will this work with merged
//  annotations?  Sheittt.

/**
 * This represents the motion that a body makes as part of its
 * behavior.
 **/
public class WMovementAnnotation extends WAnnotation
{
  private Color m_originalColor;
  
  public WMovementAnnotation( MovementAnnotation a,
			      AnnotationNotebook book )
  {
    super( a, book );
  }

  public WAnnotation makeAnnotationWidget( Annotation a,
					   AnnotationNotebook book )
  {
    Assert.check( a instanceof MovementAnnotation,
		  "Cannot make a WMovementAnnotation from: " + a );
    return new WMovementAnnotation( (MovementAnnotation)a, book );
  }

  public WSquiggleArrow getPath() 
  {
    Entity path = ((MovementAnnotation)m_annotation).getPath();
    WSquiggleArrow arrow = (WSquiggleArrow)path.getWidget();
    return arrow;
  }

  public void performAction( Surface s )
  {
    WSquiggleArrow arrow = getPath();

    if ( arrow != null ) {
      m_originalColor = arrow.getColor();
      arrow.setColor( java.awt.Color.green );
      s.addWidgetToSurface( arrow );
    }
  }

  public void undoAction( Surface s )
  {
    WSquiggleArrow arrow = getPath();
    if ( arrow != null ) {
      arrow.setColor( m_originalColor );
      s.removeWidgetFromSurface( arrow );
    }
  }
}


