Packagecom.yworks.canvas.geom
Classpublic class YRectangle
InheritanceYRectangle Inheritance Object
Implements IMovable, IMutableRectangle, IOrientedRectangle

A simple default implementation of a mutable rectangle in 2D coordinate space with double precision values stored in an instance of IMutablePoint and IMutableSize.

This implementation delegates the storage to implementations of IMutablePoint for the upper left corner of the rectangle and IMutableSize for the size of the rectangle. members. As a convenience it implements the IMovable and IOrientedRectangle interfaces.



Public Properties
 PropertyDefined By
  anchorX : Number
[read-only] Implements the IOrientedRectangle and will return the x coordinate of the position.
YRectangle
  anchorY : Number
[read-only] Implements the IOrientedRectangle and will return the y coordinate of the position plus the height.
YRectangle
  height : Number
The height of this instance from the size instance.
YRectangle
  position : IPoint
Returns the instance that stores the position of this rectangle.
YRectangle
  size : ISize
Returns the instance that stores the size of this rectangle.
YRectangle
  upX : Number
[read-only] always returns 0.
YRectangle
  upY : Number
[read-only] always returns -1.
YRectangle
  width : Number
The width of this instance from the size instance.
YRectangle
  x : Number
Gets or sets the x coordinate of the upper left corner of this instance from the position
YRectangle
  y : Number
Gets or sets the y coordinate of the upper left corner of this instance from the position
YRectangle
Public Methods
 MethodDefined By
  
YRectangle(x:Number = 0.0, y:Number = 0.0, width:Number = 0.0, height:Number = 0.0)
Creates a new instance using the provided values to initialize the position and size.
YRectangle
  
create(x:Number = 0.0, y:Number = 0.0, width:Number = 0.0, height:Number = 0.0):YRectangle
[static] Creates a new instance using the provided values to initialize the position and size.
YRectangle
  
[static] Creates a new instance using the provided instance to retrieve the initial values for the position and size from.
YRectangle
  
getCenterX(rectangle:IRectangle):Number
[static] Returns the x coordinate of the center of the given rectangle.
YRectangle
  
getCenterY(rectangle:IRectangle):Number
[static] Returns the y coordinate of the center of the given rectangle.
YRectangle
  
moveBy(dx:Number, dy:Number):Boolean
Moves this rectangle by applying the offsets to the position.
YRectangle
  
moveByDx(dx:Number):Boolean
Moves this rectangle by applying the offset to the position.
YRectangle
  
moveByDy(dy:Number):Boolean
Moves this rectangle by applying the offset to the position.
YRectangle
  
reshape(x:Number, y:Number, width:Number, height:Number):void
Applies a new position and size in that order to the instances that hold the state of this rectangle.
YRectangle
  
Reshapes this instance to the values provided by the given rectangle.
YRectangle
  
toString():String
A String representation of this instance.
YRectangle
Property Detail
anchorXproperty
anchorX:Number  [read-only]

Implements the IOrientedRectangle and will return the x coordinate of the position.


Implementation
    public function get anchorX():Number
anchorYproperty 
anchorY:Number  [read-only]

Implements the IOrientedRectangle and will return the y coordinate of the position plus the height.


Implementation
    public function get anchorY():Number
heightproperty 
height:Number

The height of this instance from the size instance.


Implementation
    public function get height():Number
    public function set height(value:Number):void
positionproperty 
position:IPoint

Returns the instance that stores the position of this rectangle.

This will return a live view of the position of this rectangle. However setting a position instance will only copy the values of the point provided to the current position.


Implementation
    public function get position():IPoint
    public function set position(value:IPoint):void
sizeproperty 
size:ISize

Returns the instance that stores the size of this rectangle.

This will return a live view of the size of this rectangle. However setting a size instance will only copy the values of the size provided to the current size.


Implementation
    public function get size():ISize
    public function set size(value:ISize):void
upXproperty 
upX:Number  [read-only]

always returns 0.


Implementation
    public function get upX():Number
upYproperty 
upY:Number  [read-only]

always returns -1.


Implementation
    public function get upY():Number
widthproperty 
width:Number

The width of this instance from the size instance.


Implementation
    public function get width():Number
    public function set width(value:Number):void
xproperty 
x:Number

Gets or sets the x coordinate of the upper left corner of this instance from the position


Implementation
    public function get x():Number
    public function set x(value:Number):void
yproperty 
y:Number

Gets or sets the y coordinate of the upper left corner of this instance from the position


Implementation
    public function get y():Number
    public function set y(value:Number):void
Constructor Detail
YRectangle()Constructor
public function YRectangle(x:Number = 0.0, y:Number = 0.0, width:Number = 0.0, height:Number = 0.0)

Creates a new instance using the provided values to initialize the position and size.

An instance of YPoint will be used to store the position and an instance of Size will be used to store the size.

Parameters
x:Number (default = 0.0) — The x coordinate of the upper left corner of the rectangle.
 
y:Number (default = 0.0) — The y coordinate of the upper left corner of the rectangle.
 
width:Number (default = 0.0) — The width of the rectangle.
 
height:Number (default = 0.0) — The height of the rectangle.
Method Detail
create()method
public static function create(x:Number = 0.0, y:Number = 0.0, width:Number = 0.0, height:Number = 0.0):YRectangle

Creates a new instance using the provided values to initialize the position and size.

Parameters

x:Number (default = 0.0) — The x coordinate of the upper left corner of the rectangle.
 
y:Number (default = 0.0) — The y coordinate of the upper left corner of the rectangle.
 
width:Number (default = 0.0) — The width of the rectangle.
 
height:Number (default = 0.0) — The height of the rectangle.

Returns
YRectangle — a new YRectangle instance with the provided values
createFrom()method 
public static function createFrom(rect:IRectangle):YRectangle

Creates a new instance using the provided instance to retrieve the initial values for the position and size from.

Parameters

rect:IRectangle — The rectangle to retrieve the initial size from.

Returns
YRectangle — A new YRectangle with the provided values
getCenterX()method 
public static function getCenterX(rectangle:IRectangle):Number

Returns the x coordinate of the center of the given rectangle.

Parameters

rectangle:IRectangle — The given rectangle

Returns
Number — The x coordinate of the rectangle's center
getCenterY()method 
public static function getCenterY(rectangle:IRectangle):Number

Returns the y coordinate of the center of the given rectangle.

Parameters

rectangle:IRectangle — The given rectangle

Returns
Number — The y coordinate of the rectangle's center
moveBy()method 
public function moveBy(dx:Number, dy:Number):Boolean

Moves this rectangle by applying the offsets to the position.

Parameters

dx:Number — The offset to move the rectangle's position by.
 
dy:Number — The offset to move the rectangle's position by.

Returns
Booleantrue if dx != 0 || dy != 0
moveByDx()method 
public function moveByDx(dx:Number):Boolean

Moves this rectangle by applying the offset to the position.

Parameters

dx:Number — The offset to move the rectangle's position by.

Returns
Booleantrue if dx != 0
moveByDy()method 
public function moveByDy(dy:Number):Boolean

Moves this rectangle by applying the offset to the position.

Parameters

dy:Number — The offset to move the rectangle's position by.

Returns
Booleantrue if dy != 0
reshape()method 
public function reshape(x:Number, y:Number, width:Number, height:Number):void

Applies a new position and size in that order to the instances that hold the state of this rectangle.

Parameters

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

setValues()method 
public function setValues(rect:IRectangle):void

Reshapes this instance to the values provided by the given rectangle.

Parameters

rect:IRectangle — The rectangle to copy the state from.

See also

toString()method 
public function toString():String

A String representation of this instance.

Returns
String — A String representation of this instance.