Package uk.ac.starlink.ttools.plot2
Class NavigationListener<A>
java.lang.Object
uk.ac.starlink.ttools.plot2.NavigationListener<A>
- All Implemented Interfaces:
MouseListener
,MouseMotionListener
,MouseWheelListener
,EventListener
public abstract class NavigationListener<A>
extends Object
implements MouseListener, MouseMotionListener, MouseWheelListener
Listener that receives mouse events and uses them in conjunction with
a supplied navigator to feed navigation actions to a set of one or
more plot surfaces.
- Since:
- 30 Oct 2013
- Author:
- Mark Taylor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListeners
(Component component) Convenience method to install this listener on a graphical component.abstract Supplier<CoordSequence>
Returns an iterable over a sequence of data space positions, which may be required to make sense of a click action.getNavigator
(int isurf) Returns a navigator which is used to convert mouse gestures into navigation actions.abstract Surface
getSurface
(int isurf) Returns the current plotting surface corresponding to a given numeric label.abstract int
getSurfaceIndex
(Point pos) Return an index labelling the plotting surface which provides the context for navigation actions referenced at a given point.protected void
handleClick
(Navigator<A> navigator, int isurf, Point pos, int ibutt, Supplier<CoordSequence> dposSupplier) Performs the actual work when a mouse click event is detected.void
mouseClicked
(MouseEvent evt) void
mouseDragged
(MouseEvent evt) void
mouseEntered
(MouseEvent evt) void
mouseExited
(MouseEvent evt) void
mouseMoved
(MouseEvent evt) void
mousePressed
(MouseEvent evt) void
mouseReleased
(MouseEvent evt) void
void
removeListeners
(Component component) Reverses the effect ofaddListeners
.protected abstract void
Receives a new aspect requested by user interface actions in conjunction with this object.protected abstract void
setDecoration
(Decoration decoration) Sets a decoration to display over the plot to indicate navigation actions in progress.void
updateDecoration
(Decoration dec, boolean autoCancel) Requests a change of the current navigation decoration.
-
Constructor Details
-
NavigationListener
protected NavigationListener()Constructor.
-
-
Method Details
-
getSurfaceIndex
Return an index labelling the plotting surface which provides the context for navigation actions referenced at a given point.- Parameters:
pos
- reference point for navigation- Returns:
- numeric label for plotting surface relevant for actions at, or starting at, the given point
-
getSurface
Returns the current plotting surface corresponding to a given numeric label. The supplied index must be one returned fromgetSurfaceIndex(java.awt.Point)
(if not, behaviour is undefined).- Parameters:
isurf
- surface index returned fromgetSurfaceIndex
- Returns:
- current plotting surface corresponding to the given index; may be null
-
createDataPosSupplier
Returns an iterable over a sequence of data space positions, which may be required to make sense of a click action.- Parameters:
pos
- reference position for data- Returns:
- iterable over data positions, may be null
- See Also:
-
setAspect
Receives a new aspect requested by user interface actions in conjunction with this object. The supplied aspect corresponds to the surface with the given index, as supplied by thegetSurfaceIndex(java.awt.Point)
method.- Parameters:
isurf
- label for surface to which new aspect appliesaspect
- definition of requested plot surface
-
setDecoration
Sets a decoration to display over the plot to indicate navigation actions in progress. This decoration should be displayed until further notice, that is, until this method is called again with a null argument.This method is called by
updateDecoration
. It should not be called directly.- Parameters:
decoration
- navigation decoration, or null for none
-
updateDecoration
Requests a change of the current navigation decoration. This performs some housekeeping operations, and callssetDecoration(uk.ac.starlink.ttools.plot2.Decoration)
. TheautoCancel
parameter controls whether the decoration will be cancelled automatically or by hand. If the caller can guarantee to make a matching call with a null decoration in the future,autoCancel
may be false, otherwise it should be true.- Parameters:
dec
- new decorationautoCancel
- if true, decoration will be automatically cancelled
-
mousePressed
- Specified by:
mousePressed
in interfaceMouseListener
-
mouseDragged
- Specified by:
mouseDragged
in interfaceMouseMotionListener
-
mouseReleased
- Specified by:
mouseReleased
in interfaceMouseListener
-
mouseClicked
- Specified by:
mouseClicked
in interfaceMouseListener
-
mouseWheelMoved
- Specified by:
mouseWheelMoved
in interfaceMouseWheelListener
-
mouseMoved
- Specified by:
mouseMoved
in interfaceMouseMotionListener
-
mouseEntered
- Specified by:
mouseEntered
in interfaceMouseListener
-
mouseExited
- Specified by:
mouseExited
in interfaceMouseListener
-
addListeners
Convenience method to install this listener on a graphical component. This currently just callsaddMouseListener
,addMouseMotionListener
andaddMouseWheelListener
.- Parameters:
component
- component to which this object should listen
-
removeListeners
Reverses the effect ofaddListeners
.- Parameters:
component
- component to which this listener was previously added
-