public abstract class Shape extends java.lang.Object implements Sizeable
Modifier and Type | Field and Description |
---|---|
protected Geometry |
geometry |
protected org.mini2Dx.gdx.utils.Array<PositionChangeListener> |
positionChangeListeners |
protected org.mini2Dx.gdx.utils.Array<SizeChangeListener> |
sizeChangeListeners |
Constructor and Description |
---|
Shape()
Constructor for shapes not belonging to the
Geometry pool |
Shape(Geometry geometry)
Constructor for shapes belonging to the
Geometry pool |
Modifier and Type | Method and Description |
---|---|
void |
add(float x,
float y)
Adds components to the position of this
Shape |
<T extends Positionable> |
addPostionChangeListener(PositionChangeListener<T> listener)
Adds a
Positionable to be notified of coordinate
changes |
<T extends Sizeable> |
addSizeChangeListener(SizeChangeListener<T> listener)
Adds a
SizeChangeListener to be notified of size changes |
protected void |
clearPositionChangeListeners() |
static <T extends Positionable> |
clearPositionListeners(org.mini2Dx.gdx.utils.Array<PositionChangeListener> positionChangeListeners) |
static <T extends Positionable> |
clearPositionListeners(java.util.concurrent.locks.ReadWriteLock lock,
org.mini2Dx.gdx.utils.Array<PositionChangeListener> positionChangeListeners) |
protected void |
clearSizeChangeListeners() |
static <T extends Sizeable> |
clearSizeListeners(org.mini2Dx.gdx.utils.Array<SizeChangeListener> sizeChangeListeners) |
static <T extends Sizeable> |
clearSizeListeners(java.util.concurrent.locks.ReadWriteLock lock,
org.mini2Dx.gdx.utils.Array<SizeChangeListener> sizeChangeListeners) |
abstract Shape |
copy()
Returns an exact copy of this
Shape |
abstract void |
dispose()
|
abstract void |
draw(Graphics g)
Draws this shape using a
Graphics instance |
abstract EdgeIterator |
edgeIterator()
Returns an
EdgeIterator for looping over the edges of this
Shape |
boolean |
equals(java.lang.Object obj) |
abstract void |
fill(Graphics g)
Fills this shape using a
Graphics instance |
float |
getDistanceTo(Positionable positionable)
Returns the distance from this
Shape to a Positionable |
abstract int |
getNumberOfSides()
Returns the number of edges of this object
|
abstract Polygon |
getPolygon()
|
abstract float |
getRotation()
Returns the rotation of this
Shape |
int |
hashCode() |
boolean |
intersects(LineSegment lineSegment)
Returns if this
Shape intersects the specified
LineSegment |
abstract boolean |
isCircle()
|
void |
moveTowards(float x,
float y,
float speed)
Moves this
Positionable towards a coordinate |
void |
moveTowards(Positionable positionable,
float speed)
Moves this
Positionable towards another Positionable |
protected void |
notifyPositionChangeListeners() |
static <T extends Positionable> |
notifyPositionListeners(org.mini2Dx.gdx.utils.Array<PositionChangeListener> positionChangeListeners,
T notifier) |
static <T extends Positionable> |
notifyPositionListeners(java.util.concurrent.locks.ReadWriteLock lock,
org.mini2Dx.gdx.utils.Array<PositionChangeListener> positionChangeListeners,
T notifier) |
protected void |
notifySizeChangeListeners() |
static <T extends Sizeable> |
notifySizeListeners(org.mini2Dx.gdx.utils.Array<SizeChangeListener> sizeChangeListeners,
T notifier) |
static <T extends Sizeable> |
notifySizeListeners(java.util.concurrent.locks.ReadWriteLock lock,
org.mini2Dx.gdx.utils.Array<SizeChangeListener> sizeChangeListeners,
T notifier) |
<T extends Positionable> |
removePositionChangeListener(PositionChangeListener<T> listener)
Removes a
PositionChangeListener to stop it being notified of
coordinate changes |
static <T extends Positionable> |
removePositionListener(org.mini2Dx.gdx.utils.Array<PositionChangeListener> positionChangeListeners,
PositionChangeListener listener) |
static <T extends Positionable> |
removePositionListener(java.util.concurrent.locks.ReadWriteLock lock,
org.mini2Dx.gdx.utils.Array<PositionChangeListener> positionChangeListeners,
PositionChangeListener listener) |
<T extends Sizeable> |
removeSizeChangeListener(SizeChangeListener<T> listener)
Removes a
SizeChangeListener to stop it being notified of size
changes |
static <T extends Sizeable> |
removeSizeListener(org.mini2Dx.gdx.utils.Array<SizeChangeListener> sizeChangeListeners,
SizeChangeListener listener) |
static <T extends Sizeable> |
removeSizeListener(java.util.concurrent.locks.ReadWriteLock lock,
org.mini2Dx.gdx.utils.Array<SizeChangeListener> sizeChangeListeners,
SizeChangeListener listener) |
abstract void |
rotate(float degrees)
Rotates this
Shape by a specified amount of degrees with its
first point as the origin |
abstract void |
rotateAround(float originX,
float originY,
float degrees)
Rotates this
Shape by a specified amount of degrees around a
specified point |
abstract void |
setRotation(float degrees)
Sets the rotation of this
Shape with its first point as the
origin |
abstract void |
setRotationAround(float originX,
float originY,
float degrees)
Sets the rotation of this
Shape with a specified point as the
origin |
void |
setRotationAround(Point center,
float degrees)
Sets the rotation of this
Shape with a specified point as the origin |
void |
subtract(float x,
float y)
Subtracts components from the position of this
Shape |
abstract void |
translate(float translateX,
float translateY)
Translates the x and y coordinate of this object
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
contains, contains, contains, getCenterX, getCenterY, getHeight, getMaxX, getMaxY, getMinX, getMinY, getWidth, intersects, intersectsLineSegment, intersectsLineSegment, scale, setCenter, setCenterX, setCenterY, setRadius
getDistanceTo, getX, getY, setX, setXY, setY
protected final Geometry geometry
protected org.mini2Dx.gdx.utils.Array<PositionChangeListener> positionChangeListeners
protected org.mini2Dx.gdx.utils.Array<SizeChangeListener> sizeChangeListeners
public Shape()
Geometry
poolpublic abstract void dispose()
public abstract Shape copy()
Shape
Shape
public boolean intersects(LineSegment lineSegment)
Shape
intersects the specified
LineSegment
intersects
in interface Sizeable
lineSegment
- The LineSegment
to checkShape
intersects the LineSegment
public float getDistanceTo(Positionable positionable)
Shape
to a Positionable
getDistanceTo
in interface Positionable
positionable
- The Positionable
to get the distance topublic void add(float x, float y)
Shape
x
- The x componenty
- The y componentpublic void subtract(float x, float y)
Shape
x
- The x componenty
- The y componentpublic abstract float getRotation()
Shape
public abstract void setRotation(float degrees)
Shape
with its first point as the
origindegrees
- The rotation in degreespublic void setRotationAround(Point center, float degrees)
Shape
with a specified point as the origincenter
- The origin Point
degrees
- The rotation in degreespublic abstract void setRotationAround(float originX, float originY, float degrees)
Shape
with a specified point as the
originoriginX
- The origin/center x coordinateoriginY
- The origin/center y coordinatedegrees
- The rotation in degreespublic abstract void rotate(float degrees)
Shape
by a specified amount of degrees with its
first point as the origindegrees
- The rotation in degreespublic abstract void rotateAround(float originX, float originY, float degrees)
Shape
by a specified amount of degrees around a
specified pointoriginX
- The origin/center x coordinateoriginY
- The origin/center y coordinatedegrees
- The rotation in degreespublic abstract void draw(Graphics g)
Graphics
instanceg
- The Graphics
context to render withpublic abstract void fill(Graphics g)
Graphics
instanceg
- The Graphics
context to render withpublic abstract void translate(float translateX, float translateY)
translateX
- The x translation amounttranslateY
- The y translation amountpublic abstract int getNumberOfSides()
getNumberOfSides
in interface Sizeable
public abstract EdgeIterator edgeIterator()
EdgeIterator
for looping over the edges of this
Shape
EdgeIterator
public abstract boolean isCircle()
public abstract Polygon getPolygon()
getPolygon
in interface Sizeable
Shape
is a Circle
public void moveTowards(float x, float y, float speed)
Positionable
Positionable
towards a coordinatemoveTowards
in interface Positionable
x
- The target x coordinatey
- The target y coordinatespeed
- The amount to move bypublic void moveTowards(Positionable positionable, float speed)
Positionable
Positionable
towards another Positionable
moveTowards
in interface Positionable
positionable
- The target Positionable
speed
- The amount to move bypublic <T extends Positionable> void addPostionChangeListener(PositionChangeListener<T> listener)
Positionable
Positionable
to be notified of coordinate
changesaddPostionChangeListener
in interface Positionable
listener
- The PositionChangeListener
to addPositionable.addPostionChangeListener(PositionChangeListener)
public <T extends Positionable> void removePositionChangeListener(PositionChangeListener<T> listener)
Positionable
PositionChangeListener
to stop it being notified of
coordinate changesremovePositionChangeListener
in interface Positionable
listener
- The PositionChangeListener
to removePositionable.removePositionChangeListener(PositionChangeListener)
public <T extends Sizeable> void addSizeChangeListener(SizeChangeListener<T> listener)
Sizeable
SizeChangeListener
to be notified of size changesaddSizeChangeListener
in interface Sizeable
listener
- The SizeChangeListener
to addpublic <T extends Sizeable> void removeSizeChangeListener(SizeChangeListener<T> listener)
Sizeable
SizeChangeListener
to stop it being notified of size
changesremoveSizeChangeListener
in interface Sizeable
listener
- The SizeChangeListener
to removeprotected void notifyPositionChangeListeners()
protected void clearPositionChangeListeners()
protected void notifySizeChangeListeners()
protected void clearSizeChangeListeners()
public static <T extends Positionable> void removePositionListener(org.mini2Dx.gdx.utils.Array<PositionChangeListener> positionChangeListeners, PositionChangeListener listener)
public static <T extends Positionable> void removePositionListener(java.util.concurrent.locks.ReadWriteLock lock, org.mini2Dx.gdx.utils.Array<PositionChangeListener> positionChangeListeners, PositionChangeListener listener)
public static <T extends Positionable> void notifyPositionListeners(org.mini2Dx.gdx.utils.Array<PositionChangeListener> positionChangeListeners, T notifier)
public static <T extends Positionable> void notifyPositionListeners(java.util.concurrent.locks.ReadWriteLock lock, org.mini2Dx.gdx.utils.Array<PositionChangeListener> positionChangeListeners, T notifier)
public static <T extends Positionable> void clearPositionListeners(org.mini2Dx.gdx.utils.Array<PositionChangeListener> positionChangeListeners)
public static <T extends Positionable> void clearPositionListeners(java.util.concurrent.locks.ReadWriteLock lock, org.mini2Dx.gdx.utils.Array<PositionChangeListener> positionChangeListeners)
public static <T extends Sizeable> void removeSizeListener(org.mini2Dx.gdx.utils.Array<SizeChangeListener> sizeChangeListeners, SizeChangeListener listener)
public static <T extends Sizeable> void removeSizeListener(java.util.concurrent.locks.ReadWriteLock lock, org.mini2Dx.gdx.utils.Array<SizeChangeListener> sizeChangeListeners, SizeChangeListener listener)
public static <T extends Sizeable> void notifySizeListeners(org.mini2Dx.gdx.utils.Array<SizeChangeListener> sizeChangeListeners, T notifier)
public static <T extends Sizeable> void notifySizeListeners(java.util.concurrent.locks.ReadWriteLock lock, org.mini2Dx.gdx.utils.Array<SizeChangeListener> sizeChangeListeners, T notifier)
public static <T extends Sizeable> void clearSizeListeners(org.mini2Dx.gdx.utils.Array<SizeChangeListener> sizeChangeListeners)
public static <T extends Sizeable> void clearSizeListeners(java.util.concurrent.locks.ReadWriteLock lock, org.mini2Dx.gdx.utils.Array<SizeChangeListener> sizeChangeListeners)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object