Packagecom.yworks.bridge.geom
Classpublic class Rectangle2D
InheritanceRectangle2D Inheritance YObject Inheritance Object
Implements Clonable
Subclasses Rectangle, Rectangle2DDouble

The Rectangle2D class describes a rectangle defined by a location (x, y) and dimension (w x h). This class is only the abstract superclass for all objects that store a 2D rectangle. The actual storage representation of the coordinates is left to the subclass.



Public Properties
 PropertyDefined By
  bounds : Rectangle
[read-only] Returns the bounding box of the Shape.
Rectangle2D
  bounds2D : Rectangle2D
[read-only] Returns the high precision bounding box of this Rectangle2D.
Rectangle2D
  centerX : Number
[read-only] Returns the X coordinate of the center of this rectangle in double precision.
Rectangle2D
  centerY : Number
[read-only] Returns the Y coordinate of the center of this rectangle in double precision.
Rectangle2D
  empty : Boolean
[read-only] Determines whether or not this Rectangle is empty.
Rectangle2D
  frame : Rectangle2D
Getter: Returns the framing Rectangle2D that defines the overall shape of this object.
Rectangle2D
  height : Number
[read-only] Returns the heigth of this rectangle in double precision.
Rectangle2D
  maxX : Number
[read-only] Returns the largest X coordinate of the upper left corner of this rectangle in double precision.
Rectangle2D
  maxY : Number
[read-only] Returns the largest Y coordinate of the upper left corner of this rectangle in double precision.
Rectangle2D
  minX : Number
[read-only] Returns the smallest X coordinate of the upper left corner of this rectangle in double precision.
Rectangle2D
  minY : Number
[read-only] Returns the smallest Y coordinate of the upper left corner of this rectangle in double precision.
Rectangle2D
  rect : Rectangle2D
[write-only] Sets this Rectangle2D to be the same as the specified Rectangle2D.
Rectangle2D
  width : Number
[read-only] Returns the width of this rectangle in double precision.
Rectangle2D
  x : Number
[read-only] Returns the X coordinate of the upper left corner of this rectangle in double precision.
Rectangle2D
  y : Number
[read-only] Returns the Y coordinate of the upper left corner of this rectangle in double precision.
Rectangle2D
Public Methods
 MethodDefined By
  
Rectangle2D(init:Boolean = true)
This is an abstract class that cannot be instantiated directly.
Rectangle2D
  
Adds the Point2D object p to this Rectangle2D.
Rectangle2D
  
addPoint2(x:Number, y:Number):void
Adds a point, specified by the double precision arguments px and py, to this Rectangle2D.
Rectangle2D
  
Adds a Rectangle2D object to this Rectangle2D.
Rectangle2D
  
clone():Object
Rectangle2D
  
containsPoint2(x:Number, y:Number):Boolean
Tests if a specified coordinate is inside the boundary of this Rectangle2D.
Rectangle2D
  
Tests if the interior of this Rectangle2D entirely contains the specified Rectangle2D.
Rectangle2D
  
containsRectangle2(x:Number, y:Number, width:Number, height:Number):Boolean
Tests if the interior of this Rectangle2D entirely contains the specified set of rectangular coordinates.
Rectangle2D
  
Returns a new Rectangle2D object representing the intersection of this Rectangle with the specified Rectangle2D.
Rectangle2D
  
Returns a new Rectangle2D object representing the union of this Rectangle with the specified Rectangle2D.
Rectangle2D
  
equals(obj:Object):Boolean
[override] Checks whether two rectangles are equal.
Rectangle2D
  
getClass():Class
[override]
Rectangle2D
  
hashCode():int
[override]
Rectangle2D
  
[static] Intersects the pair of specified source Rectangle2D objects and puts the result into the specified destination Rectangle2D object.
Rectangle2D
  
intersectsLine(x1:Number, y1:Number, x2:Number, y2:Number):Boolean
Tests if the specified line segment intersects the interior of this Rectangle2D.
Rectangle2D
  
Tests if the interior of this Rectangle2D intersects the specified Rectangle2D.
Rectangle2D
  
intersectsRectangle2(x:Number, y:Number, width:Number, height:Number):Boolean
Tests if the interior of this Rectangle2D intersects the interior of a specified set of rectangular coordinates.
Rectangle2D
  
Determines where the specified Point2D lies with respect to this Rectangle2D.
Rectangle2D
  
outcode2(x:Number, y:Number):int
Determines where the specified coordinates lie with respect to this Rectangle2D.
Rectangle2D
  
setFrame(x:Number, y:Number, width:Number, height:Number):void
Sets the location and size of the outer bounds of this Rectangle2D to the specified rectangular values.
Rectangle2D
  
setFrame2(loc:Point2D, size:Dimension):void
Rectangle2D
  
setFrameFromCenter(center:Point2D, corner:Point2D):void
Sets the framing rectangle of this Shape based on a specified center Point2D and corner Point2D.
Rectangle2D
  
setFrameFromCenter2(centerX:Number, centerY:Number, cornerX:Number, cornerY:Number):void
Sets the framing rectangle of this Shape based on the specified center point coordinates and corner point coordinates.
Rectangle2D
  
Sets the diagonal of the framing rectangle of this Shape based on the two specified coordinates.
Rectangle2D
  
setFrameFromDiagonal2(x1:Number, y1:Number, x2:Number, y2:Number):void
Sets the diagonal of the framing rectangle of this Shape based on the two specified coordinates.
Rectangle2D
  
setRect(x:Number, y:Number, width:Number, height:Number):void
Sets the location and size of this Rectangle2D to the specified double values.
Rectangle2D
  
[static] Unions the pair of specified source Rectangle2D objects and puts the result into the specified destination Rectangle2D object.
Rectangle2D
Protected Methods
 MethodDefined By
  
cloneImpl(o:Object):void
Rectangle2D
  
Rectangle2D
Public Constants
 ConstantDefined By
  OUT_BOTTOM : int = 8
[static] The bitmask that indicates that a point lies below this Rectangle2D.
Rectangle2D
  OUT_LEFT : int = 1
[static] The bitmask that indicates that a point lies to the left of this Rectangle2D.
Rectangle2D
  OUT_RIGHT : int = 4
[static] The bitmask that indicates that a point lies to the right of this Rectangle2D.
Rectangle2D
  OUT_TOP : int = 2
[static] The bitmask that indicates that a point lies above this Rectangle2D.
Rectangle2D
Property Detail
boundsproperty
bounds:Rectangle  [read-only]

Returns the bounding box of the Shape.


Implementation
    public function get bounds():Rectangle
bounds2Dproperty 
bounds2D:Rectangle2D  [read-only]

Returns the high precision bounding box of this Rectangle2D.


Implementation
    public function get bounds2D():Rectangle2D
centerXproperty 
centerX:Number  [read-only]

Returns the X coordinate of the center of this rectangle in double precision.


Implementation
    public function get centerX():Number
centerYproperty 
centerY:Number  [read-only]

Returns the Y coordinate of the center of this rectangle in double precision.


Implementation
    public function get centerY():Number
emptyproperty 
empty:Boolean  [read-only]

Determines whether or not this Rectangle is empty. A Rectangle is empty if its width or its height is less than or equal to zero.


Implementation
    public function get empty():Boolean
frameproperty 
frame:Rectangle2D

Getter: Returns the framing Rectangle2D that defines the overall shape of this object.

Setter: Sets the framing rectangle of this Shape to be the specified Rectangle2D. The framing rectangle is used by the subclasses of RectangularShape to define their geometry.


Implementation
    public function get frame():Rectangle2D
    public function set frame(value:Rectangle2D):void
heightproperty 
height:Number  [read-only]

Returns the heigth of this rectangle in double precision.


Implementation
    public function get height():Number
maxXproperty 
maxX:Number  [read-only]

Returns the largest X coordinate of the upper left corner of this rectangle in double precision.


Implementation
    public function get maxX():Number
maxYproperty 
maxY:Number  [read-only]

Returns the largest Y coordinate of the upper left corner of this rectangle in double precision.


Implementation
    public function get maxY():Number
minXproperty 
minX:Number  [read-only]

Returns the smallest X coordinate of the upper left corner of this rectangle in double precision.


Implementation
    public function get minX():Number
minYproperty 
minY:Number  [read-only]

Returns the smallest Y coordinate of the upper left corner of this rectangle in double precision.


Implementation
    public function get minY():Number
rectproperty 
rect:Rectangle2D  [write-only]

Sets this Rectangle2D to be the same as the specified Rectangle2D.


Implementation
    public function set rect(value:Rectangle2D):void
widthproperty 
width:Number  [read-only]

Returns the width of this rectangle in double precision.


Implementation
    public function get width():Number
xproperty 
x:Number  [read-only]

Returns the X coordinate of the upper left corner of this rectangle in double precision.


Implementation
    public function get x():Number
yproperty 
y:Number  [read-only]

Returns the Y coordinate of the upper left corner of this rectangle in double precision.


Implementation
    public function get y():Number
Constructor Detail
Rectangle2D()Constructor
public function Rectangle2D(init:Boolean = true)

This is an abstract class that cannot be instantiated directly. Type-specific implementation subclasses are available for instantiation and provide a number of formats for storing the information necessary to satisfy the various accessor methods below.

Parameters
init:Boolean (default = true) — An internally used switch to help handle proper instance initialization in inheritance chains where classes can have multiple constructor-like factory methods. This parameter can safely be ignored/omitted when calling the constructor.
Method Detail
addPoint()method
public function addPoint(p:Point2D):void

Adds the Point2D object p to this Rectangle2D.

The resulting Rectangle2D is the smallest Rectangle2D that contains both the original Rectangle2D and the specified Point2D.

After adding a point, a call to contains with the added point as an argument does not necessarily return true. The contains method does not return true for points on the right or bottom edges of a Rectangle. Therefore, if the added point falls on the right or bottom edge of the enlarged Rectangle, contains returns false for that point.

Parameters

p:Point2D — the new Point2D to add to this Rectangle2D.

addPoint2()method 
public function addPoint2(x:Number, y:Number):void

Adds a point, specified by the double precision arguments px and py, to this Rectangle2D.

The resulting Rectangle2D is the smallest Rectangle2D that contains both the original Rectangle2D and the specified point.

After adding a point, a call to contains with the added point as an argument does not necessarily return true. The contains method does not return true for points on the right or bottom edges of a Rectangle. Therefore, if the added point falls on the right or bottom edge of the enlarged Rectangle, contains returns false for that point.

Parameters

x:Number — the x coordinate of the new point
 
y:Number — the y coordinate of the new point

addRectangle()method 
public function addRectangle(r:Rectangle2D):void

Adds a Rectangle2D object to this Rectangle2D. The resulting Rectangle2D is the union of the two Rectangle2D objects.

Parameters

r:Rectangle2D — the Rectangle2D to add to this Rectangle2D.

clone()method 
public function clone():Object

Returns
Object
cloneImpl()method 
protected function cloneImpl(o:Object):void

Parameters

o:Object

containsPoint2()method 
public function containsPoint2(x:Number, y:Number):Boolean

Tests if a specified coordinate is inside the boundary of this Rectangle2D.

Parameters

x:Number — the x coordinate to test
 
y:Number — the y coordinate to test

Returns
Boolean — true if the specified coordinates are inside the boundary of this Rectangle2D; false otherwise.
containsRectangle()method 
public function containsRectangle(rect:Rectangle2D):Boolean

Tests if the interior of this Rectangle2D entirely contains the specified Rectangle2D.

Parameters

rect:Rectangle2D — the rectangle to test

Returns
Boolean — true if this Rectangle2D entirely contains the specified Rectangle2D; false otherwise.
containsRectangle2()method 
public function containsRectangle2(x:Number, y:Number, width:Number, height:Number):Boolean

Tests if the interior of this Rectangle2D entirely contains the specified set of rectangular coordinates.

Parameters

x:Number — the x coordinate of the upper left corner of the specified set of rectangular coordinates
 
y:Number — the y coordinate of the upper left corner of the specified set of rectangular coordinates
 
width:Number — the width of the specified set of rectangular coordinates
 
height:Number — the height of the specified set of rectangular coordinates

Returns
Boolean — true if this Rectangle2D entirely contains specified set of rectangular coordinates; false otherwise.
createIntersection()method 
public function createIntersection(r:Rectangle2D):Rectangle2D

Returns a new Rectangle2D object representing the intersection of this Rectangle with the specified Rectangle2D.

Parameters

r:Rectangle2D — the Rectangle2D to be intersected with this Rectangle.

Returns
Rectangle2D — the largest Rectangle2D contained in both the specified Rectangle2D and in this Rectangle.
createUnion()method 
public function createUnion(r:Rectangle2D):Rectangle2D

Returns a new Rectangle2D object representing the union of this Rectangle with the specified Rectangle2D.

Parameters

r:Rectangle2D — the Rectangle2D to be combined with this Rectangle.

Returns
Rectangle2D — the smallest Rectangle2D containing both the specified Rectangle2D and this Rectangle.
equals()method 
override public function equals(obj:Object):Boolean

Checks whether two rectangles are equal. The result is true if and only if the argument is not null and is a Rectangle2D object that has the same top-left corner, width, and height as this Rectangle2D.

Parameters

obj:Object — the Object to compare with this Rectangle2D

Returns
Boolean — true if the objects are equal; false otherwise.
getClass()method 
override public function getClass():Class

Returns
Class
hashCode()method 
override public function hashCode():int

Returns
int
initRectangle2D()method 
protected final function initRectangle2D():void

intersect()method 
public static function intersect(src1:Rectangle2D, src2:Rectangle2D, dst:Rectangle2D):void

Intersects the pair of specified source Rectangle2D objects and puts the result into the specified destination Rectangle2D object. One of the source rectangles can also be the destination to avoid creating a third Rectangle2D object, but in this case the original points of this source rectangle will be overwritten by this method.

Parameters

src1:Rectangle2D — the first of a pair of Rectangle2D objects to be intersected with each other
 
src2:Rectangle2D — the second of a pair of Rectangle2D objects to be intersected with each other
 
dst:Rectangle2D — the Rectangle2D that holds the results of the intersection of src1 and src2

intersectsLine()method 
public function intersectsLine(x1:Number, y1:Number, x2:Number, y2:Number):Boolean

Tests if the specified line segment intersects the interior of this Rectangle2D.

Parameters

x1:Number — the x coordinate of the first endpoint of the specified line segment.
 
y1:Number — the y coordinate of the second endpoint of the specified line segment.
 
x2:Number — the x coordinate of the second endpoint of the specified line segment.
 
y2:Number

Returns
Boolean
intersectsRectangle()method 
public function intersectsRectangle(rect:Rectangle2D):Boolean

Tests if the interior of this Rectangle2D intersects the specified Rectangle2D.

Parameters

rect:Rectangle2D — the rectangle to test

Returns
Boolean — true if this Rectangle2D intersects the specified Rectangle2D; false otherwise.
intersectsRectangle2()method 
public function intersectsRectangle2(x:Number, y:Number, width:Number, height:Number):Boolean

Tests if the interior of this Rectangle2D intersects the interior of a specified set of rectangular coordinates.

Parameters

x:Number — the x coordinate of the upper left corner of the specified set of rectangular coordinates
 
y:Number — the y coordinate of the upper left corner of the specified set of rectangular coordinates
 
width:Number — the width of the specified set of rectangular coordinates
 
height:Number — the height of the specified set of rectangular coordinates

Returns
Boolean — true if this Rectangle2D intersects the interior of a specified set of rectangular coordinates; false otherwise.
outcode()method 
public function outcode(p:Point2D):int

Determines where the specified Point2D lies with respect to this Rectangle2D. This method computes a binary OR of the appropriate mask values indicating, for each side of this Rectangle2D, whether or not the specified Point2D are on the same side of the edge as the rest of this Rectangle2D.

Parameters

p:Point2D — the specified Point2D.

Returns
int — the logical OR of all appropriate out codes.
outcode2()method 
public function outcode2(x:Number, y:Number):int

Determines where the specified coordinates lie with respect to this Rectangle2D. This method computes a binary OR of the appropriate mask values indicating, for each side of this Rectangle2D, whether or not the specified coordinates are on the same side of the edge as the rest of this Rectangle2D.

Parameters

x:Number — the specified x coordinate.
 
y:Number — the specified y coordinate.

Returns
int — the logical OR of all appropriate out codes.
setFrame()method 
public function setFrame(x:Number, y:Number, width:Number, height:Number):void

Sets the location and size of the outer bounds of this Rectangle2D to the specified rectangular values.

Parameters

x:Number — the x coordinate of the upper left corner of the outer bounds of this Rectangle2D
 
y:Number — the y coordinate of the upper left corner of the outer bounds of this Rectangle2D
 
width:Number — the value to use to set the width of the outer bounds of this Rectangle2D
 
height:Number — the value to use to set the height of the outer bounds of this Rectangle2D

setFrame2()method 
public function setFrame2(loc:Point2D, size:Dimension):void

Parameters

loc:Point2D
 
size:Dimension

setFrameFromCenter()method 
public function setFrameFromCenter(center:Point2D, corner:Point2D):void

Sets the framing rectangle of this Shape based on a specified center Point2D and corner Point2D. The framing rectangle is used by the subclasses of RectangularShape to define their geometry.

Parameters

center:Point2D — the center point
 
corner:Point2D — the corner point

setFrameFromCenter2()method 
public function setFrameFromCenter2(centerX:Number, centerY:Number, cornerX:Number, cornerY:Number):void

Sets the framing rectangle of this Shape based on the specified center point coordinates and corner point coordinates. The framing rectangle is used by the subclasses of RectangularShape to define their geometry.

Parameters

centerX:Number — the x coordinate of the center point
 
centerY:Number
 
cornerX:Number — the x coordinate of the corner point
 
cornerY:Number — the y coordinate of the corner point

setFrameFromDiagonal()method 
public function setFrameFromDiagonal(p1:Point2D, p2:Point2D):void

Sets the diagonal of the framing rectangle of this Shape based on the two specified coordinates. The framing rectangle is used by the subclasses of RectangularShape to define their geometry.

Parameters

p1:Point2D — the first coordinate
 
p2:Point2D — the second coordinate

setFrameFromDiagonal2()method 
public function setFrameFromDiagonal2(x1:Number, y1:Number, x2:Number, y2:Number):void

Sets the diagonal of the framing rectangle of this Shape based on the two specified coordinates. The framing rectangle is used by the subclasses of RectangularShape to define their geometry.

Parameters

x1:Number — the x coordinate of the first coordinate point
 
y1:Number — the y coordinate of the first coordinate point
 
x2:Number — the x coordinate of the second coordinate point
 
y2:Number — the y coordinate of the second coordinate point

setRect()method 
public function setRect(x:Number, y:Number, width:Number, height:Number):void

Sets the location and size of this Rectangle2D to the specified double values.

Parameters

x:Number — the x coordinate of the upper left corner of the rectangle
 
y:Number — the y coordinate of the upper left corner of the rectangle
 
width:Number — the value to use to set the width of this Rectangle2D
 
height:Number — the value to use to set the height of this Rectangle2D

unionOf()method 
public static function unionOf(src1:Rectangle2D, src2:Rectangle2D, dst:Rectangle2D):void

Unions the pair of specified source Rectangle2D objects and puts the result into the specified destination Rectangle2D object. One of the source rectangles can also be the destination to avoid creating a third Rectangle2D object, but in this case the original points of this source rectangle will be overwritten by this method.

Parameters

src1:Rectangle2D — the first of a pair of Rectangle2D objects to be combined with each other
 
src2:Rectangle2D — the second of a pair of Rectangle2D objects to be combined with each other
 
dst:Rectangle2D — the Rectangle2D that holds the results of the union of src1 and src2

Constant Detail
OUT_BOTTOMConstant
public static const OUT_BOTTOM:int = 8

The bitmask that indicates that a point lies below this Rectangle2D.

OUT_LEFTConstant 
public static const OUT_LEFT:int = 1

The bitmask that indicates that a point lies to the left of this Rectangle2D.

OUT_RIGHTConstant 
public static const OUT_RIGHT:int = 4

The bitmask that indicates that a point lies to the right of this Rectangle2D.

OUT_TOPConstant 
public static const OUT_TOP:int = 2

The bitmask that indicates that a point lies above this Rectangle2D.