Packagecom.yworks.canvas.geom
Classpublic class OrientedRectangle
InheritanceOrientedRectangle Inheritance Object
Implements IMovable, IMutableOrientedRectangle

A simple default implementation of a mutable oriented rectangle in 2D coordinate space with values stored in an instance of IMutablePoint and IMutableSize as well as two doubles for the up vector components.

This implementation delegates the storage to implementations of IMutablePoint for the anchor of the oriented rectangle. and IMutableSize for the size of the oriented rectangle. members. As a convenience it implements the IMovable and the IMutablePoint interfaces.



Public Properties
 PropertyDefined By
  anchor : IPoint
The IPointinstance that stores the anchor of this oriented rectangle.
OrientedRectangle
  anchorX : Number
The x coordinate of the anchor of this instance from the anchor instance.
OrientedRectangle
  anchorY : Number
The y coordinate of the anchor of this instance from the anchor instance.
OrientedRectangle
  angle : Number
The orientation of this rectangle.
OrientedRectangle
  EMPTY : OrientedRectangle
[static] An OrientedRectangle instance with width and height set to -1
OrientedRectangle
  height : Number
The height of this instance from the ISize instance.
OrientedRectangle
  size : ISize
The ISize instance that stores the size of this rectangle.
OrientedRectangle
  upX : Number
Gets or sets the x component of the up vector to the new value.
OrientedRectangle
  upY : Number
The y component of the up vector to the new value.
OrientedRectangle
  width : Number
The width of this instance from the ISize instance.
OrientedRectangle
  x : Number
Gets or sets the y coordinate of the anchor of this instance from the anchor instance.
OrientedRectangle
  y : Number
The y coordinate of the anchor of this instance from the anchor instance.
OrientedRectangle
Public Methods
 MethodDefined By
  
OrientedRectangle(position:YPoint, size:IMutableSize, upX:Number = 0, upY:Number = -1)
Creates a new instance using the provided values to initialize the anchor and size.
OrientedRectangle
  
create(x:Number = 0, y:Number = 0, w:Number = -1, h:Number = -1, upX:Number = 0, upY:Number = -1):OrientedRectangle
[static] Creates a new instance using the provided values to initialize the anchor and size.
OrientedRectangle
  
[static] Creates a new instance using the provided rectangle to initialize itself.
OrientedRectangle
  
empty():Boolean
Returns whether this instance has negative width or height.
OrientedRectangle
  
Determines the bounds of an oriented rectangle.
OrientedRectangle
  
moveBy(dx:Number, dy:Number):Boolean
Moves this rectangle by applying the offset to the anchor
OrientedRectangle
  
moveByDx(dx:Number):Boolean
Moves this rectangle by applying the offset to the anchor
OrientedRectangle
  
moveByDy(dy:Number):Boolean
Moves this rectangle by applying the offset to the anchor
OrientedRectangle
  
setAngle(value:Number):void
Deprecated: Please Use angle
Sets the orientation of this rectangle.
OrientedRectangle
  
setCenter(center:IPoint):void
Sets the center of the oriented rectangle to the given value.
OrientedRectangle
  
setUpVector(upX:Number, upY:Number):void
Sets the components of the up vector to the new values.
OrientedRectangle
  
Sets the values of this instance to the values provided by the given instance.
OrientedRectangle
Property Detail
anchorproperty
anchor:IPoint

The IPointinstance that stores the anchor of this oriented rectangle.

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


Implementation
    public function get anchor():IPoint
    public function set anchor(value:IPoint):void
anchorXproperty 
anchorX:Number

The x coordinate of the anchor of this instance from the anchor instance.


Implementation
    public function get anchorX():Number
    public function set anchorX(value:Number):void
anchorYproperty 
anchorY:Number

The y coordinate of the anchor of this instance from the anchor instance.


Implementation
    public function get anchorY():Number
    public function set anchorY(value:Number):void
angleproperty 
angle:Number

The orientation of this rectangle. An angle of 0 means the up vector points up in direction (0,-1).

The value is not stored and will be recalculated using Math.atan2( -upY, -upX ); every time this is invoked, so this is a costly method.

Setting the angle results in: upX = -Math.sin( value ); upY = -Math.cos( value );


Implementation
    public function get angle():Number
    public function set angle(value:Number):void
EMPTYproperty 
public static var EMPTY:OrientedRectangle

An OrientedRectangle instance with width and height set to -1

heightproperty 
height:Number

The height of this instance from the ISize instance.


Implementation
    public function get height():Number
    public function set height(value:Number):void
sizeproperty 
size:ISize

The ISize 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

Gets or sets the x component of the up vector to the new value.

It is up to the caller to assure that the values describe a vector of length 1.


Implementation
    public function get upX():Number
    public function set upX(value:Number):void
upYproperty 
upY:Number

The y component of the up vector to the new value.

It is up to the caller to assure that the values describe a vector of length 1.


Implementation
    public function get upY():Number
    public function set upY(value:Number):void
widthproperty 
width:Number

The width of this instance from the ISize instance.


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

Gets or sets the y coordinate of the anchor of this instance from the anchor instance.


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

The y coordinate of the anchor of this instance from the anchor instance.


Implementation
    public function get y():Number
    public function set y(value:Number):void
Constructor Detail
OrientedRectangle()Constructor
public function OrientedRectangle(position:YPoint, size:IMutableSize, upX:Number = 0, upY:Number = -1)

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

The up vector will be initialized to (0, -1).

The instances provided will be referenced by this instance. This instance will be used as a live view over the provided instances. Changes to them will indirectly change the state of this instance and changes applied through this instance will be written to the referenced implementations.

Parameters
position:YPoint — The provider for the dynamic anchor of this instance.
 
size:IMutableSize — The provider for the dynamic size of this instance.
 
upX:Number (default = 0)
 
upY:Number (default = -1)
Method Detail
create()method
public static function create(x:Number = 0, y:Number = 0, w:Number = -1, h:Number = -1, upX:Number = 0, upY:Number = -1):OrientedRectangle

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

The up vector will be initialized to (0, -1).

Parameters

x:Number (default = 0) — The x coordinate of the anchor of the oriented rectangle.
 
y:Number (default = 0) — The y coordinate of the anchor of the oriented rectangle.
 
w:Number (default = -1) — The width of the rectangle.
 
h:Number (default = -1) — The height of the rectangle.
 
upX:Number (default = 0)
 
upY:Number (default = -1)

Returns
OrientedRectangle
createFromOrientedRectangle()method 
public static function createFromOrientedRectangle(orientedRectangle:IOrientedRectangle):OrientedRectangle

Creates a new instance using the provided rectangle to initialize itself.

This will basically create a copy of the given rectangle.

Parameters

orientedRectangle:IOrientedRectangle — The rectangle to initialize the anchor and size from.

Returns
OrientedRectangle
empty()method 
public function empty():Boolean

Returns whether this instance has negative width or height.

Returns
Booleantrue if width or height is negative
getBounds()method 
public function getBounds():IRectangle

Determines the bounds of an oriented rectangle.

Bounding rectangles are parallel to the coordinate axes.

Returns
IRectangle — the bounds.
moveBy()method 
public function moveBy(dx:Number, dy:Number):Boolean

Moves this rectangle by applying the offset to the anchor

Parameters

dx:Number — The x offset to move the rectangle's position by.
 
dy:Number — The y 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 anchor

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 anchor

Parameters

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

Returns
Booleantrue if dy != 0.
setAngle()method 
public function setAngle(value:Number):void
Deprecated: Please Use angle

Sets the orientation of this rectangle.

Parameters

value:Number

setCenter()method 
public function setCenter(center:IPoint):void

Sets the center of the oriented rectangle to the given value.

Parameters

center:IPoint — The coordinates of the new center.

setUpVector()method 
public function setUpVector(upX:Number, upY:Number):void

Sets the components of the up vector to the new values.

It is up to the caller to assure that the values describe a vector of length 1.

Parameters

upX:Number — The x component of the normalized up vector.
 
upY:Number — The y component of the normalized up vector.

setValues()method 
public function setValues(rectangle:IOrientedRectangle):void

Sets the values of this instance to the values provided by the given instance.

Parameters

rectangle:IOrientedRectangle