public abstract class PositionReporter extends Object implements MouseMotionListener
PlotSurface
data coordinates.
When a mouse movement event is heard, the reportPosition(java.lang.String[])
method is called with suitable arguments.Constructor and Description |
---|
PositionReporter(uk.ac.starlink.ttools.plot.PlotSurface surface)
Constructs a new position reporter for a given plot surface.
|
PositionReporter(uk.ac.starlink.ttools.plot.PlotSurface surface,
uk.ac.starlink.ttools.convert.ValueConverter xConv,
uk.ac.starlink.ttools.convert.ValueConverter yConv)
Constructs a new position reporter for a given plot surface
using supplied value converter objects for the X and Y axes.
|
Modifier and Type | Method and Description |
---|---|
String[] |
formatPosition(int px,
int py)
Turns the numeric values of graphics space coordinates into
strings giving the positions in data space.
|
void |
mouseDragged(MouseEvent evt)
No action.
|
void |
mouseMoved(MouseEvent evt) |
protected abstract void |
reportPosition(String[] coords)
Invoked when the mouse has moved.
|
public PositionReporter(uk.ac.starlink.ttools.plot.PlotSurface surface)
surface
- plotting surfacepublic PositionReporter(uk.ac.starlink.ttools.plot.PlotSurface surface, uk.ac.starlink.ttools.convert.ValueConverter xConv, uk.ac.starlink.ttools.convert.ValueConverter yConv)
unconvert
methods of said converters should
provide the formatting (number -> formatted string) behaviour
for each axis.surface
- plotting surfacexConv
- value converter for X axis (or null)yConv
- value converter for Y axis (or null)protected abstract void reportPosition(String[] coords)
coords
array is either a two-element array giving
formatted values for the X and Y coordinates respectively,
or null
indicating that the pointer does not currently
correspond to a sensible position in data space.
Some effort is made to format the coordinate values in a compact
but consistent fashion.coords
- formatted (x,y) coordinate values, or nullpublic void mouseMoved(MouseEvent evt)
mouseMoved
in interface MouseMotionListener
public void mouseDragged(MouseEvent evt)
mouseDragged
in interface MouseMotionListener
public String[] formatPosition(int px, int py)
px
- graphics space X coordinatepy
- graphics space Y coordinateCopyright © 2003-2025 CCLRC: Council for the Central Laboratory of the Research Councils. All Rights Reserved.