Class ALcdGXYSmartController
- All Implemented Interfaces:
ILcdUndoableSource
,ILcdStatusSource
,ILcdGXYController
,KeyListener
,MouseListener
,MouseMotionListener
,Serializable
,EventListener
- Direct Known Subclasses:
TLcdAdvancedMapRulerController
,TLcdAzimuthRangeController
,TLcdGRIBGXYController
,TLcdGXYCenterRasterController
,TLcdGXYDragRectangleController
,TLcdGXYInteractiveLabelsController
,TLcdGXYMagnifierController
,TLcdGXYNewController
,TLcdGXYNewController2
,TLcdGXYOverviewController
,TLcdGXYPanController
,TLcdGXYRotateController
,TLcdMagneticNorthGXYController
,TLcdMapRulerController
,TLcdTerrainProfileController
ILcdGXYController
that adds panning and/or zooming behavior during
sub-class specific mouse interactions.
More specific, it offers the following:
- pan and zoom operations activated by customizable key strokes (e.g. see
setUpPanChars(String)
orsetUpPanCodes(int[][])
). - pan operations by moving and/or dragging the mouse outside of the
ILcdGXYView
Component. This is particularly useful when editing or creating a shape on theILcdGXYView
. This behavior is controlled by the methodssetPanOnMouseDragExit(boolean)
andsetPanOnMouseMoveExit(boolean)
. -
focus requests when the mouse is pressed or when the mouse enters the view,
using the
setRequestFocusOnMousePressed(boolean)
andsetRequestFocusOnMouseEntered(boolean)
methods, respectively.
For views that are JComponent
s, keyboard control is automatically enabled when the view's
containing window has the focus. For other view implementations, the controller relies on the KeyListener interface.
As with most ILcdGXYController implementations, the controller requires an external instance (normally the view)
to register itself as MouseListener, MouseMotionListener and KeyListener.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addUndoableListener
(ILcdUndoableListener aListener) Adds the givenILcdUndoableListener
to the list of registered listeners.protected void
doPanGXYView
(int aDeltaX, int aDeltaY) Performs the pan of thisILcdGXYController
ILcdGXYView
protected void
doZoomGXYView
(double aZoomFactor) Performs the zoom of thisILcdGXYController
ILcdGXYView
protected void
fireUndoableEvent
(TLcdUndoableEvent aEvent) Fires the givenTLcdUndoableEvent
to all listeners registered to this controller.int[][]
int[][]
int
protected int
getPanAbsDelta
(MouseEvent aMouseEvent) int[][]
protected int
Returns the number of registeredILcdUndoableListener
objects.int[][]
int[][]
int[][]
protected boolean
boolean
boolean
boolean
Returns true if pan operations from this controller will fire an undoable.boolean
boolean
boolean
Deprecated.This method has been deprecated.boolean
Returns true if zoom operations from this controller will fire an undoable.void
No action performed.void
Calls doPanGXYView or doZoomGXYView depending on the value of e.getKeyChar().void
No action performed.void
void
void
void
Will perform a pan depending on the values of isDragging, isPanOnMouseDragExit and isPanOnMouseMoveExit propertiesvoid
mouseMoved
(MouseEvent me) void
void
void
removeUndoableListener
(ILcdUndoableListener aListener) Removes the givenILcdUndoableListener
from the list of registered listeners.void
setDownPanChars
(String aDownPanChars) Set the characters that can trigger a Down pan on a keyRelease event.void
setDownPanCodes
(int[][] aDownPanCodes) Set the key codes that can trigger a Down pan on a keyReleased event.protected void
setIsDragging
(boolean aIsDragging) Sub-classes can call this method to inform this abstract class that it is performing a mouseDrag.void
setLeftPanChars
(String aLeftPanChars) Set the characters that can trigger a Left pan on a keyRelease event.void
setLeftPanCodes
(int[][] aLeftPanCodes) Set the key codes that can trigger a Left pan on a keyReleased event.void
setPanAbsDelta
(int aPanAbsDelta) Sets the absolute value of a pan operation.void
setPanOnMouseDragExit
(boolean aPanOnMouseDragExit) When this property is true, thisILcdGXYController
will perform a pan on mouseExited when dragging the mouse.void
setPanOnMouseMoveExit
(boolean aPanOnMouseMoveExit) When this property is true, thisILcdGXYController
will perform a pan on mouseExited when moving the mouse.void
setPanUndoable
(boolean aPanUndoable) Sets whether pan operations should fire an undoable.void
setRequestFocusOnMouseEntered
(boolean aRequestFocusOnMouseEntered) Sets whether the view should request the focus when the mouse enters the view.void
setRequestFocusOnMousePressed
(boolean aRequestFocusOnMousePressed) Sets whether the view should request the focus when pressed by the mouse.void
setRightPanChars
(String aRightPanChars) Set the characters that can trigger a Right pan on a keyRelease event.void
setRightPanCodes
(int[][] aRightPanCodes) Set the key codes that can trigger a Right pan on a keyReleased event.void
setTraceOn
(boolean aTraceOn) Deprecated.This method has been deprecated.void
setUpPanChars
(String aUpPanChars) Set the characters that can trigger a Up pan on a keyReleased event.void
setUpPanCodes
(int[][] aUpPanCodes) Set the key codes that can trigger a Up pan on a keyReleased event.void
setZoomInChars
(String aZoomInChars) Set the characters that can trigger a zoom in on a keyRelease event.void
setZoomInCodes
(int[][] aZoomInCodes) Set the key codes that can trigger a zoom in on a keyReleased event.void
setZoomOutChars
(String aZoomOutChars) Set the characters that can trigger a zoom out on a keyRelease event.void
setZoomOutCodes
(int[][] aZoomOutCodes) Set the key codes that can trigger a zoom out on a keyReleased event.void
setZoomUndoable
(boolean aZoomUndoable) Sets whether zoom operations should fire an undoable.void
startInteraction
(ILcdGXYView aGXYView) Sets up the controller to receive input through the view passed.void
terminateInteraction
(ILcdGXYView aGXYView) Releases a few items.protected void
updateViewLocationAfterZoomSFCT
(double aPreviousScale, int aPreviousViewOriginX, int aPreviousViewOriginY, double aPreviousWorldOriginX, double aPreviousWorldOriginY, int aPreviousXCoord, int aPreviousYCoord, Point aNewPointSFCT) Methods inherited from class com.luciad.view.gxy.controller.ALcdGXYController
addStatusListener, asGXYController, fireStatusEvent, getCursor, getGXYView, getIcon, getName, getShortDescription, paint, 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
getLayered
-
Constructor Details
-
ALcdGXYSmartController
protected ALcdGXYSmartController()
-
-
Method Details
-
setTraceOn
public void setTraceOn(boolean aTraceOn) Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Enables tracing for this class instance. Calling this method with eithertrue
orfalse
as argument automatically turns off tracing for all other class instances for whichsetTraceOn
has not been called. If the argument isfalse
then only the informative, warning and error log messages are recorded.- Overrides:
setTraceOn
in classALcdGXYController
- Parameters:
aTraceOn
- if true then all log messages are recorded for this instance. If false, then only the informative, warning and error log messages are recorded.
-
isTraceOn
public boolean isTraceOn()Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Returnstrue
if tracing is enabled for this class.- Overrides:
isTraceOn
in classALcdGXYController
- Returns:
- true if tracing is enabled for this class, false otherwise.
-
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:
-
addUndoableListener
Adds the givenILcdUndoableListener
to the list of registered listeners. The listener now receivesTLcdUndoableEvent
s from this controller. By for example adding aTLcdUndoManager
to this controller, undo/redo support can be enabled.- Specified by:
addUndoableListener
in interfaceILcdUndoableSource
- Parameters:
aListener
- The listener to add.- See Also:
-
removeUndoableListener
Removes the givenILcdUndoableListener
from the list of registered listeners. The listener no longer receivesTLcdUndoableEvent
s from this controller. Removing a listener that was never added or already removed, has no effect.- Specified by:
removeUndoableListener
in interfaceILcdUndoableSource
- Parameters:
aListener
- The listener to remove.- See Also:
-
isPanUndoable
public boolean isPanUndoable()Returns true if pan operations from this controller will fire an undoable.- Returns:
- true if pan operations from this controller will fire an undoable
-
setPanUndoable
public void setPanUndoable(boolean aPanUndoable) Sets whether pan operations should fire an undoable.- Parameters:
aPanUndoable
- if true, pan operations fire an undoable
-
isZoomUndoable
public boolean isZoomUndoable()Returns true if zoom operations from this controller will fire an undoable.- Returns:
- true if zoom operations from this controller will fire an undoable
-
setZoomUndoable
public void setZoomUndoable(boolean aZoomUndoable) Sets whether zoom operations should fire an undoable.- Parameters:
aZoomUndoable
- if true, zoom operations fire an undoable
-
fireUndoableEvent
Fires the givenTLcdUndoableEvent
to all listeners registered to this controller.- Parameters:
aEvent
- The event to fire to all registered listeners.- See Also:
-
getUndoableListenerCount
protected int getUndoableListenerCount()Returns the number of registeredILcdUndoableListener
objects.- Returns:
- The number of registered listeners. This is always greater than or equal to
0
.
-
setUpPanChars
Set the characters that can trigger a Up pan on a keyReleased event. For example, ">rR" means that a up pan will be performed when either the '>', 'r' or 'R' keyboard key is released- Parameters:
aUpPanChars
- the characters that can trigger a Up pan on a keyReleased event.
-
getUpPanChars
- Returns:
- the characters that can trigger a Up pan on a keyReleased event.
- See Also:
-
setUpPanCodes
public void setUpPanCodes(int[][] aUpPanCodes) Set the key codes that can trigger a Up pan on a keyReleased event. An example of such an array would be:
{ { KeyEvent.VK_UP, KeyEvent.SHIFT_MASK },
{ KeyEvent.VK_UP, KeyEvent.CTRL_MASK },
{ KeyEvent.VK_UP, 0 },
The up pan would be performed for each press on the up key in combination with the SHIFT or the CTRL(META on Mac OS) key or without any modifier. The combination with the ALT key wouldn't trigger the up pan.
The above could also be written as:
{ { KeyEvent.VK_UP, KeyEvent.SHIFT_MASK | KeyEvent.CTRL_MASK },
{ KeyEvent.VK_UP, 0 },
If one doesn't care about if any of the modifiers has been pressed or not, one can also use an array without specification of the modifiers.
{ { KeyEvent.VK_UP } } would trigger the up pan for any (or no) modifier pressed together with the up key.- Parameters:
aUpPanCodes
- the key codes that can trigger a Up pan on a keyReleased event
-
getUpPanCodes
public int[][] getUpPanCodes()- Returns:
- the key codes that can trigger a Up pan on a keyReleased event
- See Also:
-
setDownPanChars
Set the characters that can trigger a Down pan on a keyRelease event. For example, "dD" means that a down pan will be performed when either the 'd' or 'D' keyboard key is released- Parameters:
aDownPanChars
- the characters that can trigger a Down pan on a keyRelease event
-
getDownPanChars
- Returns:
- the characters that can trigger a Down pan on a keyRelease event
- See Also:
-
setDownPanCodes
public void setDownPanCodes(int[][] aDownPanCodes) Set the key codes that can trigger a Down pan on a keyReleased event.- Parameters:
aDownPanCodes
- the key codes that can trigger a Down pan on a keyReleased event- See Also:
-
getDownPanCodes
public int[][] getDownPanCodes()- Returns:
- the key codes that can trigger a Down pan on a keyReleased event
- See Also:
-
setRightPanChars
Set the characters that can trigger a Right pan on a keyRelease event. For example, "rR" means that a right pan will be performed when either the 'r' or 'R' keyboard key is released- Parameters:
aRightPanChars
- the characters that can trigger a Right pan on a keyRelease event
-
getRightPanChars
- Returns:
- the characters that can trigger a Right pan on a keyRelease event
- See Also:
-
setRightPanCodes
public void setRightPanCodes(int[][] aRightPanCodes) Set the key codes that can trigger a Right pan on a keyReleased event.- Parameters:
aRightPanCodes
- the key codes that can trigger a Right pan on a keyReleased event- See Also:
-
getRightPanCodes
public int[][] getRightPanCodes()- Returns:
- the key codes that can trigger a Right pan on a keyReleased event.
- See Also:
-
setLeftPanChars
Set the characters that can trigger a Left pan on a keyRelease event. For example, ">lL" means that a Left pan will be performed when either the '>', 'l' or 'L' keyboard key is released- Parameters:
aLeftPanChars
- the characters that can trigger a Left pan on a keyRelease event
-
getLeftPanChars
- Returns:
- the characters that can trigger a Left pan on a keyRelease event
- See Also:
-
setLeftPanCodes
public void setLeftPanCodes(int[][] aLeftPanCodes) Set the key codes that can trigger a Left pan on a keyReleased event.- Parameters:
aLeftPanCodes
- the key codes that can trigger a Left pan on a keyReleased event- See Also:
-
getLeftPanCodes
public int[][] getLeftPanCodes()- Returns:
- the key codes that can trigger a Left pan on a keyReleased event
- See Also:
-
setZoomInChars
Set the characters that can trigger a zoom in on a keyRelease event. For example, "+iz" means that a Left pan will be performed when either the '+', 'i' or 'z' keyboard key is released- Parameters:
aZoomInChars
- the characters that can trigger a zoom in on a keyRelease event
-
getZoomInChars
- Returns:
- the characters that can trigger a zoom in on a keyRelease event
- See Also:
-
setZoomInCodes
public void setZoomInCodes(int[][] aZoomInCodes) Set the key codes that can trigger a zoom in on a keyReleased event.- Parameters:
aZoomInCodes
- the key codes that can trigger a zoom in on a keyReleased event- See Also:
-
getZoomInCodes
public int[][] getZoomInCodes()- Returns:
- the key codes that can trigger a zoom in on a keyReleased event
- See Also:
-
setZoomOutChars
Set the characters that can trigger a zoom out on a keyRelease event. For example, "-o" means that a Left pan will be performed when either the '-' or 'o' keyboard key is released- Parameters:
aZoomOutChars
- the characters that can trigger a zoom out on a keyRelease event
-
getZoomOutChars
- Returns:
- the characters that can trigger a zoom out on a keyRelease event
- See Also:
-
setZoomOutCodes
public void setZoomOutCodes(int[][] aZoomOutCodes) Set the key codes that can trigger a zoom out on a keyReleased event.- Parameters:
aZoomOutCodes
- the key codes that can trigger a zoom out on a keyReleased event- See Also:
-
getZoomOutCodes
public int[][] getZoomOutCodes()- Returns:
- the key codes that can trigger a zoom out on a keyReleased event
- See Also:
-
setPanOnMouseMoveExit
public void setPanOnMouseMoveExit(boolean aPanOnMouseMoveExit) When this property is true, thisILcdGXYController
will perform a pan on mouseExited when moving the mouse.- Parameters:
aPanOnMouseMoveExit
- if true, a pan is performed on mouseExited when moving the mouse
-
isPanOnMouseMoveExit
public boolean isPanOnMouseMoveExit()- Returns:
- true if a pan is performed on mouseExited when moving the mouse
- See Also:
-
setPanOnMouseDragExit
public void setPanOnMouseDragExit(boolean aPanOnMouseDragExit) When this property is true, thisILcdGXYController
will perform a pan on mouseExited when dragging the mouse.- Parameters:
aPanOnMouseDragExit
- if true, a pan is performed on mouseExited when dragging the mouse
-
isPanOnMouseDragExit
public boolean isPanOnMouseDragExit()- Returns:
- true if a pan is performed on mouseExited when dragging the mouse
- See Also:
-
isRequestFocusOnMouseEntered
public boolean isRequestFocusOnMouseEntered()- Returns:
- whether the view should request the focus when entered by the mouse.
- See Also:
-
setRequestFocusOnMouseEntered
public void setRequestFocusOnMouseEntered(boolean aRequestFocusOnMouseEntered) Sets whether the view should request the focus when the mouse enters the view. This applies only when the view is ajava.awt.Component
.- Parameters:
aRequestFocusOnMouseEntered
- if true, the view will request the focus when the mouse enters it- See Also:
-
isRequestFocusOnMousePressed
public boolean isRequestFocusOnMousePressed()- Returns:
- whether the view should request the focus when pressed by the mouse.
- See Also:
-
setRequestFocusOnMousePressed
public void setRequestFocusOnMousePressed(boolean aRequestFocusOnMousePressed) Sets whether the view should request the focus when pressed by the mouse. This applies only when the view is ajava.awt.Component
.- Parameters:
aRequestFocusOnMousePressed
- if true, the view will request the focus when a mouse press occurs on it- See Also:
-
setPanAbsDelta
public void setPanAbsDelta(int aPanAbsDelta) Sets the absolute value of a pan operation.- Parameters:
aPanAbsDelta
- the absolute value of a pan operation, in pixels
-
getPanAbsDelta
public int getPanAbsDelta()- Returns:
- the current absolute value to be used for a pan, in pixels
-
getPanAbsDelta
- Parameters:
aMouseEvent
- a relevant mouse event- Returns:
- getPanAbsDelta(). Can be redefined.
-
doPanGXYView
protected void doPanGXYView(int aDeltaX, int aDeltaY) Performs the pan of thisILcdGXYController
ILcdGXYView
- Parameters:
aDeltaX
- delta along the X axis, in AWT pixelsaDeltaY
- delta along the Y axis, in AWT pixels
-
doZoomGXYView
protected void doZoomGXYView(double aZoomFactor) Performs the zoom of thisILcdGXYController
ILcdGXYView
- Parameters:
aZoomFactor
- zoom factor with which to multiply the view's scale
-
keyTyped
No action performed.- Specified by:
keyTyped
in interfaceKeyListener
-
keyPressed
No action performed.- Specified by:
keyPressed
in interfaceKeyListener
-
keyReleased
Calls doPanGXYView or doZoomGXYView depending on the value of e.getKeyChar(). This method can be redefined and make use of doZoomGXYView and or doPanGXYView- Specified by:
keyReleased
in interfaceKeyListener
-
updateViewLocationAfterZoomSFCT
protected void updateViewLocationAfterZoomSFCT(double aPreviousScale, int aPreviousViewOriginX, int aPreviousViewOriginY, double aPreviousWorldOriginX, double aPreviousWorldOriginY, int aPreviousXCoord, int aPreviousYCoord, Point aNewPointSFCT) -
mousePressed
- Specified by:
mousePressed
in interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleased
in interfaceMouseListener
-
mouseMoved
- Specified by:
mouseMoved
in interfaceMouseMotionListener
-
mouseDragged
- Specified by:
mouseDragged
in interfaceMouseMotionListener
-
mouseClicked
- Specified by:
mouseClicked
in interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEntered
in interfaceMouseListener
-
setIsDragging
protected void setIsDragging(boolean aIsDragging) Sub-classes can call this method to inform this abstract class that it is performing a mouseDrag. This will be useful on a mouseExited event- Parameters:
aIsDragging
- if true, the controller is performing a mouse drag- See Also:
-
isDragging
protected boolean isDragging()- Returns:
- true if the controller is performing a mouse drag
-
mouseExited
Will perform a pan depending on the values of isDragging, isPanOnMouseDragExit and isPanOnMouseMoveExit properties- Specified by:
mouseExited
in interfaceMouseListener
-