|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectgizmoball.board.GizmoBoard
public class GizmoBoard
This class represents a board for the Gizmoball game. The board contains the gizmos and has functions for adding and viewing the gizmos on a board. The board also has methods to move gizmos, set some gizmos properties, and govern the keyboard connections to gizmos. The board ensures that gizmos added do not overlap.
| Constructor Summary | |
|---|---|
GizmoBoard(int xsize,
int ysize,
double L)
constructs a GizmoBoard object. |
|
| Method Summary | |
|---|---|
Absorber |
addAbsorber(java.lang.String name,
java.awt.Color color,
Vect upperLeftCorner,
double height,
double width,
Vect launchVelocity)
adds an absorber to the board. |
Ball |
addBall(Ball b)
adds a given ball to the board. |
Ball |
addBall(java.lang.String name,
java.awt.Color color,
Vect center,
Vect velocity,
double radius)
adds a ball to the board |
Bumper |
addBumper(java.lang.String name,
java.awt.Color color,
Shape shape)
adds a bumper to the board. |
boolean |
addConnection(Gizmo source,
Gizmo target)
adds a connection between two gizmos that are on the board. |
ExtenderGizmo |
addExtender(java.lang.String name,
java.awt.Color color,
Vect upperLeft,
double squareLength,
double xSpanOfMotion,
double ySpanOfMotion,
double velocity,
double pausingTime)
|
Ball |
addGhostBall(java.lang.String name,
java.awt.Color color,
Vect center,
Vect velocity,
double radius)
adds a ghost ball to the board. |
void |
addKeyDownTriggerToGizmo(java.lang.Integer key,
Gizmo g)
adds a down keyboard trigger to the specified gizmo. |
void |
addKeyUpTriggerToGizmo(java.lang.Integer key,
Gizmo g)
adds an up keyboard trigger to the specified gizmo. |
RotatingGizmo |
addLeftFlipper(java.lang.String name,
java.awt.Color color,
Vect topCenter,
double distanceBetweenCenters,
double radius)
adds a left flipper to the board. |
RotatingGizmo |
addLeftFlipper(java.lang.String name,
java.awt.Color color,
Vect topCenter,
double distanceBetweenCenters,
double radius,
Angle currentAngle)
adds a left flipper to the board. |
RotatingGizmo |
addRightFlipper(java.lang.String name,
java.awt.Color color,
Vect topCenter,
double distanceBetweenCenter,
double radius)
adds a right flipper to the board. |
RotatingGizmo |
addRightFlipper(java.lang.String name,
java.awt.Color color,
Vect topCenter,
double distanceBetweenCenters,
double radius,
Angle currentAngle)
adds a right flipper to the board. |
java.lang.Boolean |
canAddAbsorber(Vect upperLeftCorner,
double height,
double width)
checks if an absorber with the given properties can be added to the board. |
boolean |
canAddBall(double radius,
Vect center)
checks if a ball with the given center and radius can be added to the board. |
boolean |
canAddBumper(Shape shape)
checks if a bumper with the given shape can be added. |
java.lang.Boolean |
canAddExtender(Vect upperLeft,
double squareLength,
double xSpanOfMotion,
double ySpanOfMotion)
checks if an extender with the given properties can be added to the baord. |
boolean |
canAddGhostBall(double radius,
Vect center)
checks if a ghost ball with the given center and radius can be added to the board. |
boolean |
canAddLeftFlipper(Vect topCenter,
double distanceBetweenCenters,
double radius)
checks if a left flipper with the given properties can be added to the board. |
boolean |
canAddLeftFlipper(Vect topCenter,
double distanceBetweenCenters,
double radius,
Angle currentAngle)
checks if a left flipper with the given properties can be added to the board. |
boolean |
canAddRightFlipper(Vect topCenter,
double distanceBetweenCenters,
double radius)
checks if a right flipper with the given properties can be added to the board. |
boolean |
canAddRightFlipper(Vect topCenter,
double distanceBetweenCenters,
double radius,
Angle currentAngle)
checks if a right flipper with the given properties can be added to the board. |
boolean |
canMoveGizmo(Gizmo g,
Vect vector)
|
boolean |
canRotateGizmo(Gizmo g,
Angle angle,
Vect centerOfRotation)
checks if the given gizmo can rotate by the given angle and around the given center of rotation. |
boolean |
contains(Gizmo giz)
checks if a board contains a given gizmo. |
void |
deleteBall(Ball bl)
removes a ball from the board. |
void |
deleteGizmo(Gizmo g)
removes the given gizmo from the board. |
void |
deleteKeyDownTriggerToGizmo(java.lang.Integer key,
Gizmo g)
removes a press key connection from the given key to the given gizmo |
void |
deleteKeyUpTriggerToGizmo(java.lang.Integer key,
Gizmo g)
removes a release key connection from the given key to the given gizmo |
void |
downTrigger(java.lang.Integer key)
adds a key to a waiting list to trigger a gizmo. |
void |
executeKeyboardEvents()
executes the action of the gizmos that got triggered. |
java.util.List<Absorber> |
getAbsorbers()
returns a list of all the absorbers that are on the board. |
java.util.List<Ball> |
getBalls()
returns a list of balls that are on the board. |
java.util.List<Bumper> |
getBumpers()
returns a list of the bumpers that are on the board. |
java.util.List<Gizmo> |
getDrawableGizmos()
returns all the gizmos that are to be drawn. |
java.util.List<ExtenderGizmo> |
getExtenders()
returns a list of all the extender gizmos that are on the board. |
java.util.List<ExtenderGizmo> |
getExtendersAt(int x,
int y)
returns the extenders that intersect with the LxL square that its upper-left vertex is at (x*L,y*L). |
Gizmo |
getGizmo(java.lang.String n)
returns the gizmo with the specified name that is on the board. |
java.util.List<Gizmo> |
getGizmoAt(Vect pt)
returns a list of gizmos that are at the location specified. |
java.util.List<Gizmo> |
getKeyDownGizmos(java.lang.Integer key)
returns the list of gizmos that are triggered by the specified key when pressed. |
java.util.Set<java.lang.Integer> |
getKeyDownTriggers()
returns all the keys that are mapped to trigger gizmos when are pressed. |
java.util.List<Gizmo> |
getKeyUpGizmos(java.lang.Integer key)
returns the list of gizmos that are triggered by the specified key when released. |
java.util.Set<java.lang.Integer> |
getKeyUpTriggers()
returns all the keys that are mapped to trigger gizmos when are released. |
java.util.List<RotatingGizmo> |
getLeftFlippers()
returns the list of the left flippers that are on the board. |
java.util.List<RotatingGizmo> |
getRightFlippers()
returns the right flippers that are on the board. |
java.util.List<RotatingGizmo> |
getRotatingGizmos()
returns a list of all the rotating objects that are on the board. |
java.util.List<RotatingGizmo> |
getRotatingGizmosAt(int x,
int y)
returns the rotating gizmos that intersect with the LxL square that its upper-left vertex is at (x*L,y*L). |
java.util.List<Gizmo> |
getStationaryGizmos()
returns a list of all the stationary objects that are on the board. |
java.util.List<Gizmo> |
getStationaryGizmosAt(int x,
int y)
returns the stationary gizmos that intersect with the LxL square that its upper-left vertex is at (x*L,y*L). |
double |
getUnitSize()
returns the scale factor. |
int |
getXSize()
returns the x-dimension of the board. |
int |
getYSize()
returns the y-dimension of the board. |
boolean |
moveGizmo(Gizmo g,
Vect vector)
|
boolean |
removeConnection(Gizmo source,
Gizmo target)
removes a connection between two gizmos that are on the board. |
void |
RotateGizmo(Gizmo g,
Angle angle,
Vect centerOfRotation)
|
void |
upTrigger(java.lang.Integer key)
adds a key to a waiting list to trigger a gizmo. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GizmoBoard(int xsize,
int ysize,
double L)
xsize - the x-dimension of the boardysize - the y-dimension of the boardL - the scale factor| Method Detail |
|---|
public int getXSize()
public int getYSize()
public double getUnitSize()
public boolean contains(Gizmo giz)
giz - the gizmo
public boolean canAddBall(double radius,
Vect center)
radius - the radius of the ballcenter - the location of the center of the ball
public boolean canAddGhostBall(double radius,
Vect center)
radius - the radius of the ballcenter - the location of the center of the ball
public boolean canAddRightFlipper(Vect topCenter,
double distanceBetweenCenters,
double radius,
Angle currentAngle)
topCenter - the center of rotationdistanceBetweenCenters - the distance between the centers of circles of the flipper shaperadius - the radius of the circles of the flipper shapecurrentAngle - the initial angle that the flipper is in
public boolean canAddRightFlipper(Vect topCenter,
double distanceBetweenCenters,
double radius)
topCenter - the center of rotationdistanceBetweenCenters - the distance between the centers of circles of the flipper shaperadius - the radius of the circles of the flipper shape
public boolean canAddBumper(Shape shape)
shape - the shape of the bumper
public boolean canAddLeftFlipper(Vect topCenter,
double distanceBetweenCenters,
double radius,
Angle currentAngle)
topCenter - the center of rotationdistanceBetweenCenters - the distance between the centers of circles of the flipper shaperadius - the radius of the circles of the flipper shapecurrentAngle - the initial angle that the flipper is in
public boolean canAddLeftFlipper(Vect topCenter,
double distanceBetweenCenters,
double radius)
topCenter - the center of rotationdistanceBetweenCenters - the distance between the centers of circles of the flipper shaperadius - the radius of the circles of the flipper shape
public java.lang.Boolean canAddAbsorber(Vect upperLeftCorner,
double height,
double width)
upperLeftCorner - the upper-left point of the absorber's rectangleheight - the height of the absorber's rectanglewidth - the width of the absorber's rectangle
public java.lang.Boolean canAddExtender(Vect upperLeft,
double squareLength,
double xSpanOfMotion,
double ySpanOfMotion)
upperLeft - the upper-left vertex of the square of the extendersquareLength - the length of the sides of the square of the extenderxSpanOfMotion - 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 + squareLength
public Ball addBall(java.lang.String name,
java.awt.Color color,
Vect center,
Vect velocity,
double radius)
name - the name of the ballcolor - the color of the ballcenter - the initial location of the center of the ballvelocity - the inital velocity of the ballradius - the radius of the ball
public Ball addBall(Ball b)
b - the ball to be added to the board
public Ball addGhostBall(java.lang.String name,
java.awt.Color color,
Vect center,
Vect velocity,
double radius)
name - the name of the ballcolor - the color of the ballcenter - the location of the center of the ballvelocity - the initial velocity of the ballradius - the radius of the ball
public Bumper addBumper(java.lang.String name,
java.awt.Color color,
Shape shape)
name - the name of the bumpercolor - the color of the bumpershape - the shape of the bumper
public RotatingGizmo addRightFlipper(java.lang.String name,
java.awt.Color color,
Vect topCenter,
double distanceBetweenCenters,
double radius,
Angle currentAngle)
name - the name of the flippercolor - the color of the flippertopCenter - the center of rotationdistanceBetweenCenters - the distance between the two centers of circles of the flipper shaperadius - the radius of the circles of the flipper shapecurrentAngle - the initial angle that the flipper is in
public RotatingGizmo addRightFlipper(java.lang.String name,
java.awt.Color color,
Vect topCenter,
double distanceBetweenCenter,
double radius)
name - the name of the flippercolor - the color of the flippertopCenter - the center of rotationdistanceBetweenCenters - the distance between the two centers of circles of the flipper shaperadius - the radius of the circles of the flipper shape
public RotatingGizmo addLeftFlipper(java.lang.String name,
java.awt.Color color,
Vect topCenter,
double distanceBetweenCenters,
double radius,
Angle currentAngle)
name - the name of the flippercolor - the color of the flippertopCenter - the center of rotationdistanceBetweenCenters - the distance between the two centers of circles of the flipper shaperadius - the radius of the circles of the flipper shapecurrentAngle - the initial angle that the flipper is in
public RotatingGizmo addLeftFlipper(java.lang.String name,
java.awt.Color color,
Vect topCenter,
double distanceBetweenCenters,
double radius)
name - the name of the flippercolor - the color of the flippertopCenter - the center of rotationdistanceBetweenCenters - the distance between the two centers of circles of the flipper shaperadius - the radius of the circles of the flipper shapecurrentAngle - the initial angle that the flipper is in
public Absorber addAbsorber(java.lang.String name,
java.awt.Color color,
Vect upperLeftCorner,
double height,
double width,
Vect launchVelocity)
name - of the absorbercolor - of the absorberupperLeftCorner - of the absorberheight - of the absorberwidth - of the absorberlaunchVelocity - of a ball that is shot from the absorber
public ExtenderGizmo addExtender(java.lang.String name,
java.awt.Color color,
Vect upperLeft,
double squareLength,
double xSpanOfMotion,
double ySpanOfMotion,
double velocity,
double pausingTime)
name - the name of the extendercolor - the color of the extenderupperLeft - the upper-left vertex of the square of the extendersquareLength - the length of the sides of the square of the extenderxSpanOfMotion - 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 transitions
public boolean canMoveGizmo(Gizmo g,
Vect vector)
public boolean moveGizmo(Gizmo g,
Vect vector)
public boolean canRotateGizmo(Gizmo g,
Angle angle,
Vect centerOfRotation)
g - the gizmoangle - the angle to be rotated bycenterOfRotation - the center of rotation
public void RotateGizmo(Gizmo g,
Angle angle,
Vect centerOfRotation)
public void deleteGizmo(Gizmo g)
g - the gizmo to be removedpublic void deleteBall(Ball bl)
bl - the ball to be removedpublic java.util.List<Gizmo> getGizmoAt(Vect pt)
pt - the location
public Gizmo getGizmo(java.lang.String n)
n - name of the gizmo that is needed
public java.util.List<Ball> getBalls()
public java.util.List<Bumper> getBumpers()
public java.util.List<RotatingGizmo> getRightFlippers()
public java.util.List<RotatingGizmo> getLeftFlippers()
public java.util.List<Absorber> getAbsorbers()
public java.util.List<ExtenderGizmo> getExtenders()
public java.util.List<RotatingGizmo> getRotatingGizmos()
public java.util.List<Gizmo> getStationaryGizmosAt(int x,
int y)
x - the xcoord of the upper-left vertex before multiplying it by the scaling factory - the ycoord of the upper-left vertex before multiplying it by the scaling factor
public java.util.List<Gizmo> getStationaryGizmos()
public java.util.List<RotatingGizmo> getRotatingGizmosAt(int x,
int y)
x - the xcoord of the upper-left vertex before multiplying it by the scaling factory - the ycoord of the upper-left vertex before multiplying it by the scaling factor
public java.util.List<ExtenderGizmo> getExtendersAt(int x,
int y)
x - the xcoord of the upper-left vertex before multiplying it by the scaling factory - the ycoord of the upper-left vertex before multiplying it by the scaling factor
public java.util.List<Gizmo> getDrawableGizmos()
public boolean addConnection(Gizmo source,
Gizmo target)
source - the gizmo that will trigger the target gizmotarget - the gizmo that will be triggered by the source gizmo
public boolean removeConnection(Gizmo source,
Gizmo target)
source - the gizmo that triggers the target gizmotarget - the gizmo that gets triggered by the source gizmo
public void addKeyUpTriggerToGizmo(java.lang.Integer key,
Gizmo g)
key - that will trigger the gizmo to do the gizmo's actiong - the gizmo that is triggered
public void addKeyDownTriggerToGizmo(java.lang.Integer key,
Gizmo g)
key - that will trigger the gizmo to do the gizmo's actiong - the gizmo that is triggered
public void deleteKeyUpTriggerToGizmo(java.lang.Integer key,
Gizmo g)
key - the key that triggers the gizmog - the gizmo that gets triggered by the key
public void deleteKeyDownTriggerToGizmo(java.lang.Integer key,
Gizmo g)
key - the key that triggers the gizmog - the gizmo that gets triggered by the keypublic void upTrigger(java.lang.Integer key)
key - that triggers a gizmopublic void downTrigger(java.lang.Integer key)
key - that triggers a gizmopublic void executeKeyboardEvents()
public java.util.Set<java.lang.Integer> getKeyUpTriggers()
public java.util.Set<java.lang.Integer> getKeyDownTriggers()
public java.util.List<Gizmo> getKeyUpGizmos(java.lang.Integer key)
key -
public java.util.List<Gizmo> getKeyDownGizmos(java.lang.Integer key)
key -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||