Packagecom.yworks.graph.drawing
Classpublic class DefaultPositionHandler
InheritanceDefaultPositionHandler Inheritance Object
Implements IPositionHandler

Generic default implementation of an IPositionHandler.

This implementation delegates to a pair of IPoint and IPointSetter implementations or an IPoint+IReshapeable implementation pair.



Public Properties
 PropertyDefined By
  x : Number
[read-only] Returns the x coordinate of the current position of the element.
DefaultPositionHandler
  y : Number
[read-only] Returns the y coordinate of the current position of the element.
DefaultPositionHandler
Protected Properties
 PropertyDefined By
  reshapeable : IReshapeable
The IReshapeable passed if this position handler is created via DefaultPositionHandler.createReshapeablePositionHandler.
DefaultPositionHandler
Public Methods
 MethodDefined By
  
DefaultPositionHandler(pointGetter:IPoint, pointSetter:IPointSetter)
Creates a position handler that delegates to two point implementations.
DefaultPositionHandler
  
applyPosition(x:Number, y:Number):Boolean
Applies the new position to the delegates.
DefaultPositionHandler
  
cancelDrag(context:IInputModeContext, originalX:Number, originalY:Number):void
Called by clients to indicate that the dragging has been canceled by the user.
DefaultPositionHandler
  
[static] Creates a position handler that delegates to a mutable point.
DefaultPositionHandler
  
[static] Creates a position handler that delegates to a mutable rectangle.
DefaultPositionHandler
  
[static] Creates a position handler that delegates to two rectangle implementations.
DefaultPositionHandler
  
dragFinished(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):void
Called by clients to indicate that the repositioning has just been finished.
DefaultPositionHandler
  
handleMove(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):Boolean
Called by clients to indicate that the element has been dragged and its position should be updated.
DefaultPositionHandler
  
Called by clients to indicate that the element is going to be dragged.
DefaultPositionHandler
  
setPosition(x:Number, y:Number):void
Called by clients to set the position to the given coordinates.
DefaultPositionHandler
Property Detail
reshapeableproperty
reshapeable:IReshapeable

The IReshapeable passed if this position handler is created via DefaultPositionHandler.createReshapeablePositionHandler.


Implementation
    protected function get reshapeable():IReshapeable
    protected function set reshapeable(value:IReshapeable):void

See also

xproperty 
x:Number  [read-only]

Returns the x coordinate of the current position of the element.

The point describes the current world coordinate position of the element. It is up to the implementation how this position is interpreted. The values returned by this method will be used for the "originalX" parameter in the handleMove, cancelDrag and dragFinished methods.


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

Returns the y coordinate of the current position of the element.

The point describes the current world coordinate position of the element. It is up to the implementation how this position is interpreted. The values returned by this method will be used for the "originalY" parameter in the handleMove, cancelDrag and dragFinished methods.


Implementation
    public function get y():Number
Constructor Detail
DefaultPositionHandler()Constructor
public function DefaultPositionHandler(pointGetter:IPoint, pointSetter:IPointSetter)

Creates a position handler that delegates to two point implementations.

Parameters
pointGetter:IPoint — The point read the position from.
 
pointSetter:IPointSetter — The point write the new position to.
Method Detail
applyPosition()method
public function applyPosition(x:Number, y:Number):Boolean

Applies the new position to the delegates.

Parameters

x:Number — The x coordinate of the new position to apply.
 
y:Number — The y coordinate of the new position to apply.

Returns
Booleantrue, if the new position differs from the old positon.
cancelDrag()method 
public function cancelDrag(context:IInputModeContext, originalX:Number, originalY:Number):void

Called by clients to indicate that the dragging has been canceled by the user.

This method may be called after the initial initializeDrag and zero or more invocations of handleMove. Implementations should reset the position of the items they modify to their initial state. Alternatively to this method the dragFinished method might be called.

Parameters

context:IInputModeContext — The context to retrieve information about the drag from.
 
originalX:Number — The value of the x property at the time of initializeDrag.
 
originalY:Number — The value of the y property at the time of initializeDrag.

createMutablePointPositionHandler()method 
public static function createMutablePointPositionHandler(point:IMutablePoint):DefaultPositionHandler

Creates a position handler that delegates to a mutable point.

Parameters

point:IMutablePoint — The point to read and write the position to.

Returns
DefaultPositionHandler — A new position handler instance
createMutableRectanglePositionHandler()method 
public static function createMutableRectanglePositionHandler(rectangle:IMutableRectangle):DefaultPositionHandler

Creates a position handler that delegates to a mutable rectangle.

Parameters

rectangle:IMutableRectangle — The rectangle to read and write its location to.

Returns
DefaultPositionHandler — A new position handler instance
createReshapeablePositionHandler()method 
public static function createReshapeablePositionHandler(rectangle:IRectangle, reshapeable:IReshapeable):DefaultPositionHandler

Creates a position handler that delegates to two rectangle implementations.

Parameters

rectangle:IRectangle — The rectangle to read the location from.
 
reshapeable:IReshapeable — The reshapeable to write the new location to.

Returns
DefaultPositionHandler — A new position handler instance
dragFinished()method 
public function dragFinished(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):void

Called by clients to indicate that the repositioning has just been finished. This method may be called after the initial initializeDrag and zero or more invocations of handleMove. Alternatively to this method the cancelDrag method might be called.

Parameters

context:IInputModeContext — The context to retrieve information about the drag from.
 
originalX:Number — The value of the x property at the time of initializeDrag.
 
originalY:Number — The value of the y property at the time of initializeDrag.
 
newX:Number — The value of the x coordinate in the world coordinate system that the client wants the handle to be at. Depending on the implementation the x and y properties or may not be modified to reflect the new value. This is the same value as delivered in the last invocation of handleMove.
 
newY:Number — The value of the y coordinate in the world coordinate system that the client wants the handle to be at. Depending on the implementation the x and y properties or may not be modified to reflect the new value. This is the same value as delivered in the last invocation of handleMove.

handleMove()method 
public function handleMove(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):Boolean

Called by clients to indicate that the element has been dragged and its position should be updated.

This method may be called more than once after an initial initializeDrag and will be followed by either dragFinished or cancelDrag.

Parameters

context:IInputModeContext — The value of the x property at the time of initializeDrag.
 
originalX:Number — The value of the y property at the time of initializeDrag.
 
originalY:Number — The value of the x coordinate in the world coordinate system that the client wants the handle to be at. Depending on the implementation the x property may or may not be modified to reflect the new value.
 
newX:Number — The value of the y coordinate in the world coordinate system that the client wants the handle to be at. Depending on the implementation the y property may or may not be modified to reflect the new value.
 
newY:Number

Returns
Boolean — Whether the move had any visual effect. This is a hint to the engine to optimize invalidation.
initializeDrag()method 
public function initializeDrag(context:IInputModeContext):void

Called by clients to indicate that the element is going to be dragged.

This call will be followed by one or more calls to handleMove, and a final dragFinished or cancelDrag.

Parameters

context:IInputModeContext — The context to retrieve information about the drag from.

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

Called by clients to set the position to the given coordinates.

It is up to the implementation to decide how the position of the element in question should be interpreted. This may be the upper left corner of the element, its center or anything else. The implementation may decide to not use the values provided or use different values internally.

Parameters

x:Number — The new x coordinate.
 
y:Number — The new y coordinate.