|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.newdawn.slick.geom.Shape
public abstract class Shape
The description of any 2D shape that can be transformed. The points provided approximate the intent of the shape.
Field Summary | |
---|---|
protected float |
boundingCircleRadius
Radius of a circle that can completely enclose this shape. |
protected float[] |
center
Center point of the polygon. |
protected float |
maxX
The right most point of this shape |
protected float |
maxY
The bottom most point of this shape |
protected float |
minX
The left most point of this shape. |
protected float |
minY
The top most point of this shape. |
protected float[] |
points
The points representing this polygon. |
protected boolean |
pointsDirty
Flag to tell whether points need to be generated |
protected boolean |
trianglesDirty
True if the triangles need updating |
protected Triangulator |
tris
The triangles that define the shape |
protected float |
x
The left most point of this shape. |
protected float |
y
The top most point of this shape. |
Constructor Summary | |
---|---|
Shape()
Shape constructor. |
Method Summary | |
---|---|
protected void |
calculateRadius()
Calculate the radius of a circle that can completely enclose this shape. |
protected void |
calculateTriangles()
Calculate the triangles that can fill this shape |
protected void |
checkPoints()
Check the dirty flag and create points as necessary. |
boolean |
closed()
True if this is a closed shape |
boolean |
contains(float x,
float y)
Check if this polygon contains the given point |
boolean |
contains(Shape other)
Check if the shape passed is entirely contained within this shape. |
protected abstract void |
createPoints()
Subclasses implement this to create the points of the shape. |
protected void |
findCenter()
Get the center of this polygon. |
float |
getBoundingCircleRadius()
Get the radius of a circle that can completely enclose this shape. |
float[] |
getCenter()
Get the point closet to the center of all the points in this Shape |
float |
getCenterX()
Get the x center of this shape. |
float |
getCenterY()
Get the y center of this shape. |
float |
getHeight()
Get the height of the shape |
Vector2f |
getLocation()
Get the top-left location of this shape. |
float |
getMaxX()
Get the right most point of this shape. |
float |
getMaxY()
Get the bottom most point of this shape. |
float |
getMinX()
Get the left most point of this shape. |
float |
getMinY()
Get the top most point of this shape. |
float[] |
getNormal(int index)
Get the combine normal of a given point |
float[] |
getPoint(int index)
Get a single point in this polygon |
int |
getPointCount()
Get the number of points in this polygon |
float[] |
getPoints()
Get the points that outline this shape. |
Triangulator |
getTriangles()
The triangles that define the filled version of this shape |
float |
getWidth()
Get the width of the shape |
float |
getX()
Get the x location of the left side of this shape. |
float |
getY()
Get the y position of the top of this shape. |
boolean |
hasVertex(float x,
float y)
Check if a particular location is a vertex of this polygon |
boolean |
includes(float x,
float y)
Check if the given point is part of the path that forms this shape |
void |
increaseTriangulation()
Increase triangulation |
int |
indexOf(float x,
float y)
Get the index of a given point |
boolean |
intersects(Shape shape)
Check if this shape intersects with the shape provided. |
void |
preCache()
Cause all internal state to be generated and cached |
Shape |
prune()
Prune any required points in this shape |
void |
setCenterX(float centerX)
Set the x center of this shape. |
void |
setCenterY(float centerY)
Set the y center of this shape. |
void |
setLocation(float x,
float y)
Set the top-left location of this shape |
void |
setLocation(Vector2f loc)
Set the top-left location of this shape |
void |
setX(float x)
Set the x position of the left side this shape. |
void |
setY(float y)
Set the y position of the top of this shape. |
Shape[] |
subtract(Shape other)
Subtract the given shape from this one. |
abstract Shape |
transform(Transform transform)
Apply a transformation and return a new shape. |
Shape[] |
union(Shape other)
Join this shape with another. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected float[] points
protected float[] center
protected float x
protected float y
protected float maxX
protected float maxY
protected float minX
protected float minY
protected float boundingCircleRadius
protected boolean pointsDirty
protected transient Triangulator tris
protected boolean trianglesDirty
Constructor Detail |
---|
public Shape()
Method Detail |
---|
public void setLocation(float x, float y)
x
- The x coordinate of the new location of the shapey
- The y coordinate of the new location of the shapepublic abstract Shape transform(Transform transform)
transform
- The transform to be applied
protected abstract void createPoints()
public float getX()
public void setX(float x)
x
- The new x position of the left side this shape.public void setY(float y)
y
- The new y position of the top of this shape.public float getY()
public Vector2f getLocation()
public void setLocation(Vector2f loc)
loc
- The new coordinate of the top-left of this shapepublic float getCenterX()
public void setCenterX(float centerX)
centerX
- The center point to set.public float getCenterY()
public void setCenterY(float centerY)
centerY
- The center point to set.public float getMaxX()
public float getMaxY()
public float getMinX()
public float getMinY()
public float getBoundingCircleRadius()
public float[] getCenter()
public float[] getPoints()
public int getPointCount()
public float[] getPoint(int index)
index
- The index of the point to retrieve
public float[] getNormal(int index)
index
- The index of the point whose normal should be retrieved
public boolean contains(Shape other)
other
- The other shape to test against this one
public boolean includes(float x, float y)
x
- The x position of the point to checky
- The y position of the point to check
public int indexOf(float x, float y)
x
- The x coordinate of the pointy
- The y coordinate of the point
public boolean contains(float x, float y)
x
- The x position of the point to checky
- The y position of the point to check
public boolean intersects(Shape shape)
shape
- The shape to check if it intersects with this one.
public boolean hasVertex(float x, float y)
x
- The x coordinate to checky
- The y coordinate to check
protected void findCenter()
protected void calculateRadius()
protected void calculateTriangles()
public void increaseTriangulation()
public Triangulator getTriangles()
protected final void checkPoints()
public void preCache()
public boolean closed()
public Shape prune()
public Shape[] subtract(Shape other)
other
- The other shape to subtract from this one
public Shape[] union(Shape other)
other
- The other shape to join with this one
public float getWidth()
public float getHeight()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |