package primitives.machines;
import java.awt.Graphics;
import java.awt.event.*;
import primitives.geomtry.Coordinate;
/**
* This interface declares the methods defining a functional linkage.
* A functional linkage is a machine which can compute functions.
* given the locations of "input" joints the result is given by the location
* of the "output" joint.An object declared as a FunctionalLinkage can be a Machine
* or a composition of composed objects of FunctionalLinkage.
*@see Translator1
*@see Inversor1
*@see ScalarMultiplier1
*@see Adder
*@autohr Dori Eldar
*/ 
public interface FunctionalLinkage extends MachineListener{
	/**
	*Forces the input joints to be moved to the specified locations.
	*If the specifeid location is not valid then this object should implement
	*a resizing of the machine such that the specified locations should be valid.
	*@param inputs an array of the  required input joints locations. The size
	*of the array is implementation specific.
	*@retrun the new locations of the output joints.
	*/
	public Coordinate[] forceInputJoints(Coordinate[] inputs);
	/**
	*
	*@return an array of the locations of the output joints.
	*the size of the array is implementation specific.
	*/
	public Coordinate[] getOutputJoints();
	/**
	*
	*@return an array of the locations of the input joints.
	*the size of the array is implementation specific.
	*/
	public Coordinate[] getInputJoints();
	/**
	*changes the state of the machine by moving the location of the input joints.
	*@param inputJoints an array of the required locations. The size of the  array 
	*is implementation specific.
	*@return an array of the new locations of the output joints.
	*@exception MachineException if the required locations are not valid. If 
	*the implementation must accept the locations use < a href="#forceInputJoints">forceInputJoints</a>
	*/
	public Coordinate[] setInputJoints(Coordinate[] inputJoints) throws MachineException;
	/**
	*@return an array of parameters specific to every implementation.
	*@see #setParameters
	*/
	public double[] getParameters();
	/**
	*Request the implementation to change its parameters.
	*@param parameters an implementation specific array of parameters.
	*@exception MachineException if the required parametrs are not acceptable by 
	*the implementation.
	*/
	public void setParameters(double[] parameters)throws MachineException;
	/**
	*A method which controls mouse move user requests.
	*@param m the mouseEvent object specifying location of the mouse pointer.
	*@return the enumerated joint the the mouse pointer is over or 0 if the mouse
	*pointer is elsewhere.
	*/
	public int mouseMoved(MouseEvent m);
	/**
	*A method which controls mouse darg user requests.
	*@param m the mouseEvent object specifying location of the mouse pointer.
	*@exception MachineException if the new location requested is declared not valid by the
	*specific implementation.
	*/
	public void mouseDragged(MouseEvent m) throws MachineException;
	/**
	*Returns a String to be displayed. 
	*@param activeJoint dispalys the enumerated string usualy associated with a joint.
	*/
	public String getActiveStr(int activeJoint);
	/**
	*@return the enumerated joint the mouse pointer is over(0 value indicates the mouse pointer
	*is located elsewhere)
	*@see #mouseMoved
	*/
	public int getActiveJoint();
	/**
	*Sets the activeJoint.
	*@param activeJoint the joint to set.
	*@see #mouseMoved
	*/
	public void setActiveJoint(int activeJoint);

	final static char comma = ',';
	final static char bracket =  ')';
	final static char[] annulus = {' ','<',' ','a','n','n','u','l','u','s',' ','<',' '};
	final static char dot = '.';
}	