ReportMill 10 API

com.reportmill.base
Class RMRect

java.lang.Object
  extended by java.awt.geom.RectangularShape
      extended by java.awt.geom.Rectangle2D
          extended by java.awt.geom.Rectangle2D.Float
              extended by com.reportmill.base.RMRect
All Implemented Interfaces:
java.awt.Shape, java.lang.Cloneable

public class RMRect
extends java.awt.geom.Rectangle2D.Float

This class extends Rectanlge2D to add some convenient rect methods.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.geom.Rectangle2D
java.awt.geom.Rectangle2D.Double, java.awt.geom.Rectangle2D.Float
 
Field Summary
static byte maxXEdge
           
static byte maxYEdge
           
static byte minXEdge
           
static byte minYEdge
           
static RMRect unitRect
           
static RMRect zeroRect
           
 
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
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.Rectangle2D aRect)
          Creates a rect from an awt rect.
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.lang.String s)
          Creates a rect from a string of the form "x y w h".
 
Method Summary
 boolean containsRect(RMRect aRect)
          Returns whether the receiver contains the given rect.
 RMRect divideRect(float amount, byte edge)
          Slices rect by given amount (from given edge) - returns remainder.
 RMRect divideRect(float amount, byte edge, RMRect remainder)
          Slices rect by given amount (from given edge) - returns remainder.
static RMRect fromXMLString(java.lang.String aString)
          Creates a rect from an String in XML format as defined in toXMLString().
 RMPoint getOrigin()
          Returns the origin of the rect as an RMPoint.
 RMPoint getPerimeterPointForRadial(float 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.
 RMRect inset(float inset)
          Insets the receiver rect by the given amount.
 RMRect inset(float xInset, float yInset)
          Insets the receiver rect by the given amount.
 RMRect insetRect(float anInset)
          Creates a rect derived from the receiver inset by the given amount.
 RMRect insetRect(float xInset, float yInset)
          Creates a rect derived from the receiver inset by the given amount.
 RMRect intersectedRect(RMRect r2)
          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.
 RMRect offset(float dx, float dy)
          Offsets the receiver by the given x & y.
 RMRect offsetRect(float dx, float dy)
          Creates a rect derived by offsetting the receiver by the given x & y.
 RMRect scale(float amount)
          Scales the receiver rect by the given amount.
 RMRect scaledRect(float amount)
          Creates a rect derived from the receiver scaled by the given amount.
 RMRect setOrigin(float x, float y)
          Sets the origin of the rect.
 RMSize size()
          Returns the size of the rect as an RMSize.
 RMRect squareRectInRect()
          Creates a rect representing the largest square inside rect.
 java.lang.String toString()
          Returns a String reprsentation of this rect.
 java.lang.String toXMLString()
          Returns an XML string representation of this rect.
 RMRect union(RMRect r2)
          Unions the receiver rect with the given rect.
 RMRect unionEvenIfEmpty(RMRect r2)
          Unions the receiver rect with the given rect.
 RMRect unionRect(RMRect r2)
          Creates a rect encompassing the receiver and the given rect.
 boolean widthsIntersect(RMRect r2)
          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
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

zeroRect

public static final RMRect zeroRect

unitRect

public static final RMRect unitRect

minXEdge

public static final byte minXEdge
See Also:
Constant Field Values

minYEdge

public static final byte minYEdge
See Also:
Constant Field Values

maxXEdge

public static final byte maxXEdge
See Also:
Constant Field Values

maxYEdge

public static final byte maxYEdge
See Also:
Constant Field Values
Constructor Detail

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

public RMRect(RMPoint or,
              RMSize sz)
Creates a rect from the given location and size.


RMRect

public RMRect(java.awt.geom.Rectangle2D aRect)
Creates a rect from an awt rect.


RMRect

public RMRect(RMPoint p1,
              RMPoint p2)
Creates a rect enclosing the two given points.


RMRect

public RMRect(java.lang.String s)
       throws java.io.IOException
Creates a rect from a string of the form "x y w h".

Throws:
java.io.IOException

RMRect

public RMRect(RMPoint[] p)
Creates a rect enclosing the given array of points.

Method Detail

getOrigin

public RMPoint getOrigin()
Returns the origin of the rect as an RMPoint.


setOrigin

public RMRect setOrigin(float x,
                        float y)
Sets the origin of the rect.


size

public RMSize 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

public RMRect union(RMRect r2)
Unions the receiver rect with the given rect.


unionRect

public RMRect unionRect(RMRect r2)
Creates a rect encompassing the receiver and the given rect.


unionEvenIfEmpty

public RMRect unionEvenIfEmpty(RMRect r2)
Unions the receiver rect with the given rect.


intersectsRect

public boolean intersectsRect(RMRect aRect)
Returns whether the receiver intersects with the given rect.


intersectsRectEvenIfEmpty

public boolean intersectsRectEvenIfEmpty(RMRect aRect)
Returns whether the receiver intersects with the given rect.


intersectedRect

public RMRect intersectedRect(RMRect r2)
Returns the rect formed by the area overlapping with the given rect.


widthsIntersect

public boolean widthsIntersect(RMRect r2)
Returns whether the receiver intersects with the given rect (horizontally only).


offset

public RMRect offset(float dx,
                     float dy)
Offsets the receiver by the given x & y.


offsetRect

public RMRect offsetRect(float dx,
                         float dy)
Creates a rect derived by offsetting the receiver by the given x & y.


squareRectInRect

public RMRect squareRectInRect()
Creates a rect representing the largest square inside rect.


containsRect

public boolean containsRect(RMRect aRect)
Returns whether the receiver contains the given rect.


getPoints

public RMPoint[] getPoints()
Returns an array of four points containing each corner of the rect.


inset

public RMRect inset(float inset)
Insets the receiver rect by the given amount.


inset

public RMRect inset(float xInset,
                    float yInset)
Insets the receiver rect by the given amount.


insetRect

public RMRect insetRect(float anInset)
Creates a rect derived from the receiver inset by the given amount.


insetRect

public RMRect insetRect(float xInset,
                        float yInset)
Creates a rect derived from the receiver inset by the given amount.


divideRect

public RMRect divideRect(float amount,
                         byte edge)
Slices rect by given amount (from given edge) - returns remainder.


divideRect

public RMRect divideRect(float amount,
                         byte edge,
                         RMRect remainder)
Slices rect by given amount (from given edge) - returns remainder.


scale

public RMRect scale(float amount)
Scales the receiver rect by the given amount.


scaledRect

public RMRect scaledRect(float amount)
Creates a rect derived from the receiver scaled by the given amount.


getPerimeterPointForRadial

public RMPoint getPerimeterPointForRadial(float 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.

toString

public java.lang.String toString()
Returns a String reprsentation of this rect.

Overrides:
toString in class java.awt.geom.Rectangle2D.Float

toXMLString

public java.lang.String toXMLString()
Returns an XML string representation of this rect.


fromXMLString

public static RMRect fromXMLString(java.lang.String aString)
Creates a rect from an String in XML format as defined in toXMLString().


ReportMill 10 API