Package uk.ac.starlink.topcat.plot

## Class PositionReporter

- java.lang.Object
- - uk.ac.starlink.topcat.plot.PositionReporter

- All Implemented Interfaces:
    `java.awt.event.MouseMotionListener`, `java.util.EventListener`

      public abstract class PositionReporter
      extends java.lang.Object
      implements java.awt.event.MouseMotionListener

  MouseMotionListener which acts on mouse movement events to provide the position of the pointer in `PlotSurface` data coordinates. When a mouse movement event is heard, the `reportPosition(java.lang.String[])` method is called with suitable arguments.
  Since:
    10 Nov 2005
  Author:
    Mark Taylor

- - ### Constructor Summary

    Constructors
    Constructor | 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.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `java.lang.String[]` | `formatPosition​(int px, int py)` | Turns the numeric values of graphics space coordinates into strings giving the positions in data space.
    `void` | `mouseDragged​(java.awt.event.MouseEvent evt)` | No action.
    `void` | `mouseMoved​(java.awt.event.MouseEvent evt)` |
    `protected abstract void` | `reportPosition​(java.lang.String[] coords)` | Invoked when the mouse has moved.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PositionReporter

          public PositionReporter​(uk.ac.starlink.ttools.plot.PlotSurface surface)

      Constructs a new position reporter for a given plot surface.
      Parameters:
        `surface` - plotting surface

    - #### PositionReporter

          public 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. The `unconvert` methods of said converters should provide the formatting (number -> formatted string) behaviour for each axis.
      Parameters:
        `surface` - plotting surface
        `xConv` - value converter for X axis (or null)
        `yConv` - value converter for Y axis (or null)

  - ### Method Detail

    - #### reportPosition

          protected abstract void reportPosition​(java.lang.String[] coords)

      Invoked when the mouse has moved. The `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.
      Parameters:
        `coords` - formatted (x,y) coordinate values, or null

    - #### mouseMoved

          public void mouseMoved​(java.awt.event.MouseEvent evt)

      Specified by:
        `mouseMoved` in interface `java.awt.event.MouseMotionListener`

    - #### mouseDragged

          public void mouseDragged​(java.awt.event.MouseEvent evt)

      No action.
      Specified by:
        `mouseDragged` in interface `java.awt.event.MouseMotionListener`

    - #### formatPosition

          public java.lang.String[] formatPosition​(int px,
                                                   int py)

      Turns the numeric values of graphics space coordinates into strings giving the positions in data space.
      Parameters:
        `px` - graphics space X coordinate
        `py` - graphics space Y coordinate
      Returns:
        2-element (x,y) array giving formatted data space coords, or null

Copyright © 2003-2018 CCLRC: Council for the Central Laboratory of the Research Councils. All Rights Reserved.