/** 
  * 
  * See the end of the file for the log of changes.
  * 
  * $Author: mtsezgin $
  * $Date: 2000/06/03 01:52:33 $   
  * $Revision: 1.4 $
  * $Headers$
  * $Id: GraphicsUtil.java,v 1.4 2000/06/03 01:52:33 mtsezgin Exp $     
  * $Name:  $   
  * $Locker:  $
  * $Source: /mit/mtsezgin/CVS/Repository/REC/GraphicsUtil.java,v $
  *  
  **/


import java.awt.Graphics;


/**
  *
  * Implements some methods not found in jdk 1.1
  *
  **/
public class
GraphicsUtil
{
    /**
    *
    * Plot a thick line from (x1, y1) to (x2,y2) with radius r
    *
    **/
    public static void
    drawThickLine( int r, Graphics g, int x1, int y1, int x2, int y2 ) 
    {
        if ( r == 1 ) {
            g.drawLine( x1, y1, x2, y2 );
            return;
        }
        int iterations = (int)Math.sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
        for ( int i=0; i<iterations; i++ ) {
            g.fillOval( ( x1*i + x2*(iterations-i) )/iterations,
                        ( y1*i + y2*(iterations-i) )/iterations,
                        r,
                        r);
        }
    }
    
    /**
    *
    * Plot a thick line from (x1, y1) to (x2,y2) with radius r
    *
    **/
    public static void
    drawThickLine( double r, 
                   Graphics g, 
                   double x1, 
                   double y1, 
                   double x2, 
                   double y2 ) 
    {
        if ( r == 1 ) {
            g.drawLine( (int)x1, (int)y1, (int)x2, (int)y2 );
            return;
        }
        int iterations = (int)Math.sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
        for ( int i=0; i<iterations; i++ ) {
            g.fillOval( (int)(( x1*i + x2*(iterations-i) )/iterations),
                        (int)(( y1*i + y2*(iterations-i) )/iterations),
                        (int)r,
                        (int)r );
        }
    }
    
    /**
    *
    * Plot a thick line from (x1, y1) to (x2,y2) with radius r
    *
    **/
    public static void
    drawThickOval( int r,  Graphics g, int x, int y, int r1, int r2 )
    {   
        if ( r == 1 ) {
            g.drawOval( x, y, r1, r2 );
            return;
        }     
        for ( int i=0; i<r; i++ ) {
            g.drawOval( x+i,
                         y+i,
                         r1-i*2,
                         r2-i*2);
        }
    }
}


/** 
  * 
  * $Log: GraphicsUtil.java,v $
  * Revision 1.4  2000/06/03 01:52:33  mtsezgin
  * *** empty log message ***
  *
  * Revision 1.3  2000/04/28 04:45:03  mtsezgin
  *
  * Now each GeometricObject keeps the mouse input that was previously
  * discarded. User can switch between seeing the recognized mode and
  * the raw mode. setDataPoints( Polygon points ) and getDataPoints()
  * are added to GeometricObject, and all the implementors are modified
  * accordingly.
  *
  * Revision 1.2  2000/04/25 22:15:29  mtsezgin
  *
  * Added more utility functions.
  *
  * Revision 1.1.1.1  2000/04/01 03:07:07  mtsezgin
  * Imported sources
  *
  * Revision 1.2  2000/03/31 22:41:03  mtsezgin
  *
  * Started Log tracking.
  *
  *  
  **/
