An implementation of IPositionHandler that shows the various label position candidates and lets the user move a label to one of those candidate positions.
Remarks
Instances of this class can be used to change the visualization of labels while moving them.
The candidate positions rendered by the candidateRenderer provide the following CSS classes:
yfiles-label-position-candidate-template
for all possible positionsyfiles-label-position-highlight-template
for the position that would currently be taken
Examples
graph.decorator.labels.positionHandler.addFactory((label) => {
const positionHandler = new LabelPositionHandler(label)
positionHandler.visualization = 'live'
return positionHandler
})
Related Reading in the Developer's Guide
Type Details
- yFiles module
- view
Constructors
Initializes a new instance of the LabelPositionHandler class.
Parameters
A map of options to pass to the method.
- label - ILabel
- The label that shall be moved.
Properties
Gets or sets the IObjectRenderer<LabelCandidateRenderTag> that visualizes label candidates while moving labels.
Remarks
When queried for an IVisualCreator to obtain the visualizations for label candidates, this renderer is passed instances of LabelCandidateRenderTag as render tag.
This property is not used if the visualization is set to NONE.
Gets the graph instance from the IInputModeContext that has been passed to the initializeDrag method.
Gets the label instance.
Property Value
Gets a view of the location of the item.
Remarks
Implements
Gets or sets a property that determines whether the handler should refuse to move the label when there are other, possibly conflicting items being moved at the same time.
Remarks
Gets or sets the recognizer that determines whether the user wants to manually enable the usage of ILabelModelParameterFinder to specify the position for new label.
Remarks
Signature Details
function(evt: EventArgs, eventSource: unknown) : boolean
Parameters
- evt - EventArgs
- The arguments of the event to be decided to handle.
- eventSource - unknown
- The source of the event.
Returns
- boolean
true
if theevt
is considered to be handled.
Gets or sets how the moved label should be shown during the gesture.
Remarks
This property must not be changed during the gesture.
Default is PLACEHOLDER.
Examples
graph.decorator.labels.positionHandler.addFactory((label) => {
const positionHandler = new LabelPositionHandler(label)
positionHandler.visualization = 'live'
return positionHandler
})
Methods
Called by clients to indicate that the dragging has been canceled by the user.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context to retrieve information about the drag from.
- originalLocation - Point
- The value of the coordinate of the location property at the time of initializeDrag.
Implements
Called by clients to indicate that the repositioning has just been finished.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context to retrieve information about the drag from.
- originalLocation - Point
- The value of the location property at the time of initializeDrag.
- newLocation - Point
- The coordinates in the world coordinate system that the client wants the handle to be at. Depending on the implementation the location may or may not be modified to reflect the new value. This is the same value as delivered in the last invocation of handleMove.
Implements
Calculates a distance value between a candidate rectangle and the mouse location.
Parameters
A map of options to pass to the method.
- rectangle - IOrientedRectangle
- The rectangle candidate.
- location - Point
- The mouse location.
Returns
- ↪number
- A value indicating the closeness of the mouse to the rectangle.
Gets the candidates for the given label.
Parameters
A map of options to pass to the method.
- label - ILabel
- The label.
Returns
- ↪IEnumerable<ILabelModelParameter>
- A possibly empty enumerator over possible label parameter candidates.
Provides the ILabelModelParameterFinder for calculating the label's candidates.
Parameters
A map of options to pass to the method.
- label - ILabel
- The label for which to find the parameter
Returns
- ↪ILabelModelParameterFinder
- An ILabelModelParameterFinder provided in the lookup of the given label, or a default implementation that finds the closest matching parameter.
Called by clients to indicate that the element has been dragged and its position should be updated.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context to retrieve information about the drag from.
- originalLocation - Point
- The value of the location property at the time of initializeDrag.
- newLocation - Point
- The coordinates in the world coordinate system that the client wants the handle to be at. Depending on the implementation, the location may or may not be modified to reflect the new value.
Implements
Called by clients to indicate that the element is going to be dragged.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context to retrieve information about the drag from.
Implements
Actually applies the given parameter at the end of the gesture.
Parameters
A map of options to pass to the method.
- label - ILabel
- The label to set the parameter for.
- layoutParameter - ILabelModelParameter
- The new parameter.
Determines whether to ignore upcoming handleMove and dragFinished calls.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context of drag-started.
Returns
- ↪boolean
Determines whether to use a ILabelModelParameterFinder to find the best candidate.
Remarks
true
if there are either no candidates at all or useParameterFinderRecognizer matches for the last input event received by the canvasComponent.Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context that is currently being used.
Returns
- ↪boolean