Class AreaCoord<DG extends DataGeom>

java.lang.Object
uk.ac.starlink.ttools.plot2.data.AreaCoord<DG>
All Implemented Interfaces:
Coord

public abstract class AreaCoord<DG extends DataGeom> extends Object implements Coord
Coord implementation for Area (shape) values. It can currently work with shapes specified as strings using (a subset of) the STC-S syntax referenced by TAP 1.0, and as floating point arrays using the CIRCLE, POLYGON and POINT xtypes defined in DALI 1.1.

The serialisation to floating point array is in three parts:

  1. characteristic (typically central) position in data space (2 elements for plane coords, 3 elements for sky coords)
  2. type code (1 element, equal to an integer)
  3. data array giving area details (variable length, interpretation dependent on type code)
The point of storing the characteristic position is so that that position can be extracted for each row, for use in a point cloud to benefit from the standard machinery for auto-ranging, selection by region etc. Note that to decode this position information, a DataGeom supplied from the getAreaDataGeom(DG) method must be used.
Since:
27 Mar 2020
Author:
Mark Taylor
See Also:
  • Field Details

    • PLANE_COORD

      public static final AreaCoord<PlaneDataGeom> PLANE_COORD
      Instance for use with Plane plot type.
    • SKY_COORD

      public static final AreaCoord<SkyDataGeom> SKY_COORD
      Instance for use with Sky plot type.
    • SPHERE_COORD

      public static final AreaCoord<SphereDataGeom> SPHERE_COORD
      Instance for use with Sphere plot type.
  • Method Details

    • writeDataPos

      protected abstract void writeDataPos(Area area, double[] dpos)
      Writes the position in data coordinates of the characteristic (typically central) point of a given area object into the start of a supplied array.
      Parameters:
      area - area object
      dpos - coordinate array into which characteristic position data coords are written
    • getAreaDataGeom

      public abstract DG getAreaDataGeom(DG baseGeom)
      Returns a DataGeom that can be used to read position data from objects serialized by this coordinate. The returned DataGeom instance is based on a given instance; it may inherit some behaviour (for instance coordinate rotation in case of a SkyDataGeom).
      Parameters:
      baseGeom - DataGeom instance providing context behaviour
      Returns:
      data geom
    • getInputs

      public Input[] getInputs()
      Description copied from interface: Coord
      Returns specifications of the one or more input values the user supplies to provide the data values for this coord.
      Specified by:
      getInputs in interface Coord
      Returns:
      one or more items describing the user input values for this quantity
    • getStorageType

      public StorageType getStorageType()
      Description copied from interface: Coord
      Returns a code indicating how the quantity defined by this object is stored internally and presented to the plotting classes.
      Specified by:
      getStorageType in interface Coord
      Returns:
      storage type enum instance
    • isRequired

      public boolean isRequired()
      Description copied from interface: Coord
      Indicates whether this item must have a non-blank value in order for a plot to be possible.
      Specified by:
      isRequired in interface Coord
      Returns:
      if true, values must be supplied to make a plot
    • inputStorage

      public Function<Object[],double[]> inputStorage(uk.ac.starlink.table.ValueInfo[] infos, uk.ac.starlink.table.DomainMapper[] dms)
      Description copied from interface: Coord
      Provides a function to turn a quantity in the user view to a plotting view object.

      The supplied infos and domainMappers arrays correspond to (have the same length as) this object's Inputs array, and may influence the return values. However, Coord instances that always behave the same way (for instance whose Input Domains have fixed DomainMappers) are free to ignore these arguments.

      The returned function converts an array of per-input user values to a storable object of the type corresponding to the result of Coord.getStorageType(); the return value of the returned function is never null.

      Specified by:
      inputStorage in interface Coord
      Parameters:
      infos - per-input array of column input metadata
      dms - per-input array of input value->domain value mappers
      Returns:
      input values to storage object conversion function, or null if such conversions will never be possible
    • readAreaCoord

      public Area readAreaCoord(Tuple tuple, int icol)
      Reads an Area value from an appropriate field in a given Tuple.
      Parameters:
      tuple - tuple
      Returns:
      icol index of column in tuple corresponding to this coord
    • createPlaneCoord

      public static AreaCoord<PlaneDataGeom> createPlaneCoord(InputMeta meta, boolean isRequired)
      Constructs a custom AreaCoord instance for use with Plane plot type.
      Parameters:
      meta - user coordinate metadata
      isRequired - true iff this coordinate is required for plot
      Returns:
      new instance
    • createSkyCoord

      public static AreaCoord<SkyDataGeom> createSkyCoord(InputMeta meta, boolean isRequired)
      Constructs a custom AreaCoord instance for use with Sky plot type.
      Parameters:
      meta - user coordinate metadata
      isRequired - true iff this coordinate is required for plot
      Returns:
      new instance
    • createSphereCoord

      public static AreaCoord<SphereDataGeom> createSphereCoord(InputMeta meta, boolean isRequired)
      Constructs a custom AreaCoord instance for use with Sphere plot type. Note this assumes that the supplied Tuples have the radial coordinate directly after the area coordinate.
      Parameters:
      meta - user coordinate metadata
      isRequired - true iff this coordinate is required for plot
      Returns:
      new instance