|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectgizmoball.board.Gizmo
gizmoball.board.ExtenderGizmo
public class ExtenderGizmo
This class represents an extender gizmo that extends the abstract Gizmo class. The extender can be in two modes: stationary and in motion. Once the extender is in motion, it changes its shape as follows: It starts out as a square, expands horizontally to max of xSpanOfMotion, contracts to a square, expands vertically to max of ySpanOfMotion, and contracts to a square again. The extender will follow that motion until it is in stationary mode.
| Field Summary |
|---|
| Fields inherited from class gizmoball.board.Gizmo |
|---|
color, connections, name, reverseConnections |
| Constructor Summary | |
|---|---|
ExtenderGizmo(java.lang.String name,
java.awt.Color color,
Vect upperLeft,
double squareLength,
double xSpanOfMotion,
double ySpanOfMotion,
double velocity,
double pausingTime,
java.lang.Boolean isStationary)
constructs a new ExtenderGizmo object. |
|
| Method Summary | |
|---|---|
void |
action()
executes the action of the extender which switches the state(stationary/motion) of the extender. |
Polygon |
getEnclosingPolygon()
returns the enclosing polygon of the extender (the whole area that the extender occupies at least at one point during its motion cycle. |
double |
getExpansionSpeed(LineSegment ls)
returns the speed in which the side is expanding, ie the speed at which it changes its length. |
Polygon |
getFutureShape(double dt)
returns the shape that the extender will have after dt time from now without changing the actual state of the extender. |
double |
getPausingTime()
returns the pausing time between expansion/contraction transitions |
Polygon |
getShape()
returns the current shape of the extender. |
Vect |
getUpperLeft()
returns the location of the upper left corner of the square (the upper-left point of the extender's shape at its smallest size). |
double |
getVelocity()
returns the velocity of the extender. |
Vect |
getVelocity(Circle c)
returns the velocity of one of the vertices of the extender. |
Vect |
getVelocity(LineSegment ls)
returns the velocity of one of the sides of the extender. |
double |
getXSpanOfMotion()
returns the horizontal span of motion of the extender. |
double |
getYSpanOfMotion()
returns the vertical span of motion of the extender. |
double |
height()
returns the current height of the extender. |
boolean |
isContractingX()
returns a boolean stating whether the extender is contracting horizontally. |
boolean |
isContractingY()
returns a boolean stating whether the extender is contracting vertically. |
boolean |
isExpandingX()
returns a boolean stating whether the extender is expanding horizontally. |
boolean |
isExpandingY()
returns a boolean stating whether the extender is expanding vertically. |
java.lang.Boolean |
isStationary()
returns a boolean that indicates if the extender is in motion (changes its shape) or stationary. |
void |
setVelocity(double vel)
sets the speed of expansion/contraction. |
double |
timeTo()
returns the time until a transition between states occurs. |
void |
updateExtender(double dt)
updates the shape of the extender to the shape that the extender should have after dt time. |
double |
width()
returns the current width of the extender. |
| Methods inherited from class gizmoball.board.Gizmo |
|---|
getColor, getName, getTriggeredGizmos, getTriggeringGizmos, setColor, triggerConnections |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ExtenderGizmo(java.lang.String name,
java.awt.Color color,
Vect upperLeft,
double squareLength,
double xSpanOfMotion,
double ySpanOfMotion,
double velocity,
double pausingTime,
java.lang.Boolean isStationary)
name - the name of the ExtenderGizmocolor - the color of the ExtenderGizmoupperLeft - the location of the upper-left corner of the square shapesquareLength - the length of the sides of the squarexSpanOfMotion - the maximum horizontal expansion, which means that the max width of
the extender is 2*xSpanOfMotion + squareLengthySpanOfMotion - the maximum vertical expansion, which means that the max height of
the extender is 2*ySpanOfMotion + squareLengthvelocity - the speed of the extender when its in motionpausingTime - the pausing time between expansion/contraction transitionsisStationary - a boolean representing the mode of the extender(stationary/in motion)| Method Detail |
|---|
public Polygon getShape()
getShape in class Gizmopublic double getVelocity()
public void setVelocity(double vel)
vel - the new velocitypublic boolean isExpandingX()
public boolean isExpandingY()
public boolean isContractingX()
public boolean isContractingY()
public double width()
public double height()
public Vect getVelocity(Circle c)
c - a circle which its center is at the location of one of the vertices of the extender's shape
public Vect getVelocity(LineSegment ls)
ls - a line segment representing one of the sides of the extender's shape
public double getExpansionSpeed(LineSegment ls)
ls - a line segment representing one of the sides of the extender's shape
public Vect getUpperLeft()
public Polygon getEnclosingPolygon()
public double getXSpanOfMotion()
public double getYSpanOfMotion()
public double getPausingTime()
public java.lang.Boolean isStationary()
public double timeTo()
public Polygon getFutureShape(double dt)
dt - time
public void updateExtender(double dt)
dt - timepublic void action()
action in class Gizmo
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||