public class Rectangle extends com.badlogic.gdx.math.Rectangle implements Parallelogram
Constructor and Description |
---|
Rectangle()
Default constructor.
|
Rectangle(float x,
float y,
float width,
float height)
Constructor
|
Modifier and Type | Method and Description |
---|---|
<T extends Positionable> |
addPostionChangeListener(PositionChangeListener<T> listener)
Adds a
PositionChangeListener to be notified of coordinate
changes |
boolean |
contains(float x,
float y)
Returns if the specified coordinates are contained within this
Parallelogram |
boolean |
contains(Parallelogram parallelogram)
Returns if the specified
Parallelogram is contained within this
one |
boolean |
contains(Rectangle rectangle) |
boolean |
contains(com.badlogic.gdx.math.Rectangle rectangle) |
boolean |
contains(com.badlogic.gdx.math.Vector2 point) |
void |
debug(Graphics g)
Renders this
Rectangle and the LineSegment s between each
of its point and its rotational center |
void |
draw(Graphics g) |
float |
getCenterX()
Returns the x coordinate of the center of this
Rectangle |
float |
getCenterY()
Returns the y coordinate of the center of this
Rectangle |
float |
getDistanceTo(Positionable positionable)
Returns this distance between this object's x,y coordinates and the
provided
Positionable 's xy coordinates |
float |
getMaxX()
Returns the greatest x coordinate this
Rectangle |
float |
getMaxY()
Returns the greatest y coordinate this
Rectangle |
float |
getMinX()
Returns the least x coordinate this
Rectangle |
float |
getMinY()
Returns the least y coordinate this
Rectangle |
int |
getNumberOfSides() |
float |
getRotation()
Returns the current rotation of the shape in degrees
|
Rectangle |
intersection(Rectangle rect) |
boolean |
intersects(float x,
float y,
float width,
float height)
Returns if this shape intersects a specified rectangle dimensions
|
boolean |
intersects(LineSegment lineSegment)
Returns if this shape intersects a specified
LineSegment |
boolean |
intersects(Parallelogram parallelogram)
Returns if this shape intersects a specified
Parallelogram |
boolean |
intersects(Rectangle rectangle)
Returns if the specified
Rectangle intersects this one |
boolean |
overlaps(com.badlogic.gdx.math.Rectangle rectangle) |
<T extends Positionable> |
removePositionChangeListener(PositionChangeListener<T> listener)
Removes a
PositionChangeListener to stop it being notified of
coordinate changes |
void |
rotate(float degrees)
Rotates the shape around its top-left corner by the specified degrees
adding to its existing rotation
|
void |
rotateAround(Point center,
float degrees)
Rotates the shape around a center point by the specified degrees adding
to its existing rotation
|
Rectangle |
set(float x,
float y,
float width,
float height) |
void |
set(Rectangle rectangle) |
com.badlogic.gdx.math.Rectangle |
set(com.badlogic.gdx.math.Rectangle rectangle) |
Rectangle |
setHeight(float height) |
Rectangle |
setPosition(float x,
float y) |
Rectangle |
setPosition(com.badlogic.gdx.math.Vector2 position) |
void |
setRotation(float degrees)
Sets the current rotation of the shape around its top-left corner
Note: Rotates around the top-left corner
|
void |
setRotationAround(Point center,
float degrees)
Sets the current rotation of the shape around a center point
|
Rectangle |
setSize(float sizeXY) |
Rectangle |
setSize(float width,
float height) |
Rectangle |
setWidth(float width) |
Rectangle |
setX(float x) |
Rectangle |
setY(float y) |
java.lang.String |
toString() |
area, equals, fitInside, fitOutside, getAspectRatio, getCenter, getHeight, getPosition, getSize, getWidth, getX, getY, hashCode, merge, merge, merge, merge, perimeter, setCenter, setCenter
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getHeight, getWidth
getX, getY
public Rectangle()
Rectangle
at 0,0 with a width and
height of 1public void debug(Graphics g)
Rectangle
and the LineSegment
s between each
of its point and its rotational centerg
- The Graphics
context to render topublic float getDistanceTo(Positionable positionable)
Positionable
Positionable
's xy coordinatesgetDistanceTo
in interface Positionable
positionable
- The Positionable
to retrieve the distance fromPositionable.getDistanceTo(Positionable)
public <T extends Positionable> void addPostionChangeListener(PositionChangeListener<T> listener)
Positionable
PositionChangeListener
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 float getRotation()
Parallelogram
getRotation
in interface Parallelogram
Parallelogram.getRotation()
public void setRotation(float degrees)
Parallelogram
setRotation
in interface Parallelogram
degrees
- The rotation angle in degreesParallelogram.setRotation(float)
public void setRotationAround(Point center, float degrees)
Parallelogram
setRotationAround
in interface Parallelogram
center
- The center point to rotate arounddegrees
- The rotation angle in degreesParallelogram.setRotationAround(Point, float)
public void rotate(float degrees)
Parallelogram
rotate
in interface Parallelogram
degrees
- The rotation in degreesParallelogram.rotate(float)
public void rotateAround(Point center, float degrees)
Parallelogram
rotateAround
in interface Parallelogram
degrees
- The rotation in degreesParallelogram.rotateAround(Point, float)
public boolean intersects(LineSegment lineSegment)
Parallelogram
LineSegment
intersects
in interface Parallelogram
lineSegment
- The LineSegment
to test for intersectionParallelogram.intersects(LineSegment)
public boolean intersects(Rectangle rectangle)
Rectangle
intersects this onepublic boolean overlaps(com.badlogic.gdx.math.Rectangle rectangle)
overlaps
in class com.badlogic.gdx.math.Rectangle
public boolean intersects(Parallelogram parallelogram)
Parallelogram
Parallelogram
intersects
in interface Parallelogram
parallelogram
- The Parallelogram
to test for intersectionParallelogram.intersects(Parallelogram)
public boolean intersects(float x, float y, float width, float height)
Parallelogram
intersects
in interface Parallelogram
x
- The x coordinate of the rectangley
- The y coordinate of the rectanglewidth
- The width of the rectangleheight
- The height of the rectangleParallelogram.intersects(float, float, float, float)
public boolean contains(Parallelogram parallelogram)
Parallelogram
Parallelogram
is contained within this
onecontains
in interface Parallelogram
parallelogram
- The Parallelogram
to testParallelogram.contains(Parallelogram)
public boolean contains(Rectangle rectangle)
Parallelogram.contains(Parallelogram)
public boolean contains(com.badlogic.gdx.math.Rectangle rectangle)
contains
in class com.badlogic.gdx.math.Rectangle
public boolean contains(float x, float y)
Parallelogram
Parallelogram
contains
in interface Parallelogram
contains
in class com.badlogic.gdx.math.Rectangle
x
- The x coordinatey
- The y coordinatepublic boolean contains(com.badlogic.gdx.math.Vector2 point)
contains
in class com.badlogic.gdx.math.Rectangle
public int getNumberOfSides()
getNumberOfSides
in interface Shape
Shape.getNumberOfSides()
public void draw(Graphics g)
draw
in interface Shape
Shape.draw(Graphics)
public Rectangle set(float x, float y, float width, float height)
set
in class com.badlogic.gdx.math.Rectangle
public void set(Rectangle rectangle)
public com.badlogic.gdx.math.Rectangle set(com.badlogic.gdx.math.Rectangle rectangle)
set
in class com.badlogic.gdx.math.Rectangle
public Rectangle setPosition(float x, float y)
setPosition
in class com.badlogic.gdx.math.Rectangle
public Rectangle setPosition(com.badlogic.gdx.math.Vector2 position)
setPosition
in class com.badlogic.gdx.math.Rectangle
public Rectangle setX(float x)
setX
in class com.badlogic.gdx.math.Rectangle
public Rectangle setY(float y)
setY
in class com.badlogic.gdx.math.Rectangle
public Rectangle setWidth(float width)
setWidth
in class com.badlogic.gdx.math.Rectangle
public Rectangle setHeight(float height)
setHeight
in class com.badlogic.gdx.math.Rectangle
public Rectangle setSize(float width, float height)
setSize
in class com.badlogic.gdx.math.Rectangle
public Rectangle setSize(float sizeXY)
setSize
in class com.badlogic.gdx.math.Rectangle
public float getCenterX()
Rectangle
public float getCenterY()
Rectangle
public float getMinX()
Rectangle
public float getMinY()
Rectangle
public float getMaxX()
Rectangle
getMaxX
in interface Parallelogram
public float getMaxY()
Rectangle
getMaxY
in interface Parallelogram
public java.lang.String toString()
toString
in class com.badlogic.gdx.math.Rectangle