All Packages Class Hierarchy This Package Previous Next Index
Class primitives.machines.Machine
java.lang.Object
|
+----primitives.machines.Machine
- public abstract class Machine
- extends Object
- implements MachineListener
An abstract class which is ancestor to all machines.
The class defines the information on the machine's joints and anchors.
Provide common methods shared by all machine objects.
-
anchors
- The integer location of the anchors.
-
barLength
- The length of the rigid bar.
-
bendStates
- Each joint can take to bending positions.
-
d
- The dimension of the rectangle the machine is being drawn in.
-
dAnchors
- The array of the location of the machine's anchors.
-
dJoints
- The array of the location of the machine's joints.
-
joints
- The integer location of the joints.
-
tempJoints
- stores the last joints locations for if restore is needed.
-
Machine(int, int, Dimension)
-
-
drawAnchors(Graphics)
- Draws the anchors of this machine.
-
drawJoints(Graphics)
- Draws the machine's joints.
-
drawLine(Graphics, Point, Point)
- Draws a line between to locations.
-
finalize()
- Sets object fields to null.
-
integrizeAnchors()
- Rounds the location of the anchors to the nearest integer location.
-
redraw(Graphics)
- Implementation of the MachineListener interface.
-
restorePoints()
- Restores the location of the joints by setting its location to the locations saved
in tempJoints.
-
rotateJoint(Coordinate, Coordinate, double)
- rotates specified joint c2 around joint c1 in dalpha radians.
-
savePoints()
- sets the tempJoints array to the current location of the dJoints array.
-
switchBend(Coordinate, Coordinate, Coordinate)
- Returns the second possible location of of
mid
.
-
updatePoints(Coordinate[], ExtPoint[])
- copies the locations of array of Coordinate to an array of ExtPoint.
dJoints
protected Coordinate dJoints[]
- The array of the location of the machine's joints.
dAnchors
protected Coordinate dAnchors[]
- The array of the location of the machine's anchors.
tempJoints
protected Coordinate tempJoints[]
- stores the last joints locations for if restore is needed.
anchors
public ExtPoint anchors[]
- The integer location of the anchors.
Used in the calls to the Graphic methods.
joints
public ExtPoint joints[]
- The integer location of the joints.
Used in the calls to the Graphic methods.
barLength
public int barLength
- The length of the rigid bar.
All bars are presumed to be of same length.
machines with differnt bar length should define its own fields.
bendStates
public int bendStates[]
- Each joint can take to bending positions.
These values should be only 1 and -1.
d
protected Dimension d
- The dimension of the rectangle the machine is being drawn in.
Machine
public Machine(int joints,
int anchors,
Dimension d)
- Parameters:
- joints - number of joints in the machine.
- anchors - number of anchor in the machine.
- d - the dimension of the rectangle the machine should be drawn in.
finalize
public void finalize() throws Throwable
- Sets object fields to null.
- Throws: Throwable
- .
- Overrides:
- finalize in class Object
integrizeAnchors
protected void integrizeAnchors()
- Rounds the location of the anchors to the nearest integer location.
Since anchors do not change there position, there real location should be integral.
savePoints
protected void savePoints()
- sets the tempJoints array to the current location of the dJoints array.
restorePoints
protected void restorePoints()
- Restores the location of the joints by setting its location to the locations saved
in tempJoints.
drawAnchors
protected void drawAnchors(Graphics g)
- Draws the anchors of this machine.
- Parameters:
- g - the graphic context to draw on.
redraw
public void redraw(Graphics g)
- Implementation of the MachineListener interface.
Draws the joints and anchors of the machine.
rotateJoint
protected double rotateJoint(Coordinate c1,
Coordinate c2,
double dalpha)
- rotates specified joint c2 around joint c1 in dalpha radians.
- Parameters:
- c1 - the joint at the origin.
- c2 - the joint to rotate.
- dalpha - the angle to rotata.
- Returns:
- the new angle between c1 and c2.
updatePoints
protected static void updatePoints(Coordinate src[],
ExtPoint dst[])
- copies the locations of array of Coordinate to an array of ExtPoint.
The locations are rounded to the nearest integer values.
- Parameters:
- src - the source.
- dst - the destination array of Point.
- See Also:
- redraw
drawJoints
protected void drawJoints(Graphics g)
- Draws the machine's joints.
- Parameters:
- g - the graphic context to draw on.
drawLine
public static void drawLine(Graphics g,
Point p1,
Point p2)
- Draws a line between to locations.
The color of the line should be set before calling this method.
- Parameters:
- g - the graphic context to draw on.
- p1, - p2 the endpoints of the line.
switchBend
protected static Coordinate switchBend(Coordinate c1,
Coordinate c2,
Coordinate mid) throws ArithmeticException
- Returns the second possible location of of
mid
.
mid is supposed to be an adjacent joint of c1 and c2.
- Throws: ArithmeticException
- never throws this exception.
All Packages Class Hierarchy This Package Previous Next Index