- I
Remarks
Examples
class CustomEditLabelHelper extends BaseClass(EditLabelHelper) {
protected onLabelAdding(
context: IInputModeContext,
evt: LabelEditingEventArgs,
): void {
// let the base implementation do the work
super.onLabelAdding(context, evt)
// for new edge labels: use a custom parameter
if (evt.owner instanceof IEdge) {
evt.layoutParameter =
new EdgeSegmentLabelModel().createParameterFromCenter()
}
}
}graph.decorator.edges.editLabelHelper.addConstant(
new CustomEditLabelHelper(),
)See Also
Developer's Guide
Members
Properties
Gets or sets the graph instance to retrieve the default values from.
Property Value
Methods
Handles adding the label upon finish.
Parameters
- context: IInputModeContext
- The valid input mode context for this action.
- evt: LabelEditingEventArgs
- A template to get all properties to create the label from. Note that the preferredSize can be
null. In this case it will be determined automatically.
Return Value
- ILabel
- The newly created label, or
nullif no graph is available.
Invoked if the label editing action has been canceled.
Parameters
- context: IInputModeContext
- The current input mode context.
- evt: LabelEditingEventArgs
- Additional information about the label or label owner and whether the editing operation has been canceled programmatically.
Implements
IEditLabelHelper.cancelInvoked after the label editing gesture has successfully finished.
Completes the gesture by applying the changes, according to action.
Depending on action, this method delegates to addLabel, setLabelText, removeLabel, and labelDropped.
Parameters
- context: IInputModeContext
- The input mode context from the input mode which invoked that method.
- evt: LabelEditingEventArgs
- The LabelEditingEventArgs which provide the information for the label to be added or edited. In particular, the owner for newly added labels or the label to edit or remove, and the text to set
- action: LabelEditingAction
Return Value
- ILabel
- The added, edited, or removed label if the action has been completed successfully.
null, otherwise.
Implements
IEditLabelHelper.finishObtains the defaults for the label owner.
Parameters
- context: IInputModeContext
- The input mode context
- owner: ILabelOwner
- The owner to get the label defaults for
Return Value
- ILabelDefaults
- The label defaults.
Determines the label model parameter to use for the label, depending on the owner.
owner.owner.Parameters
- context: IInputModeContext
- The input mode context.
- owner: ILabelOwner
- The label's owner.
Return Value
- ILabelModelParameter
- The layout parameter to use or
null.
Determines the style to use for the label, depending on the owner.
owner.owner.Parameters
- context: IInputModeContext
- The input mode context.
- owner: ILabelOwner
- The label's owner.
Return Value
- ILabelStyle
- The style to use or
null.
Gets the preferred size for the label.
null to indicate that the preferred size should be calculated after the text has been entered.Parameters
- context: IInputModeContext
- The input mode context.
- label: ILabel
- The label to get the preferred size from.
Return Value
- Size
- The size to use or
null.
Invoked at the beginning of a label adding or label editing gesture.
action.Parameters
- context: IInputModeContext
- The input mode context from the input mode which invoked that method.
- evt: LabelEditingEventArgs
- A configuration object which supports customizing the label editing.
- action: LabelEditingAction
Implements
IEditLabelHelper.initializeHandles adding the label upon finish after the drop action of a drag and drop operation.
evt' owner. If this helper's graph is not null, said instance is used to add the label. If graph is null, this implementation tries to retrieve a graph from the given context. If the retrieved graph is not null, said instance is used to add the label. If the retrieved graph is null, this implementation returns null without adding a label.Parameters
- context: IInputModeContext
- The valid input mode context for this action.
- evt: LabelEditingEventArgs
Return Value
- ILabel
- The newly created label.
Will be called from initialize to initialize the helper for ADDing labels.
evt and sets the handled property to true. Label creation thus is always possible and will be handled by this instance.Parameters
- context: IInputModeContext
- The input mode context.
- evt: LabelEditingEventArgs
- The original event arguments.
Invoked from initialize to initialize the helper for adding labels after the drop action of a drag and drop operation.
Called by LabelDropInputMode when a label is dropped on the owner.
This implementation does nothing.
Parameters
- context: IInputModeContext
- The input mode context.
- evt: LabelEditingEventArgs
- The original event arguments.
Will be called from initialize to initialize the helper for EDITing labels.
If label is set, this implementation does nothing which means that this label will be edited normally.
If label is null but owner is not null, this method sets the label of the given evt to the first of the labels that belong to said owner. If no label is found, this method sets the properties of the given evt to the values returned by getLabelParameter, getLabelStyle, and getPreferredSize to prepare defaults for label adding.
This method always sets the handled property of the given evt to true, so label editing is always possible and will be handled by this EditLabelHelper instance.
Parameters
- context: IInputModeContext
- The input mode context.
- evt: LabelEditingEventArgs
- The original event arguments.
Invoked from initialize to initialize the helper for adding labels during paste from the GraphClipboard.
Called by GraphClipboard when a label is pasted.
This implementation uses getLabelParameter to provide a suitable layoutParameter if the item type of the model changed.
Parameters
- context: IInputModeContext
- The input mode context.
- evt: LabelEditingEventArgs
- The original event arguments.
- newOwner: ILabelOwner
- The owner the new label will be pasted on.
- originalLabel: ILabel
- The original of the new label.
Handles removing the label upon finish.
Parameters
- context: IInputModeContext
- The IInputModeContext.
- label: ILabel
- The label to remove.
Return Value
- boolean
- Whether a label was removed.
Handles changing the label text upon finish.
This implementation uses setLabelText to add the label to the graph. The graph is tried to retrieve from graph first. If graph is null, the context is asked for a graph implementation. If no graph is retrieved, null is returned.
If the label's text is not changed, null is returned.
Parameters
- context: IInputModeContext
- The IInputModeContext.
- label: ILabel
- The label on which to set the text.
- text: string
- The text to set on the label.
Return Value
- boolean
- Whether a new label text was set.