public abstract class ALcdGXYInteractiveLabelProvider extends Object
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
.
TLcdGXYInteractiveLabelsController
,
About label- and sublabel-indices
Modifier and Type | Class and Description |
---|---|
static interface |
ALcdGXYInteractiveLabelProvider.LabelInteractionListener
This listener can be used to be notified when interaction is started, stopped or cancelled.
|
Constructor and Description |
---|
ALcdGXYInteractiveLabelProvider() |
Modifier and Type | Method and Description |
---|---|
void |
addLabelInteractionListener(ALcdGXYInteractiveLabelProvider.LabelInteractionListener aListener)
|
abstract void |
cancelInteraction()
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 this
ALcdGXYInteractiveLabelProvider can
provide a Component for the specified label. |
abstract boolean |
canStopInteraction()
Returns whether or not the interactive label that was last provided can be stopped.
|
protected AWTEvent |
convertAWTEvent(AWTEvent aAWTEvent,
Component aGXYView)
The
dispatch*Event method might decide an AWTEvent must be dispatched on another
component. |
void |
dispatchAWTEvent(AWTEvent aAWTEvent,
Component aInteractiveLabel,
Component aGXYView)
Dispatches an
AWTEvent to either the interactive label or the
ILcdGXYView to which it belongs. |
void |
dispatchMouseEvent(MouseEvent aMouseEvent,
Component aInteractiveLabel,
Component aGXYView)
Dispatches a
MouseEvent to either the interactive label or the
ILcdGXYView to which it belongs. |
protected void |
fireInteractionCancelledEvent()
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 |
fireInteractionStoppedEvent()
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 of
aObject . |
void |
removeLabelInteractionListener(ALcdGXYInteractiveLabelProvider.LabelInteractionListener aListener)
Removes the given
ALcdGXYInteractiveLabelProvider.LabelInteractionListener . |
abstract boolean |
stopInteraction()
Tells the interactive label that was last provided to stop editing.
|
public abstract boolean canProvideInteractiveLabel(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdGXYContext aGXYContext)
This method determines whether or not this ALcdGXYInteractiveLabelProvider
can
provide a Component
for the specified label. This method should be called before
calling provideInteractiveLabel
.
aObject
- The domain object of the label for which to determine if a
Component
can be provided.aLabelIndex
- The index of the label for which to determine if a Component
can be provided.aSubLabelIndex
- The index of the sublabel for which to determine if a
Component
can be provided.aGXYContext
- The ILcdGXYContext
instance containing the layer and view.
The location information is not filled in.true
if this ALcdGXYInteractiveLabelProvider
can provide a
Component
for the specified label, false
otherwise.About label- and sublabel-indices
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, either stopInteraction()
or cancelInteraction()
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.
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
- The ILcdGXYContext
instance containing the layer and view.
The location information is not filled in.Component
, configured to display or edit the properties of the given
domain object.About label- and sublabel-indices
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
.
true
if the interactive label can be stopped, false
otherwise.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.
true
if the interactive label could be stopped, false
otherwise.canStopInteraction()
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.
public void dispatchMouseEvent(MouseEvent aMouseEvent, Component aInteractiveLabel, Component aGXYView)
Dispatches a MouseEvent
to either the interactive label or the
ILcdGXYView
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
the TLcdGXYEditController2
, it can move the label.
By default this method dispatches to the ILcdGXYView
when the source of
aMouseEvent
is a JLabel
or a JPanel
. Otherwise it
dispatches the mouse event to that source itself.
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 if ALcdGXYInteractiveStampLabelPainter.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 with SwingUtilities#convertMouseEvent
. By
default, this conversion is done in the convertAWTEvent
method.public void dispatchAWTEvent(AWTEvent aAWTEvent, Component aInteractiveLabel, Component aGXYView)
Dispatches an AWTEvent
to either the interactive label or the
ILcdGXYView
to which it belongs. When an AWTEvent
is passed to the
view, its associated controller can handle the events. For instance, when the active controller
is TLcdGXYEditController2
, it can move the label.
By default this method dispatches mouse events to the ILcdGXYView
when the source of the
event is a JLabel
or a JPanel
.
Otherwise it dispatches the AWTEvent
to that source itself.
For MouseEvent
s, this method by default delegates to the dispatchMouseEvent
method.
aAWTEvent
- The AWTEvent
that needs to be dispatched. The source of
this AWTEvent
is the child component of the interactive
label.aInteractiveLabel
- The interactive label to which the source of the AWTEvent
belongs. This is contextual information. It is not the intention that
the AWTEvent
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 if ALcdGXYInteractiveStampLabelPainter.getComponentForGXYView(ILcdGXYView)
is overridden. Dispatch to this component if the view should receive
the AWTEvent
. In this case the AWTEvent
must
be converted. By default, this conversion is done in the convertAWTEvent
method.protected AWTEvent convertAWTEvent(AWTEvent aAWTEvent, Component aGXYView)
dispatch*Event
method might decide an AWTEvent
must be dispatched on another
component. In this case, the event must be converted. This is done by this method.aAWTEvent
- the event which must be convertedaGXYView
- the component to which the event will be dispatchedAWTEvent
dispatchAWTEvent(java.awt.AWTEvent, java.awt.Component, java.awt.Component)
,
dispatchMouseEvent(java.awt.event.MouseEvent, java.awt.Component, java.awt.Component)
public void addLabelInteractionListener(ALcdGXYInteractiveLabelProvider.LabelInteractionListener aListener)
ALcdGXYInteractiveLabelProvider.LabelInteractionListener
. This listener should be used to notify when interaction
with an interactive label was stopped or cancelled.aListener
- a LabelInteractionListener
.public void removeLabelInteractionListener(ALcdGXYInteractiveLabelProvider.LabelInteractionListener aListener)
ALcdGXYInteractiveLabelProvider.LabelInteractionListener
. After calling this method, the given
listener will not be notified when interaction with an interactive label was stopped or
cancelled anymore.aListener
- a LabelInteractionListener
.protected void fireInteractionStartedEvent(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdGXYContext aGXYContext, Component aInteractiveLabel)
addLabelInteractionListener(com.luciad.view.gxy.ALcdGXYInteractiveLabelProvider.LabelInteractionListener)
.
Implementations should call this method when interaction has started.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.provideInteractiveLabel(Object, int, int, ILcdGXYContext)
protected void fireInteractionStoppedEvent()
addLabelInteractionListener(com.luciad.view.gxy.ALcdGXYInteractiveLabelProvider.LabelInteractionListener)
.
Implementations should call this method when interaction has stopped.stopInteraction()
protected void fireInteractionCancelledEvent()
addLabelInteractionListener(com.luciad.view.gxy.ALcdGXYInteractiveLabelProvider.LabelInteractionListener)
.
Implementations should call this method when interaction has been cancelled.cancelInteraction()