Class TLcdGXYZoomWheelController
- All Implemented Interfaces:
ILcdUndoableSource,ILcdAWTEventListener,ILcdStatusSource,ILcdGXYChainableController,ILcdGXYController,MouseMotionListener,MouseWheelListener,Serializable,EventListener
When the mouse wheel is scrolled then the scale of the view to which this controller is set is changed exponentially. The direction of the zoom (in or out for forward scrolling) and the zooming factor can be set.
The controller allows setting whether the view should be repainted continuously or not. When the view contains layers which take a long time to paint and which are not painted asynchronously it is not advisable to use continuous painting as the higher number of repaints blocks the GUI for a longer time.
- Since:
- 8.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newTLcdGXYZoomWheelControllerthat zooms out when scrolling down and zooms in when scrolling up.TLcdGXYZoomWheelController(boolean aScrollUpZoomOut, boolean aContinuousRepaint) Constructs a newTLcdGXYZoomWheelController. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddUndoableListener(ILcdUndoableListener aListener) Adds a listener to this source, so this listener is notified when something undoable has happened.voidThis method will append the passed controller to the end of the chain.protected voidfireUndoableHappened(ILcdUndoable aUndoable) 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.Returns the scale level provider used for ctrl-zoom.doubleReturns the factor by which the view will be zoomed in or out for one mouse wheel 'click'.voidhandleAWTEvent(AWTEvent aEvent) This is method is called when the target of the listener has a new AWTEvent available.booleanReturns if snapping to scale levels is enabled when holding the control key.voidmouseDragged(MouseEvent aMouseEvent) Stores the location to zoom in to or to zoom out from.voidmouseMoved(MouseEvent aMouseEvent) Stores the location to zoom in to or to zoom out from.voidZooms the map in or out or stores the total mouse wheel activity depending on whether the view should be repainted continuously or not.voidEnables the controller to give visual feedback on the current user interactions.voidremoveUndoableListener(ILcdUndoableListener aListener) Removes the specified listener so it is no longer notified.voidsetEnableSnapToScaleLevels(boolean aEnableSnapToScaleLevels) Enables or disables snapping to scale levels when holding the control key.voidThis method sets the next controller in the chain for this controller.voidsetScaleLevelProvider(ILcdGXYScaleLevelProvider aScaleLevelProvider) Sets the scale level provider used for ctrl-zoom.voidsetZoomFactor(double aZoomFactor) Sets the factor by which the view will be zoomed in or out for one mouse wheel 'click'.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.ALcdGXYController
addStatusListener, asGXYController, fireStatusEvent, getCursor, getGXYView, getIcon, getName, getShortDescription, isTraceOn, registerInstance, removeStatusListener, retrieveGXYViewXYWorldTransformation, setClassTraceOn, setCursor, setGXYView, setIcon, setName, setShortDescription, setTraceOn, 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
-
TLcdGXYZoomWheelController
public TLcdGXYZoomWheelController()Creates a newTLcdGXYZoomWheelControllerthat zooms out when scrolling down and zooms in when scrolling up. It repaints continuously, on every mouse wheel change. -
TLcdGXYZoomWheelController
public TLcdGXYZoomWheelController(boolean aScrollUpZoomOut, boolean aContinuousRepaint) Constructs a newTLcdGXYZoomWheelController.- Parameters:
aScrollUpZoomOut- the zoom direction of the scroll wheel.truemeans when the scroll wheel is pushed away from the user (scroll up), the map 'moves away' (zooms out). If set to false, scrolling up means zooming in.aContinuousRepaint- true means the map will be zoomed on every mouse wheel change. On false, mouse wheel changes are accumulated and performed only once.
-
-
Method Details
-
addUndoableListener
Description copied from interface:ILcdUndoableSourceAdds a listener to this source, so this listener is notified when something undoable has happened.- Specified by:
addUndoableListenerin interfaceILcdUndoableSource- Parameters:
aListener- The listener to be notified when something undoable has happened.
-
removeUndoableListener
Description copied from interface:ILcdUndoableSourceRemoves the specified listener so it is no longer notified.- Specified by:
removeUndoableListenerin interfaceILcdUndoableSource- Parameters:
aListener- The listener to remove.
-
fireUndoableHappened
-
getZoomFactor
public double getZoomFactor()Returns the factor by which the view will be zoomed in or out for one mouse wheel 'click'. The default value is 1.3.- Returns:
- the factor by which the view will be zoomed in or out for one mouse wheel 'click'.
- See Also:
-
setZoomFactor
public void setZoomFactor(double aZoomFactor) Sets the factor by which the view will be zoomed in or out for one mouse wheel 'click'. The default value is 1.3.- Parameters:
aZoomFactor- the factor by which the view will be zoomed in or out for one mouse wheel 'click'.- See Also:
-
setEnableSnapToScaleLevels
public void setEnableSnapToScaleLevels(boolean aEnableSnapToScaleLevels) Enables or disables snapping to scale levels when holding the control key. If enabled, the configured scale level provider will be used to determine the scale to snap to.- Parameters:
aEnableSnapToScaleLevels-trueto enable snapping to scale levels.- See Also:
-
isEnableSnapToScaleLevels
public boolean isEnableSnapToScaleLevels()Returns if snapping to scale levels is enabled when holding the control key. By default, snapping to scale levels is enabled.- Returns:
- if snapping to scale levels is enabled.
- See Also:
-
getScaleLevelProvider
Returns the scale level provider used for ctrl-zoom.- Returns:
- the scale level provider used for ctrl-zoom.
- See Also:
-
setScaleLevelProvider
Sets the scale level provider used for ctrl-zoom.
The default provider supports raster models containing
ILcdRasterorILcdMultilevelRasterelements.When an empty array, or
nullis returned, no zooming will be performed.- Parameters:
aScaleLevelProvider- the scale level provider used for ctrl-zoom.- See Also:
-
mouseMoved
Stores the location to zoom in to or to zoom out from.- Specified by:
mouseMovedin interfaceMouseMotionListener- Parameters:
aMouseEvent- contains the location on the map to zoom in to or to zoom out from.
-
mouseDragged
Stores the location to zoom in to or to zoom out from.- Specified by:
mouseDraggedin interfaceMouseMotionListener- Parameters:
aMouseEvent- contains the location on the map to zoom in to or to zoom out from.
-
mouseWheelMoved
Zooms the map in or out or stores the total mouse wheel activity depending on whether the view should be repainted continuously or not.- Specified by:
mouseWheelMovedin interfaceMouseWheelListener- Parameters:
e- contains the mouse wheel clicks. These are only taken into account when none of the modifiers is activated.
-
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.
-
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 classALcdGXYController- 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 classALcdGXYController- Parameters:
aGXYView- theILcdGXYViewthisILcdGXYControllerinteracted with.- See Also:
-
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.
-