Class ALcdGXYInteractiveLabelProvider
An ALcdGXYInteractiveLabelProvider
can provide a java.awt.Component
that can be shown to the user so he can modify the properties of the object. One can think of
this Component
as a rich, interactive label.
This provider is used by TLcdGXYInteractiveLabelsController
to provide an interactive label
when the user moves his mouse cursor over one of its label. This provider is asked if it can
provide a Component
for the label with the canProvideInteractiveLabel(java.lang.Object, int, int, com.luciad.view.gxy.ILcdGXYContext)
method, and if it can it is then asked to provide Component
for it with the provideInteractiveLabel(java.lang.Object, int, int, com.luciad.view.gxy.ILcdGXYContext)
method.
At all times there will be at most one interactive label active from a single
ALcdGXYInteractiveLabelProvider
. This means implementations can return the same
java.awt.Component
instance every time they are asked to provide an interactive
label.
Between two calls to provideInteractiveLabel
, the label interaction will always
be stopped, either with stopInteraction
or otherwise with
cancelInteraction
.
- Since:
- 7.0
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
This listener can be used to be notified when interaction is started, stopped or cancelled. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
abstract void
Cancels the interaction with the interactive label that was last provided.abstract boolean
canProvideInteractiveLabel
(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdGXYContext aGXYContext) This method determines whether or not thisALcdGXYInteractiveLabelProvider
can provide aComponent
for the specified label.abstract boolean
Returns whether or not the interactive label that was last provided can be stopped.protected AWTEvent
convertAWTEvent
(AWTEvent aAWTEvent, Component aGXYView) Thedispatch*Event
method might decide anAWTEvent
must be dispatched on another component.void
dispatchAWTEvent
(AWTEvent aAWTEvent, Component aInteractiveLabel, Component aGXYView) Dispatches anAWTEvent
to either the interactive label or theILcdGXYView
to which it belongs.void
dispatchMouseEvent
(MouseEvent aMouseEvent, Component aInteractiveLabel, Component aGXYView) Dispatches aMouseEvent
to either the interactive label or theILcdGXYView
to which it belongs.protected void
This method should be called to fire an 'interaction cancelled' event.protected void
fireInteractionStartedEvent
(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdGXYContext aGXYContext, Component aInteractiveLabel) This method should be called to fire an 'interaction started' event.protected void
This method should be called to fire an 'interaction stopped' event.abstract Component
provideInteractiveLabel
(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdGXYContext aGXYContext) Returns a component, configured to display or edit the properties ofaObject
.void
Removes the givenALcdGXYInteractiveLabelProvider.LabelInteractionListener
.abstract boolean
Tells the interactive label that was last provided to stop editing.
-
Constructor Details
-
ALcdGXYInteractiveLabelProvider
public ALcdGXYInteractiveLabelProvider()
-
-
Method Details
-
canProvideInteractiveLabel
public abstract boolean canProvideInteractiveLabel(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdGXYContext aGXYContext) This method determines whether or not this
ALcdGXYInteractiveLabelProvider
can provide aComponent
for the specified label. This method should be called before callingprovideInteractiveLabel
.- Parameters:
aObject
- The domain object of the label for which to determine if aComponent
can be provided.aLabelIndex
- The index of the label for which to determine if aComponent
can be provided.aSubLabelIndex
- The index of the sublabel for which to determine if aComponent
can be provided.aGXYContext
- TheILcdGXYContext
instance containing the layer and view. The location information is not filled in.- Returns:
true
if thisALcdGXYInteractiveLabelProvider
can provide aComponent
for the specified label,false
otherwise.- See Also:
-
provideInteractiveLabel
public abstract Component provideInteractiveLabel(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdGXYContext aGXYContext) Returns a component, configured to display or edit the properties of
aObject
. Before this method is called again, eitherstopInteraction()
orcancelInteraction()
will be called - depending on user interaction - allowing the implementation to perform any necessary cleanup operations.This method will not be called unless
canProvideInteractiveLabel
returns true for the same arguments.- Parameters:
aObject
- The domain object of the label for which the component is requested.aLabelIndex
- The index of the label for which the component is requested.aSubLabelIndex
- The index of the sublabel for which the component is requestedaGXYContext
- TheILcdGXYContext
instance containing the layer and view. The location information is not filled in.- Returns:
- A
Component
, configured to display or edit the properties of the given domain object. - See Also:
-
canStopInteraction
public abstract boolean canStopInteraction()Returns whether or not the interactive label that was last provided can be stopped. For instance, if the interactive label is in a non-valid state, this method should return
false
.- Returns:
true
if the interactive label can be stopped,false
otherwise.- See Also:
-
stopInteraction
public abstract boolean stopInteraction()Tells the interactive label that was last provided to stop editing. Any outstanding changes should be persisted when this method is called.
This method is always called after the call to
provideInteractiveLabel(java.lang.Object, int, int, com.luciad.view.gxy.ILcdGXYContext)
and before the provided component is removed from the user interface.This method returns a boolean indicating whether or not the interactive label could be stopped. If the interactive label could not be stopped, this provider could choose to change the interactive label to visually indicate what prevents it from being stopped. For instance, if a text field in the interactive label contained invalid text, the text in the text field could be shown in red.
This method should return the same value as the
canStopInteraction
method. The reason that method exists is that that method does not imply that the client actually wants to stop, whereas this method does.- Returns:
true
if the interactive label could be stopped,false
otherwise.- See Also:
-
cancelInteraction
public abstract void cancelInteraction()Cancels the interaction with the interactive label that was last provided. Any outstanding changes should be discarded when this method is called.
This method is always called after the call to
provideInteractiveLabel(java.lang.Object, int, int, com.luciad.view.gxy.ILcdGXYContext)
and before the provided component is removed from the user interface. -
dispatchMouseEvent
public void dispatchMouseEvent(MouseEvent aMouseEvent, Component aInteractiveLabel, Component aGXYView) Dispatches a
MouseEvent
to either the interactive label or theILcdGXYView
to which it belongs. When a mouse event is passed to the view, its associated controller can handle the mouse events. For instance, when the active controller is theTLcdGXYEditController2
, it can move the label.By default this method dispatches to the
ILcdGXYView
when the source ofaMouseEvent
is aJLabel
or aJPanel
. Otherwise it dispatches the mouse event to that source itself.- Parameters:
aMouseEvent
- The mouse event that needs to be dispatched. The source of this mouse event is the child component of the interactive labelaInteractiveLabel
- The interactive label to which the source of the mouse event belongs. This is contextual information. It is not the intention that the mouse event is dispatched to this component.aGXYView
- The component representing the view. Most of the time this will be the view itself, but it can be different ifALcdGXYInteractiveStampLabelPainter.getComponentForGXYView(ILcdGXYView)
is overridden. Dispatch to this component if the view should receive the mouse event. In that case the mouse event must be converted, for instance withSwingUtilities#convertMouseEvent
. By default, this conversion is done in theconvertAWTEvent
method.
-
dispatchAWTEvent
Dispatches an
AWTEvent
to either the interactive label or theILcdGXYView
to which it belongs. When anAWTEvent
is passed to the view, its associated controller can handle the events. For instance, when the active controller isTLcdGXYEditController2
, it can move the label.By default this method dispatches mouse events to the
ILcdGXYView
when the source of the event is aJLabel
or aJPanel
. Otherwise it dispatches theAWTEvent
to that source itself.For
MouseEvent
s, this method by default delegates to thedispatchMouseEvent
method.- Parameters:
aAWTEvent
- TheAWTEvent
that needs to be dispatched. The source of thisAWTEvent
is the child component of the interactive label.aInteractiveLabel
- The interactive label to which the source of theAWTEvent
belongs. This is contextual information. It is not the intention that theAWTEvent
is dispatched to this component.aGXYView
- The component representing the view. Most of the time this will be the view itself, but it can be different ifALcdGXYInteractiveStampLabelPainter.getComponentForGXYView(ILcdGXYView)
is overridden. Dispatch to this component if the view should receive theAWTEvent
. In this case theAWTEvent
must be converted. By default, this conversion is done in theconvertAWTEvent
method.- Since:
- 10.0
-
convertAWTEvent
Thedispatch*Event
method might decide anAWTEvent
must be dispatched on another component. In this case, the event must be converted. This is done by this method.- Parameters:
aAWTEvent
- the event which must be convertedaGXYView
- the component to which the event will be dispatched- Returns:
- the converted
AWTEvent
- Since:
- 10.0
- See Also:
-
addLabelInteractionListener
public void addLabelInteractionListener(ALcdGXYInteractiveLabelProvider.LabelInteractionListener aListener) Adds aALcdGXYInteractiveLabelProvider.LabelInteractionListener
. This listener should be used to notify when interaction with an interactive label was stopped or cancelled.- Parameters:
aListener
- aLabelInteractionListener
.
-
removeLabelInteractionListener
public void removeLabelInteractionListener(ALcdGXYInteractiveLabelProvider.LabelInteractionListener aListener) Removes the givenALcdGXYInteractiveLabelProvider.LabelInteractionListener
. After calling this method, the given listener will not be notified when interaction with an interactive label was stopped or cancelled anymore.- Parameters:
aListener
- aLabelInteractionListener
.
-
fireInteractionStartedEvent
protected void fireInteractionStartedEvent(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdGXYContext aGXYContext, Component aInteractiveLabel) This method should be called to fire an 'interaction started' event. This method will call all listeners that were registered usingaddLabelInteractionListener(com.luciad.view.gxy.ALcdGXYInteractiveLabelProvider.LabelInteractionListener)
. Implementations should call this method when interaction has started.- Parameters:
aObject
- the object for the interactive label.aLabelIndex
- the label index of the interactive label.aSubLabelIndex
- the sublabel index of the interactive label.aGXYContext
- the context.aInteractiveLabel
- the component used for the interactive label.- See Also:
-
fireInteractionStoppedEvent
protected void fireInteractionStoppedEvent()This method should be called to fire an 'interaction stopped' event. This method will call all listeners that were registered usingaddLabelInteractionListener(com.luciad.view.gxy.ALcdGXYInteractiveLabelProvider.LabelInteractionListener)
. Implementations should call this method when interaction has stopped.- See Also:
-
fireInteractionCancelledEvent
protected void fireInteractionCancelledEvent()This method should be called to fire an 'interaction cancelled' event. This method will call all listeners that were registered usingaddLabelInteractionListener(com.luciad.view.gxy.ALcdGXYInteractiveLabelProvider.LabelInteractionListener)
. Implementations should call this method when interaction has been cancelled.- See Also:
-