Class TLcdGXYOverviewController

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

public class TLcdGXYOverviewController extends ALcdGXYSmartController implements MouseListener, MouseMotionListener
This ILcdGXYController allows to fit one "slave" ILcdGXYView into a rectangle painted on the ILcdGXYView this ILcdGXYController is interacting with (the "master" ILcdGXYView).

Each time the rectangle is moved or reshaped on the master ILcdGXYView, this TLcdGXYOverviewController tries to make the area visible in the slave ILcdGXYView corresponding to the area that the rectangle covers. If the scale or the origin of the slave ILcdGXYView changes (after a zoom or a pan for example), this TLcdGXYOverviewController will redraw the rectangle on its ILcdGXYView, to make it match the area covered by the slave ILcdGXYView.

When the slave view is modified to display the specified rectangle, the necessary TLcdUndoableEvent objects are fired to make this modification undoable. All listeners registered with the addUndoableListener method will be notified of these events.

To use this ILcdGXYController properly, you must set a valid ILcdXYWorldXYWorldTransformation, that can transform a XYWorld bounds in the master ILcdGXYView into a XYWorld bounds in the slave ILcdGXYView.

See Also:
  • Constructor Details

    • TLcdGXYOverviewController

      public TLcdGXYOverviewController()
    • TLcdGXYOverviewController

      public TLcdGXYOverviewController(ILcdGXYView aSlaveView)
    • TLcdGXYOverviewController

      public TLcdGXYOverviewController(boolean aRegisterInstance)
      Deprecated.
      use one of the constructors without the aRegisterInstance parameter.
    • TLcdGXYOverviewController

      public TLcdGXYOverviewController(ILcdGXYView aSlaveView, boolean aRegisterInstance)
      Deprecated.
      use one of the constructors without the aRegisterInstance parameter.
  • 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:
    • setSlaveView

      public void setSlaveView(ILcdGXYView aSlaveView)
      Sets a "slave" ILcdGXYView.
    • getSlaveView

      public ILcdGXYView getSlaveView()
      Gets the current "slave" ILcdGXYView.
    • setGhostColor

      public void setGhostColor(Color aGhostColor)
      Sets the Color to use when dragging the rectangle on the "master" ILcdGXYView, i.e. the ILcdGXYView this ILcdGXYController is interacting with.
    • getGhostColor

      public Color getGhostColor()
      Gets the Color used when dragging the rectangle on the "master" ILcdGXYView, i.e. the ILcdGXYView this ILcdGXYController is interacting with.
    • setLineWidth

      public void setLineWidth(int aLineWidth)
      Sets the line width to use when dragging the rectangle on the "master" ILcdGXYView, i.e. the ILcdGXYView this ILcdGXYController is interacting with.
    • getLineWidth

      public int getLineWidth()
      Gets the line width used when dragging the rectangle on the "master" ILcdGXYView, i.e. the ILcdGXYView this ILcdGXYController is interacting with.
    • setFilled

      public void setFilled(boolean aFilled)
      Sets whether the master view's rectangle should be filled. A filled rectangle can be moved by dragging its contents or its border, whereas an unfilled rectangle can only be moved by dragging its border.
      Parameters:
      aFilled - true to fill the master view rectangle with the set fill color.
      See Also:
    • isFilled

      public boolean isFilled()
      Returns whether the master view's rectangle is filled.
      Returns:
      true if the master view rectangle is filled with the set fill color
      See Also:
    • setFillColor

      public void setFillColor(Color aFillColor)
      Sets the color with which to fill the master view's rectangle to aFillColor.
      Parameters:
      aFillColor - the color to be used when filling the master view rectangle
      See Also:
    • getFillColor

      public Color getFillColor()
      Returns the color with which to fill the master view's rectangle.
      Returns:
      the color to be used when filling the master view rectangle
      See Also:
    • setForceToSquare

      public void setForceToSquare(boolean aForceToSquare)
      Forces the dragged rectangle to be square or not.
    • isForceToSquare

      public boolean isForceToSquare()
      See Also:
    • setDragCentered

      public void setDragCentered(boolean aDragCentered)
      Parameters:
      aDragCentered - if true, the center of the dragged rectangle will stay where the mouse has been pressed. If false, it will be at the center of the rectangle defined by where the mouse has been pressed, and it current location. Default value if true.
    • isDragCentered

      public boolean isDragCentered()
      See Also:
    • setRepaintOnReleased

      public void setRepaintOnReleased(boolean aRepaintOnReleased)
      Parameters:
      aRepaintOnReleased - if true, this TLcdGXYDragRectangleController will repaint the ILcdGXYView on mouseReleased. Default if true.
    • isRepaintOnReleased

      public boolean isRepaintOnReleased()
      See Also:
    • getCurrentRectangle

      public Rectangle getCurrentRectangle()
      Returns:
      the current dragged rectangle as a java.awt.Rectangle. Do not attempt to keep reference or change the returned Rectangle. Make a copy if necessary.
    • paint

      public void paint(Graphics aGraphics)
      Description copied from class: ALcdGXYController
      Enables the controller to give visual feedback on the current user interactions. Note that the controller is responsible for repainting the view.

      Empty implementation. Redefine this method to render on the Graphics on which the view is rendered.

      Specified by:
      paint in interface ILcdGXYController
      Overrides:
      paint in class ALcdGXYController
      Parameters:
      aGraphics - the Graphics on which the view was rendered.
    • 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.
    • drawGhost

      protected void drawGhost(Graphics aGraphics)
      Draws the dragged Rectangle on getGXYView().getGraphics().
    • drawGhost

      protected void drawGhost(Rectangle aRectangle, Graphics aGraphics)
      Draws the dragged Rectangle on aGraphics.
    • cleanGhost

      protected void cleanGhost()
    • mousePressed

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

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

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

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

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

      public void mouseExited(MouseEvent me)
      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
    • mouseReleased

      public void mouseReleased(MouseEvent me)
      Specified by:
      mouseReleased in interface MouseListener
      Overrides:
      mouseReleased in class ALcdGXYSmartController
    • adjustSlaveView

      public void adjustSlaveView(EventObject aEventObject, Rectangle aRectangleDragged)
      Adjusts the "slave" ILcdGXYView to fit into aRectangleDragged painted on the ILcdGXYView this ILcdGXYController is interacting with.
      Throws:
      NullPointerException - if no ILcdXYWorldXYWorldTransformation has been set.
    • setXYWorldXYWorldTransformation

      public void setXYWorldXYWorldTransformation(ILcdXYWorldXYWorldTransformation newXYWorldXYWorldTransformation)
      Sets an ILcdXYWorldXYWorldTransformation. A non null value must be set.
    • getXYWorldXYWorldTransformation

      public ILcdXYWorldXYWorldTransformation getXYWorldXYWorldTransformation()
      Gets the current ILcdXYWorldXYWorldTransformation.