Class DefaultMouseHandler

java.lang.Object
org.eclipse.nebula.widgets.geomap.internal.DefaultMouseHandler
All Implemented Interfaces:
java.util.EventListener, org.eclipse.swt.events.MouseListener, org.eclipse.swt.events.MouseMoveListener, org.eclipse.swt.events.MouseTrackListener, org.eclipse.swt.events.MouseWheelListener, org.eclipse.swt.events.PaintListener, org.eclipse.swt.internal.SWTEventListener

public abstract class DefaultMouseHandler
extends java.lang.Object
implements org.eclipse.swt.events.MouseListener, org.eclipse.swt.events.MouseWheelListener, org.eclipse.swt.events.MouseMoveListener, org.eclipse.swt.events.MouseTrackListener, org.eclipse.swt.events.PaintListener
Implements default interactive behavior, with support for panning and zooming.
Since:
3.3
  • Constructor Summary

    Constructors 
    Constructor Description
    DefaultMouseHandler​(GeoMapPositioned geoMap)  
  • Method Summary

    Modifier and Type Method Description
    protected void center​(org.eclipse.swt.events.MouseEvent e)
    Center at cursor position
    protected boolean checkButtons​(org.eclipse.swt.events.MouseEvent e, int buttons)
    Checks that the MouseEvent corresponds to the provided buttons bit mask.
    protected GeoMapPositioned getGeoMap()  
    abstract org.eclipse.swt.graphics.Point getMapSize()
    Gets the size of the map viewport/pane.
    int getPanButtons()  
    int getPanCenterButtons()  
    int getPanClickCount()  
    int getPanScrollButtons()  
    int getPanScrollSpeed()  
    int getZoomClickCount()  
    int getZoomInClickButtons()  
    int getZoomOutClickButtons()  
    int getZoomRectangleButtons()  
    int getZoomScrollButtons()  
    protected boolean handleDown​(org.eclipse.swt.events.MouseEvent e)
    Checks if a down event is (the start of) a pan or zoom and initiates it.
    protected boolean handlePanDrag​(org.eclipse.swt.events.MouseEvent e)
    Handles one pan step, according to the distance from the click to the current position
    protected boolean handlePanUp​(org.eclipse.swt.events.MouseEvent e)
    Handles end of pan.
    protected boolean handleZoomClick​(org.eclipse.swt.events.MouseEvent e)
    Checks if a click event is a zoom and performs it.
    protected boolean handleZoomDrag​(org.eclipse.swt.events.MouseEvent e)
    Handles one zoom step, extending the zoom rectangle.
    protected boolean handleZoomUp​(org.eclipse.swt.events.MouseEvent e)
    Handles zooming to rectangle.
    protected boolean isPanning()  
    protected boolean isPanStart​(org.eclipse.swt.events.MouseEvent e)  
    protected boolean isZooming()  
    protected boolean isZoomStart​(org.eclipse.swt.events.MouseEvent e)  
    void mouseDoubleClick​(org.eclipse.swt.events.MouseEvent e)  
    void mouseDown​(org.eclipse.swt.events.MouseEvent e)  
    void mouseEnter​(org.eclipse.swt.events.MouseEvent e)  
    void mouseExit​(org.eclipse.swt.events.MouseEvent e)  
    void mouseHover​(org.eclipse.swt.events.MouseEvent e)  
    void mouseMove​(org.eclipse.swt.events.MouseEvent e)  
    void mouseScrolled​(org.eclipse.swt.events.MouseEvent e)  
    void mouseUp​(org.eclipse.swt.events.MouseEvent e)  
    void paintControl​(org.eclipse.swt.events.PaintEvent e)  
    protected void pan​(int x, int y, boolean relative)
    Sets the map position
    protected boolean panStart​(org.eclipse.swt.events.MouseEvent e)
    Initiates a pan.
    void setPanButtons​(int panButtons)
    Sets the button(s) that triggers a pan.
    void setPanCenterButtons​(int panCenterButtons)  
    void setPanClickCount​(int panClickCount)
    Sets the number of clicks that triggers a pan.
    void setPanScrollButtons​(int panScrollButtons)
    Sets the button(s) that triggers a pan, when using the scroll wheel.
    void setPanScrollSpeed​(int panScrollSpeed)
    Sets the panning speed, when using the scroll wheel.
    void setZoomClickCount​(int zoomClickCount)
    Sets the number of clicks that triggers a zoom.
    void setZoomInClickButtons​(int zoomInClickButtons)
    Sets the button(s) that triggers a zoom in.
    void setZoomOutClickButtons​(int zoomOutClickButtons)
    Sets the button(s) that triggers a zoom out.
    void setZoomRectangleButtons​(int zoomRectangleButtons)
    Sets the button(s) that triggers a zoom (rectangle).
    void setZoomScrollButtons​(int zoomScrollButtons)
    Sets the button(s) that triggers a zoom, when using the scroll wheel.
    protected void zoomIn​(org.eclipse.swt.events.MouseEvent e)
    Zoom in at cursor position
    protected void zoomOut​(org.eclipse.swt.events.MouseEvent e)
    Zoom out at cursor position
    protected boolean zoomStart​(org.eclipse.swt.events.MouseEvent e)
    Initiates a zoom (rectangle).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getGeoMap

      protected GeoMapPositioned getGeoMap()
      Returns:
    • zoomIn

      protected void zoomIn​(org.eclipse.swt.events.MouseEvent e)
      Zoom in at cursor position
      Parameters:
      e - the MouseEvent
    • zoomOut

      protected void zoomOut​(org.eclipse.swt.events.MouseEvent e)
      Zoom out at cursor position
      Parameters:
      e - the MouseEvent
    • pan

      protected void pan​(int x, int y, boolean relative)
      Sets the map position
      Parameters:
      x - the x or x offset
      y - the y or y offset
      relative - tells whether x and y are offsets
    • getMapSize

      public abstract org.eclipse.swt.graphics.Point getMapSize()
      Gets the size of the map viewport/pane.
      Returns:
      the size of the map viewport/pane
    • center

      protected void center​(org.eclipse.swt.events.MouseEvent e)
      Center at cursor position
      Parameters:
      e - the MouseEvent
    • getZoomClickCount

      public int getZoomClickCount()
      Returns:
      Returns the zoomClickCount.
    • setZoomClickCount

      public void setZoomClickCount​(int zoomClickCount)
      Sets the number of clicks that triggers a zoom.
      Parameters:
      zoomClickCount - The zoomClickCount to set.
    • getPanCenterButtons

      public int getPanCenterButtons()
      Returns:
      Returns the panCenterButtons.
    • setPanCenterButtons

      public void setPanCenterButtons​(int panCenterButtons)
      Parameters:
      panCenterButtons - The panCenterButtons to set.
    • getZoomInClickButtons

      public int getZoomInClickButtons()
      Returns:
      Returns the zoomInClickButtons.
    • setZoomInClickButtons

      public void setZoomInClickButtons​(int zoomInClickButtons)
      Sets the button(s) that triggers a zoom in.
      Parameters:
      zoomInClickButtons - The zoomInClickButtons to set.
    • getZoomOutClickButtons

      public int getZoomOutClickButtons()
      Returns:
      Returns the zoomOutClickButtons.
    • setZoomOutClickButtons

      public void setZoomOutClickButtons​(int zoomOutClickButtons)
      Sets the button(s) that triggers a zoom out.
      Parameters:
      zoomOutClickButtons - The zoomOutClickButtons to set.
    • getPanClickCount

      public int getPanClickCount()
      Returns:
      Returns the panClickCount.
    • setPanClickCount

      public void setPanClickCount​(int panClickCount)
      Sets the number of clicks that triggers a pan.
      Parameters:
      panClickCount - The panClickCount to set.
    • getPanButtons

      public int getPanButtons()
      Returns:
      Returns the panButtons.
    • setPanButtons

      public void setPanButtons​(int panButtons)
      Sets the button(s) that triggers a pan.
      Parameters:
      panButtons - The panButtons to set.
    • getPanScrollButtons

      public int getPanScrollButtons()
      Returns:
      Returns the panScrollButtons.
    • setPanScrollButtons

      public void setPanScrollButtons​(int panScrollButtons)
      Sets the button(s) that triggers a pan, when using the scroll wheel.
      Parameters:
      panScrollButtons - The panScrollButtons to set.
    • getPanScrollSpeed

      public int getPanScrollSpeed()
      Returns:
      Returns the panScrollSpeed.
    • setPanScrollSpeed

      public void setPanScrollSpeed​(int panScrollSpeed)
      Sets the panning speed, when using the scroll wheel.
      Parameters:
      panScrollSpeed - The panScrollSpeed to set.
    • getZoomScrollButtons

      public int getZoomScrollButtons()
      Returns:
      Returns the zoomScrollButtons.
    • setZoomScrollButtons

      public void setZoomScrollButtons​(int zoomScrollButtons)
      Sets the button(s) that triggers a zoom, when using the scroll wheel.
      Parameters:
      zoomScrollButtons - The zoomScrollButtons to set.
    • getZoomRectangleButtons

      public int getZoomRectangleButtons()
      Returns:
      Returns the zoomRectangleButtons.
    • setZoomRectangleButtons

      public void setZoomRectangleButtons​(int zoomRectangleButtons)
      Sets the button(s) that triggers a zoom (rectangle).
      Parameters:
      zoomRectangleButtons - The zoomRectangleButtons to set.
    • mouseEnter

      public void mouseEnter​(org.eclipse.swt.events.MouseEvent e)
      Specified by:
      mouseEnter in interface org.eclipse.swt.events.MouseTrackListener
    • mouseExit

      public void mouseExit​(org.eclipse.swt.events.MouseEvent e)
      Specified by:
      mouseExit in interface org.eclipse.swt.events.MouseTrackListener
    • mouseHover

      public void mouseHover​(org.eclipse.swt.events.MouseEvent e)
      Specified by:
      mouseHover in interface org.eclipse.swt.events.MouseTrackListener
    • checkButtons

      protected boolean checkButtons​(org.eclipse.swt.events.MouseEvent e, int buttons)
      Checks that the MouseEvent corresponds to the provided buttons bit mask. The buttons are or'ed button bits for modifiers keys and mouse buttons.
      Parameters:
      e - the MouseEvent
      buttons - Or'ed button bits for modifiers keys and mouse buttons.
      Returns:
      true if the MouseEvent corresponds to the provided buttons, false otherwise
    • mouseDown

      public void mouseDown​(org.eclipse.swt.events.MouseEvent e)
      Specified by:
      mouseDown in interface org.eclipse.swt.events.MouseListener
    • mouseMove

      public void mouseMove​(org.eclipse.swt.events.MouseEvent e)
      Specified by:
      mouseMove in interface org.eclipse.swt.events.MouseMoveListener
    • mouseDoubleClick

      public void mouseDoubleClick​(org.eclipse.swt.events.MouseEvent e)
      Specified by:
      mouseDoubleClick in interface org.eclipse.swt.events.MouseListener
    • handleZoomClick

      protected boolean handleZoomClick​(org.eclipse.swt.events.MouseEvent e)
      Checks if a click event is a zoom and performs it.
      Parameters:
      e - the MouseEvent
      Returns:
      if the click event is a zoom
    • handleDown

      protected boolean handleDown​(org.eclipse.swt.events.MouseEvent e)
      Checks if a down event is (the start of) a pan or zoom and initiates it.
      Parameters:
      e - the MouseEvent
      Returns:
      if the click event is a zoom
    • isPanStart

      protected boolean isPanStart​(org.eclipse.swt.events.MouseEvent e)
      Parameters:
      e - the MouseEvent
      Returns:
      if the MouseEvent is considered start of a pan
    • isZoomStart

      protected boolean isZoomStart​(org.eclipse.swt.events.MouseEvent e)
      Parameters:
      e - the MouseEvent
      Returns:
      if the MouseEvent is considered start of a zoom
    • panStart

      protected boolean panStart​(org.eclipse.swt.events.MouseEvent e)
      Initiates a pan.
      Parameters:
      e - the MouseEvent
      Returns:
      if pan was really initiated
    • isPanning

      protected boolean isPanning()
      Returns:
      if a pan has been initiated.
    • zoomStart

      protected boolean zoomStart​(org.eclipse.swt.events.MouseEvent e)
      Initiates a zoom (rectangle).
      Parameters:
      e - the MouseEvent
      Returns:
      if zoom was really initiated
    • isZooming

      protected boolean isZooming()
      Returns:
      if a zoom has been initiated.
    • mouseUp

      public void mouseUp​(org.eclipse.swt.events.MouseEvent e)
      Specified by:
      mouseUp in interface org.eclipse.swt.events.MouseListener
    • mouseScrolled

      public void mouseScrolled​(org.eclipse.swt.events.MouseEvent e)
      Specified by:
      mouseScrolled in interface org.eclipse.swt.events.MouseWheelListener
    • handlePanDrag

      protected boolean handlePanDrag​(org.eclipse.swt.events.MouseEvent e)
      Handles one pan step, according to the distance from the click to the current position
      Parameters:
      e - the MouseEvent
      Returns:
      if pan was active and the movement offset large enough
    • handleZoomDrag

      protected boolean handleZoomDrag​(org.eclipse.swt.events.MouseEvent e)
      Handles one zoom step, extending the zoom rectangle.
      Parameters:
      e - the MouseEvent
      Returns:
      if zoom was active
    • handlePanUp

      protected boolean handlePanUp​(org.eclipse.swt.events.MouseEvent e)
      Handles end of pan.
      Parameters:
      e - the MouseEvent
      Returns:
      if pan was active
    • handleZoomUp

      protected boolean handleZoomUp​(org.eclipse.swt.events.MouseEvent e)
      Handles zooming to rectangle.
      Parameters:
      e - the MouseEvent
      Returns:
      if zoom was active
    • paintControl

      public void paintControl​(org.eclipse.swt.events.PaintEvent e)
      Specified by:
      paintControl in interface org.eclipse.swt.events.PaintListener