//***********************************************************
//*
//* File:           Movejava
//* Author:         Abhinav Kamra
//* Contact:        kamra-at-cs.columbia.edu
//* Update:         11.9.2002
//*
//* Description:    Basic Move object representing individaul
//*                 transformations of a polygon for Project
//*                 4, CS4444 Fall 2003.
//*
//***********************************************************

package CookieCutter;

import java.io.Serializable;

public class Move implements IFCConstants, Serializable {

	double _right_boundary;
	double _fixed_minboundary;
	Vertex[]	_cookie_center;
	double[]	_rotation_angle;

	public Move(int __cookie_copies) throws Exception
	{
		_cookie_center = new Vertex[__cookie_copies];
		_rotation_angle = new double[__cookie_copies];
		for(int i=0;i < __cookie_copies;i++)
		{
			_rotation_angle[i] = 0.0;
			_cookie_center[i] = new Vertex(0.0, 0.0);
		}
	}

	public double GetRightBoundary() throws Exception
	{
        	return _right_boundary;
	}

	public Vertex GetCookieCenter(int index)
	{
		return _cookie_center[index];
	}

	public double GetCookieAngle(int index)
	{
		return _rotation_angle[index];
	}

	public void setRightBoundary(double __right_boundary)
	{
		_right_boundary = __right_boundary;
		_fixed_minboundary = __right_boundary;
	}

	public void AdjustRightBoundary(double new_right_boundary)
	{
		double PRECISION = 1000.0;
		if(new_right_boundary > _fixed_minboundary)
			_right_boundary = new_right_boundary;
		double tmpB = _right_boundary * PRECISION;
		_right_boundary = Math.ceil(tmpB)/PRECISION;
	}

	public void setCookiePosition(int index, Vertex center, double angle) throws Exception
	{
		_cookie_center[index] = new Vertex(center);
		_rotation_angle[index] = angle;
	}

	public static boolean CheckMove(Vertex[] originalcookie, Move __move)
	{
		return true;
	}

    public String toString() {
        try {
            StringBuffer SB = new StringBuffer();

		for(int i=0;i < _cookie_center.length;i++)
		{
			SB.append("\n[Center = ("+_cookie_center[i].xpos()+","+_cookie_center[i].ypos()+")  Rotation = "+_rotation_angle[i]+"]");
		}
		return new String(SB);

        } catch (Exception EXC) {
            return _CERROR_STRING;
        }
    }
}
