public abstract class ALcdGXYSmartController extends ALcdGXYController implements MouseListener, MouseMotionListener, KeyListener, ILcdUndoableSource
ILcdGXYController
that adds panning and/or zooming behavior during
sub-class specific mouse interactions.
More specific, it offers the following:
setUpPanChars(String)
or setUpPanCodes(int[][])
).ILcdGXYView
Component.
This is particularly useful when editing or creating a shape on the ILcdGXYView
.
This behavior is controlled by the methods setPanOnMouseDragExit(boolean)
and
setPanOnMouseMoveExit(boolean)
.setRequestFocusOnMousePressed(boolean)
and setRequestFocusOnMouseEntered(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.
Modifier | Constructor and Description |
---|---|
protected |
ALcdGXYSmartController() |
Modifier and Type | Method and Description |
---|---|
void |
addUndoableListener(ILcdUndoableListener aListener)
Adds the given
ILcdUndoableListener to the list of registered listeners. |
protected void |
doPanGXYView(int aDeltaX,
int aDeltaY)
Performs the pan of this
ILcdGXYController
ILcdGXYView |
protected void |
doZoomGXYView(double aZoomFactor)
Performs the zoom of this
ILcdGXYController
ILcdGXYView |
protected void |
fireUndoableEvent(TLcdUndoableEvent aEvent)
Fires the given
TLcdUndoableEvent to all listeners registered to this
controller. |
String |
getDownPanChars() |
int[][] |
getDownPanCodes() |
String |
getLeftPanChars() |
int[][] |
getLeftPanCodes() |
int |
getPanAbsDelta() |
protected int |
getPanAbsDelta(MouseEvent aMouseEvent) |
String |
getRightPanChars() |
int[][] |
getRightPanCodes() |
protected int |
getUndoableListenerCount()
Returns the number of registered
ILcdUndoableListener objects. |
String |
getUpPanChars() |
int[][] |
getUpPanCodes() |
String |
getZoomInChars() |
int[][] |
getZoomInCodes() |
String |
getZoomOutChars() |
int[][] |
getZoomOutCodes() |
protected boolean |
isDragging() |
boolean |
isPanOnMouseDragExit() |
boolean |
isPanOnMouseMoveExit() |
boolean |
isPanUndoable()
Returns true if pan operations from this controller will fire an undoable.
|
boolean |
isRequestFocusOnMouseEntered() |
boolean |
isRequestFocusOnMousePressed() |
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
boolean |
isZoomUndoable()
Returns true if zoom operations from this controller will fire an undoable.
|
void |
keyPressed(KeyEvent e)
No action performed.
|
void |
keyReleased(KeyEvent e)
Calls doPanGXYView or doZoomGXYView depending on
the value of e.getKeyChar().
|
void |
keyTyped(KeyEvent e)
No action performed.
|
void |
mouseClicked(MouseEvent me) |
void |
mouseDragged(MouseEvent me) |
void |
mouseEntered(MouseEvent me) |
void |
mouseExited(MouseEvent me)
Will perform a pan depending on the values of isDragging,
isPanOnMouseDragExit and isPanOnMouseMoveExit properties
|
void |
mouseMoved(MouseEvent me) |
void |
mousePressed(MouseEvent me) |
void |
mouseReleased(MouseEvent me) |
void |
removeUndoableListener(ILcdUndoableListener aListener)
Removes the given
ILcdUndoableListener 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, this
ILcdGXYController will
perform a pan on mouseExited when dragging the mouse. |
void |
setPanOnMouseMoveExit(boolean aPanOnMouseMoveExit)
When this property is true, this
ILcdGXYController 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. It is recommended to use the
standard Java logging framework directly.
|
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) |
addStatusListener, asGXYController, fireStatusEvent, getCursor, getGXYView, getIcon, getName, getShortDescription, paint, registerInstance, removeStatusListener, retrieveGXYViewXYWorldTransformation, setClassTraceOn, setCursor, setGXYView, setIcon, setName, setShortDescription, viewRepaint
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLayered
public void setTraceOn(boolean aTraceOn)
true
or false
as argument automatically turns
off tracing for all other class instances for which
setTraceOn
has not been called.
If the argument is false
then only the informative, warning
and error log messages are recorded.setTraceOn
in class ALcdGXYController
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.public boolean isTraceOn()
true
if tracing is enabled for this class.isTraceOn
in class ALcdGXYController
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 void addUndoableListener(ILcdUndoableListener aListener)
ILcdUndoableListener
to the list of registered listeners.
The listener now receives TLcdUndoableEvent
s from this controller.
By for example adding a TLcdUndoManager
to this controller,
undo/redo support can be enabled.addUndoableListener
in interface ILcdUndoableSource
aListener
- The listener to add.removeUndoableListener(com.luciad.gui.ILcdUndoableListener)
,
getUndoableListenerCount()
public void removeUndoableListener(ILcdUndoableListener aListener)
ILcdUndoableListener
from the list of registered listeners.
The listener no longer receives TLcdUndoableEvent
s from this controller.
Removing a listener that was never added or already removed, has no effect.removeUndoableListener
in interface ILcdUndoableSource
aListener
- The listener to remove.addUndoableListener(com.luciad.gui.ILcdUndoableListener)
,
getUndoableListenerCount()
public boolean isPanUndoable()
public void setPanUndoable(boolean aPanUndoable)
aPanUndoable
- if true, pan operations fire an undoablepublic boolean isZoomUndoable()
public void setZoomUndoable(boolean aZoomUndoable)
aZoomUndoable
- if true, zoom operations fire an undoableprotected void fireUndoableEvent(TLcdUndoableEvent aEvent)
TLcdUndoableEvent
to all listeners registered to this
controller.aEvent
- The event to fire to all registered listeners.addUndoableListener(com.luciad.gui.ILcdUndoableListener)
protected int getUndoableListenerCount()
ILcdUndoableListener
objects.0
.public void setUpPanChars(String aUpPanChars)
aUpPanChars
- the characters that can trigger a Up pan on a keyReleased event.public String getUpPanChars()
setUpPanChars(java.lang.String)
public void setUpPanCodes(int[][] aUpPanCodes)
aUpPanCodes
- the key codes that can trigger a Up pan on a keyReleased eventpublic int[][] getUpPanCodes()
setUpPanCodes(int[][])
public void setDownPanChars(String aDownPanChars)
aDownPanChars
- the characters that can trigger a Down pan on a keyRelease eventpublic String getDownPanChars()
setDownPanChars(java.lang.String)
public void setDownPanCodes(int[][] aDownPanCodes)
aDownPanCodes
- the key codes that can trigger a Down pan on a keyReleased eventsetUpPanCodes(int[][])
public int[][] getDownPanCodes()
setDownPanCodes(int[][])
public void setRightPanChars(String aRightPanChars)
aRightPanChars
- the characters that can trigger a Right pan on a keyRelease eventpublic String getRightPanChars()
setRightPanChars(java.lang.String)
public void setRightPanCodes(int[][] aRightPanCodes)
aRightPanCodes
- the key codes that can trigger a Right pan on a keyReleased eventsetUpPanCodes(int[][])
public int[][] getRightPanCodes()
setRightPanCodes(int[][])
public void setLeftPanChars(String aLeftPanChars)
aLeftPanChars
- the characters that can trigger a Left pan on a keyRelease eventpublic String getLeftPanChars()
setLeftPanChars(java.lang.String)
public void setLeftPanCodes(int[][] aLeftPanCodes)
aLeftPanCodes
- the key codes that can trigger a Left pan on a keyReleased eventsetUpPanCodes(int[][])
public int[][] getLeftPanCodes()
setLeftPanCodes(int[][])
public void setZoomInChars(String aZoomInChars)
aZoomInChars
- the characters that can trigger a zoom in on a keyRelease eventpublic String getZoomInChars()
setZoomInChars(java.lang.String)
public void setZoomInCodes(int[][] aZoomInCodes)
aZoomInCodes
- the key codes that can trigger a zoom in on a keyReleased eventsetUpPanCodes(int[][])
public int[][] getZoomInCodes()
setZoomInCodes(int[][])
public void setZoomOutChars(String aZoomOutChars)
aZoomOutChars
- the characters that can trigger a zoom out on a keyRelease eventpublic String getZoomOutChars()
setZoomOutChars(java.lang.String)
public void setZoomOutCodes(int[][] aZoomOutCodes)
aZoomOutCodes
- the key codes that can trigger a zoom out on a keyReleased eventsetUpPanCodes(int[][])
public int[][] getZoomOutCodes()
setZoomOutCodes(int[][])
public void setPanOnMouseMoveExit(boolean aPanOnMouseMoveExit)
ILcdGXYController
will
perform a pan on mouseExited when moving the mouse.aPanOnMouseMoveExit
- if true, a pan is performed on mouseExited when moving the mousepublic boolean isPanOnMouseMoveExit()
setPanOnMouseMoveExit(boolean)
public void setPanOnMouseDragExit(boolean aPanOnMouseDragExit)
ILcdGXYController
will
perform a pan on mouseExited when dragging the mouse.aPanOnMouseDragExit
- if true, a pan is performed on mouseExited when dragging the mousepublic boolean isPanOnMouseDragExit()
setPanOnMouseDragExit(boolean)
public boolean isRequestFocusOnMouseEntered()
setRequestFocusOnMouseEntered(boolean)
public void setRequestFocusOnMouseEntered(boolean aRequestFocusOnMouseEntered)
java.awt.Component
.aRequestFocusOnMouseEntered
- if true, the view will request the focus when the mouse enters itisRequestFocusOnMouseEntered()
public boolean isRequestFocusOnMousePressed()
setRequestFocusOnMousePressed(boolean)
public void setRequestFocusOnMousePressed(boolean aRequestFocusOnMousePressed)
java.awt.Component
.aRequestFocusOnMousePressed
- if true, the view will request the focus when a mouse press occurs on itisRequestFocusOnMousePressed()
public void setPanAbsDelta(int aPanAbsDelta)
aPanAbsDelta
- the absolute value of a pan operation, in pixelspublic int getPanAbsDelta()
protected int getPanAbsDelta(MouseEvent aMouseEvent)
aMouseEvent
- a relevant mouse eventprotected void doPanGXYView(int aDeltaX, int aDeltaY)
ILcdGXYController
ILcdGXYView
aDeltaX
- delta along the X axis, in AWT pixelsaDeltaY
- delta along the Y axis, in AWT pixelsprotected void doZoomGXYView(double aZoomFactor)
ILcdGXYController
ILcdGXYView
aZoomFactor
- zoom factor with which to multiply the view's scalepublic void keyTyped(KeyEvent e)
keyTyped
in interface KeyListener
public void keyPressed(KeyEvent e)
keyPressed
in interface KeyListener
public void keyReleased(KeyEvent e)
keyReleased
in interface KeyListener
protected void updateViewLocationAfterZoomSFCT(double aPreviousScale, int aPreviousViewOriginX, int aPreviousViewOriginY, double aPreviousWorldOriginX, double aPreviousWorldOriginY, int aPreviousXCoord, int aPreviousYCoord, Point aNewPointSFCT)
public void mousePressed(MouseEvent me)
mousePressed
in interface MouseListener
public void mouseReleased(MouseEvent me)
mouseReleased
in interface MouseListener
public void mouseMoved(MouseEvent me)
mouseMoved
in interface MouseMotionListener
public void mouseDragged(MouseEvent me)
mouseDragged
in interface MouseMotionListener
public void mouseClicked(MouseEvent me)
mouseClicked
in interface MouseListener
public void mouseEntered(MouseEvent me)
mouseEntered
in interface MouseListener
protected void setIsDragging(boolean aIsDragging)
aIsDragging
- if true, the controller is performing a mouse dragmouseExited(java.awt.event.MouseEvent)
protected boolean isDragging()
public void mouseExited(MouseEvent me)
mouseExited
in interface MouseListener