Class ALcdGXYSmartController

java.lang.Object
com.luciad.view.gxy.controller.ALcdGXYController
com.luciad.view.gxy.controller.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

public abstract class ALcdGXYSmartController extends ALcdGXYController implements MouseListener, MouseMotionListener, KeyListener, ILcdUndoableSource
Abstract ILcdGXYController that adds panning and/or zooming behavior during sub-class specific mouse interactions. More specific, it offers the following:

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 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 either 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.
      Overrides:
      setTraceOn in class ALcdGXYController
      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.
      Returns true if tracing is enabled for this class.
      Overrides:
      isTraceOn in class ALcdGXYController
      Returns:
      true if tracing is enabled for this class, false otherwise.
    • startInteraction

      public void startInteraction(ILcdGXYView aGXYView)
      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 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.

      Specified by:
      startInteraction in interface ILcdGXYController
      Overrides:
      startInteraction in class ALcdGXYController
      Parameters:
      aGXYView - the ILcdGXYView this ILcdGXYController will interact with.
      See Also:
    • terminateInteraction

      public void terminateInteraction(ILcdGXYView aGXYView)
      Description copied from class: ALcdGXYController
      Releases a few items. Can be redefined but this 'super' method should be called too.
      Specified by:
      terminateInteraction in interface ILcdGXYController
      Overrides:
      terminateInteraction in class ALcdGXYController
      Parameters:
      aGXYView - the ILcdGXYView this ILcdGXYController interacted with.
      See Also:
    • addUndoableListener

      public void addUndoableListener(ILcdUndoableListener aListener)
      Adds the given ILcdUndoableListener to the list of registered listeners. The listener now receives TLcdUndoableEvents from this controller.

      By for example adding a TLcdUndoManager to this controller, undo/redo support can be enabled.

      Specified by:
      addUndoableListener in interface ILcdUndoableSource
      Parameters:
      aListener - The listener to add.
      See Also:
    • removeUndoableListener

      public void removeUndoableListener(ILcdUndoableListener aListener)
      Removes the given ILcdUndoableListener from the list of registered listeners. The listener no longer receives TLcdUndoableEvents from this controller.

      Removing a listener that was never added or already removed, has no effect.

      Specified by:
      removeUndoableListener in interface ILcdUndoableSource
      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

      protected void fireUndoableEvent(TLcdUndoableEvent aEvent)
      Fires the given TLcdUndoableEvent 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 registered ILcdUndoableListener objects.
      Returns:
      The number of registered listeners. This is always greater than or equal to 0.
    • setUpPanChars

      public void setUpPanChars(String aUpPanChars)
      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

      public String 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

      public void setDownPanChars(String aDownPanChars)
      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

      public String 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

      public void setRightPanChars(String aRightPanChars)
      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

      public String 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

      public void setLeftPanChars(String aLeftPanChars)
      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

      public String 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

      public void setZoomInChars(String aZoomInChars)
      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

      public String 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

      public void setZoomOutChars(String aZoomOutChars)
      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

      public String 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, this ILcdGXYController 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, this ILcdGXYController 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 a java.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 a java.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

      protected int getPanAbsDelta(MouseEvent aMouseEvent)
      Parameters:
      aMouseEvent - a relevant mouse event
      Returns:
      getPanAbsDelta(). Can be redefined.
    • doPanGXYView

      protected void doPanGXYView(int aDeltaX, int aDeltaY)
      Performs the pan of this ILcdGXYController ILcdGXYView
      Parameters:
      aDeltaX - delta along the X axis, in AWT pixels
      aDeltaY - delta along the Y axis, in AWT pixels
    • doZoomGXYView

      protected void doZoomGXYView(double aZoomFactor)
      Performs the zoom of this ILcdGXYController ILcdGXYView
      Parameters:
      aZoomFactor - zoom factor with which to multiply the view's scale
    • keyTyped

      public void keyTyped(KeyEvent e)
      No action performed.
      Specified by:
      keyTyped in interface KeyListener
    • keyPressed

      public void keyPressed(KeyEvent e)
      No action performed.
      Specified by:
      keyPressed in interface KeyListener
    • keyReleased

      public void keyReleased(KeyEvent e)
      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 interface KeyListener
    • updateViewLocationAfterZoomSFCT

      protected void updateViewLocationAfterZoomSFCT(double aPreviousScale, int aPreviousViewOriginX, int aPreviousViewOriginY, double aPreviousWorldOriginX, double aPreviousWorldOriginY, int aPreviousXCoord, int aPreviousYCoord, Point aNewPointSFCT)
    • mousePressed

      public void mousePressed(MouseEvent me)
      Specified by:
      mousePressed in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent me)
      Specified by:
      mouseReleased in interface MouseListener
    • mouseMoved

      public void mouseMoved(MouseEvent me)
      Specified by:
      mouseMoved in interface MouseMotionListener
    • mouseDragged

      public void mouseDragged(MouseEvent me)
      Specified by:
      mouseDragged in interface MouseMotionListener
    • mouseClicked

      public void mouseClicked(MouseEvent me)
      Specified by:
      mouseClicked in interface MouseListener
    • mouseEntered

      public void mouseEntered(MouseEvent me)
      Specified by:
      mouseEntered in interface MouseListener
    • 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

      public void mouseExited(MouseEvent me)
      Will perform a pan depending on the values of isDragging, isPanOnMouseDragExit and isPanOnMouseMoveExit properties
      Specified by:
      mouseExited in interface MouseListener