// ac_hand.java
//
// Authors
// =======
//
// SBH  Steve Hill      100144.3120@compuserve.com
//
//
// Revision History
// ================
//
// 04-Dec-1995/SBH     Created, my first Applett
// 28-Jan-1996/SBH     Added these comments, and created
//                     demo release v0.0. Made no attempt to 
//                     clean up the code!
// --------------------------------------------------------------------------
import java.awt.Graphics;        // The Screen
import java.awt.Color;

public class ac_hand
{
  private int iShort = 0;     // Length of the short end of the hand, in pixels
  private int iLong  = 100;   // Length of the long end of the hand, in pixels
  private int iWidth = 1;     // Width, at the widest point (centre of rotation)
  private int ix = 0;         // Center of the clock, around which we rotate.
  private int iy = 0;         //
  private Color myColor;      // Color of the hand

  void ac_hand(int i_Short, int i_Long, int i_Width)
  // Constructor to use when creating a 'complex' hand

  {
    iShort = i_Short;
    iLong  = i_Long;
    iWidth = i_Width;
  }

  void ac_hand()
  {

  }

  public void setLength(int i_Long, int i_Short, int i_Width)
  {
    iLong  = i_Long;
    iShort = i_Short;
    iWidth = i_Width;
  }
  public void setColor(Color _myColor)
  {
    myColor = _myColor;
  }

  public void draw(Graphics _g, double d_Theta)
  {
   double x,y;                  // end where it points to
   double x1,y1;                // The short end
   double x3,y3;                // The LH 'corner'
   double x4,y4;                // The RH 'corner'

   x = Math.sin(d_Theta*2.0*Math.PI) * (double) iLong;
   y = Math.cos(d_Theta*2.0*Math.PI) * (double) iLong;
   x1 = Math.sin(d_Theta*2.0*Math.PI) * (double) iShort;
   y1 = Math.cos(d_Theta*2.0*Math.PI) * (double) iShort;

   //Do Sides

   d_Theta = d_Theta + 0.25;      // subtract 90'
   x3 = Math.sin(d_Theta*2.0*Math.PI) * (double) iWidth;
   y3 = Math.cos(d_Theta*2.0*Math.PI) * (double) iWidth;

   d_Theta = d_Theta - 0.5;      // add 180'

   x4 = Math.sin(d_Theta*2.0*Math.PI) * (double) iWidth;
   y4 = Math.cos(d_Theta*2.0*Math.PI) * (double) iWidth;

 //  _g.setColor(Color.darkGray);
     _g.setColor(myColor);

   // centre
   _g.drawLine((int)(ix+x),(int)(iy-y),(int)(ix-x1),(int)(iy+y1));

   // one side

   _g.drawLine((int)(ix-x1),(int)(iy+y1),(int)(ix-x3),(int)(iy+y3));
   _g.drawLine((int)(ix+x),(int)(iy-y),(int)(ix-x3),(int)(iy+y3));

   // and the other

   _g.drawLine((int)(ix-x1),(int)(iy+y1),(int)(ix-x4),(int)(iy+y4));
   _g.drawLine((int)(ix+x),(int)(iy-y),(int)(ix-x4),(int)(iy+y4));

  }

  void setCenter(int i_cx, int i_cy)

  {
    ix = i_cx;
    iy = i_cy;
  }

}
