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
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThis listener can be used to be notified when interaction is started, stopped or cancelled. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidabstract voidCancels the interaction with the interactive label that was last provided.abstract booleancanProvideInteractiveLabel(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdGXYContext aGXYContext) This method determines whether or not thisALcdGXYInteractiveLabelProvidercan provide aComponentfor the specified label.abstract booleanReturns whether or not the interactive label that was last provided can be stopped.protected AWTEventconvertAWTEvent(AWTEvent aAWTEvent, Component aGXYView) Thedispatch*Eventmethod might decide anAWTEventmust be dispatched on another component.voiddispatchAWTEvent(AWTEvent aAWTEvent, Component aInteractiveLabel, Component aGXYView) Dispatches anAWTEventto either the interactive label or theILcdGXYViewto which it belongs.voiddispatchMouseEvent(MouseEvent aMouseEvent, Component aInteractiveLabel, Component aGXYView) Dispatches aMouseEventto either the interactive label or theILcdGXYViewto which it belongs.protected voidThis method should be called to fire an 'interaction cancelled' event.protected voidfireInteractionStartedEvent(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdGXYContext aGXYContext, Component aInteractiveLabel) This method should be called to fire an 'interaction started' event.protected voidThis method should be called to fire an 'interaction stopped' event.abstract ComponentprovideInteractiveLabel(Object aObject, int aLabelIndex, int aSubLabelIndex, ILcdGXYContext aGXYContext) Returns a component, configured to display or edit the properties ofaObject.voidRemoves the givenALcdGXYInteractiveLabelProvider.LabelInteractionListener.abstract booleanTells 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
ALcdGXYInteractiveLabelProvidercan provide aComponentfor the specified label. This method should be called before callingprovideInteractiveLabel.- Parameters:
aObject- The domain object of the label for which to determine if aComponentcan be provided.aLabelIndex- The index of the label for which to determine if aComponentcan be provided.aSubLabelIndex- The index of the sublabel for which to determine if aComponentcan be provided.aGXYContext- TheILcdGXYContextinstance containing the layer and view. The location information is not filled in.- Returns:
trueif thisALcdGXYInteractiveLabelProvidercan provide aComponentfor the specified label,falseotherwise.- 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
canProvideInteractiveLabelreturns 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- TheILcdGXYContextinstance 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:
trueif the interactive label can be stopped,falseotherwise.- 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
canStopInteractionmethod. The reason that method exists is that that method does not imply that the client actually wants to stop, whereas this method does.- Returns:
trueif the interactive label could be stopped,falseotherwise.- 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
MouseEventto either the interactive label or theILcdGXYViewto 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
ILcdGXYViewwhen the source ofaMouseEventis aJLabelor 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 theconvertAWTEventmethod.
-
dispatchAWTEvent
Dispatches an
AWTEventto either the interactive label or theILcdGXYViewto which it belongs. When anAWTEventis 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
ILcdGXYViewwhen the source of the event is aJLabelor aJPanel. Otherwise it dispatches theAWTEventto that source itself.For
MouseEvents, this method by default delegates to thedispatchMouseEventmethod.- Parameters:
aAWTEvent- TheAWTEventthat needs to be dispatched. The source of thisAWTEventis the child component of the interactive label.aInteractiveLabel- The interactive label to which the source of theAWTEventbelongs. This is contextual information. It is not the intention that theAWTEventis 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 theAWTEventmust be converted. By default, this conversion is done in theconvertAWTEventmethod.- Since:
- 10.0
-
convertAWTEvent
Thedispatch*Eventmethod might decide anAWTEventmust 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:
-