# Class PlotContext<P,A>

java.lang.Object
uk.ac.starlink.ttools.plot2.task.PlotContext<P,A>

public abstract class PlotContext<P,A> extends Object
Aggregates some miscellaneous information required for a plot task that may not be available until execution time.

Since:
  22 Aug 2014
Author:
  Mark Taylor

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`GEOM_PARAM_NAME`
Name of the standard geometry parameter.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`PlotContext(PlotType<P,A> plotType, DataGeom[] exampleGeoms)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static <P,A> PlotContext<P,A>`
`createFixedContext(PlotType<P,A> plotType, DataGeom geom)`
Constructs a PlotContext which always uses a fixed given DataGeom.
`static <P,A> PlotContext<P,A>`
`createStandardContext(PlotType<P,A> plotType)`
Constructs a PlotContext which allows per-layer choice of DataGeom between those known by a given plot type.
`DataGeom[]`
`getExampleGeoms()`
Returns a list of one or more DataGeom objects to be used for example purposes.
`abstract DataGeom`
`getGeom(uk.ac.starlink.task.Environment env, String layerSuffix)`
Returns the DataGeom to use for a given layer in the context of a given execution environment.
`abstract uk.ac.starlink.task.Parameter<?>`
`getGeomParameter(String layerSuffix)`
Returns a parameter associated with a particular layer required for determining DataGeom at runtime, if any.
`PlotType<P,A>`
`getPlotType()`
Returns the plot type.

### Methods inherited from class Object

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

## Field Details

### GEOM_PARAM_NAME

public static final String GEOM_PARAM_NAME
Name of the standard geometry parameter.

See Also:
  - Constant Field Values

## Constructor Details

### PlotContext

protected PlotContext(PlotType<P,A> plotType, DataGeom[] exampleGeoms)
Constructor. Information that is not dependent on other variables (environment, layer suffix) is specified here.

Parameters:
  `plotType` - plot type
  `exampleGeoms` - example data geoms

## Method Details

### getPlotType

public PlotType<P,A> getPlotType()
Returns the plot type.

Returns:
  plot type

### getExampleGeoms

public DataGeom[] getExampleGeoms()
Returns a list of one or more DataGeom objects to be used for example purposes. These may be used to construct parameter auto-documentation, which is needed in absence of an execution environment. The first item in the list is considered most important.

Returns:
  one or more example data geoms

### getGeomParameter

public abstract uk.ac.starlink.task.Parameter<?> getGeomParameter(String layerSuffix)
Returns a parameter associated with a particular layer required for determining DataGeom at runtime, if any. The value class of the returned parameter may or may not be DataGeom.

Parameters:
  `layerSuffix` - parameter suffix string identifying a plot layer
Returns:
  parameter used for determining DataGeom, or null

### getGeom

public abstract DataGeom getGeom(uk.ac.starlink.task.Environment env, String layerSuffix) throws uk.ac.starlink.task.TaskException
Returns the DataGeom to use for a given layer in the context of a given execution environment.

Parameters:
  `env` - execution environment
  `layerSuffix` - parameter suffix string identifying a plot layer
Returns:
  datageom
Throws:
  `uk.ac.starlink.task.TaskException`

### createStandardContext

public static <P,A> PlotContext<P,A> createStandardContext(PlotType<P,A> plotType)
Constructs a PlotContext which allows per-layer choice of DataGeom between those known by a given plot type. The choice is offered (a per-layer parameter is present) even if only a single DataGeom is known by the PlotType. This might conceivably be useful, in that it allows pluggable DataGeoms specified by classname.

Parameters:
  `plotType` - plot type
Returns:
  standard plot context

### createFixedContext

public static <P,A> PlotContext<P,A> createFixedContext(PlotType<P,A> plotType, DataGeom geom)
Constructs a PlotContext which always uses a fixed given DataGeom. No DataGeom-specific parameters are required or provided.

Parameters:
  `plotType` - plot type
  `geom` - data geom used in all cases
Returns:
  fixed-geom plot context