# Class ArrayShapePlotter

java.lang.Object
uk.ac.starlink.ttools.plot2.layer.AbstractPlotter<ShapeStyle>
uk.ac.starlink.ttools.plot2.layer.ShapePlotter
uk.ac.starlink.ttools.plot2.layer.ArrayShapePlotter

All Implemented Interfaces:
  `ModePlotter<ShapeStyle>, ShapeModePlotter, Plotter<ShapeStyle>`

public class ArrayShapePlotter extends ShapePlotter
ShapePlotter subclass that plots multiple shapes for each row, based on array-valued coordinates. This class provides some additional functionality specific to array-valued positions.

This plotter does not report positions and point clouds in the usual way, since each row typically corresponds to a large region of the plot surface, and reporting a single point is not very helpful. Instead, the PlotLayers it supplies are doctored to adjust the coordinate ranges to cover the whole of the relevant area for the plotted rows.

Since:
  27 Jan 2021
Author:
  Mark Taylor

## Nested Class Summary

### Nested classes/interfaces inherited from interface ModePlotter

`ModePlotter.Form, ModePlotter.Mode`

## Constructor Summary

Constructors
Constructor
Description
`ArrayShapePlotter(String name, ShapeForm form, ShapeMode mode)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static ArrayShapePlotter[]`
`createArrayShapePlotters(ShapeForm[] forms, ShapeMode[] modes)`
Creates an array of ArrayShapePlotters, using all combinations of the specified list of ShapeForms and ShapeModes.
`PlotLayer`
`createLayer(DataGeom pointDataGeom, DataSpec dataSpec, ShapeStyle style)`
Creates a PlotLayer based on the given geometry, data and style.
`static Function<Tuple, XYArrayData>`
`createXYArrayReader(FloatingArrayCoord xsCoord, FloatingArrayCoord ysCoord, int icXs, int icYs, DataSpec dataSpec)`
Returns a reader for matched X/Y array data for use with array plotters.
`int`
`getModeCoordsIndex(DataGeom geom)`
Returns the index into a dataspec used by this plotter at which the first of its ShapeMode's "extra" coordinates is found.
`static boolean`
`matchesAxis(String axName, Input input)`
Utility method that identifies whether an Input corresponds to a named axis.

### Methods inherited from class ShapePlotter

`createFlat2dPlotter, createShapePlotters, createStyle, getForm, getMode, getPlotterDescription, getStyleKeys`

### Methods inherited from class AbstractPlotter

`getCoordGroup, getPlotterIcon, getPlotterName, getRangeStyleKey, hasReports`

### Methods inherited from class Object

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

### Methods inherited from interface Plotter

`getCoordGroup, getPlotterIcon, getPlotterName, getRangeStyleKey, hasReports`

## Constructor Details

### ArrayShapePlotter

public ArrayShapePlotter(String name, ShapeForm form, ShapeMode mode)
Constructor.

Parameters:
  `name` - plotter name
  `form` - multiple shape determiner
  `mode` - colour determiner

## Method Details

### getModeCoordsIndex

public int getModeCoordsIndex(DataGeom geom)
Description copied from class: `ShapePlotter`
Returns the index into a dataspec used by this plotter at which the first of its ShapeMode's "extra" coordinates is found.

Overrides:
  `getModeCoordsIndex` in class `ShapePlotter`
Parameters:
  `geom` - data position coordinate description
Returns:
  index of first mode-specific coordinate

### createLayer

public PlotLayer createLayer(DataGeom pointDataGeom, DataSpec dataSpec, ShapeStyle style)
Description copied from interface: `Plotter`
Creates a PlotLayer based on the given geometry, data and style.

The `style` parameter is the result of a call to `Plotter.createStyle(ConfigMap)`.

The `dataSpec` parameter must contain the coordinates defined by this plotter's CoordGroup.

The `pointDataGeom` parameter is only used if the `CoordGroup.getBasicPositionCount()` or `CoordGroup.getExtraPositionCount()` method from this plotter's CoordGroup return a non-zero value, otherwise the plot does not have point positions.

It is legal to supply null for any of the parameters; if insufficient data is supplied to generate a plot, then the method should return null.

Creating a layer should be cheap; layers may be created and not used.

Specified by:
  `createLayer` in interface `Plotter<ShapeStyle>`
Overrides:
  `createLayer` in class `ShapePlotter`
Parameters:
  `pointDataGeom` - indicates base position coordinates and their mapping to points in the data space
  `dataSpec` - specifies the data required for the plot
  `style` - data style as obtained from `createStyle`
Returns:
  new plot layer, or null if no drawing will take place

### createArrayShapePlotters

public static ArrayShapePlotter[] createArrayShapePlotters(ShapeForm[] forms, ShapeMode[] modes)
Creates an array of ArrayShapePlotters, using all combinations of the specified list of ShapeForms and ShapeModes. Since these implement the `ModePlotter` interface, other parts of the UI may be able to group them.

Parameters:
  `forms` - array of shape forms
  `modes` - array of shape modes
Returns:
  `forms.length*modes.length`-element array of plotters

### matchesAxis

public static boolean matchesAxis(String axName, Input input)
Utility method that identifies whether an Input corresponds to a named axis. This is an ad hoc method put in place to assist in working out how to annotate axes on which array plots are represented.

Parameters:
  `axName` - geometric axis name, e.g. "X"
  `input` - coordinate input specification
Returns:
  true iff the input corresponds to an array value specifier intended for the named axis

### createXYArrayReader

public static Function<Tuple, XYArrayData> createXYArrayReader(FloatingArrayCoord xsCoord, FloatingArrayCoord ysCoord, int icXs, int icYs, DataSpec dataSpec)
Returns a reader for matched X/Y array data for use with array plotters. If null is returned from this function, no plotting should be done.

Parameters:
  `xsCoord` - coordinate for X array
  `ysCoord` - coordinate for Y array
  `icXs` - X array coordinate index in group
  `icYs` - Y array coordinate index in group
  `dataSpec` - data specification
Returns:
  thread-safe function to map tuples to XYArrayData; the function returns null for tuples that should not be plotted/accumulated