|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Marble
The abstract class for the Marble object. Based on the Ball class implemented by Steve Revilak
Field Summary | |
protected java.awt.Color |
color The color of the marble. |
protected static double |
FRICTION A change to velocity; applied each time the marble moves. |
protected static int |
RADIUS Radius for each Marble is a fixed 6 pixels. |
protected static int |
TERMINAL_VELOCITY
The fastest that the marble is allowed to move (in pixels/move). |
protected int |
x The x coordinate of the vertex of the marble. |
protected int |
y The y coordinate of the vertex of the marble. |
Constructor Summary | |
Marble(java.awt.Color c,
int ringCenterX, int ringCenterY, int ringRadius)
Construct a new marble with the specified color, ringCenterX, ringCenterY, and ringRadius. |
Method Summary | |
void |
applyForce(double magnitude,
double direction) Apply a force to this marble (causing it to move). |
abstract void |
draw(java.awt.Graphics g)
Ask this marble to draw itself on the given Graphics object. |
java.awt.Color |
getColor() Get the color of this marble. |
double |
getDirection()
Get this marble's direction of travel (in radians). |
java.util.Enumeration |
getPathEnumerator()
Return an object that will enumerate the Points through which this marble will pass during its next move. |
double |
getVelocity()
Get this marble's current velocity (the number of pixels it moves between redraws). |
java.awt.Point |
getVertex() Get the location (in Point) of this marble. |
boolean |
isMoving() Check if this marble is moving. |
boolean |
isOutsideRing()
Check if this marble is outside the boundary of the ring. |
boolean |
isTouching(Marble other)
Check if this marble is touching the other marble. |
boolean |
isTouching(java.awt.Point p)
Check if this marble is touching the given point. |
boolean |
isTouching(java.awt.Point p,
double distance) Check if this marble is within the distance distance of the given point. |
boolean |
move() Move this marble, by having it recompute its coordinate, adjusting speed and velocity as necessary. |
void |
setVertex(double x,
double y) Set the location of this marble, after rounding x and y to integers. |
void |
setVertex(int x,
int y) Set the location of this marble. |
java.lang.String |
toString() Get the string representation of this marble. |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected static final int RADIUS
protected int x
protected int y
protected java.awt.Color color
protected static final int TERMINAL_VELOCITY
protected static final double FRICTION
Constructor Detail |
public Marble(java.awt.Color c, int ringCenterX, int ringCenterY, int ringRadius)
c
- the color of this MarbleringCenterX
- the x coordinate of the center of the ringringCenterY
- the y coordinate of the center of the ringringRadius
- the radius of the ringMethod Detail |
public final java.awt.Point getVertex()
public final java.awt.Color getColor()
public final void setVertex(int x, int y)
x
- the x coordinate of this marbley
- the y coordinate of this marblepublic final void setVertex(double x, double y)
x
- the new x coordinate of this marbley
- the new y coordinate of this marblepublic final double getDirection()
MotionUtils.java
public final boolean isMoving()
public final double getVelocity()
public final boolean isTouching(Marble other)
other
- the other marblepublic final boolean isTouching(java.awt.Point p, double distance)
p
- the point to testdistance
- the distance around the pointpublic final boolean isTouching(java.awt.Point p)
p
- the point to testpublic final boolean isOutsideRing()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean move()
public void applyForce(double magnitude, double direction)
magnitude
- the amount of force to applydirection
- the direction in which to apply the force,
(0 <= direction <= 2pi).public abstract void draw(java.awt.Graphics g)
g
- the graphics object onto which the marble should draw itselfpublic final java.util.Enumeration getPathEnumerator()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |