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

// $Id: MoveTransition.java,v 1.10 2003/03/06 00:40:48 moltmans Exp $
// Time-stamp: <2000-03-11 18:54:45 moltmans>
package rec.core;


import rec.util.*;
import rec.geo.*;
import rec.sys.*;

public class MoveTransition extends AlterTransition
{
  private GPoint m_NewLocation;
  private GPoint m_OldLocation;

  public MoveTransition( Surface s, VisibleWidget movedWidget,
			 GPoint oldLocation, GPoint newLocation )
  {
    super( s, movedWidget );

    m_TargetWidget = movedWidget;
    m_NewLocation = newLocation;
    m_OldLocation = oldLocation;
  }
  
  public MoveTransition( Surface s, VisibleWidget movedWidget,
			 GPoint newLocation )
  {
    super( s, movedWidget );

    m_TargetWidget = movedWidget;
    m_NewLocation = newLocation;
    m_OldLocation = new GPoint( m_TargetWidget.getLocation().getCenter() );
  }

  public void doDo()
  {
    m_TargetWidget.move( m_NewLocation );
  }

  public void doUndo()
  {
    m_TargetWidget.move( m_OldLocation );
  }


  public String getAction()
  {
    return "move widget " + m_TargetWidget + " from " + m_OldLocation
      + " to " + m_NewLocation;
  }
  
  public GPoint getChange()
  {
    return new GPoint(  m_NewLocation.x - m_OldLocation.x,
			m_NewLocation.y - m_OldLocation.y );
  }

  public GPoint getOldLocation()
  {
    return( m_OldLocation );
  }
  
}

////////////////////////////////////////////////////////////////////////////////
