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

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


import java.awt.*;
import java.util.*;
import rec.util.*;
import rec.geo.*;
import rec.sys.*;
import rec.core.*;

public class WMove extends LocatableWidget
{
  private VisibleWidget m_Widget;
  private GPoint m_Dest;
  
  public WMove( VisibleWidget vw, GPoint dest )
  {
    super( vw.getLocation().getCenter() );

    m_Widget = vw;
    m_Dest = dest;
  }


  public double size()
  {
    return( m_Widget.size() );
  }

  public void resize( double scaleFactor )
  {
    m_Widget.resize( scaleFactor );
  }


  public void move( GPoint gp )
  {
    Assert.error( "cannot move a move -- but this assert may not apply" );
  }

  public void rotate( GPoint gp, double angle )
  {
    Assert.error( "cannot rotate a move -- but this assert may not apply" );
  }


  public Location getLocation()
  {
    return( m_Widget.getLocation() );
  }

  public VisibleWidget getDeleted()
  {
    return m_Widget;
  }

  public Rectangle getBounds()
  {
    return( m_Widget.getBounds() );
  }

  public boolean includes( GPoint gp, double offset )
  {
    return m_Widget.includes( gp, offset );
  }

  public VisibleWidget getWidget()
  {
    return( m_Widget );
  }

  public Object clone()
  {
    return( new WMove( m_Widget, m_Dest ) );
  }

  protected void makeDefaultSuitcase( Surface s )
  {
    addToSuitcase( new CertainTransition( s, this ) );

    // perhaps this loop should be in a transition of its own.
    Collection anc_and_me = m_Widget.getAncestors();
    anc_and_me.add( m_Widget );
    Iterator it = anc_and_me.iterator();
    while ( it.hasNext() ) {
      Object o = it.next();
      if ( o instanceof VisibleWidget ) {
	addToSuitcase( new MoveTransition( s, (VisibleWidget)o , m_Dest ) );
      }
    }

    // now also get rid of any children of 
    addToSuitcase( new DieTransition( s, this ) );
    
  }
  
  
 
}

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

