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

package rec.fun;

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

public class Arrowhead extends VisibleWidget
{
  WLine line_on;
  boolean head;
  GPoint loc;

  public Arrowhead( WLine l, boolean head )
  {
    line_on = l;
    this.head = head;

    if ( head ) loc = line_on.getHead();
    else
      loc = line_on.getTail();
  }



  public WLine getLine()
  {
    return line_on;
  }

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

  public void resize( double scaleFactor )
  {
  }


  public void move( GPoint gp )
  {
    loc = new GPoint( gp );
  }

  public void rotate( GPoint gp, double angle )
  {
    // Rotating a click has no effect.
  }


  public Location getLocation()
  {
    return( new Location( loc ) );
  }

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

  public boolean includes( GPoint pt, double l )
  {
    return line_on.includes( pt, l );
  }

  public boolean contains( GPoint pt )
  {
    return line_on.contains( pt );
  }

  public Object clone()
  {
    return( new Arrowhead( line_on, head ) );
  }


  public void draw( Graphics g )
  {
    g.drawOval( (int)loc.x - 5, (int)loc.y - 5, 10, 10 );
  }


}

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