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:
- Shape,- Serializable,- Cloneable
This class extends Rectanlge2D to add some convenient rect methods.
- See Also:
- 
Nested Class SummaryNested classes/interfaces inherited from class java.awt.geom.Rectangle2DRectangle2D.Double, Rectangle2D.Float
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final bytestatic final bytestatic final bytestatic final bytestatic final RMRectstatic final RMRectFields inherited from class java.awt.geom.Rectangle2D.Doubleheight, width, x, yFields inherited from class java.awt.geom.Rectangle2DOUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP
- 
Constructor SummaryConstructorsConstructorDescriptionRMRect()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.RMRect(Rectangle2D aRect) Creates a rect from an awt rect.
- 
Method SummaryModifier and TypeMethodDescriptionclone()Standard clone implementation.booleancontainsRect(RMRect aRect) Returns whether the receiver contains the given rect.divideRect(double anAmount, byte anEdge) Slices rect by given amount (from given edge) - returns remainder.divideRect(double anAmount, byte anEdge, RMRect aRmndr) Slices rect by given amount (from given edge) - returns remainder.static RMRectfromXMLString(String aString) Creates a rect from an String in XML format as defined in toXMLString().getCorraledRect(RMRect aRect, float anInset) Returns the given rect moved, if needed, to be contained by this rect.intgetHitEdges(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.Returns the origin of the rect as an 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.RMPoint[]Returns an array of four points containing each corner of the rect.inset(double anInset) Insets the receiver rect by the given amount.inset(double xInset, double yInset) Insets the receiver rect by the given amount.insetRect(double anInset) Creates a rect derived from the receiver inset by the given amount.insetRect(double xInset, double 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.booleanintersectsRect(RMRect aRect) Returns whether the receiver intersects with the given rect.booleanintersectsRectEvenIfEmpty(RMRect aRect) Returns whether the receiver intersects with the given rect.offset(double dx, double dy) Offsets the receiver by the given x & y.offsetRect(double dx, double dy) Creates a rect derived by offsetting the receiver by the given x & y.scale(double anAmount) Scales the receiver rect by the given amount.scaledRect(double anAmount) Creates a rect derived from the receiver scaled by the given amount.voidsetHitEdges(Point2D aPoint, int anEdgeMask) Resets the edges of a rect, given a mask of edges and a new point.setOrigin(double x, double y) Sets the origin of the rect.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.voidUnions the receiver rect with the given rect.voidUnions the receiver rect with the given rect.Creates a rect encompassing the receiver and the given rect.booleanReturns 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, setRectMethods inherited from class java.awt.geom.Rectangle2Dadd, add, add, contains, contains, equals, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, unionMethods inherited from class java.awt.geom.RectangularShapecontains, contains, getBounds, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal
- 
Field Details- 
zeroRect
- 
unitRect
- 
MinXEdgepublic static final byte MinXEdge- See Also:
 
- 
MinYEdgepublic static final byte MinYEdge- See Also:
 
- 
MaxXEdgepublic static final byte MaxXEdge- See Also:
 
- 
MaxYEdgepublic static final byte MaxYEdge- See Also:
 
 
- 
- 
Constructor Details- 
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).
- 
RMRectCreates a rect enclosing the given array of points.
- 
RMRectCreates a rect from an awt rect.
 
- 
- 
Method Details- 
getOriginReturns the origin of the rect as an RMPoint.
- 
setOriginSets 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.
- 
unionUnions the receiver rect with the given rect.
- 
unionRectCreates a rect encompassing the receiver and the given rect.
- 
unionEvenIfEmptyUnions the receiver rect with the given rect.
- 
intersectsRectReturns whether the receiver intersects with the given rect.
- 
intersectsRectEvenIfEmptyReturns whether the receiver intersects with the given rect.
- 
intersectedRectReturns the rect formed by the area overlapping with the given rect.
- 
widthsIntersectReturns whether the receiver intersects with the given rect (horizontally only).
- 
offsetOffsets the receiver by the given x & y.
- 
offsetRectCreates a rect derived by offsetting the receiver by the given x & y.
- 
squareRectInRectCreates a rect representing the largest square inside rect.
- 
containsRectReturns whether the receiver contains the given rect.
- 
getPointsReturns an array of four points containing each corner of the rect.
- 
insetInsets the receiver rect by the given amount.
- 
insetInsets the receiver rect by the given amount.
- 
insetRectCreates a rect derived from the receiver inset by the given amount.
- 
insetRectCreates a rect derived from the receiver inset by the given amount.
- 
getHitEdgesReturns the mask of edges hit by the given point.
- 
setHitEdgesResets the edges of a rect, given a mask of edges and a new point.
- 
divideRectSlices rect by given amount (from given edge) - returns remainder.
- 
divideRectSlices rect by given amount (from given edge) - returns remainder.
- 
scaleScales the receiver rect by the given amount.
- 
scaledRectCreates a rect derived from the receiver scaled by the given amount.
- 
getPerimeterPointForRadialReturns 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.
 
- 
getCorraledRectReturns the given rect moved, if needed, to be contained by this rect.
- 
toStringReturns a String reprsentation of this rect.- Overrides:
- toStringin class- Rectangle2D.Double
 
- 
toXMLStringReturns an XML string representation of this rect.
- 
fromXMLStringCreates a rect from an String in XML format as defined in toXMLString().
- 
cloneStandard clone implementation.- Overrides:
- clonein class- RectangularShape
 
 
-