Package uk.ac.starlink.ttools.plot2.data
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 java.lang.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:
- characteristic (typically central) position in data space (2 elements for plane coords, 3 elements for sky coords)
- type code (1 element, equal to an integer)
- data array giving area details (variable length, interpretation dependent on type code)
getAreaDataGeom(DG)
method must be used.- Since:
- 27 Mar 2020
- Author:
- Mark Taylor
- See Also:
- DALI 1.1 section 3.3, TAP 1.0 section 6
-
-
Field Summary
Fields Modifier and Type Field Description static AreaCoord<PlaneDataGeom>
PLANE_COORD
Instance for use with Plane plot type.static AreaCoord<SkyDataGeom>
SKY_COORD
Instance for use with Sky plot type.static AreaCoord<SphereDataGeom>
SPHERE_COORD
Instance for use with Sphere plot type.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static AreaCoord<PlaneDataGeom>
createPlaneCoord(InputMeta meta, boolean isRequired)
Constructs a custom AreaCoord instance for use with Plane plot type.static AreaCoord<SkyDataGeom>
createSkyCoord(InputMeta meta, boolean isRequired)
Constructs a custom AreaCoord instance for use with Sky plot type.static AreaCoord<SphereDataGeom>
createSphereCoord(InputMeta meta, boolean isRequired)
Constructs a custom AreaCoord instance for use with Sphere plot type.abstract DG
getAreaDataGeom(DG baseGeom)
Returns a DataGeom that can be used to read position data from objects serialized by this coordinate.Input[]
getInputs()
Returns specifications of the one or more input values the user supplies to provide the data values for this coord.StorageType
getStorageType()
Returns a code indicating how the quantity defined by this object is stored internally and presented to the plotting classes.java.util.function.Function<java.lang.Object[],double[]>
inputStorage(uk.ac.starlink.table.ValueInfo[] infos, uk.ac.starlink.table.DomainMapper[] dms)
Provides a function to turn a quantity in the user view to a plotting view object.boolean
isRequired()
Indicates whether this item must have a non-blank value in order for a plot to be possible.Area
readAreaCoord(Tuple tuple, int icol)
Reads an Area value from an appropriate field in a given Tuple.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.
-
-
-
Field Detail
-
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 Detail
-
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 objectdpos
- 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.
-
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 interfaceCoord
- 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 interfaceCoord
- Returns:
- if true, values must be supplied to make a plot
-
inputStorage
public java.util.function.Function<java.lang.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
anddomainMappers
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 interfaceCoord
- Parameters:
infos
- per-input array of column input metadatadms
- 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 metadataisRequired
- 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 metadataisRequired
- 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 metadataisRequired
- true iff this coordinate is required for plot- Returns:
- new instance
-
-