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

package rec.core;


////////////////////////////////////////////////////////////////////////////////
//
// FILE:	DeletePolygonTransition.java
//
// AUTHOR:	Manoj D. Muzumdar
//		archon@ai.mit.edu
//
// DATE:	June, 1998
//
// COPYRIGHT:	Massachusetts Institute of Technology
//		All rights reserved.
//
// PURPOSE:	Drawing recognition
//
// HISTORY:     September, 1998
//              MDM
//              modified to fit with new recognition model
//
////////////////////////////////////////////////////////////////////////////////


import rec.sys.*;

public class DeletePolygonTransition extends Transition
{
  public DeletePolygonTransition( Surface s, Widget deletedWidget,
				  PolygonInfo pi )
  {
    super( s );

    m_DeletedWidget = deletedWidget;
    m_PolygonInfo = pi;
  }

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

  public Widget getDeletedWidget()
  {
    return( m_DeletedWidget );
  }

  public PolygonInfo getPolygonInfo()
  {
    return( m_PolygonInfo );
  }

  public void doUndo()
  {
    for( int i = 0; i < m_PolygonInfo.getNumberOfSides(); ++i )
      getSurface().removeWidget( m_PolygonInfo.getLineAt( i ) );

    getSurface().addWidget( m_DeletedWidget );

  }

  public Transition makeRedoTransition( )
  {
    return( new CreatePolygonTransition( getSurface(), m_DeletedWidget,
					 m_PolygonInfo ) );
  }

  public String name()
  {
    return "deletePolygon";
  }
			     
  //////////////////////////////////////////////////////////////////////////////

  private Widget m_DeletedWidget;
  private PolygonInfo m_PolygonInfo;
}

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