public class TLcdGXYZoomWheelController extends ALcdGXYController implements MouseMotionListener, MouseWheelListener, ILcdUndoableSource, ILcdGXYChainableController
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.
Constructor and Description |
---|
TLcdGXYZoomWheelController()
Creates a new
TLcdGXYZoomWheelController that zooms out when scrolling down and zooms in when
scrolling up. |
TLcdGXYZoomWheelController(boolean aScrollUpZoomOut,
boolean aContinuousRepaint)
Constructs a new
TLcdGXYZoomWheelController . |
Modifier and Type | Method and Description |
---|---|
void |
addUndoableListener(ILcdUndoableListener aListener)
Adds a listener to this source, so this listener is notified when something undoable has
happened.
|
void |
appendGXYController(ILcdGXYChainableController aEnd)
This method will append the passed controller to the end of the chain.
|
protected void |
fireUndoableHappened(ILcdUndoable aUndoable) |
ILcdGXYChainableController |
getNextGXYController()
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.
|
ILcdGXYScaleLevelProvider |
getScaleLevelProvider()
Returns the scale level provider used for ctrl-zoom.
|
double |
getZoomFactor()
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 |
isEnableSnapToScaleLevels()
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 |
mouseWheelMoved(MouseWheelEvent e)
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 |
paint(Graphics aGraphics)
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 |
setNextGXYController(ILcdGXYChainableController aNext)
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.
|
addStatusListener, asGXYController, fireStatusEvent, getCursor, getGXYView, getIcon, getName, getShortDescription, isTraceOn, registerInstance, removeStatusListener, retrieveGXYViewXYWorldTransformation, setClassTraceOn, setCursor, setGXYView, setIcon, setName, setShortDescription, setTraceOn, viewRepaint
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCursor, getIcon, getLayered, getName, getShortDescription, viewRepaint
public TLcdGXYZoomWheelController()
TLcdGXYZoomWheelController
that zooms out when scrolling down and zooms in when
scrolling up. It repaints continuously, on every mouse wheel change.public TLcdGXYZoomWheelController(boolean aScrollUpZoomOut, boolean aContinuousRepaint)
TLcdGXYZoomWheelController
.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.public void addUndoableListener(ILcdUndoableListener aListener)
ILcdUndoableSource
addUndoableListener
in interface ILcdUndoableSource
aListener
- The listener to be notified when something undoable has happened.public void removeUndoableListener(ILcdUndoableListener aListener)
ILcdUndoableSource
removeUndoableListener
in interface ILcdUndoableSource
aListener
- The listener to remove.protected void fireUndoableHappened(ILcdUndoable aUndoable)
public double getZoomFactor()
setZoomFactor(double)
public void setZoomFactor(double aZoomFactor)
aZoomFactor
- the factor by which the view will be zoomed in or out for one mouse wheel 'click'.getZoomFactor()
public void setEnableSnapToScaleLevels(boolean aEnableSnapToScaleLevels)
aEnableSnapToScaleLevels
- true
to enable snapping to scale levels.isEnableSnapToScaleLevels()
,
setScaleLevelProvider(ILcdGXYScaleLevelProvider)
public boolean isEnableSnapToScaleLevels()
setEnableSnapToScaleLevels(boolean)
public ILcdGXYScaleLevelProvider getScaleLevelProvider()
setScaleLevelProvider(ILcdGXYScaleLevelProvider)
public void setScaleLevelProvider(ILcdGXYScaleLevelProvider aScaleLevelProvider)
Sets the scale level provider used for ctrl-zoom.
The default provider supports raster models containing ILcdRaster
or
ILcdMultilevelRaster
elements.
When an empty array, or null
is returned, no zooming will be performed.
aScaleLevelProvider
- the scale level provider used for ctrl-zoom.getScaleLevelProvider()
,
setEnableSnapToScaleLevels(boolean)
public void mouseMoved(MouseEvent aMouseEvent)
mouseMoved
in interface MouseMotionListener
aMouseEvent
- contains the location on the map to zoom in to or to zoom out from.public void mouseDragged(MouseEvent aMouseEvent)
mouseDragged
in interface MouseMotionListener
aMouseEvent
- contains the location on the map to zoom in to or to zoom out from.public void mouseWheelMoved(MouseWheelEvent e)
mouseWheelMoved
in interface MouseWheelListener
e
- contains the mouse wheel clicks. These are only taken into account when none of the modifiers is activated.public void paint(Graphics aGraphics)
ALcdGXYController
Empty implementation. Redefine this method to render on the Graphics on which the view is rendered.
paint
in interface ILcdGXYController
paint
in class ALcdGXYController
aGraphics
- the Graphics on which the view was rendered.public void startInteraction(ILcdGXYView aGXYView)
ALcdGXYController
All ILcdGXYView
implementations that support interaction call this method when the controller
has been made active with setGXYController
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
.
startInteraction
in interface ILcdGXYController
startInteraction
in class ALcdGXYController
aGXYView
- the ILcdGXYView
this ILcdGXYController
will interact with.ILcdGXYView.setGXYController(com.luciad.view.gxy.ILcdGXYController)
,
ILcdGXYController.terminateInteraction(com.luciad.view.gxy.ILcdGXYView)
public void terminateInteraction(ILcdGXYView aGXYView)
ALcdGXYController
terminateInteraction
in interface ILcdGXYController
terminateInteraction
in class ALcdGXYController
aGXYView
- the ILcdGXYView
this ILcdGXYController
interacted with.ILcdGXYView.setGXYController(com.luciad.view.gxy.ILcdGXYController)
,
ILcdGXYController.startInteraction(com.luciad.view.gxy.ILcdGXYView)
public ILcdGXYChainableController getNextGXYController()
ILcdGXYChainableController
getNextGXYController
in interface ILcdGXYChainableController
ILcdGXYChainableController.setNextGXYController(ILcdGXYChainableController)
public void setNextGXYController(ILcdGXYChainableController aNext)
ILcdGXYChainableController
setNextGXYController
in interface ILcdGXYChainableController
aNext
- the reference to the controller that will be the next element in the chainILcdGXYChainableController.getNextGXYController()
public void appendGXYController(ILcdGXYChainableController aEnd)
ILcdGXYChainableController
appendGXYController
in interface ILcdGXYChainableController
aEnd
- the controller to be appended to the end of the chain.public void handleAWTEvent(AWTEvent aEvent)
ILcdAWTEventListener
handleAWTEvent
in interface ILcdAWTEventListener
aEvent
- The event to be handled.