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
TLcdLabelLocationobject, it will only work for layers implementingILcdGXYEditableLabelsLayerand 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
ConstructorsConstructorDescriptionTLcdGXYInteractiveLabelsController(ALcdGXYInteractiveLabelProvider aGXYInteractiveLabelProvider) Creates a newTLcdGXYInteractiveLabelsControllerusing the given interactive label provider. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddComponentToGXYView(ILcdGXYView aGXYView, Component aComponent) Adds the specified interactive label to the user interface.voidThis method will append the passed controller to the end of the chain.protected booleancanAddComponentToGXYView(ILcdGXYView aGXYView) Returns whether or not an interactive label can be added to the given view.protected ComponentgetComponentForGXYView(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.voidhandleAWTEvent(AWTEvent aEvent) This is method is called when the target of the listener has a new AWTEvent available.booleanReturns if the object is automatically selected during interaction.voidvoidvoidvoidWill perform a pan depending on the values of isDragging, isPanOnMouseDragExit and isPanOnMouseMoveExit propertiesvoidvoidvoidvoidEnables the controller to give visual feedback on the current user interactions.protected voidremoveComponentFromGXYView(ILcdGXYView aGXYView, Component aComponent) Removes the specifiedjava.awt.Componentfrom the user interface.voidThis method sets the next controller in the chain for this controller.voidsetProvideInteractiveLabelOnMouseOver(boolean aProvideInteractiveLabelOnMouseOver) Enables theALcdGXYInteractiveLabelProviderfunctionality, so that the interactive label is present when the mouse hoovers over a label.voidsetSelectObjectDuringInteraction(boolean aSelectObjectDuringInteraction) Sets if the object should automatically be selected during interaction.voidstartInteraction(ILcdGXYView aGXYView) Sets up the controller to receive input through the view passed.voidterminateInteraction(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, updateViewLocationAfterZoomSFCTMethods 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, viewRepaintMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.view.gxy.ILcdGXYController
getCursor, getIcon, getLayered, getName, getShortDescription, viewRepaint
-
Constructor Details
-
TLcdGXYInteractiveLabelsController
public TLcdGXYInteractiveLabelsController(ALcdGXYInteractiveLabelProvider aGXYInteractiveLabelProvider) Creates a newTLcdGXYInteractiveLabelsControllerusing the given interactive label provider.- Parameters:
aGXYInteractiveLabelProvider- an interactive label provider. This class will be used to create thejava.awt.Componentfor the labels.
-
-
Method Details
-
setProvideInteractiveLabelOnMouseOver
public void setProvideInteractiveLabelOnMouseOver(boolean aProvideInteractiveLabelOnMouseOver) Enables theALcdGXYInteractiveLabelProviderfunctionality, 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-trueto activate the automatic behavior andfalseotherwise.
-
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-trueto automatically select the object during interaction.- See Also:
-
startInteraction
Description copied from class:ALcdGXYControllerSets up the controller to receive input through the view passed.All
ILcdGXYViewimplementations that support interaction call this method when the controller has been made active withsetGXYControlleron 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:
startInteractionin interfaceILcdGXYController- Overrides:
startInteractionin classALcdGXYSmartController- Parameters:
aGXYView- theILcdGXYViewthisILcdGXYControllerwill interact with.- See Also:
-
terminateInteraction
Description copied from class:ALcdGXYControllerReleases a few items. Can be redefined but this 'super' method should be called too.- Specified by:
terminateInteractionin interfaceILcdGXYController- Overrides:
terminateInteractionin classALcdGXYSmartController- Parameters:
aGXYView- theILcdGXYViewthisILcdGXYControllerinteracted with.- See Also:
-
paint
Description copied from class:ALcdGXYControllerEnables 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:
paintin interfaceILcdGXYController- Overrides:
paintin 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,addComponentToGXYViewmust not be called. By default this method checks if the givenILcdGXYViewis an instance ofjava.awt.Containerwithout a layout set on it.Override this method if your
ILcdGXYViewimplementation is not ajava.awt.Containeror if you add components to another container than the specifiedILcdGXYView.- Parameters:
aGXYView- TheILcdGXYViewfor which to check if a component can be added.- Returns:
trueif a component can be added,falseotherwise.- 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
ILcdGXYViewimplementation does not extend fromjava.awt.Component.- Parameters:
aGXYView- The view for which aComponentmust be retrieved.- Returns:
- The
java.awt.Componentwhich corresponds to the givenILcdGXYView - Throws:
IllegalArgumentException- By default whenaGXYViewis not ajava.awt.Component- See Also:
-
addComponentToGXYView
Adds the specified interactive label to the user interface. By default this method casts the givenILcdGXYViewtojava.awt.Containerand adds the component to the view.Override this method if your implementation of
ILcdGXYViewdoes not extend fromjava.awt.Containeror if you want to add the interactive label to anotherjava.awt.Containerbecause, for instance, you already need to add other components to the specifiedILcdGXYView.If you override this method, you also need to override
canAddComponentToGXYViewandremoveComponentFromGXYViewas these methods are closely related to each other.This method will not be called if
canAddComponentToGXYViewreturnsfalse.- 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 ifaGXYViewis not an instance ofjava.awt.Containeror if the layout ofaGXYViewis not null.- See Also:
-
removeComponentFromGXYView
Removes the specifiedjava.awt.Componentfrom the user interface. By default this method casts the specifiedILcdGXYViewtojava.awt.Containerand 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:
mouseClickedin interfaceMouseListener- Overrides:
mouseClickedin classALcdGXYSmartController
-
mouseMoved
- Specified by:
mouseMovedin interfaceMouseMotionListener- Overrides:
mouseMovedin classALcdGXYSmartController
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener- Overrides:
mousePressedin classALcdGXYSmartController
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener- Overrides:
mouseReleasedin classALcdGXYSmartController
-
mouseDragged
- Specified by:
mouseDraggedin interfaceMouseMotionListener- Overrides:
mouseDraggedin classALcdGXYSmartController
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener- Overrides:
mouseEnteredin classALcdGXYSmartController
-
mouseExited
Description copied from class:ALcdGXYSmartControllerWill perform a pan depending on the values of isDragging, isPanOnMouseDragExit and isPanOnMouseMoveExit properties- Specified by:
mouseExitedin interfaceMouseListener- Overrides:
mouseExitedin classALcdGXYSmartController
-
getNextGXYController
Description copied from interface:ILcdGXYChainableControllerReturns 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:
getNextGXYControllerin interfaceILcdGXYChainableController- Returns:
- a reference to the next controller.
- See Also:
-
setNextGXYController
Description copied from interface:ILcdGXYChainableControllerThis 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:
setNextGXYControllerin interfaceILcdGXYChainableController- Parameters:
aNext- the reference to the controller that will be the next element in the chain- See Also:
-
appendGXYController
Description copied from interface:ILcdGXYChainableControllerThis 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:
appendGXYControllerin interfaceILcdGXYChainableController- Parameters:
aEnd- the controller to be appended to the end of the chain.
-
handleAWTEvent
Description copied from interface:ILcdAWTEventListenerThis is method is called when the target of the listener has a new AWTEvent available.- Specified by:
handleAWTEventin interfaceILcdAWTEventListener- Parameters:
aEvent- The event to be handled.
-