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

// -*-Mode: Java-*- 
// $Id: WArrow.java,v 1.3 2003/03/06 00:40:47 moltmans Exp $
// WArrow.java -- 
// Author: Michael Oltmans <moltmans@ai.mit.edu> 
// Created: <Fri Mar 17 11:11:10 2000> 
// Time-stamp: <2000-06-10 11:14:58 moltmans> 
package rec.core.widgets;

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

public class WArrow extends SelfDrawingWidget
{
  private GSegment m_stem;
  
  public WArrow( GSegment stem )
  {
    super();
    setEnglishName( "Arrow" );
    m_stem = stem;
    buildArrow( stem );
  }

  private void buildArrow( GSegment stem )
  {
    Collection arrow = new LinkedList();

    double size = stem.getLength() / 4.0;
    double angle = stem.getAngle();
    GPoint head = stem.getHeadPoint();

    GPoint head1 = Geometry.locatePoint( head, size,
					 angle + (Math.PI / 4.0) );
    GPoint head2 = Geometry.locatePoint( head, size,
					 angle - (Math.PI / 4.0) );
    
    arrow.add( stem );
    arrow.add( new GSegment( head, head1 ) );
    arrow.add( new GSegment( head, head2 ) );

    m_size = stem.getLength();
    m_angle = stem.getAngle();
  }
  
  

  public GPoint getHead()
  {
    return m_stem.getHeadPoint();
  }

  public GPoint getTail()
  {
    return m_stem.getTailPoint();
  }
    
}
