public class EditLabelHelper extends Object implements IEditLabelHelper
IEditLabelHelper
interface.
This class provided a number of factory methods that can be overwritten to change the default behavior which is modeled
after the behavior used by GraphEditorInputMode
's GraphEditorInputMode.createLabel(ILabelOwner)
and
GraphEditorInputMode.editLabel(ILabel)
.
Constructor and Description |
---|
EditLabelHelper() |
Modifier and Type | Method and Description |
---|---|
IGraph |
getGraph()
Gets the graph instance to retrieve the default values from.
|
protected ILabelModelParameter |
getLabelParameter(IInputModeContext context,
ILabelOwner owner)
Determines the label model parameter to use for the label, depending on the
owner . |
protected ILabelStyle |
getLabelStyle(IInputModeContext context,
ILabelOwner owner)
Determines the style to use for the label, depending on the
owner . |
protected SizeD |
getPreferredSize(IInputModeContext context,
ILabel label)
Gets the preferred size for the label.
|
void |
onLabelAdding(LabelEditingEventArgs args)
Helper method that will be called for
ILabelOwner s. |
void |
onLabelEditing(LabelEditingEventArgs args)
Helper method that will be called for
ILabelOwner s. |
void |
setGraph(IGraph value)
Sets the graph instance to retrieve the default values from.
|
public final IGraph getGraph()
If this instance is not set, the implementation will try to retrieve the graph from the IInputModeContext
's
ILookup
.
setGraph(IGraph)
protected ILabelModelParameter getLabelParameter(IInputModeContext context, ILabelOwner owner)
owner
.
This method will obtain the default parameter instances from the Graph
considering the type of the
current owner
.
context
- The input mode context.owner
- The label's owner.null
.protected ILabelStyle getLabelStyle(IInputModeContext context, ILabelOwner owner)
owner
.
This method will obtain the default style instances from the Graph
considering the type of the
current owner
.
context
- The input mode context.owner
- The label's owner.null
.protected SizeD getPreferredSize(IInputModeContext context, ILabel label)
This implementation yields null
to indicate that the preferred size should be calculated after the text has been
entered.
context
- The input mode context.label
- The label to get the preferred size from.null
.public void onLabelAdding(LabelEditingEventArgs args)
ILabelOwner
s.
This method delegates to getLabelParameter(IInputModeContext, ILabelOwner)
,
getLabelStyle(IInputModeContext, ILabelOwner)
, and getPreferredSize(IInputModeContext, ILabel)
to
set the appropriate properties on args
and sets the Handled
property
to true
. Label creation thus is always possible.
onLabelAdding
in interface IEditLabelHelper
args
- The original event arguments.IEditLabelHelper.onLabelEditing(LabelEditingEventArgs)
public void onLabelEditing(LabelEditingEventArgs args)
ILabelOwner
s.
This method returns the first of the Labels
that belong to the
Owner
, if set. Otherwise, it delegates to
getLabelParameter(IInputModeContext, ILabelOwner)
, getLabelStyle(IInputModeContext, ILabelOwner)
,
and getPreferredSize(IInputModeContext, ILabel)
to set the appropriate properties on args
.
The arguments are always set as Handled
, so label editing is always possible.
onLabelEditing
in interface IEditLabelHelper
args
- The original event arguments.IEditLabelHelper.onLabelAdding(LabelEditingEventArgs)
public final void setGraph(IGraph value)
If this instance is not set, the implementation will try to retrieve the graph from the IInputModeContext
's
ILookup
.
value
- The graph instance.getGraph()