Package com.reportmill.base
Class RMRect
java.lang.Object
java.awt.geom.RectangularShape
java.awt.geom.Rectangle2D
java.awt.geom.Rectangle2D.Float
com.reportmill.base.RMRect
- All Implemented Interfaces:
Shape
,Serializable
,Cloneable
This class extends Rectanlge2D to add some convenient rect methods.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.awt.geom.Rectangle2D
Rectangle2D.Double, Rectangle2D.Float
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byte
static final byte
static final byte
static final byte
static final RMRect
static final RMRect
Fields inherited from class java.awt.geom.Rectangle2D.Float
height, width, x, y
Fields inherited from class java.awt.geom.Rectangle2D
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP
-
Constructor Summary
ConstructorsConstructorDescriptionRMRect()
Creates an empty rect.RMRect
(double x, double y, double w, double h) Creates a rect with the given x, y, width and height (doubles).Creates a rect enclosing the given array of points.Creates a rect enclosing the two given points.Creates a rect from the given location and size.RMRect
(Rectangle2D aRect) Creates a rect from an awt rect.Creates a rect from a string of the form "x y w h". -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsRect
(RMRect aRect) Returns whether the receiver contains the given rect.divideRect
(float amount, byte edge) Slices rect by given amount (from given edge) - returns remainder.divideRect
(float amount, byte edge, RMRect remainder) Slices rect by given amount (from given edge) - returns remainder.static RMRect
fromXMLString
(String aString) Creates a rect from an String in XML format as defined in toXMLString().Returns the origin of the rect as an RMPoint.RMPoint[]
Returns an array of four points containing each corner of the rect.inset
(float inset) Insets the receiver rect by the given amount.inset
(float xInset, float yInset) Insets the receiver rect by the given amount.insetRect
(float anInset) Creates a rect derived from the receiver inset by the given amount.insetRect
(float xInset, float yInset) Creates a rect derived from the receiver inset by the given amount.Returns the rect formed by the area overlapping with the given rect.boolean
intersectsRect
(RMRect aRect) Returns whether the receiver intersects with the given rect.boolean
intersectsRectEvenIfEmpty
(RMRect aRect) Returns whether the receiver intersects with the given rect.float
maxX()
Returns the max x of the rect.float
maxY()
Returns the max y of the rect.float
midX()
Returns the x mid-point of the rect.float
midY()
Returns the y mid-point of the rect.offset
(float dx, float dy) Offsets the receiver by the given x & y.offsetRect
(float dx, float dy) Creates a rect derived by offsetting the receiver by the given x & y.scale
(float amount) Scales the receiver rect by the given amount.scaledRect
(float amount) Creates a rect derived from the receiver scaled by the given amount.setOrigin
(float x, float y) Sets the origin of the rect.size()
Returns the size of the rect as an RMSize.Creates a rect representing the largest square inside rect.toString()
Returns a String reprsentation of this rect.Returns an XML string representation of this rect.Unions the receiver rect with the given rect.Unions the receiver rect with the given rect.Creates a rect encompassing the receiver and the given rect.boolean
Returns whether the receiver intersects with the given rect (horizontally only).Methods inherited from class java.awt.geom.Rectangle2D.Float
createIntersection, createUnion, getBounds2D, getHeight, getWidth, getX, getY, isEmpty, outcode, setRect, setRect, setRect
Methods inherited from class java.awt.geom.Rectangle2D
add, add, add, contains, contains, equals, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, union
Methods inherited from class java.awt.geom.RectangularShape
clone, contains, contains, getBounds, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal
-
Field Details
-
zeroRect
-
unitRect
-
minXEdge
public static final byte minXEdge- See Also:
-
minYEdge
public static final byte minYEdge- See Also:
-
maxXEdge
public static final byte maxXEdge- See Also:
-
maxYEdge
public static final byte maxYEdge- See Also:
-
-
Constructor Details
-
RMRect
public RMRect()Creates an empty rect. -
RMRect
public RMRect(double x, double y, double w, double h) Creates a rect with the given x, y, width and height (doubles). -
RMRect
Creates a rect from the given location and size. -
RMRect
Creates a rect from an awt rect. -
RMRect
Creates a rect enclosing the two given points. -
RMRect
Creates a rect from a string of the form "x y w h".- Throws:
IOException
-
RMRect
Creates a rect enclosing the given array of points.
-
-
Method Details
-
getOrigin
Returns the origin of the rect as an RMPoint. -
setOrigin
Sets the origin of the rect. -
size
Returns the size of the rect as an RMSize. Please rename as getSize()! -
maxX
public float maxX()Returns the max x of the rect. -
maxY
public float maxY()Returns the max y of the rect. -
midX
public float midX()Returns the x mid-point of the rect. -
midY
public float midY()Returns the y mid-point of the rect. -
union
Unions the receiver rect with the given rect. -
unionRect
Creates a rect encompassing the receiver and the given rect. -
unionEvenIfEmpty
Unions the receiver rect with the given rect. -
intersectsRect
Returns whether the receiver intersects with the given rect. -
intersectsRectEvenIfEmpty
Returns whether the receiver intersects with the given rect. -
intersectedRect
Returns the rect formed by the area overlapping with the given rect. -
widthsIntersect
Returns whether the receiver intersects with the given rect (horizontally only). -
offset
Offsets the receiver by the given x & y. -
offsetRect
Creates a rect derived by offsetting the receiver by the given x & y. -
squareRectInRect
Creates a rect representing the largest square inside rect. -
containsRect
Returns whether the receiver contains the given rect. -
getPoints
Returns an array of four points containing each corner of the rect. -
inset
Insets the receiver rect by the given amount. -
inset
Insets the receiver rect by the given amount. -
insetRect
Creates a rect derived from the receiver inset by the given amount. -
insetRect
Creates a rect derived from the receiver inset by the given amount. -
divideRect
Slices rect by given amount (from given edge) - returns remainder. -
divideRect
Slices rect by given amount (from given edge) - returns remainder. -
scale
Scales the receiver rect by the given amount. -
scaledRect
Creates a rect derived from the receiver scaled by the given amount. -
toString
Returns a String reprsentation of this rect.- Overrides:
toString
in classRectangle2D.Float
-
toXMLString
Returns an XML string representation of this rect. -
fromXMLString
Creates a rect from an String in XML format as defined in toXMLString().
-