public final class OrientedRectangle extends Object implements IMutablePoint, IMutableOrientedRectangle, ICloneable
IMutablePoint and IMutableSize as well as two doubles for the up vector
components.
This implementation delegates the storage to implementations of IMutablePoint for the anchor of the oriented
rectangle. and IMutableSize for the size of the oriented rectangle. members. As a convenience it implements the
IMutablePoint and the ICloneable interfaces.
IOrientedRectangle,
IMutableOrientedRectangle| Constructor and Description |
|---|
OrientedRectangle()
Initializes a new instance of the
OrientedRectangle class located at 0.0d,0.0d with empty width and
height (-1.0d). |
OrientedRectangle(double anchorX,
double anchorY,
double width,
double height)
Creates a new instance using the provided values to initialize the anchor and size.
|
OrientedRectangle(double anchorX,
double anchorY,
double width,
double height,
double upX)
Creates a new instance using the provided values to initialize the anchor and size.
|
OrientedRectangle(double anchorX,
double anchorY,
double width,
double height,
double upX,
double upY)
Creates a new instance using the provided values to initialize the anchor and size.
|
OrientedRectangle(IMutablePoint anchor,
IMutableSize size)
Creates a new instance using the provided values to initialize the anchor and size.
|
OrientedRectangle(IOrientedRectangle rectangle)
Creates a new instance using the provided values to initialize.
|
OrientedRectangle(IRectangle rectangle)
Creates a new instance using the provided rectangle to initialize the anchor and size.
|
| Modifier and Type | Method and Description |
|---|---|
OrientedRectangle |
clone()
Creates a copy of the current state of this instance using a new
MutablePoint and Size to
store the anchor and size. |
static OrientedRectangle |
convertFrom(MutableRectangle rect)
A casting operator that creates a new instance of
OrientedRectangle using the current state of the rectangle
that is cast. |
static IOrientedRectangle |
createImmutable(double anchorX,
double anchorY,
double width,
double height,
double upX,
double upY)
Creates an immutable
IOrientedRectangle with the given values. |
boolean |
equals(IOrientedRectangle other) |
boolean |
equals(Object other)
Implements the equals method by comparing the given object's values.
|
IPoint |
getAnchor()
Returns the instance that stores the anchor of this oriented rectangle.
|
double |
getAnchorX()
Gets the x coordinate of the anchor of this instance from the
Anchor instance. |
double |
getAnchorY()
Gets the y coordinate of the anchor of this instance from the
Anchor instance. |
double |
getAngle()
Gets the orientation of this rectangle.
|
double |
getHeight()
Gets the height of this instance from the
Size instance. |
ISize |
getSize()
Returns the instance that stores the size of this rectangle.
|
double |
getUpX()
Gets the x component of the up vector to the new value.
|
double |
getUpY()
Gets the y component of the up vector to the new value.
|
double |
getWidth()
Gets the width of this instance from the
Size instance. |
double |
getX()
Gets the x coordinate of the anchor of this instance from the
Anchor instance. |
double |
getY()
Gets the y coordinate of the anchor of this instance from the
Anchor instance. |
int |
hashCode()
|
boolean |
isEmpty()
Returns whether this instance has negative width or height.
|
void |
moveBy(PointD delta)
Moves this rectangle by applying the offset to the
Anchor. |
void |
reshape(IOrientedRectangle rectangle)
Applies the values provided by the given instance to the values of this instance.
|
void |
setAnchor(IPoint value)
Returns the instance that stores the anchor of this oriented rectangle.
|
void |
setAnchorX(double value)
Sets the x coordinate of the anchor of this instance from the
Anchor instance. |
void |
setAnchorY(double value)
Sets the y coordinate of the anchor of this instance from the
Anchor instance. |
void |
setAngle(double value)
Sets the orientation of this rectangle.
|
void |
setHeight(double value)
Sets the height of this instance from the
Size instance. |
void |
setSize(ISize value)
Returns the instance that stores the size of this rectangle.
|
void |
setUpVector(double upx,
double upy)
Sets the components of the up vector to the new values.
|
void |
setUpX(double value)
Sets the x component of the up vector to the new value.
|
void |
setUpY(double value)
Sets the y component of the up vector to the new value.
|
void |
setWidth(double value)
Sets the width of this instance from the
Size instance. |
void |
setX(double value)
Sets the x coordinate of the anchor of this instance from the
Anchor instance. |
void |
setY(double value)
Sets the y coordinate of the anchor of this instance from the
Anchor instance. |
String |
toString()
Creates a human readable from of this instance.
|
finalize, getClass, notify, notifyAll, wait, wait, waitrelocate, relocate, relocatedistanceTo, toPointDresize, resize, setAnchor, setCenter, setUpVectorcontains, createTransform, getAnchorLocation, getBounds, getCenter, getDynamicCenter, getTopLeftLocation, getUp, hits, toSizeDresizepublic OrientedRectangle()
OrientedRectangle class located at 0.0d,0.0d with empty width and
height (-1.0d).public OrientedRectangle(double anchorX,
double anchorY,
double width,
double height)
It is up to the caller to ensure that the up vector is normalized.
anchorX - The x coordinate of the anchor of the oriented rectangle.anchorY - The y coordinate of the anchor of the oriented rectangle.width - The width of the rectangle.height - The height of the rectangle.public OrientedRectangle(double anchorX,
double anchorY,
double width,
double height,
double upX)
It is up to the caller to ensure that the up vector is normalized.
anchorX - The x coordinate of the anchor of the oriented rectangle.anchorY - The y coordinate of the anchor of the oriented rectangle.width - The width of the rectangle.height - The height of the rectangle.upX - The x component of the up vector.public OrientedRectangle(double anchorX,
double anchorY,
double width,
double height,
double upX,
double upY)
It is up to the caller to ensure that the up vector is normalized.
anchorX - The x coordinate of the anchor of the oriented rectangle.anchorY - The y coordinate of the anchor of the oriented rectangle.width - The width of the rectangle.height - The height of the rectangle.upX - The x component of the up vector.upY - The y component of the up vector.public OrientedRectangle(IMutablePoint anchor, IMutableSize size)
The up vector will be initialized to
(0, -1). The instances provided will be referenced by this instance. This instance will be used as a live
view over the provided instances. Changes to them will indirectly change the state of this instance and changes applied
through this instance will be written to the referenced implementations.
anchor - The provider for the dynamic anchor of this instance.size - The provider for the dynamic size of this instance.public OrientedRectangle(IOrientedRectangle rectangle)
This will basically create a copy of the given rectangle
rectangle - The rectangle to initialize the anchor and size and up vector from.public OrientedRectangle(IRectangle rectangle)
The anchor will be set to the lower left corner of the provided rectangle. Thus this instance will have the exact same
bounds as the rectangle initially. The up vector will be initialized to (0, -1).
rectangle - The rectangle to initialize the anchor and size from.public final OrientedRectangle clone()
MutablePoint and Size to
store the anchor and size.clone in interface ICloneableclone in class ObjectOrientedRectangleObject.clone()public static final OrientedRectangle convertFrom(MutableRectangle rect)
OrientedRectangle using the current state of the rectangle
that is cast.
The anchor will be set to the lower left corner of the provided rectangle. Thus this instance will have the exact same
bounds as the rectangle initially. The up vector will be initialized to
(0, -1). Unlike true casting this will create a new instance that will be initialized to the current state
of the object being cast, but which will not stay in sync with the state of the object.
rect - the rectangle to get the current state fromOrientedRectangle that holds no reference to the provided rectangle.public static final IOrientedRectangle createImmutable(double anchorX, double anchorY, double width, double height, double upX, double upY)
IOrientedRectangle with the given values.public final boolean equals(IOrientedRectangle other)
public boolean equals(Object other)
Note that only instances of this type and the ones returned by the factory methods of this type can be equal to each other.
public final IPoint getAnchor()
This will return a live view of the anchor of this rectangle. However setting an anchor instance will only copy the values of the point provided to the current anchor.
setAnchor(IPoint)public final double getAnchorX()
Anchor instance.
Note that depending on the implementation used for holding the anchor the results may vary. However the default implementation will do just that: read and write the values without modifying them in any way.
getAnchorX in interface IMutableOrientedRectanglegetAnchorX in interface IOrientedRectanglesetAnchorX(double)public final double getAnchorY()
Anchor instance.
Note that depending on the implementation used for holding the anchor the results may vary. However the default implementation will do just that: read and write the values without modifying them in any way.
getAnchorY in interface IMutableOrientedRectanglegetAnchorY in interface IOrientedRectanglesetAnchorY(double)public final double getAngle()
The angle is specified in radians. An angle of 0 means the up vector points up in direction (0,-1). The
angle value is not stored and will be recalculated from UpX and UpY every time this
is invoked, so this is a costly method. Setting the angle changes the UpX and UpY
values accordingly.
setAngle(double)public final double getHeight()
Size instance.
Note that that depending on the implementation used for holding the size the results may vary. However the default implementation will do just that: read and write the values without modifying them in any way.
getHeight in interface IMutableSizegetHeight in interface ISizesetHeight(double)public final ISize getSize()
This will return a live view of the size of this rectangle. However setting a size instance will only copy the values of the size provided to the current size.
setSize(ISize)public final double getUpX()
It is up to the caller to assure that the values describe a vector of length 1.
getUpX in interface IOrientedRectanglegetAngle(),
setUpVector(double, double),
getUpY(),
setUpX(double)public final double getUpY()
It is up to the caller to assure that the values describe a vector of length 1.
getUpY in interface IOrientedRectanglegetAngle(),
setUpVector(double, double),
getUpX(),
setUpY(double)public final double getWidth()
Size instance.
Note that depending on the implementation used for holding the size the results may vary. However the default implementation will do just that: read and write the values without modifying them in any way.
getWidth in interface IMutableSizegetWidth in interface ISizesetWidth(double)public final double getX()
Anchor instance.
Note that depending on the implementation used for holding the anchor the results may vary. However the default implementation will do just that: read and write the values without modifying them in any way.
getX in interface IMutablePointgetX in interface IPointsetX(double)public final double getY()
Anchor instance.
Note that depending on the implementation used for holding the anchor the results may vary. However the default implementation will do just that: read and write the values without modifying them in any way.
getY in interface IMutablePointgetY in interface IPointsetY(double)public int hashCode()
public final boolean isEmpty()
public final void moveBy(PointD delta)
Anchor.delta - The offset to move the rectangle's anchor by.public final void reshape(IOrientedRectangle rectangle)
rectangle - The instance to retrieve the values from.public final void setAnchor(IPoint value)
This will return a live view of the anchor of this rectangle. However setting an anchor instance will only copy the values of the point provided to the current anchor.
value - The Anchor to set.getAnchor()public final void setAnchorX(double value)
Anchor instance.
Note that depending on the implementation used for holding the anchor the results may vary. However the default implementation will do just that: read and write the values without modifying them in any way.
setAnchorX in interface IMutableOrientedRectanglevalue - The AnchorX to set.getAnchorX()public final void setAnchorY(double value)
Anchor instance.
Note that depending on the implementation used for holding the anchor the results may vary. However the default implementation will do just that: read and write the values without modifying them in any way.
setAnchorY in interface IMutableOrientedRectanglevalue - The AnchorY to set.getAnchorY()public final void setAngle(double value)
The angle is specified in radians. An angle of 0 means the up vector points up in direction (0,-1). The
angle value is not stored and will be recalculated from UpX and UpY every time this
is invoked, so this is a costly method. Setting the angle changes the UpX and UpY
values accordingly.
value - The Angle to set.getAngle()public final void setHeight(double value)
Size instance.
Note that that depending on the implementation used for holding the size the results may vary. However the default implementation will do just that: read and write the values without modifying them in any way.
setHeight in interface IMutableSizevalue - The Height to set.getHeight()public final void setSize(ISize value)
This will return a live view of the size of this rectangle. However setting a size instance will only copy the values of the size provided to the current size.
value - The Size to set.getSize()public final void setUpVector(double upx,
double upy)
It is up to the caller to assure that the values describe a vector of length 1.
setUpVector in interface IMutableOrientedRectangleupx - The x component of the normalized up vector.upy - The y component of the normalized up vector.getAngle()public final void setUpX(double value)
It is up to the caller to assure that the values describe a vector of length 1.
value - The UpX to set.getAngle(),
setUpVector(double, double),
getUpY(),
getUpX()public final void setUpY(double value)
It is up to the caller to assure that the values describe a vector of length 1.
value - The UpY to set.getAngle(),
setUpVector(double, double),
getUpX(),
getUpY()public final void setWidth(double value)
Size instance.
Note that depending on the implementation used for holding the size the results may vary. However the default implementation will do just that: read and write the values without modifying them in any way.
setWidth in interface IMutableSizevalue - The Width to set.getWidth()public final void setX(double value)
Anchor instance.
Note that depending on the implementation used for holding the anchor the results may vary. However the default implementation will do just that: read and write the values without modifying them in any way.
setX in interface IMutablePointvalue - The X to set.getX()public final void setY(double value)
Anchor instance.
Note that depending on the implementation used for holding the anchor the results may vary. However the default implementation will do just that: read and write the values without modifying them in any way.
setY in interface IMutablePointvalue - The Y to set.getY()