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
- Direct Known Subclasses:
GeoMapViewer.MovePinMouseHandler
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
-
-
Field Summary
Fields Modifier and Type Field Description private org.eclipse.swt.graphics.Point
downPosition
private GeoMapPositioned
geoMap
private int
panButtons
private int
panCenterButtons
private int
panClickCount
private int
panScrollButtons
private int
panScrollSpeed
private org.eclipse.swt.graphics.Point
panStart
private int
zoomClickCount
private int
zoomInClickButtons
private int
zoomOutClickButtons
private org.eclipse.swt.graphics.Rectangle
zoomRectangle
private int
zoomRectangleButtons
private int
zoomScrollButtons
private org.eclipse.swt.graphics.Point
zoomStart
-
Constructor Summary
Constructors Constructor Description DefaultMouseHandler(GeoMapPositioned geoMap)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
center(org.eclipse.swt.events.MouseEvent e)
Center at cursor positionprotected 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 positionprotected 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 positionprotected 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 positionprotected void
zoomOut(org.eclipse.swt.events.MouseEvent e)
Zoom out at cursor positionprotected boolean
zoomStart(org.eclipse.swt.events.MouseEvent e)
Initiates a zoom (rectangle).
-
-
-
Field Detail
-
geoMap
private final GeoMapPositioned geoMap
-
panStart
private org.eclipse.swt.graphics.Point panStart
-
downPosition
private org.eclipse.swt.graphics.Point downPosition
-
zoomClickCount
private int zoomClickCount
-
zoomInClickButtons
private int zoomInClickButtons
-
zoomOutClickButtons
private int zoomOutClickButtons
-
zoomRectangleButtons
private int zoomRectangleButtons
-
zoomStart
private org.eclipse.swt.graphics.Point zoomStart
-
zoomRectangle
private org.eclipse.swt.graphics.Rectangle zoomRectangle
-
panClickCount
private int panClickCount
-
panButtons
private int panButtons
-
panCenterButtons
private int panCenterButtons
-
panScrollButtons
private int panScrollButtons
-
panScrollSpeed
private int panScrollSpeed
-
zoomScrollButtons
private int zoomScrollButtons
-
-
Constructor Detail
-
DefaultMouseHandler
public DefaultMouseHandler(GeoMapPositioned geoMap)
- Parameters:
geoMap
-control
-
-
-
Method Detail
-
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 offsety
- the y or y offsetrelative
- 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 interfaceorg.eclipse.swt.events.MouseTrackListener
-
mouseExit
public void mouseExit(org.eclipse.swt.events.MouseEvent e)
- Specified by:
mouseExit
in interfaceorg.eclipse.swt.events.MouseTrackListener
-
mouseHover
public void mouseHover(org.eclipse.swt.events.MouseEvent e)
- Specified by:
mouseHover
in interfaceorg.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 MouseEventbuttons
- 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 interfaceorg.eclipse.swt.events.MouseListener
-
mouseMove
public void mouseMove(org.eclipse.swt.events.MouseEvent e)
- Specified by:
mouseMove
in interfaceorg.eclipse.swt.events.MouseMoveListener
-
mouseDoubleClick
public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e)
- Specified by:
mouseDoubleClick
in interfaceorg.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 interfaceorg.eclipse.swt.events.MouseListener
-
mouseScrolled
public void mouseScrolled(org.eclipse.swt.events.MouseEvent e)
- Specified by:
mouseScrolled
in interfaceorg.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 interfaceorg.eclipse.swt.events.PaintListener
-
-