Package | com.yworks.canvas.input |
Class | public class LabelPositionHandler |
Inheritance | LabelPositionHandler Object |
Implements | IPositionHandler, IPoint |
IPositionHandler
that shows the various label position candidates
and lets the user move a label to one of those candidate positions.
See also
Property | Defined 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 |
Property | Defined By | ||
---|---|---|---|
graph : IGraph [read-only]
Gets the graph instance. | LabelPositionHandler | ||
label : ILabel [read-only]
Gets the label instance. | LabelPositionHandler |
Method | Defined 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 | ||
initializeDrag(context:IInputModeContext):void
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 |
Method | Defined By | ||
---|---|---|---|
createCandidateCreator(candidateGeometry:IOrientedRectangle, highlight:Boolean):IDisplayObjectCreator
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 | ||
useParameterFinder():Boolean
Determines whether to use a ILabelModelParameterFinder to find the best candidate. | LabelPositionHandler |
graph | property |
graph:IGraph
[read-only] Gets the graph instance.
protected function get graph():IGraph
inputModeCanvasGroup | property |
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.
public function get inputModeCanvasGroup():ICanvasObjectGroup
public function set inputModeCanvasGroup(value:ICanvasObjectGroup):void
label | property |
label:ILabel
[read-only] Gets the label instance.
protected function get label():ILabel
location | property |
location:IPoint
[read-only]
Returns the current location, i.e. the center of the label's layout as a IPoint
.
public function get location():IPoint
useFinder | property |
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
public function get useFinder():Boolean
public function set useFinder(value:Boolean):void
See also
x | property |
x:Number
[read-only] Gets the current x coordinate of this point.
Depending on context the values returned may change over time.
public function get x():Number
y | property |
y:Number
[read-only] Gets the current y coordinate of this point.
Depending on context the values returned may change over time.
public function get y():Number
LabelPositionHandler | () | Constructor |
public function LabelPositionHandler(graph:IGraph, label:ILabel)
Initializes a new instance of the LabelPositionHandler
class.
graph:IGraph — The graph that contains the label.
| |
label:ILabel — The label that shall be moved.
|
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.
|
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.
|
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.
|
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 |
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.
Boolean — true if a ILabelModelParameterFinder is used to find the best candidate.
|
See also