Class TLcdGXYInteractiveLabelsController
- All Implemented Interfaces:
ILcdUndoableSource
,ILcdAWTEventListener
,ILcdStatusSource
,ILcdGXYChainableController
,ILcdGXYController
,KeyListener
,MouseListener
,MouseMotionListener
,Serializable
,EventListener
Component
when the mouse moves over a label, to make the label interactive.
Setting up the controller
To set up interactive labels, first configure regular labeling. Next, implement anALcdGXYInteractiveLabelProvider
that returns the interactive version of the label.
Make sure to call fireInteractionStartedEvent
in the provide method.
Showing and hiding interactive labels
By default, the provider is shown when the mouse moves over a label. In order to start, stop or cancel the interaction manually, the usedALcdGXYInteractiveLabelProvider
can be called directly. This controller
will adjust its state automatically to the state of the interactive label provider.
Using your own label painter
This controller works by setting the 'interactive label' property of the labelsTLcdLabelLocation
to true
. So in order for this controller
to work, label painters should respect this property. They can do this by
- painting the 'interactive' label instead of the 'regular' label.
- not painting the swing components of the interactive label. These should not be painted by the label painter since this controller is responsible for showing the interactive label. The painter should paint the rest of the label (e.g. the pin) however.
Additional prerequisites
- Because the functionality works through
TLcdLabelLocation
object, it will only work for layers implementingILcdGXYEditableLabelsLayer
and label painters implementingILcdGXYLabelPainter2
- Because the functionality is not coupled to the label painter implementation, this controller does not know
the effects of temporary editing behavior
(see
ILcdGXYLabelPainter2
's TRANSLATING, RESHAPING, and CREATING modes), Therefore, it requires instant editing in order to function correctly (seeTLcdGXYEditController2.setInstantEditing(boolean)
).
- Since:
- 11.0
- See Also:
-
Constructor Summary
ConstructorDescriptionTLcdGXYInteractiveLabelsController
(ALcdGXYInteractiveLabelProvider aGXYInteractiveLabelProvider) Creates a newTLcdGXYInteractiveLabelsController
using the given interactive label provider. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addComponentToGXYView
(ILcdGXYView aGXYView, Component aComponent) Adds the specified interactive label to the user interface.void
This method will append the passed controller to the end of the chain.protected boolean
canAddComponentToGXYView
(ILcdGXYView aGXYView) Returns whether or not an interactive label can be added to the given view.protected Component
getComponentForGXYView
(ILcdGXYView aGXYView) Gets the component that represents the givenILcdGXYView
.Returns a reference to the controller that is located after this one in a chain, or null if this controller is the last element of the chain.void
handleAWTEvent
(AWTEvent aEvent) This is method is called when the target of the listener has a new AWTEvent available.boolean
Returns if the object is automatically selected during interaction.void
void
void
void
Will perform a pan depending on the values of isDragging, isPanOnMouseDragExit and isPanOnMouseMoveExit propertiesvoid
void
void
void
Enables the controller to give visual feedback on the current user interactions.protected void
removeComponentFromGXYView
(ILcdGXYView aGXYView, Component aComponent) Removes the specifiedjava.awt.Component
from the user interface.void
This method sets the next controller in the chain for this controller.void
setProvideInteractiveLabelOnMouseOver
(boolean aProvideInteractiveLabelOnMouseOver) Enables theALcdGXYInteractiveLabelProvider
functionality, so that the interactive label is present when the mouse hoovers over a label.void
setSelectObjectDuringInteraction
(boolean aSelectObjectDuringInteraction) Sets if the object should automatically be selected during interaction.void
startInteraction
(ILcdGXYView aGXYView) Sets up the controller to receive input through the view passed.void
terminateInteraction
(ILcdGXYView aGXYView) Releases a few items.Methods inherited from class com.luciad.view.gxy.controller.ALcdGXYSmartController
addUndoableListener, doPanGXYView, doZoomGXYView, fireUndoableEvent, getDownPanChars, getDownPanCodes, getLeftPanChars, getLeftPanCodes, getPanAbsDelta, getPanAbsDelta, getRightPanChars, getRightPanCodes, getUndoableListenerCount, getUpPanChars, getUpPanCodes, getZoomInChars, getZoomInCodes, getZoomOutChars, getZoomOutCodes, isDragging, isPanOnMouseDragExit, isPanOnMouseMoveExit, isPanUndoable, isRequestFocusOnMouseEntered, isRequestFocusOnMousePressed, isTraceOn, isZoomUndoable, keyPressed, keyReleased, keyTyped, removeUndoableListener, setDownPanChars, setDownPanCodes, setIsDragging, setLeftPanChars, setLeftPanCodes, setPanAbsDelta, setPanOnMouseDragExit, setPanOnMouseMoveExit, setPanUndoable, setRequestFocusOnMouseEntered, setRequestFocusOnMousePressed, setRightPanChars, setRightPanCodes, setTraceOn, setUpPanChars, setUpPanCodes, setZoomInChars, setZoomInCodes, setZoomOutChars, setZoomOutCodes, setZoomUndoable, updateViewLocationAfterZoomSFCT
Methods inherited from class com.luciad.view.gxy.controller.ALcdGXYController
addStatusListener, asGXYController, fireStatusEvent, getCursor, getGXYView, getIcon, getName, getShortDescription, registerInstance, removeStatusListener, retrieveGXYViewXYWorldTransformation, setClassTraceOn, setCursor, setGXYView, setIcon, setName, setShortDescription, viewRepaint
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.view.gxy.ILcdGXYController
getCursor, getIcon, getLayered, getName, getShortDescription, viewRepaint
-
Constructor Details
-
TLcdGXYInteractiveLabelsController
public TLcdGXYInteractiveLabelsController(ALcdGXYInteractiveLabelProvider aGXYInteractiveLabelProvider) Creates a newTLcdGXYInteractiveLabelsController
using the given interactive label provider.- Parameters:
aGXYInteractiveLabelProvider
- an interactive label provider. This class will be used to create thejava.awt.Component
for the labels.
-
-
Method Details
-
setProvideInteractiveLabelOnMouseOver
public void setProvideInteractiveLabelOnMouseOver(boolean aProvideInteractiveLabelOnMouseOver) Enables theALcdGXYInteractiveLabelProvider
functionality, so that the interactive label is present when the mouse hoovers over a label. This flag is typically disabled whenever the interactive label functionality is not wanted or when the interactive label behavior should be set up manually.- Parameters:
aProvideInteractiveLabelOnMouseOver
-true
to activate the automatic behavior andfalse
otherwise.
-
isSelectObjectDuringInteraction
public boolean isSelectObjectDuringInteraction()Returns if the object is automatically selected during interaction.- Returns:
- if the object is automatically selected during interaction.
- See Also:
-
setSelectObjectDuringInteraction
public void setSelectObjectDuringInteraction(boolean aSelectObjectDuringInteraction) Sets if the object should automatically be selected during interaction. The default value istrue
.- Parameters:
aSelectObjectDuringInteraction
-true
to automatically select the object during interaction.- See Also:
-
startInteraction
Description copied from class:ALcdGXYController
Sets up the controller to receive input through the view passed.All
ILcdGXYView
implementations that support interaction call this method when the controller has been made active withsetGXYController
on the view, so this method shouldn't normally be called directly. Note that most view implementations add the controller as listener if appropriate before calling this method.Sets the cursor on the view and sets the view for which this controller is now active. Sends out a status event based on the
short description
.- Specified by:
startInteraction
in interfaceILcdGXYController
- Overrides:
startInteraction
in classALcdGXYSmartController
- Parameters:
aGXYView
- theILcdGXYView
thisILcdGXYController
will interact with.- See Also:
-
terminateInteraction
Description copied from class:ALcdGXYController
Releases a few items. Can be redefined but this 'super' method should be called too.- Specified by:
terminateInteraction
in interfaceILcdGXYController
- Overrides:
terminateInteraction
in classALcdGXYSmartController
- Parameters:
aGXYView
- theILcdGXYView
thisILcdGXYController
interacted with.- See Also:
-
paint
Description copied from class:ALcdGXYController
Enables the controller to give visual feedback on the current user interactions. Note that the controller is responsible for repainting the view.Empty implementation. Redefine this method to render on the Graphics on which the view is rendered.
- Specified by:
paint
in interfaceILcdGXYController
- Overrides:
paint
in classALcdGXYController
- Parameters:
aGraphics
- the Graphics on which the view was rendered.
-
canAddComponentToGXYView
Returns whether or not an interactive label can be added to the given view. If this method returnsfalse
,addComponentToGXYView
must not be called. By default this method checks if the givenILcdGXYView
is an instance ofjava.awt.Container
without a layout set on it.Override this method if your
ILcdGXYView
implementation is not ajava.awt.Container
or if you add components to another container than the specifiedILcdGXYView
.- Parameters:
aGXYView
- TheILcdGXYView
for which to check if a component can be added.- Returns:
true
if a component can be added,false
otherwise.- See Also:
-
getComponentForGXYView
Gets the component that represents the givenILcdGXYView
. By default this is the view itself casted tojava.awt.Component
. This information is used for handling mouse events.Override this method if your
ILcdGXYView
implementation does not extend fromjava.awt.Component
.- Parameters:
aGXYView
- The view for which aComponent
must be retrieved.- Returns:
- The
java.awt.Component
which corresponds to the givenILcdGXYView
- Throws:
IllegalArgumentException
- By default whenaGXYView
is not ajava.awt.Component
- See Also:
-
addComponentToGXYView
Adds the specified interactive label to the user interface. By default this method casts the givenILcdGXYView
tojava.awt.Container
and adds the component to the view.Override this method if your implementation of
ILcdGXYView
does not extend fromjava.awt.Container
or if you want to add the interactive label to anotherjava.awt.Container
because, for instance, you already need to add other components to the specifiedILcdGXYView
.If you override this method, you also need to override
canAddComponentToGXYView
andremoveComponentFromGXYView
as these methods are closely related to each other.This method will not be called if
canAddComponentToGXYView
returnsfalse
.- Parameters:
aGXYView
- The view to which the interactive label should be added.aComponent
- The interactive label that should be added to the user interface.- Throws:
IllegalArgumentException
- By default ifaGXYView
is not an instance ofjava.awt.Container
or if the layout ofaGXYView
is not null.- See Also:
-
removeComponentFromGXYView
Removes the specifiedjava.awt.Component
from the user interface. By default this method casts the specifiedILcdGXYView
tojava.awt.Container
and removes the component from that container.Override this method if you have overridden
addComponentToGXYView
.- Parameters:
aGXYView
- The view from which the interactive label should be removed.aComponent
- The interactive label that should be removed from the user interface- Throws:
IllegalArgumentException
- By default if the view does not extend fromjava.awt.Container
-
mouseClicked
- Specified by:
mouseClicked
in interfaceMouseListener
- Overrides:
mouseClicked
in classALcdGXYSmartController
-
mouseMoved
- Specified by:
mouseMoved
in interfaceMouseMotionListener
- Overrides:
mouseMoved
in classALcdGXYSmartController
-
mousePressed
- Specified by:
mousePressed
in interfaceMouseListener
- Overrides:
mousePressed
in classALcdGXYSmartController
-
mouseReleased
- Specified by:
mouseReleased
in interfaceMouseListener
- Overrides:
mouseReleased
in classALcdGXYSmartController
-
mouseDragged
- Specified by:
mouseDragged
in interfaceMouseMotionListener
- Overrides:
mouseDragged
in classALcdGXYSmartController
-
mouseEntered
- Specified by:
mouseEntered
in interfaceMouseListener
- Overrides:
mouseEntered
in classALcdGXYSmartController
-
mouseExited
Description copied from class:ALcdGXYSmartController
Will perform a pan depending on the values of isDragging, isPanOnMouseDragExit and isPanOnMouseMoveExit properties- Specified by:
mouseExited
in interfaceMouseListener
- Overrides:
mouseExited
in classALcdGXYSmartController
-
getNextGXYController
Description copied from interface:ILcdGXYChainableController
Returns a reference to the controller that is located after this one in a chain, or null if this controller is the last element of the chain.- Specified by:
getNextGXYController
in interfaceILcdGXYChainableController
- Returns:
- a reference to the next controller.
- See Also:
-
setNextGXYController
Description copied from interface:ILcdGXYChainableController
This method sets the next controller in the chain for this controller. You can set null if you want the chain to end. This method does not start or terminate any interaction. If you need to replace a controller while it's being used you are responsible for properly terminating and starting it yourself.- Specified by:
setNextGXYController
in interfaceILcdGXYChainableController
- Parameters:
aNext
- the reference to the controller that will be the next element in the chain- See Also:
-
appendGXYController
Description copied from interface:ILcdGXYChainableController
This method will append the passed controller to the end of the chain. The controller will be the stored as the next controller in the last element of the current chain.- Specified by:
appendGXYController
in interfaceILcdGXYChainableController
- Parameters:
aEnd
- the controller to be appended to the end of the chain.
-
handleAWTEvent
Description copied from interface:ILcdAWTEventListener
This is method is called when the target of the listener has a new AWTEvent available.- Specified by:
handleAWTEvent
in interfaceILcdAWTEventListener
- Parameters:
aEvent
- The event to be handled.
-