|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectvisual.dynamic.described.AbstractSprite
public abstract class AbstractSprite
A Sprite is an "actor" on a Stage. In essence, a Sprite decorates a TransformableContent object, providing it with additional capabilities. Note: We don't immediately delegate since the content and the location/rotation/scale may change at any time and in any order. Instead, we set the location/rotation/scale before rendering.
| Field Summary | |
|---|---|
protected double |
angle
|
protected boolean |
rotationPoint
|
protected double |
rotationX
|
protected double |
rotationY
|
protected double |
scaleX
|
protected double |
scaleY
|
protected boolean |
visible
|
protected double |
x
|
protected double |
y
|
| Constructor Summary | |
|---|---|
AbstractSprite()
Default Constructor |
|
| Method Summary | |
|---|---|
java.awt.geom.Rectangle2D |
getBounds2D()
Returns a high precision bounding box of the transformed Content |
java.awt.geom.Rectangle2D |
getBounds2D(boolean ofTransformed)
Returns a high precision bounding box of the Content either before or after it is transformed |
protected abstract TransformableContent |
getContent()
Gets the (current) visual content for this Sprite This method is called by various setters and the render() method. |
abstract void |
handleTick(int time)
Handle a tick event (required by MetronomeListener) |
boolean |
intersects(Sprite s)
Does the bounding box of this Sprite intersect the bounding box of the given Sprite? (given their current state) |
protected void |
reinitialize()
Initialize state variables |
void |
render(java.awt.Graphics g)
Render this Sprite |
void |
setLocation(double x,
double y)
Set the location (on the Stage) of the Sprite |
void |
setRotation(double r)
Set the rotation angle (the Sprite will rotate around its midpoint) |
void |
setRotation(double r,
double x,
double y)
Set the rotation angle and point to rotate around |
void |
setScale(double s)
Set the scaling (enlargement, reduction) of the Sprite |
void |
setScale(double sx,
double sy)
Set the scaling (enlargement, reduction) of the Sprite |
void |
setVisible(boolean v)
Set the visibility of this Sprite |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean rotationPoint
protected boolean visible
protected double angle
protected double rotationX
protected double rotationY
protected double scaleX
protected double scaleY
protected double x
protected double y
| Constructor Detail |
|---|
public AbstractSprite()
| Method Detail |
|---|
public java.awt.geom.Rectangle2D getBounds2D(boolean ofTransformed)
getBounds2D in interface TransformableContentofTransformed - true to get the bounds of the transformed content
public java.awt.geom.Rectangle2D getBounds2D()
protected abstract TransformableContent getContent()
public abstract void handleTick(int time)
handleTick in interface MetronomeListenertime - The current time (in milliseconds)protected void reinitialize()
public boolean intersects(Sprite s)
s - The other Sprite
public void render(java.awt.Graphics g)
render in interface SimpleContentg - The rendering engine to use
public void setLocation(double x,
double y)
setLocation in interface TransformableContentx - The horizontal locationy - The vertical location
public void setRotation(double r,
double x,
double y)
setRotation in interface TransformableContentr - The new rotation anglex - The x-coordinate of the point to rotate aroundy - The y-coordinate of the point to rotate aroundpublic void setRotation(double r)
r - The new rotation angle
public void setScale(double sx,
double sy)
setScale in interface TransformableContentsx - The scale in the x-dimensionsy - The scale in the y-dimensionpublic void setScale(double s)
s - The new scalepublic void setVisible(boolean v)
v - true for visible, false for invisible
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||