public abstract class NavigationListener<A> extends Object implements MouseListener, MouseMotionListener, MouseWheelListener
Modifier | Constructor and Description |
---|---|
protected |
NavigationListener()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addListeners(Component component)
Convenience method to install this listener on a graphical component.
|
abstract java.util.function.Supplier<CoordSequence> |
createDataPosSupplier(Point pos)
Returns an iterable over a sequence of data space positions,
which may be required to make sense of a click action.
|
abstract Navigator<A> |
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,
java.util.function.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 |
mouseWheelMoved(MouseWheelEvent evt) |
void |
removeListeners(Component component)
Reverses the effect of
addListeners . |
protected abstract void |
setAspect(int isurf,
A aspect)
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.
|
public abstract int getSurfaceIndex(Point pos)
pos
- reference point for navigationpublic abstract Surface getSurface(int isurf)
getSurfaceIndex(java.awt.Point)
(if not, behaviour is undefined).isurf
- surface index returned from getSurfaceIndex
public abstract Navigator<A> getNavigator(int isurf)
isurf
- surface index returned from getSurfaceIndex
public abstract java.util.function.Supplier<CoordSequence> createDataPosSupplier(Point pos)
pos
- reference position for dataNavigator.click(uk.ac.starlink.ttools.plot2.Surface, java.awt.Point, int, java.util.function.Supplier<uk.ac.starlink.ttools.plot2.CoordSequence>)
protected abstract void setAspect(int isurf, A aspect)
getSurfaceIndex(java.awt.Point)
method.isurf
- label for surface to which new aspect appliesaspect
- definition of requested plot surfaceprotected abstract void setDecoration(Decoration decoration)
This method is called by updateDecoration
.
It should not be called directly.
decoration
- navigation decoration, or null for nonepublic void updateDecoration(Decoration dec, boolean autoCancel)
setDecoration(uk.ac.starlink.ttools.plot2.Decoration)
.
The autoCancel
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.dec
- new decorationautoCancel
- if true, decoration will be automatically cancelledpublic void mousePressed(MouseEvent evt)
mousePressed
in interface MouseListener
public void mouseDragged(MouseEvent evt)
mouseDragged
in interface MouseMotionListener
public void mouseReleased(MouseEvent evt)
mouseReleased
in interface MouseListener
public void mouseClicked(MouseEvent evt)
mouseClicked
in interface MouseListener
protected void handleClick(Navigator<A> navigator, int isurf, Point pos, int ibutt, java.util.function.Supplier<CoordSequence> dposSupplier)
mouseClicked
.
The default behaviour is to get a corresponding navigation action
from the navigator,
and call setAspect(int, A)
and updateDecoration(uk.ac.starlink.ttools.plot2.Decoration, boolean)
accordingly.
However, it may be overridden by subclasses.navigator
- navigatorisurf
- surface numeric labelpos
- mouse positionibutt
- logical mouse button indexdposSupplier
- iterable over points if availablepublic void mouseWheelMoved(MouseWheelEvent evt)
mouseWheelMoved
in interface MouseWheelListener
public void mouseMoved(MouseEvent evt)
mouseMoved
in interface MouseMotionListener
public void mouseEntered(MouseEvent evt)
mouseEntered
in interface MouseListener
public void mouseExited(MouseEvent evt)
mouseExited
in interface MouseListener
public void addListeners(Component component)
addMouseListener
,
addMouseMotionListener
and
addMouseWheelListener
.component
- component to which this object should listenpublic void removeListeners(Component component)
addListeners
.component
- component to which this listener was previously addedCopyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.