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.PaintListenerImplements 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.PointdownPositionprivate GeoMapPositionedgeoMapprivate intpanButtonsprivate intpanCenterButtonsprivate intpanClickCountprivate intpanScrollButtonsprivate intpanScrollSpeedprivate org.eclipse.swt.graphics.PointpanStartprivate intzoomClickCountprivate intzoomInClickButtonsprivate intzoomOutClickButtonsprivate org.eclipse.swt.graphics.RectanglezoomRectangleprivate intzoomRectangleButtonsprivate intzoomScrollButtonsprivate org.eclipse.swt.graphics.PointzoomStart
-
Constructor Summary
Constructors Constructor Description DefaultMouseHandler(GeoMapPositioned geoMap)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcenter(org.eclipse.swt.events.MouseEvent e)Center at cursor positionprotected booleancheckButtons(org.eclipse.swt.events.MouseEvent e, int buttons)Checks that the MouseEvent corresponds to the provided buttons bit mask.protected GeoMapPositionedgetGeoMap()abstract org.eclipse.swt.graphics.PointgetMapSize()Gets the size of the map viewport/pane.intgetPanButtons()intgetPanCenterButtons()intgetPanClickCount()intgetPanScrollButtons()intgetPanScrollSpeed()intgetZoomClickCount()intgetZoomInClickButtons()intgetZoomOutClickButtons()intgetZoomRectangleButtons()intgetZoomScrollButtons()protected booleanhandleDown(org.eclipse.swt.events.MouseEvent e)Checks if a down event is (the start of) a pan or zoom and initiates it.protected booleanhandlePanDrag(org.eclipse.swt.events.MouseEvent e)Handles one pan step, according to the distance from the click to the current positionprotected booleanhandlePanUp(org.eclipse.swt.events.MouseEvent e)Handles end of pan.protected booleanhandleZoomClick(org.eclipse.swt.events.MouseEvent e)Checks if a click event is a zoom and performs it.protected booleanhandleZoomDrag(org.eclipse.swt.events.MouseEvent e)Handles one zoom step, extending the zoom rectangle.protected booleanhandleZoomUp(org.eclipse.swt.events.MouseEvent e)Handles zooming to rectangle.protected booleanisPanning()protected booleanisPanStart(org.eclipse.swt.events.MouseEvent e)protected booleanisZooming()protected booleanisZoomStart(org.eclipse.swt.events.MouseEvent e)voidmouseDoubleClick(org.eclipse.swt.events.MouseEvent e)voidmouseDown(org.eclipse.swt.events.MouseEvent e)voidmouseEnter(org.eclipse.swt.events.MouseEvent e)voidmouseExit(org.eclipse.swt.events.MouseEvent e)voidmouseHover(org.eclipse.swt.events.MouseEvent e)voidmouseMove(org.eclipse.swt.events.MouseEvent e)voidmouseScrolled(org.eclipse.swt.events.MouseEvent e)voidmouseUp(org.eclipse.swt.events.MouseEvent e)voidpaintControl(org.eclipse.swt.events.PaintEvent e)protected voidpan(int x, int y, boolean relative)Sets the map positionprotected booleanpanStart(org.eclipse.swt.events.MouseEvent e)Initiates a pan.voidsetPanButtons(int panButtons)Sets the button(s) that triggers a pan.voidsetPanCenterButtons(int panCenterButtons)voidsetPanClickCount(int panClickCount)Sets the number of clicks that triggers a pan.voidsetPanScrollButtons(int panScrollButtons)Sets the button(s) that triggers a pan, when using the scroll wheel.voidsetPanScrollSpeed(int panScrollSpeed)Sets the panning speed, when using the scroll wheel.voidsetZoomClickCount(int zoomClickCount)Sets the number of clicks that triggers a zoom.voidsetZoomInClickButtons(int zoomInClickButtons)Sets the button(s) that triggers a zoom in.voidsetZoomOutClickButtons(int zoomOutClickButtons)Sets the button(s) that triggers a zoom out.voidsetZoomRectangleButtons(int zoomRectangleButtons)Sets the button(s) that triggers a zoom (rectangle).voidsetZoomScrollButtons(int zoomScrollButtons)Sets the button(s) that triggers a zoom, when using the scroll wheel.protected voidzoomIn(org.eclipse.swt.events.MouseEvent e)Zoom in at cursor positionprotected voidzoomOut(org.eclipse.swt.events.MouseEvent e)Zoom out at cursor positionprotected booleanzoomStart(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:
mouseEnterin interfaceorg.eclipse.swt.events.MouseTrackListener
-
mouseExit
public void mouseExit(org.eclipse.swt.events.MouseEvent e)
- Specified by:
mouseExitin interfaceorg.eclipse.swt.events.MouseTrackListener
-
mouseHover
public void mouseHover(org.eclipse.swt.events.MouseEvent e)
- Specified by:
mouseHoverin 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:
mouseDownin interfaceorg.eclipse.swt.events.MouseListener
-
mouseMove
public void mouseMove(org.eclipse.swt.events.MouseEvent e)
- Specified by:
mouseMovein interfaceorg.eclipse.swt.events.MouseMoveListener
-
mouseDoubleClick
public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e)
- Specified by:
mouseDoubleClickin 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:
mouseUpin interfaceorg.eclipse.swt.events.MouseListener
-
mouseScrolled
public void mouseScrolled(org.eclipse.swt.events.MouseEvent e)
- Specified by:
mouseScrolledin 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:
paintControlin interfaceorg.eclipse.swt.events.PaintListener
-
-