/*******************************************************************

  Class:	CS6600, Graphics
  Author:	Yury Izrailevsky
	
  Assignment 1 - Paint program


  This file contains the implementation of Y_FHD class.
*******************************************************************/

import java.awt.*;

public class Y_FHD extends Polygon implements YI_Figures
{
    //------------------ Data members -----------------------
    Color fColor = Color.black;
    boolean fFillIn = false;


    // ----------------- METHODS ----------------------------
    
    //~~~~~~~~~~~~~~~~~~~ CONSTRUCTOR ~~~~~~~~~~~~~~~~~~~~~~~
    public Y_FHD(Color color)
    {
	fColor = color;

    }//~~~~~~~~~~~~ end of constructor ~~~~~~~~~~~~~~~~~~~~~~~~~~

    // overrides interface function
    public int whatFigureAmI() {return FT_FHD;}
    
    // overrides interface draw()
    public int draw(Graphics g)
    {
	int i;

	// save old color and set object's color
	Color old_color = g.getColor();
	g.setColor(fColor);

	for (i = 0; i < (npoints-1); i++){
	    g.drawLine(xpoints[i], ypoints[i], 
		       xpoints[i+1], ypoints[i+1]);
	}
	
	// reinstate color
	g.setColor(old_color);

	return E.OK;
	
    }// end of draw()
    
    // override interface setColor
    public int setColor(Color color)
    {
	fColor = color;
	return E.OK;
    }

    // override interface setFillIn
    public int setFillIn(boolean mode)
    {
	fFillIn = mode;
	return E.OK;
    }

    // implemet scalePoint
    // scales all points by a certain value
    public void scalePoints(double coef)
    {
	int i;
	for (i=0; i < npoints; i++){
	    xpoints[i] = (int)(xpoints[i] * coef);
	    ypoints[i] = (int)(ypoints[i] * coef);
	}// end for
    }

}// end of Y_Rectangle implementation

