Class ALcdGXYInteractiveLabelProvider

java.lang.Object
com.luciad.view.gxy.ALcdGXYInteractiveLabelProvider

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.

Since:
7.0
See Also:
  • 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 a Component for the specified label. This method should be called before calling provideInteractiveLabel.

      Parameters:
      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.
      Returns:
      true if this ALcdGXYInteractiveLabelProvider can provide a Component 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, 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.

      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 requested
      aGXYContext - The ILcdGXYContext 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 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.

      Parameters:
      aMouseEvent - The mouse event that needs to be dispatched. The source of this mouse event is the child component of the interactive label
      aInteractiveLabel - 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.
    • dispatchAWTEvent

      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 MouseEvents, this method by default delegates to the dispatchMouseEvent method.

      Parameters:
      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.
      Since:
      10.0
    • convertAWTEvent

      protected AWTEvent convertAWTEvent(AWTEvent aAWTEvent, Component aGXYView)
      The 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.
      Parameters:
      aAWTEvent - the event which must be converted
      aGXYView - 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 a ALcdGXYInteractiveLabelProvider.LabelInteractionListener. This listener should be used to notify when interaction with an interactive label was stopped or cancelled.
      Parameters:
      aListener - a LabelInteractionListener.
    • removeLabelInteractionListener

      public void removeLabelInteractionListener(ALcdGXYInteractiveLabelProvider.LabelInteractionListener aListener)
      Removes the given ALcdGXYInteractiveLabelProvider.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 - a LabelInteractionListener.
    • 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 using addLabelInteractionListener(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 using addLabelInteractionListener(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 using addLabelInteractionListener(com.luciad.view.gxy.ALcdGXYInteractiveLabelProvider.LabelInteractionListener). Implementations should call this method when interaction has been cancelled.
      See Also: