Packagecom.yworks.yfiles.geom
Classpublic class YRectangle
InheritanceYRectangle Inheritance YDimension Inheritance YObject Inheritance Object
Implements PlaneObject

This class defines a rectangle and provides utility methods for it.



Public Properties
 PropertyDefined By
  boundingBox : YRectangle
[read-only] Returns this object.
YRectangle
 Inheritedheight : Number
[read-only] Get the height of the dimension object.
YDimension
  location : YPoint
[read-only] Returns coordinates of upper left corner.
YRectangle
 Inheritedwidth : Number
[read-only] Get the width of the dimension object.
YDimension
  x : Number
[read-only] Returns x-coordinate of upper left corner.
YRectangle
  y : Number
[read-only] Returns y-coordinate of upper left corner.
YRectangle
Public Methods
 MethodDefined By
  
YRectangle(x:Number, y:Number, width:Number, height:Number, init:Boolean = true)
Creates a new rectangle with given upper left corner and size.
YRectangle
  
compareTo(o:Object):int
[override]
YRectangle
  
contains(rx:Number, ry:Number, rw:Number, rh:Number, x:Number, y:Number):Boolean
[static] Determines whether the specified rectangle contains the specified point.
YRectangle
  
contains2(rx:Number, ry:Number, rw:Number, rh:Number, x:Number, y:Number, closed:Boolean):Boolean
[static] Determines whether the specified rectangle contains the specified point.
YRectangle
  
Checks whether or not this YRectangle contains the given point.
YRectangle
  
containsPoint2(x:Number, y:Number):Boolean
Checks whether or not this YRectangle contains the given point.
YRectangle
  
Checks whether or not this YRectangle contains the given rectangle.
YRectangle
  
containsRectangle2(x:Number, y:Number, width:Number, height:Number):Boolean
Checks whether or not this YRectangle contains the rectangle defined by the given frame.
YRectangle
  
equals(o:Object):Boolean
[override]
YRectangle
  
getClass():Class
[override]
YRectangle
  
Returns the Manhattan distance to the passed rectangle.
YRectangle
  
hashCode():int
[override]
YRectangle
  
[static] Returns whether or not the given rectangles intersect.
YRectangle
 Inherited
newYDimension(width:Number, height:Number):YDimension
[static] Creates a new YDimension2D object for given size.
YDimension
  
[static] Creates a new rectangle with upper left corner (0,0) and size (0,0).
YRectangle
  
[static] Creates a new rectangle with given upper left corner and size.
YRectangle
  
newYRectangle3(x:Number, y:Number, width:Number, height:Number):YRectangle
[static] Creates a new rectangle with given upper left corner and size.
YRectangle
  
toString():String
[override] Returns a string representation of this rectangle
YRectangle
Protected Methods
 MethodDefined By
 Inherited
initYDimension(width:Number, height:Number):void
Initializes this object.
YDimension
  
Initializes this object.
YRectangle
  
Initializes this object.
YRectangle
  
initYRectangle3(x:Number, y:Number, width:Number, height:Number):void
Initializes this object.
YRectangle
Property Detail
boundingBoxproperty
boundingBox:YRectangle  [read-only]

Returns this object.


Implementation
    public function get boundingBox():YRectangle
locationproperty 
location:YPoint  [read-only]

Returns coordinates of upper left corner.


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

Returns x-coordinate of upper left corner.


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

Returns y-coordinate of upper left corner.


Implementation
    public function get y():Number
Constructor Detail
YRectangle()Constructor
public function YRectangle(x:Number, y:Number, width:Number, height:Number, init:Boolean = true)

Creates a new rectangle with given upper left corner and size.

Parameters
x:Number — x-coordinate of upper left corner of the rectangle.
 
y:Number — y-coordinate of upper left corner of the rectangle.
 
width:Number — width of the rectangle.
 
height:Number — height of the rectangle.
 
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
compareTo()method
override public function compareTo(o:Object):int

Parameters

o:Object

Returns
int
contains()method 
public static function contains(rx:Number, ry:Number, rw:Number, rh:Number, x:Number, y:Number):Boolean

Determines whether the specified rectangle contains the specified point.

Parameters

rx:Number — the x-coordinate of the upper left corner of the rectangle.
 
ry:Number — the y-coordinate of the upper left corner of the rectangle.
 
rw:Number — the width of the rectangle.
 
rh:Number — the height of the rectangle.
 
x:Number — the x-coordinate of the point to check.
 
y:Number — the x-coordinate of the point to check.

Returns
Booleantrue if the point lies inside the rectangle; false otherwise.
contains2()method 
public static function contains2(rx:Number, ry:Number, rw:Number, rh:Number, x:Number, y:Number, closed:Boolean):Boolean

Determines whether the specified rectangle contains the specified point.

Parameters

rx:Number — the x-coordinate of the upper left corner of the rectangle.
 
ry:Number — the y-coordinate of the upper left corner of the rectangle.
 
rw:Number — the width of the rectangle.
 
rh:Number — the height of the rectangle.
 
x:Number — the x-coordinate of the point to check.
 
y:Number — the x-coordinate of the point to check.
 
closed:Boolean — if true, all points on the border of the rectangle are considered to be contained.

Returns
Booleantrue if the point lies inside the rectangle; false otherwise.
containsPoint()method 
public function containsPoint(p:YPoint):Boolean

Checks whether or not this YRectangle contains the given point.

Parameters

p:YPoint

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

Checks whether or not this YRectangle contains the given point.

Parameters

x:Number — the x-coordinate of the point to check.
 
y:Number — the x-coordinate of the point to check.

Returns
Booleantrue if the point lies inside the rectangle; false otherwise.
containsRectangle()method 
public function containsRectangle(p:YRectangle):Boolean

Checks whether or not this YRectangle contains the given rectangle.

Parameters

p:YRectangle

Returns
Boolean
containsRectangle2()method 
public function containsRectangle2(x:Number, y:Number, width:Number, height:Number):Boolean

Checks whether or not this YRectangle contains the rectangle defined by the given frame.

Parameters

x:Number
 
y:Number
 
width:Number
 
height:Number

Returns
Boolean
equals()method 
override public function equals(o:Object):Boolean

Parameters

o:Object

Returns
Boolean
getClass()method 
override public function getClass():Class

Returns
Class
getManhattanDistance()method 
public function getManhattanDistance(other:YRectangle):Number

Returns the Manhattan distance to the passed rectangle. If they overlap the distance is 0.

Parameters

other:YRectangle — the second rectangle.

Returns
Number — the distance to the given rectangle.
hashCode()method 
override public function hashCode():int

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

Initializes this object. See the documentation of the corresponding factory method newYRectangle1() for details.

See also

initYRectangle2()method 
protected final function initYRectangle2(pos:YPoint, size:YDimension):void

Initializes this object. See the documentation of the corresponding factory method newYRectangle2() for details.

Parameters

pos:YPoint
 
size:YDimension

See also

initYRectangle3()method 
protected final function initYRectangle3(x:Number, y:Number, width:Number, height:Number):void

Initializes this object. See the documentation of the corresponding factory method newYRectangle3() for details.

Parameters

x:Number
 
y:Number
 
width:Number
 
height:Number

See also

intersects()method 
public static function intersects(r1:YRectangle, r2:YRectangle):Boolean

Returns whether or not the given rectangles intersect.

Parameters

r1:YRectangle
 
r2:YRectangle

Returns
Boolean
newYRectangle1()method 
public static function newYRectangle1():YRectangle

Creates a new rectangle with upper left corner (0,0) and size (0,0).

Returns
YRectangle
newYRectangle2()method 
public static function newYRectangle2(pos:YPoint, size:YDimension):YRectangle

Creates a new rectangle with given upper left corner and size.

Parameters

pos:YPoint — upper left corner of the rectangle.
 
size:YDimension — size of the rectangle.

Returns
YRectangle
newYRectangle3()method 
public static function newYRectangle3(x:Number, y:Number, width:Number, height:Number):YRectangle

Creates a new rectangle with given upper left corner and size.

Parameters

x:Number — x-coordinate of upper left corner of the rectangle.
 
y:Number — y-coordinate of upper left corner of the rectangle.
 
width:Number — width of the rectangle.
 
height:Number — height of the rectangle.

Returns
YRectangle
toString()method 
override public function toString():String

Returns a string representation of this rectangle

Returns
String