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

package rec.house;

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

public class Scale extends WLine
{
  static int scale = 100;
  static Scale lastScale = null;

  public static int getScale( )
  {
    if ( lastScale != null )
      {
	return (int)lastScale.getLength();
      }
    else
      return scale;
  }


  public Scale( GPoint p1, GPoint p2 )
  {
    super( p1, p2 );

    scale = (int) getLength();
    lastScale = this;
  }

  public Scale( Squiggle s )
  {
    super( s );

    scale = (int) getLength();
    lastScale = this;
  }



  public void draw( Graphics g )
  {
    Color oc = g.getColor();

    GPoint h = getHead(), t = getTail();

    if ( getColor() != null )
      g.setColor( getColor() );
    else
      g.setColor( Color.white );

    int x = h.getIntX(), y = h.getIntY(), x2 = t.getIntX(), y2 = t.getIntY();

    // give the nice thick-line look.
    rec.fsm.Edge.thickLine( g, x, y, x2, y2 );

    // draw the legend
    g.setColor( Color.white );
    GPoint d = new GPoint( ( h.x + t.x) / 2, (h.y + t.y) / 2 );

    g.drawString( "1 foot", (int) d.x, (int) d.y - 10 );
    
    g.setColor( oc );
  }

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

  public Object clone()
  {
    return( new Scale( getHead(), getTail() ) );
  }


}

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