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

////////////////////////////////////////////////////////////////////////////////
//
// FILE:	WMSocket.java
//
// AUTHOR:	Manoj D. Muzumdar
//		archon@ai.mit.edu
//
// DATE:	April 99
//
// COPYRIGHT:	Massachusetts Institute of Technology
//		All rights reserved.
//
// PURPOSE:     Socket widget
//
// HISTORY:     April 99  archon  created
//
////////////////////////////////////////////////////////////////////////////////

package rec.meche;

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

public class WMSocket extends WPart
{
  public WMSocket( GPoint center, double angle, double size, Cloneable data )
  {
    super( center, angle, size, data );

    //    setColor( Color.cyan );
  }

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

  public Object clone()
  {
    return( new WMSocket( getCenter(), getAngle(), size(), getData() ) );
  }

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

  protected GShape[] create( double size, Cloneable data )
  {
    GShape[] shapes = new GShape[2];

    double unit = size / 2.0;

    // Calculate the center.

    setCenter( new GPoint( unit * 4.0, unit ) );

    // Create the line.

    shapes[0] = new GSegment( new GPoint( 0.0, unit ), getCenter() );

    // Create the socket.

    shapes[1] = new GArc( new GPoint( unit * 5.0, unit ),
			  Math.PI / 2.0,
			  unit,
			  unit,
			  0.0,
			  Math.PI );

    return( shapes );
  }

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

  public GPoint getJoint()
  {
    return( ((GArc)getComponents()[1]).getCenter() );
  }
}

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