Package com.inductiveautomation.rm.base
Class RMRect
- java.lang.Object
- 
- java.awt.geom.RectangularShape
- 
- java.awt.geom.Rectangle2D
- 
- java.awt.geom.Rectangle2D.Double
- 
- com.inductiveautomation.rm.base.RMRect
 
 
 
 
- 
- All Implemented Interfaces:
- java.awt.Shape,- java.io.Serializable,- java.lang.Cloneable
 
 public class RMRect extends java.awt.geom.Rectangle2D.DoubleThis 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(java.awt.geom.Point2D... points)Creates a rect enclosing the given array of points.RMRect(java.awt.geom.Rectangle2D aRect)Creates a rect from an awt rect.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RMRectclone()Standard clone implementation.booleancontainsRect(RMRect aRect)Returns whether the receiver contains the given rect.RMRectdivideRect(double anAmount, byte anEdge)Slices rect by given amount (from given edge) - returns remainder.RMRectdivideRect(double anAmount, byte anEdge, RMRect aRmndr)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().RMRectgetCorraledRect(RMRect aRect, float anInset)Returns the given rect moved, if needed, to be contained by this rect.intgetHitEdges(java.awt.geom.Point2D aPoint, double aRadius)Returns the mask of edges hit by the given point.doublegetMidX()Returns the x mid-point of the rect.doublegetMidY()Returns the y mid-point of the rect.RMPointgetOrigin()Returns the origin of the rect as an RMPoint.RMPointgetPerimeterPointForRadial(double anAngle, boolean doEllipse)Returns the point on the rectangle's perimeter that is intersected by a radial at the given angle from the center of the rect.RMPoint[]getPoints()Returns an array of four points containing each corner of the rect.RMRectinset(double anInset)Insets the receiver rect by the given amount.RMRectinset(double xInset, double yInset)Insets the receiver rect by the given amount.RMRectinsetRect(double anInset)Creates a rect derived from the receiver inset by the given amount.RMRectinsetRect(double xInset, double 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.RMRectoffset(double dx, double dy)Offsets the receiver by the given x & y.RMRectoffsetRect(double dx, double dy)Creates a rect derived by offsetting the receiver by the given x & y.RMRectscale(double anAmount)Scales the receiver rect by the given amount.RMRectscaledRect(double anAmount)Creates a rect derived from the receiver scaled by the given amount.voidsetHitEdges(java.awt.geom.Point2D aPoint, int anEdgeMask)Resets the edges of a rect, given a mask of edges and a new point.RMRectsetOrigin(double x, double y)Sets the origin of the rect.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.voidunion(RMRect r2)Unions the receiver rect with the given rect.voidunionEvenIfEmpty(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.DoublecreateIntersection, createUnion, getBounds2D, getHeight, getWidth, getX, getY, isEmpty, outcode, 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.Point2D... points) Creates a rect enclosing the given array of points.
 - 
RMRectpublic RMRect(java.awt.geom.Rectangle2D aRect) Creates a rect from an awt rect.
 
- 
 - 
Method Detail- 
getOriginpublic RMPoint getOrigin() Returns the origin of the rect as an RMPoint.
 - 
setOriginpublic RMRect setOrigin(double x, double y) Sets the origin of the rect.
 - 
getMidXpublic double getMidX() Returns the x mid-point of the rect.
 - 
getMidYpublic double getMidY() Returns the y mid-point of the rect.
 - 
unionpublic void union(RMRect r2) Unions the receiver rect with the given rect.
 - 
unionRectpublic RMRect unionRect(RMRect r2) Creates a rect encompassing the receiver and the given rect.
 - 
unionEvenIfEmptypublic void 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(double dx, double dy) Offsets the receiver by the given x & y.
 - 
offsetRectpublic RMRect offsetRect(double dx, double 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(double anInset) Insets the receiver rect by the given amount.
 - 
insetpublic RMRect inset(double xInset, double yInset) Insets the receiver rect by the given amount.
 - 
insetRectpublic RMRect insetRect(double anInset) Creates a rect derived from the receiver inset by the given amount.
 - 
insetRectpublic RMRect insetRect(double xInset, double yInset) Creates a rect derived from the receiver inset by the given amount.
 - 
getHitEdgespublic int getHitEdges(java.awt.geom.Point2D aPoint, double aRadius)Returns the mask of edges hit by the given point.
 - 
setHitEdgespublic void setHitEdges(java.awt.geom.Point2D aPoint, int anEdgeMask)Resets the edges of a rect, given a mask of edges and a new point.
 - 
divideRectpublic RMRect divideRect(double anAmount, byte anEdge) Slices rect by given amount (from given edge) - returns remainder.
 - 
divideRectpublic RMRect divideRect(double anAmount, byte anEdge, RMRect aRmndr) Slices rect by given amount (from given edge) - returns remainder.
 - 
scalepublic RMRect scale(double anAmount) Scales the receiver rect by the given amount.
 - 
scaledRectpublic RMRect scaledRect(double anAmount) Creates a rect derived from the receiver scaled by the given amount.
 - 
getPerimeterPointForRadialpublic RMPoint getPerimeterPointForRadial(double anAngle, boolean doEllipse) Returns the point on the rectangle's perimeter that is intersected by a radial at the given angle from the center of the rect. Zero degrees is at the 3 o'clock position.- Parameters:
- anAngle- Angle in degrees.
- doEllipse- Whether to scale radials into ellipse or leave them normal.
- Returns:
- Returns point on perimeter of rect intersected by radial at given angle.
 
 - 
getCorraledRectpublic RMRect getCorraledRect(RMRect aRect, float anInset) Returns the given rect moved, if needed, to be contained by this rect.
 - 
toStringpublic java.lang.String toString() Returns a String reprsentation of this rect.- Overrides:
- toStringin class- java.awt.geom.Rectangle2D.Double
 
 - 
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().
 - 
clonepublic RMRect clone() Standard clone implementation.- Overrides:
- clonein class- java.awt.geom.RectangularShape
 
 
- 
 
-