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:
- java.awt.Shape,- java.io.Serializable,- java.lang.Cloneable
 
 public class RMRect extends java.awt.geom.Rectangle2D.FloatThis class extends Rectanlge2D to add some convenient rect methods.- See Also:
- Serialized Form
 
- 
- 
Constructor SummaryConstructors Constructor Description RMRect()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).RMRect(RMPoint[] p)Creates a rect enclosing the given array of points.RMRect(RMPoint p1, RMPoint p2)Creates a rect enclosing the two given points.RMRect(RMPoint or, RMSize sz)Creates a rect from the given location and size.RMRect(java.awt.geom.Rectangle2D aRect)Creates a rect from an awt rect.RMRect(java.lang.String s)Creates a rect from a string of the form "x y w h".
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsRect(RMRect aRect)Returns whether the receiver contains the given rect.RMRectdivideRect(float amount, byte edge)Slices rect by given amount (from given edge) - returns remainder.RMRectdivideRect(float amount, byte edge, RMRect remainder)Slices rect by given amount (from given edge) - returns remainder.static RMRectfromXMLString(java.lang.String aString)Creates a rect from an String in XML format as defined in toXMLString().RMPointgetOrigin()Returns the origin of the rect as an RMPoint.RMPoint[]getPoints()Returns an array of four points containing each corner of the rect.RMRectinset(float inset)Insets the receiver rect by the given amount.RMRectinset(float xInset, float yInset)Insets the receiver rect by the given amount.RMRectinsetRect(float anInset)Creates a rect derived from the receiver inset by the given amount.RMRectinsetRect(float xInset, float yInset)Creates a rect derived from the receiver inset by the given amount.RMRectintersectedRect(RMRect r2)Returns the rect formed by the area overlapping with the given rect.booleanintersectsRect(RMRect aRect)Returns whether the receiver intersects with the given rect.booleanintersectsRectEvenIfEmpty(RMRect aRect)Returns whether the receiver intersects with the given rect.floatmaxX()Returns the max x of the rect.floatmaxY()Returns the max y of the rect.floatmidX()Returns the x mid-point of the rect.floatmidY()Returns the y mid-point of the rect.RMRectoffset(float dx, float dy)Offsets the receiver by the given x & y.RMRectoffsetRect(float dx, float dy)Creates a rect derived by offsetting the receiver by the given x & y.RMRectscale(float amount)Scales the receiver rect by the given amount.RMRectscaledRect(float amount)Creates a rect derived from the receiver scaled by the given amount.RMRectsetOrigin(float x, float y)Sets the origin of the rect.RMSizesize()Returns the size of the rect as an RMSize.RMRectsquareRectInRect()Creates a rect representing the largest square inside rect.java.lang.StringtoString()Returns a String reprsentation of this rect.java.lang.StringtoXMLString()Returns an XML string representation of this rect.RMRectunion(RMRect r2)Unions the receiver rect with the given rect.RMRectunionEvenIfEmpty(RMRect r2)Unions the receiver rect with the given rect.RMRectunionRect(RMRect r2)Creates a rect encompassing the receiver and the given rect.booleanwidthsIntersect(RMRect r2)Returns whether the receiver intersects with the given rect (horizontally only).- 
Methods inherited from class java.awt.geom.Rectangle2D.FloatcreateIntersection, createUnion, getBounds2D, getHeight, getWidth, getX, getY, isEmpty, outcode, setRect, setRect, setRect
 - 
Methods inherited from class java.awt.geom.Rectangle2Dadd, add, add, contains, contains, equals, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, union
 
- 
 
- 
- 
- 
Field Detail- 
zeroRectpublic static final RMRect zeroRect 
 - 
unitRectpublic static final RMRect unitRect 
 - 
minXEdgepublic static final byte minXEdge - See Also:
- Constant Field Values
 
 - 
minYEdgepublic static final byte minYEdge - See Also:
- Constant Field Values
 
 - 
maxXEdgepublic static final byte maxXEdge - See Also:
- Constant Field Values
 
 - 
maxYEdgepublic static final byte maxYEdge - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
RMRectpublic RMRect() Creates an empty rect.
 - 
RMRectpublic RMRect(double x, double y, double w, double h)Creates a rect with the given x, y, width and height (doubles).
 - 
RMRectpublic RMRect(java.awt.geom.Rectangle2D aRect) Creates a rect from an awt rect.
 - 
RMRectpublic RMRect(java.lang.String s) throws java.io.IOExceptionCreates a rect from a string of the form "x y w h".- Throws:
- java.io.IOException
 
 - 
RMRectpublic RMRect(RMPoint[] p) Creates a rect enclosing the given array of points.
 
- 
 - 
Method Detail- 
getOriginpublic RMPoint getOrigin() Returns the origin of the rect as an RMPoint.
 - 
setOriginpublic RMRect setOrigin(float x, float y) Sets the origin of the rect.
 - 
sizepublic RMSize size() Returns the size of the rect as an RMSize. Please rename as getSize()!
 - 
maxXpublic float maxX() Returns the max x of the rect.
 - 
maxYpublic float maxY() Returns the max y of the rect.
 - 
midXpublic float midX() Returns the x mid-point of the rect.
 - 
midYpublic float midY() Returns the y mid-point of the rect.
 - 
unionRectpublic RMRect unionRect(RMRect r2) Creates a rect encompassing the receiver and the given rect.
 - 
unionEvenIfEmptypublic RMRect unionEvenIfEmpty(RMRect r2) Unions the receiver rect with the given rect.
 - 
intersectsRectpublic boolean intersectsRect(RMRect aRect) Returns whether the receiver intersects with the given rect.
 - 
intersectsRectEvenIfEmptypublic boolean intersectsRectEvenIfEmpty(RMRect aRect) Returns whether the receiver intersects with the given rect.
 - 
intersectedRectpublic RMRect intersectedRect(RMRect r2) Returns the rect formed by the area overlapping with the given rect.
 - 
widthsIntersectpublic boolean widthsIntersect(RMRect r2) Returns whether the receiver intersects with the given rect (horizontally only).
 - 
offsetpublic RMRect offset(float dx, float dy) Offsets the receiver by the given x & y.
 - 
offsetRectpublic RMRect offsetRect(float dx, float dy) Creates a rect derived by offsetting the receiver by the given x & y.
 - 
squareRectInRectpublic RMRect squareRectInRect() Creates a rect representing the largest square inside rect.
 - 
containsRectpublic boolean containsRect(RMRect aRect) Returns whether the receiver contains the given rect.
 - 
getPointspublic RMPoint[] getPoints() Returns an array of four points containing each corner of the rect.
 - 
insetpublic RMRect inset(float inset) Insets the receiver rect by the given amount.
 - 
insetpublic RMRect inset(float xInset, float yInset) Insets the receiver rect by the given amount.
 - 
insetRectpublic RMRect insetRect(float anInset) Creates a rect derived from the receiver inset by the given amount.
 - 
insetRectpublic RMRect insetRect(float xInset, float yInset) Creates a rect derived from the receiver inset by the given amount.
 - 
divideRectpublic RMRect divideRect(float amount, byte edge) Slices rect by given amount (from given edge) - returns remainder.
 - 
divideRectpublic RMRect divideRect(float amount, byte edge, RMRect remainder) Slices rect by given amount (from given edge) - returns remainder.
 - 
scalepublic RMRect scale(float amount) Scales the receiver rect by the given amount.
 - 
scaledRectpublic RMRect scaledRect(float amount) Creates a rect derived from the receiver scaled by the given amount.
 - 
toStringpublic java.lang.String toString() Returns a String reprsentation of this rect.- Overrides:
- toStringin class- java.awt.geom.Rectangle2D.Float
 
 - 
toXMLStringpublic java.lang.String toXMLString() Returns an XML string representation of this rect.
 - 
fromXMLStringpublic static RMRect fromXMLString(java.lang.String aString) Creates a rect from an String in XML format as defined in toXMLString().
 
- 
 
-