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
ILcdGXYViewComponent. 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 JComponents, 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddUndoableListener(ILcdUndoableListener aListener) Adds the givenILcdUndoableListenerto the list of registered listeners.protected voiddoPanGXYView(int aDeltaX, int aDeltaY) Performs the pan of thisILcdGXYControllerILcdGXYViewprotected voiddoZoomGXYView(double aZoomFactor) Performs the zoom of thisILcdGXYControllerILcdGXYViewprotected voidfireUndoableEvent(TLcdUndoableEvent aEvent) Fires the givenTLcdUndoableEventto all listeners registered to this controller.int[][]int[][]intprotected intgetPanAbsDelta(MouseEvent aMouseEvent) int[][]protected intReturns the number of registeredILcdUndoableListenerobjects.int[][]int[][]int[][]protected booleanbooleanbooleanbooleanReturns true if pan operations from this controller will fire an undoable.booleanbooleanbooleanDeprecated.This method has been deprecated.booleanReturns true if zoom operations from this controller will fire an undoable.voidNo action performed.voidCalls doPanGXYView or doZoomGXYView depending on the value of e.getKeyChar().voidNo action performed.voidvoidvoidvoidWill perform a pan depending on the values of isDragging, isPanOnMouseDragExit and isPanOnMouseMoveExit propertiesvoidmouseMoved(MouseEvent me) voidvoidvoidremoveUndoableListener(ILcdUndoableListener aListener) Removes the givenILcdUndoableListenerfrom the list of registered listeners.voidsetDownPanChars(String aDownPanChars) Set the characters that can trigger a Down pan on a keyRelease event.voidsetDownPanCodes(int[][] aDownPanCodes) Set the key codes that can trigger a Down pan on a keyReleased event.protected voidsetIsDragging(boolean aIsDragging) Sub-classes can call this method to inform this abstract class that it is performing a mouseDrag.voidsetLeftPanChars(String aLeftPanChars) Set the characters that can trigger a Left pan on a keyRelease event.voidsetLeftPanCodes(int[][] aLeftPanCodes) Set the key codes that can trigger a Left pan on a keyReleased event.voidsetPanAbsDelta(int aPanAbsDelta) Sets the absolute value of a pan operation.voidsetPanOnMouseDragExit(boolean aPanOnMouseDragExit) When this property is true, thisILcdGXYControllerwill perform a pan on mouseExited when dragging the mouse.voidsetPanOnMouseMoveExit(boolean aPanOnMouseMoveExit) When this property is true, thisILcdGXYControllerwill perform a pan on mouseExited when moving the mouse.voidsetPanUndoable(boolean aPanUndoable) Sets whether pan operations should fire an undoable.voidsetRequestFocusOnMouseEntered(boolean aRequestFocusOnMouseEntered) Sets whether the view should request the focus when the mouse enters the view.voidsetRequestFocusOnMousePressed(boolean aRequestFocusOnMousePressed) Sets whether the view should request the focus when pressed by the mouse.voidsetRightPanChars(String aRightPanChars) Set the characters that can trigger a Right pan on a keyRelease event.voidsetRightPanCodes(int[][] aRightPanCodes) Set the key codes that can trigger a Right pan on a keyReleased event.voidsetTraceOn(boolean aTraceOn) Deprecated.This method has been deprecated.voidsetUpPanChars(String aUpPanChars) Set the characters that can trigger a Up pan on a keyReleased event.voidsetUpPanCodes(int[][] aUpPanCodes) Set the key codes that can trigger a Up pan on a keyReleased event.voidsetZoomInChars(String aZoomInChars) Set the characters that can trigger a zoom in on a keyRelease event.voidsetZoomInCodes(int[][] aZoomInCodes) Set the key codes that can trigger a zoom in on a keyReleased event.voidsetZoomOutChars(String aZoomOutChars) Set the characters that can trigger a zoom out on a keyRelease event.voidsetZoomOutCodes(int[][] aZoomOutCodes) Set the key codes that can trigger a zoom out on a keyReleased event.voidsetZoomUndoable(boolean aZoomUndoable) Sets whether zoom operations should fire an undoable.voidstartInteraction(ILcdGXYView aGXYView) Sets up the controller to receive input through the view passed.voidterminateInteraction(ILcdGXYView aGXYView) Releases a few items.protected voidupdateViewLocationAfterZoomSFCT(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, 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
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 eithertrueorfalseas argument automatically turns off tracing for all other class instances for whichsetTraceOnhas not been called. If the argument isfalsethen only the informative, warning and error log messages are recorded.- Overrides:
setTraceOnin 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.Returnstrueif tracing is enabled for this class.- Overrides:
isTraceOnin classALcdGXYController- Returns:
- true if tracing is enabled for this class, false otherwise.
-
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:
-
addUndoableListener
Adds the givenILcdUndoableListenerto the list of registered listeners. The listener now receivesTLcdUndoableEvents from this controller. By for example adding aTLcdUndoManagerto this controller, undo/redo support can be enabled.- Specified by:
addUndoableListenerin interfaceILcdUndoableSource- Parameters:
aListener- The listener to add.- See Also:
-
removeUndoableListener
Removes the givenILcdUndoableListenerfrom the list of registered listeners. The listener no longer receivesTLcdUndoableEvents from this controller. Removing a listener that was never added or already removed, has no effect.- Specified by:
removeUndoableListenerin 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 givenTLcdUndoableEventto 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 registeredILcdUndoableListenerobjects.- 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, thisILcdGXYControllerwill 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, thisILcdGXYControllerwill 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 thisILcdGXYControllerILcdGXYView- 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 thisILcdGXYControllerILcdGXYView- Parameters:
aZoomFactor- zoom factor with which to multiply the view's scale
-
keyTyped
No action performed.- Specified by:
keyTypedin interfaceKeyListener
-
keyPressed
No action performed.- Specified by:
keyPressedin 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:
keyReleasedin interfaceKeyListener
-
updateViewLocationAfterZoomSFCT
protected void updateViewLocationAfterZoomSFCT(double aPreviousScale, int aPreviousViewOriginX, int aPreviousViewOriginY, double aPreviousWorldOriginX, double aPreviousWorldOriginY, int aPreviousXCoord, int aPreviousYCoord, Point aNewPointSFCT) -
mousePressed
- Specified by:
mousePressedin interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener
-
mouseMoved
- Specified by:
mouseMovedin interfaceMouseMotionListener
-
mouseDragged
- Specified by:
mouseDraggedin interfaceMouseMotionListener
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEnteredin 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:
mouseExitedin interfaceMouseListener
-