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

package rec.core;


////////////////////////////////////////////////////////////////////////////////
//
// FILE:	CreatePolygonTransition.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 CreatePolygonTransition extends Transition
{
  public CreatePolygonTransition( Surface s, Widget createdWidget,
				  PolygonInfo pi )
  {
    super( s );

    m_CreatedWidget = createdWidget;
    m_PolygonInfo = pi;
  }

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

  public Widget getCreatedWidget()
  {
    return( m_CreatedWidget );
  }

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

  public void doUndo()
  {
    getSurface().removeWidget( m_CreatedWidget );

    for( int i = 0; i < m_PolygonInfo.getNumberOfSides(); ++i )
      getSurface().addWidget( m_PolygonInfo.getLineAt( i ) );

  }

  public Transition makeRedoTransition( )
  {
    return( new DeletePolygonTransition( getSurface(),
					 m_CreatedWidget,
					 m_PolygonInfo ) );
  }

  public String name()
  {
    return "createPolygon";
  }

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

  private Widget m_CreatedWidget;
  private PolygonInfo m_PolygonInfo;
}

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