|
Ball World Problem Set Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ballworld.BallRenderer
Holds and animates one ball which can be rendered upon requested. Also provides methods for transforming between world corrdinates (cartesian with 0,0 at center) and GUI coordinates (0,0 at upper left with inverted vertical scale as is the norm in Java GUI components)
Constructor Summary | |
BallRenderer(Ball b,
BallWorld w)
Creates a new instance of BallRenderer |
Method Summary | |
boolean |
containsPoint(java.awt.Point p)
Check whether or not the given point resides within the radius of the ball. |
double |
distanceTo(java.awt.Point p)
Find the distance from our ball to the given point. |
void |
drawBall(java.awt.Graphics2D G)
Draw the ball on the given graphics context. |
Ball |
getBall()
Get the ball held by this renderer. |
void |
setSelected(boolean state)
Set the selection status for this ball; |
void |
stop()
Stop the Animator thread. |
static java.awt.Point |
transformGUI2World(java.awt.Point p,
BallWorld w)
Convert a point from GUI coordinates to world coordinates. |
static java.awt.Point |
transformWorld2GUI(java.awt.Point p,
BallWorld w)
Convert a point from world coordinates to GUI coordinates. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public BallRenderer(Ball b, BallWorld w)
b
- The Ball
we are responsible for renderingw
- The BallWorld
thatMethod Detail |
public void drawBall(java.awt.Graphics2D G)
G
- A graphics context for drawingpublic Ball getBall()
public void setSelected(boolean state)
state
- the state to set (selected or not)public boolean containsPoint(java.awt.Point p)
p
- The point to check
true
if our ball contains this point, false
otherwise.public double distanceTo(java.awt.Point p)
p
- The point to measure the distance to
public void stop()
public static java.awt.Point transformWorld2GUI(java.awt.Point p, BallWorld w)
w
- The world we are converting fromp
- A point in world coordinates
public static java.awt.Point transformGUI2World(java.awt.Point p, BallWorld w)
w
- The world we are converting top
- A point in GUI coordinates
|
Ball World Problem Set Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |