Class TLcdGXYMagnifierController

All Implemented Interfaces:
ILcdUndoableSource, ILcdStatusSource, ILcdGXYController, KeyListener, MouseListener, MouseMotionListener, Serializable, EventListener

public class TLcdGXYMagnifierController extends ALcdGXYSmartController
A MagnifierController is an ILcdGXYController to magnify an area of a given ILcdGXYView around the location where a mouse button is pressed. The magnified area is shown in a magnifier window.

If the left mouse button is pressed, the magnifier window disappears when the mouse button is released. If the mouse is dragged with the left mouse button pressed, the magnifier window is moved along, such that it always shows the area around the location where the mouse button is pressed.

If the right mouse button is pressed, the magnifier window remains visible, even after releasing the mouse button. The magnifier window can be closed by clicking on it.

If the shift key is pressed at the same time as pressing the mouse, the magnification is accelerated, i.e., made stronger.

The TLcdGXYMagnifierController has several modes of update (i.e., refresh of what is displayed inside):

  • IMMEDIATE_UPDATE_MODE: the magnifier window is updated whenever it is dragged around.
  • INTERVAL_UPDATE_MODE: the magnifier window is updated at fixed intervals. The length of the interval is UpdateInterval milliseconds.
  • LAZY_UPDATE_MODE: the magnifier window is updated whenever the mouse is not moved for UpdateInterval milliseconds.
  • ADAPTIVE_UPDATE_MODE: the magnifier window behaves like IMMEDIATE_UPDATE_MODE if its first update takes less than UpdateDurationThreshold milliseconds, and like LAZY_UPDATE_MODE otherwise. This is the default value.
Properties of the magnifier window:
  • Width and Height to indicate its size (default value: 80x80).
  • ScaleFactor, to indicate the magnification (default value: 5).
  • ScaleAccelerator, to indicate the acceleration of the magnification (default value: 2).
  • UpdateInterval, to indicate at which interval the magnifier window must be updated (in milliseconds). The UpdateInterval must be strictly positive. The default value is 200.
  • UpdateDurationTreshold, to indicate a threshold (in milliseconds) for deciding upon the behavior in ADAPTIVE_UPDATE_MODE. The default value is 100.
The Scale of the magnifier window always equals the Scale of the ILcdGXYView multiplied by the ScaleFactor multiplied by the ScaleAccelerator.

The Width of the magnifier window is constrained by half the Width of the ILcdGXYView. The Height of the magnifier window is constrained by half the Height of the ILcdGXYView.

The magnifier window can be made UserAdjustable. When this is the case, the user can adapt some of the above properties with the keyboard as long as the magnifier window is visible:

  • typing '+' increases the Width and Height of the magnifier window.
  • typing '-' decreases the Width and Height of the magnifier window.
  • typing '*' increases the ScaleFactor of the magnifier window.
  • typing '/' decreases the ScaleFactor of the magnifier window.
By default, the magnifier window is UserAdjustable.
See Also:
  • Field Details

    • IMMEDIATE_UPDATE_MODE

      public static final int IMMEDIATE_UPDATE_MODE
      See Also:
    • INTERVAL_UPDATE_MODE

      public static final int INTERVAL_UPDATE_MODE
      See Also:
    • ADAPTIVE_UPDATE_MODE

      public static final int ADAPTIVE_UPDATE_MODE
      See Also:
    • LAZY_UPDATE_MODE

      public static final int LAZY_UPDATE_MODE
      See Also:
    • LAST_MODE

      public static final int LAST_MODE
      The possible modes are consecutive int values, starting from 0 to LAST_MODE.
      See Also:
  • Constructor Details

  • 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 ALcdGXYSmartController
      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 ALcdGXYSmartController
      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 ALcdGXYSmartController
      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 ALcdGXYSmartController
      Parameters:
      aGXYView - the ILcdGXYView this ILcdGXYController interacted with.
      See Also:
    • createGlassGXYView

      protected ILcdGXYView createGlassGXYView()
      Returns the ILcdGXYView that will be used as a magnifier on top of this controllers ILcdGXYView. This method shall return an instance of Component or an IllegalArgumentException will be thrown in the startInteraction method.
      Returns:
      returns a new TLcdGXYViewJPanel
    • getGXYLayerFilter

      public ILcdFilter getGXYLayerFilter()
      Returns the filter to determine if a layer of the original view is visible in the magnifier window.
      Returns:
      the filter to determine if a layer of the original view is visible in the magnifier window
    • setGXYLayerFilter

      public void setGXYLayerFilter(ILcdFilter aFilter)
      Sets a filter that determines if a layer of the original view is visible in the magnifier window.
      Parameters:
      aFilter - the used filter. If the filter returns true for an ILcdGXYLayer, that layer will be included in the magnifier window.
    • viewRepaint

      public void viewRepaint(ILcdGXYView aGXYView)
      Description copied from class: ALcdGXYController
      Empty implementation.
      Specified by:
      viewRepaint in interface ILcdGXYController
      Overrides:
      viewRepaint in class ALcdGXYController
      Parameters:
      aGXYView - the ILcdGXYView to draw on.
    • mouseDragged

      public void mouseDragged(MouseEvent e)
      When the mouse is dragged with the left-button pressed, a magnifier window is shown whose center is the location below the mouse.

      The same constraints apply at the borders as in mousePressed.

      If the scale accelerator was activated when the mouse was pressed at the beginning of the drag, it remains activated.

      Specified by:
      mouseDragged in interface MouseMotionListener
      Overrides:
      mouseDragged in class ALcdGXYSmartController
      See Also:
    • mouseMoved

      public void mouseMoved(MouseEvent e)
      Specified by:
      mouseMoved in interface MouseMotionListener
      Overrides:
      mouseMoved in class ALcdGXYSmartController
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      Specified by:
      mouseClicked in interface MouseListener
      Overrides:
      mouseClicked in class ALcdGXYSmartController
    • mousePressed

      public void mousePressed(MouseEvent e)
      When the left-button or right-button of the mouse is pressed, a magnifier window is shown whose center is the location below the mouse.

      At the left and right borders of the ILcdGXYView on which this MagnifierController operates, the center of the magnifier window is the location with minimum x (resp. maximum x) such that the magnifier window is still within the borders of the ILcdGXYView.

      Similarly, at the bottom and top borders of the ILcdGXYView, the center of the magnifier window is the location with minimum y (resp. maximum y) such that the magnifier window is still within the borders of the ILcdGXYView.

      If the SHIFT key is held when pressing the mouse, the scale accelerator of the magnifier is activated.

      Specified by:
      mousePressed in interface MouseListener
      Overrides:
      mousePressed in class ALcdGXYSmartController
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      When the left-button of the mouse is released, the magnifier window disappears. When the right-button of the mouse is released, the magnifier window remains.
      Specified by:
      mouseReleased in interface MouseListener
      Overrides:
      mouseReleased in class ALcdGXYSmartController
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      Specified by:
      mouseEntered in interface MouseListener
      Overrides:
      mouseEntered in class ALcdGXYSmartController
    • mouseExited

      public void mouseExited(MouseEvent e)
      Description copied from class: ALcdGXYSmartController
      Will perform a pan depending on the values of isDragging, isPanOnMouseDragExit and isPanOnMouseMoveExit properties
      Specified by:
      mouseExited in interface MouseListener
      Overrides:
      mouseExited in class ALcdGXYSmartController
    • setUserAdjustable

      public void setUserAdjustable(boolean aUserAdjustable)
      Deprecated.
      This property is never taken into account and may be removed in the future.
      Set whether or not the magnifier window is user adjustable
    • isUserAdjustable

      public boolean isUserAdjustable()
      Deprecated.
      This property is never taken into account and may be removed in the future.
      Returns:
      true if and only if the magnifier window is user adjustable
    • setUpdateInterval

      public void setUpdateInterval(int aUpdateInterval)
      Set the update interval of the magnifier window to aUpdateInterval

      The new value for the update interval is taken into account at the latest after a delay of the old value of update interval.

    • getUpdateInterval

      public int getUpdateInterval()
      Returns:
      the update interval of the magnifier window
    • setUpdateDurationTreshold

      public void setUpdateDurationTreshold(int aUpdateDurationThreshold)
      Set the update duration threshold of the magnifier window to aUpdateDurationThreshold

      The new value for the duration threshold is taken into account at the next mouse drag.

    • getUpdateDurationTreshold

      public int getUpdateDurationTreshold()
      Returns:
      the update duration threshold of the magnifier window
    • setWidth

      public void setWidth(int aWidth)
      Sets aWidth as the width of the magnifier window.
    • getWidth

      public int getWidth()
      Returns:
      the width of the magnifier window.
    • setHeight

      public void setHeight(int aHeight)
      Sets aHeight as the height of the magnifier window.
    • getHeight

      public int getHeight()
      Returns:
      the height of the magnifier window.
    • setScaleFactor

      public void setScaleFactor(double aScaleFactor)
      Sets aScaleFactor as the scale factor of the magnifier window.
    • getScaleFactor

      public double getScaleFactor()
      Returns:
      the scale factor of the magnifier window.
    • setScaleAccelerator

      public void setScaleAccelerator(double aScaleAccelerator)
      Sets aScaleAccelerator as the scale accelerator of the magnifier window.
    • getScaleAccelerator

      public double getScaleAccelerator()
      Returns:
      the scale accelerator of the magnifier window.
    • setMode

      public void setMode(int aMode)
      Set the mode of the magnifier window.
    • isIntervalUpdateMode

      public boolean isIntervalUpdateMode()
      Returns:
      true if and only if the mode of the magnifier window is INTERVAL_UPDATE_MODE
    • isImmediateUpdateMode

      public boolean isImmediateUpdateMode()
      Returns:
      true if and only if the mode of the magnifier window is IMMEDIATE_UPDATE_MODE
    • isAdaptiveUpdateMode

      public boolean isAdaptiveUpdateMode()
      Returns:
      true if and only if the mode of the magnifier window is ADAPTIVE_UPDATE_MODE
    • isLazyUpdateMode

      public boolean isLazyUpdateMode()
      Returns:
      true if and only if the mode of the magnifier window is LAZY_UPDATE_MODE