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

// $Id: WDeletion.java,v 1.5 2003/03/06 00:40:47 moltmans Exp $
// Time-stamp: <2000-04-06 17:16:22 moltmans>
package rec.core.widgets;


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

public class WDeletion extends LocatableWidget
{
  private WGroup m_Deleted;
  private Collection m_DeletedSaved;

  public WDeletion( WGroup vw )
  {
    super( vw.getLocation().getCenter() );

    setEnglishName( "Deletion" );
    m_Deleted = vw;
    m_DeletedSaved = new HashSet( m_Deleted.getWidgets() );
  }


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

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


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

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


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

  public VisibleWidget getDeleted()
  {
    return m_Deleted;
  }

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

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

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

  public Object clone()
  {
    return( new WDeletion( m_Deleted ) );
  }

  public void draw( Graphics g )
  {
    Rectangle r = m_Deleted.getBounds();

    //super.draw( g );

    g.drawRect( r.x, r.y, r.width, r.height );
  }


  // here's the transition suitcase for when the deletion is elected.
  public void makeDefaultSuitcase( Surface s )
  {
    Iterator it = m_DeletedSaved.iterator();
    while ( it.hasNext() ) {
      Widget w = (Widget)it.next();
      addToSuitcase( new DieTransition( s, w ) );
    }
    addToSuitcase( new CertainTransition( s, this ) );
    addToSuitcase( new DieTransition( s, this ) );
  }
  
 
}

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

