# Class SpectrogramPlotter

java.lang.Object
uk.ac.starlink.ttools.plot2.layer.SpectrogramPlotter

All Implemented Interfaces:
  `Plotter<SpectrogramPlotter.SpectroStyle>`

public class SpectrogramPlotter extends Object implements Plotter<SpectrogramPlotter.SpectroStyle>
Plotter for spectrograms. A spectrogram is a spectrum represented as a vertical line of pixels at successive positions in a time series (time axis horizontal, spectral axis vertical).

Since:
  16 Jul 2013
Author:
  Mark Taylor

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static interface`
`SpectrogramPlotter.ChannelGrid`
Defines the spectrum frequency channels.
`static class`
`SpectrogramPlotter.SpectroStyle`
Style subclass for SpectrogramPlotter.

## Constructor Summary

Constructors
Constructor
Description
`SpectrogramPlotter(FloatingCoord xCoord)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`PlotLayer`
`createLayer(DataGeom geom, DataSpec dataSpec, SpectrogramPlotter.SpectroStyle style)`
The supplied `geom` is ignored.
`SpectrogramPlotter.SpectroStyle`
`createStyle(ConfigMap config)`
Creates a style that can be used when creating a plot layer.
`SpectrogramPlotter.ChannelGrid`
`getChannelGrid(SpectrogramPlotter.SpectroStyle style, uk.ac.starlink.table.ColumnInfo specInfo, uk.ac.starlink.table.StarTable table)`
Returns the channel grid to use for a given style, spectrum column and table.
`CoordGroup`
`getCoordGroup()`
Returns an object describing which data coordinates are used for this plotter and how they are arranged in supplied DataSpec objects.
`int`
`getExtentCoordIndex()`
Returns the coordinate index for the time extent coordinate.
`String`
`getPlotterDescription()`
Returns an XML description of this plotter.
`Icon`
`getPlotterIcon()`
Returns an icon for this plotter for use in user interface.
`String`
`getPlotterName()`
Returns the name of this plotter for use in user interface.
`Object`
`getRangeStyleKey(SpectrogramPlotter.SpectroStyle style)`
Returns an opaque object characterising the region of the plot surface covered when using a given plotter style.
`int`
`getSpectrumCoordIndex()`
Returns the coordinate index for the spectral coordinate.
`ConfigKey<?>[]`
`getStyleKeys()`
Returns the configuration keys used to configure style for this plotter.
`boolean`
`hasReports()`
Indicates whether the drawings produced by this plotter will return general interest report information to upstream plotting code.

### Methods inherited from class Object

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

## Constructor Details

### SpectrogramPlotter

public SpectrogramPlotter(FloatingCoord xCoord)
Constructor.

Parameters:
  `xCoord` - horizontal axis coordinate

## Method Details

### getSpectrumCoordIndex

public int getSpectrumCoordIndex()
Returns the coordinate index for the spectral coordinate.

Returns:
  spectrum coordinate index

### getExtentCoordIndex

public int getExtentCoordIndex()
Returns the coordinate index for the time extent coordinate.

Returns:
  time extent coordinate index

### getPlotterName

public String getPlotterName()
Description copied from interface: `Plotter`
Returns the name of this plotter for use in user interface.

Specified by:
  `getPlotterName` in interface `Plotter<SpectrogramPlotter.SpectroStyle>`
Returns:
  user-directed plotter name

### getPlotterIcon

public Icon getPlotterIcon()
Description copied from interface: `Plotter`
Returns an icon for this plotter for use in user interface.

Specified by:
  `getPlotterIcon` in interface `Plotter<SpectrogramPlotter.SpectroStyle>`
Returns:
  plotter icon

### getPlotterDescription

public String getPlotterDescription()
Description copied from interface: `Plotter`
Returns an XML description of this plotter.

Note: really this should appear at the LayerType level.

Specified by:
  `getPlotterDescription` in interface `Plotter<SpectrogramPlotter.SpectroStyle>`
Returns:
  one or more <p> elements

### getCoordGroup

public CoordGroup getCoordGroup()
Description copied from interface: `Plotter`
Returns an object describing which data coordinates are used for this plotter and how they are arranged in supplied DataSpec objects.

Specified by:
  `getCoordGroup` in interface `Plotter<SpectrogramPlotter.SpectroStyle>`
Returns:
  coordinate group

### getStyleKeys

public ConfigKey<?>[] getStyleKeys()
Description copied from interface: `Plotter`
Returns the configuration keys used to configure style for this plotter. The keys in the return value are used in the map supplied to the `Plotter.createStyle(ConfigMap)` method.

Specified by:
  `getStyleKeys` in interface `Plotter<SpectrogramPlotter.SpectroStyle>`
Returns:
  keys used when creating a style for this plotter.

### createStyle

public SpectrogramPlotter.SpectroStyle createStyle(ConfigMap config)
Description copied from interface: `Plotter`
Creates a style that can be used when creating a plot layer. The keys that are significant in the supplied config map are those returned by `Plotter.getStyleKeys()`. The return value can be used as input to `Plotter.createLayer(DataGeom, DataSpec, S)`.

Specified by:
  `createStyle` in interface `Plotter<SpectrogramPlotter.SpectroStyle>`
Parameters:
  `config` - map of style configuration items
Returns:
  plotter-specific plot style

### getRangeStyleKey

public Object getRangeStyleKey(SpectrogramPlotter.SpectroStyle style)
Description copied from interface: `Plotter`
Returns an opaque object characterising the region of the plot surface covered when using a given plotter style. If this object changes between layers produced by this plotter, it provides a hint that it may be necessary to redetermine the axis ranges (using `extendCoordinateRanges`).

In many cases, such as scatter-plot-like plotters, the range is determined only by the coordinate data (managed by `DataSpec` inputs) so a null value may be returned. This method is chiefly required by histogram-like plotters for which the region on the plot surface is not the union of the input positions.

Specified by:
  `getRangeStyleKey` in interface `Plotter<SpectrogramPlotter.SpectroStyle>`
Parameters:
  `style` - plot style to assess
Returns:
  opaque object with equality semantics, or null if axis range is not a function of style

### hasReports

public boolean hasReports()
Description copied from interface: `Plotter`
Indicates whether the drawings produced by this plotter will return general interest report information to upstream plotting code.

Specified by:
  `hasReports` in interface `Plotter<SpectrogramPlotter.SpectroStyle>`
Returns:
  true if the plot report may return interesting information
See Also:
  - `Drawing.getReport(Object)`

### createLayer

public PlotLayer createLayer(DataGeom geom, DataSpec dataSpec, SpectrogramPlotter.SpectroStyle style)
The supplied `geom` is ignored.

Specified by:
  `createLayer` in interface `Plotter<SpectrogramPlotter.SpectroStyle>`
Parameters:
  `geom` - 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

### getChannelGrid

public SpectrogramPlotter.ChannelGrid getChannelGrid(SpectrogramPlotter.SpectroStyle style, uk.ac.starlink.table.ColumnInfo specInfo, uk.ac.starlink.table.StarTable table)
Returns the channel grid to use for a given style, spectrum column and table. The column metadata aux items, and the per-table metadata, are trawled to find something appropriate. If nothing is found, a suitable default grid is returned.

Currently, anything that looks like an array with shape `(n)` is interpreted as central channel positions, and an array with shape `(2,n)` is interpreted as channel low/high bounds.

It's a bit ad hoc.

Parameters:
  `style` - style
  `specInfo` - column metadata for spectral column
  `table` - table from which spectral column is taken
Returns:
  channel grid, not null