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
ConstructorDescriptionCreates a newTLcdGXYZoomWheelController
that zooms out when scrolling down and zooms in when scrolling up.TLcdGXYZoomWheelController
(boolean aScrollUpZoomOut, boolean aContinuousRepaint) Constructs a newTLcdGXYZoomWheelController
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addUndoableListener
(ILcdUndoableListener aListener) Adds a listener to this source, so this listener is notified when something undoable has happened.void
This method will append the passed controller to the end of the chain.protected void
fireUndoableHappened
(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.double
Returns the factor by which the view will be zoomed in or out for one mouse wheel 'click'.void
handleAWTEvent
(AWTEvent aEvent) This is method is called when the target of the listener has a new AWTEvent available.boolean
Returns if snapping to scale levels is enabled when holding the control key.void
mouseDragged
(MouseEvent aMouseEvent) Stores the location to zoom in to or to zoom out from.void
mouseMoved
(MouseEvent aMouseEvent) Stores the location to zoom in to or to zoom out from.void
Zooms the map in or out or stores the total mouse wheel activity depending on whether the view should be repainted continuously or not.void
Enables the controller to give visual feedback on the current user interactions.void
removeUndoableListener
(ILcdUndoableListener aListener) Removes the specified listener so it is no longer notified.void
setEnableSnapToScaleLevels
(boolean aEnableSnapToScaleLevels) Enables or disables snapping to scale levels when holding the control key.void
This method sets the next controller in the chain for this controller.void
setScaleLevelProvider
(ILcdGXYScaleLevelProvider aScaleLevelProvider) Sets the scale level provider used for ctrl-zoom.void
setZoomFactor
(double aZoomFactor) Sets the factor by which the view will be zoomed in or out for one mouse wheel 'click'.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.ALcdGXYController
addStatusListener, asGXYController, fireStatusEvent, getCursor, getGXYView, getIcon, getName, getShortDescription, isTraceOn, registerInstance, removeStatusListener, retrieveGXYViewXYWorldTransformation, setClassTraceOn, setCursor, setGXYView, setIcon, setName, setShortDescription, setTraceOn, 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
-
TLcdGXYZoomWheelController
public TLcdGXYZoomWheelController()Creates a newTLcdGXYZoomWheelController
that 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.true
means 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:ILcdUndoableSource
Adds a listener to this source, so this listener is notified when something undoable has happened.- Specified by:
addUndoableListener
in interfaceILcdUndoableSource
- Parameters:
aListener
- The listener to be notified when something undoable has happened.
-
removeUndoableListener
Description copied from interface:ILcdUndoableSource
Removes the specified listener so it is no longer notified.- Specified by:
removeUndoableListener
in 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
-true
to 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
ILcdRaster
orILcdMultilevelRaster
elements.When an empty array, or
null
is 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:
mouseMoved
in 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:
mouseDragged
in 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:
mouseWheelMoved
in 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: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.
-
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 classALcdGXYController
- 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 classALcdGXYController
- Parameters:
aGXYView
- theILcdGXYView
thisILcdGXYController
interacted with.- See Also:
-
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.
-