import java.util.Enumeration;


public abstract class FeatureDrafter3 extends Drafter
{
    //[1

    // The RectangularHull of all of the Feature objects
    protected RectangularHull         hull;
    
    // The coordinate-by-coordinate maximum of the screen coordinates
    protected Point                   smax;
    


    /**
     * Draw a Feature scaled to fit the paper
     *
     * @param feature    The Feature to draw
     */
    protected void drawFeature(Feature feature)
    {
       double               alpha;
       Enumeration          points;
       Point                p, q, rho, sigma, wmax, wmin, wminhat;
       
       // Determine the range in world coorinates
       wmax = hull.getMax();
       wmin = hull.getMin();
       rho = wmax.minus(wmin);

       // Determine the scale for each coordinate
       sigma = screenMax.cover(rho);
       
       // Maintain the aspect ratio by using the smallest element of scale
       alpha = sigma.smallestCoordinate();

       // Scale the minimum in world coordinates (for the translation)
       wminhat = wmin.times(alpha);
       

       // Scale and translate each point
       //
       points = feature.points();

       // The first Point in the feature
       p = (Point)e.nextElement();
       q = (p.times(alpha)).minus(wminhat);
       moveTo(q);
          
       if (!e.hasMoreElements()) // The Feature is a Point
       {
          drawTo(q);
       }
       else                     // The Feature is a LineSegment, etc...
       {
          while (e.hasMoreElements())
          {
             // The subsequent Point objects in the feature
             p = (Point)e.nextElement();
             q = (q.times(alpha)).minus(wminhat);
             drawTo(q);
          }
       }
    }
    //]1
}
