Packagecom.yworks.canvas.input
Classpublic class LabelPositionHandler
InheritanceLabelPositionHandler Inheritance Object
Implements IPositionHandler, IPoint

An implementation of IPositionHandler that shows the various label position candidates and lets the user move a label to one of those candidate positions.

See also

IPositionHandler


Public Properties
 PropertyDefined By
  inputModeCanvasGroup : ICanvasObjectGroup
Gets or sets the input mode canvas group.
LabelPositionHandler
  location : IPoint
[read-only] Returns the current location, i.e.
LabelPositionHandler
  useFinder : Boolean
Gets or sets a property that determines whether the handler may use a ILabelModelParameterFinder to assign arbitrary positions.
LabelPositionHandler
  x : Number
[read-only] Gets the current x coordinate of this point.
LabelPositionHandler
  y : Number
[read-only] Gets the current y coordinate of this point.
LabelPositionHandler
Protected Properties
 PropertyDefined By
  graph : IGraph
[read-only] Gets the graph instance.
LabelPositionHandler
  label : ILabel
[read-only] Gets the label instance.
LabelPositionHandler
Public Methods
 MethodDefined By
  
Initializes a new instance of the LabelPositionHandler class.
LabelPositionHandler
  
cancelDrag(context:IInputModeContext, originalX:Number, originalY:Number):void
Called by clients to indicate that the dragging has been canceled by the user.
LabelPositionHandler
  
dragFinished(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):void
Called by clients to indicate that the repositioning has just been finished.
LabelPositionHandler
  
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.
LabelPositionHandler
  
Called by clients to indicate that the element is going to be dragged.
LabelPositionHandler
  
setPosition(x:Number, y:Number):void
Called by clients to set the position to the given coordinates.
LabelPositionHandler
Protected Methods
 MethodDefined By
  
Creates an IDisplayObjectCreator to display the given candidate position.
LabelPositionHandler
  
getDistance(rectangle:IOrientedRectangle, x:Number, y:Number):Number
Calculates a distance value between a candidate rectangle and the mouse location.
LabelPositionHandler
  
Callback method that gets the candidates for the given graph and label.
LabelPositionHandler
  
Actually applies the given parameter at the end of the gesture.
LabelPositionHandler
  
Determines whether to use a ILabelModelParameterFinder to find the best candidate.
LabelPositionHandler
Property Detail
graphproperty
graph:IGraph  [read-only]

Gets the graph instance.


Implementation
    protected function get graph():IGraph
inputModeCanvasGroupproperty 
inputModeCanvasGroup:ICanvasObjectGroup

Gets or sets the input mode canvas group.

This group will be used by the position handler instances to paint the candidate boxes in.


Implementation
    public function get inputModeCanvasGroup():ICanvasObjectGroup
    public function set inputModeCanvasGroup(value:ICanvasObjectGroup):void
labelproperty 
label:ILabel  [read-only]

Gets the label instance.


Implementation
    protected function get label():ILabel
locationproperty 
location:IPoint  [read-only]

Returns the current location, i.e. the center of the label's layout as a IPoint.


Implementation
    public function get location():IPoint
useFinderproperty 
useFinder:Boolean

Gets or sets a property that determines whether the handler may use a ILabelModelParameterFinder to assign arbitrary positions.

The default valus is true


Implementation
    public function get useFinder():Boolean
    public function set useFinder(value:Boolean):void

See also

useParameterFinder
xproperty 
x:Number  [read-only]

Gets the current x coordinate of this point.

Depending on context the values returned may change over time.


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

Gets the current y coordinate of this point.

Depending on context the values returned may change over time.


Implementation
    public function get y():Number
Constructor Detail
LabelPositionHandler()Constructor
public function LabelPositionHandler(graph:IGraph, label:ILabel)

Initializes a new instance of the LabelPositionHandler class.

Parameters
graph:IGraph — The graph that contains the label.
 
label:ILabel — The label that shall be moved.
Method Detail
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.

createCandidateCreator()method 
protected function createCandidateCreator(candidateGeometry:IOrientedRectangle, highlight:Boolean):IDisplayObjectCreator

Creates an IDisplayObjectCreator to display the given candidate position.

Parameters

candidateGeometry:IOrientedRectangle — The geometry to use for the painting.
 
highlight:Boolean — Whether to highlight the display object. This will be true for the current position and false for the others.

Returns
IDisplayObjectCreator — An implementation that will create a DisplayObject for the given candidate.
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.

getDistance()method 
protected function getDistance(rectangle:IOrientedRectangle, x:Number, y:Number):Number

Calculates a distance value between a candidate rectangle and the mouse location.

Parameters

rectangle:IOrientedRectangle — The rectangle candidate.
 
x:Number — The mouse location.
 
y:Number — The mouse location.

Returns
Number — A value indicating the closeness of the mouse to the rectangle.
getParameterCandidates()method 
protected function getParameterCandidates(graph:IGraph, label:ILabel):Iterator

Callback method that gets the candidates for the given graph and label.

Parameters

graph:IGraph — The graph.
 
label:ILabel — The label.

Returns
Iterator — A possibly empty enumerator over possible label parameter candidates.
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.

setLabelModelParameter()method 
protected function setLabelModelParameter(label:ILabel, parameter:ILabelModelParameter):void

Actually applies the given parameter at the end of the gesture.

Parameters

label:ILabel — The label to set the parameter for.
 
parameter:ILabelModelParameter — The new parameter.

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.

useParameterFinder()method 
protected function useParameterFinder():Boolean

Determines whether to use a ILabelModelParameterFinder to find the best candidate.

This implementation returns true if the useFinder property is true and no candidates are available or the Ctrl key is pressed.

Returns
Booleantrue if a ILabelModelParameterFinder is used to find the best candidate.

See also

ILabelModelParameterFinder