# Class TimeSurfaceFactory

java.lang.Object
uk.ac.starlink.ttools.plot2.geom.TimeSurfaceFactory

All Implemented Interfaces:
  `SurfaceFactory<TimeSurfaceFactory.Profile, TimeAspect>`

public class TimeSurfaceFactory extends Object implements SurfaceFactory<TimeSurfaceFactory.Profile, TimeAspect>
Surface factory for time plots.

Since:
  15 Aug 2013
Author:
  Mark Taylor

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`TimeSurfaceFactory.Profile`
Profile class which defines fixed configuration items for a TimeSurface.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final ConfigKey<Boolean>`
`GRID_KEY`
Config key to determine if grid lines are drawn.
`static final ConfigKey<OrientationPolicy>`
`ORIENTATIONS_KEY`
Config key to control axis label orientation.
`static final ConfigKey<TimeJELFunction>`
`T2FUNC_KEY`
Config key for secondary time axis function.
`static final ConfigKey<String>`
`T2LABEL_KEY`
Config key for secondary time axis text label.
`static final ConfigKey<Double>`
`TCROWD_KEY`
Config key to control tick mark crowding on time axis.
`static final ConfigKey<TimeFormat>`
`TFORMAT_KEY`
Config key to control time value formatting.
`static final ConfigKey<String>`
`TLABEL_KEY`
Config key for time axis text label.
`static final ConfigKey<Double>`
`TMAX_KEY`
Config key for time axis upper bound, before subranging.
`static final ConfigKey<Double>`
`TMIN_KEY`
Config key for time axis lower bound, before subranging.
`static final ConfigKey<Subrange>`
`TSUBRANGE_KEY`
Config key for time axis subrange.
`static final ConfigKey<JELFunction>`
`Y2FUNC_KEY`
Config key for secondary Y axis function.
`static final ConfigKey<String>`
`Y2LABEL_KEY`
Config key for secondary Y axis text label.
`static final ConfigKey<Double>`
`YCROWD_KEY`
Config key to control tick mark crowding on Y axis.
`static final ConfigKey<Boolean>`
`YFLIP_KEY`
Config key for Y axis flip flag.
`static final ConfigKey<String>`
`YLABEL_KEY`
Config key for Y axis text label.
`static final ConfigKey<Boolean>`
`YLOG_KEY`
Config key for Y axis log scale flag.
`static final ConfigKey<Double>`
`YMAX_KEY`
Config key for Y axis upper bound, before subranging.
`static final ConfigKey<Double>`
`YMIN_KEY`
Config key for Y axis lower bound, before subranging.
`static final ConfigKey<Subrange>`
`YSUBRANGE_KEY`
Config key for Y axis subrange.

## Constructor Summary

Constructors
Constructor
Description
`TimeSurfaceFactory()`

## Method Summary

Modifier and Type
Method
Description
`TimeAspect`
`createAspect(TimeSurfaceFactory.Profile profile, ConfigMap config, Range[] ranges)`
Creates an aspect from configuration information.
`Navigator<TimeAspect>`
`createNavigator(ConfigMap navConfig)`
Creates a navigator from configuration information.
`TimeSurfaceFactory.Profile`
`createProfile(ConfigMap config)`
Creates a profile that can be used when creating a plot surface.
`Surface`
`createSurface(Rectangle plotBounds, TimeSurfaceFactory.Profile profile, TimeAspect aspect)`
Returns a new plot surface.
`ConfigMap`
`getAspectConfig(Surface surf)`
Returns a ConfigMap that corresponds to the configuration of the given surface, which must have been created by this factory.
`ConfigKey<?>[]`
`getAspectKeys()`
Returns the configuration keys that may be used to configure aspect for this surface factory.
`ConfigKey<?>[]`
`getNavigatorKeys()`
Returns the configuration keys that may be used to configure a navigator for use with this surface factory.
`PlotMetric`
`getPlotMetric()`
Returns an object that can assess distances between graphic positions on the plot surface.
`ConfigKey<?>[]`
`getProfileKeys()`
Returns the configuration keys used to configure profile for this surface factory.
`Range[]`
`readRanges(TimeSurfaceFactory.Profile profile, PlotLayer[] layers, DataStore dataStore)`
Provides the ranges that may be passed to `createAspect`.
`boolean`
`useRanges(TimeSurfaceFactory.Profile profile, ConfigMap config)`
Indicates whether ranges should be provided to generate an aspect.

### Methods inherited from class Object

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

## Field Details

### TMIN_KEY

public static final ConfigKey<Double> TMIN_KEY
Config key for time axis lower bound, before subranging.

### TMAX_KEY

public static final ConfigKey<Double> TMAX_KEY
Config key for time axis upper bound, before subranging.

### TSUBRANGE_KEY

public static final ConfigKey<Subrange> TSUBRANGE_KEY
Config key for time axis subrange.

### YMIN_KEY

public static final ConfigKey<Double> YMIN_KEY
Config key for Y axis lower bound, before subranging.

### YMAX_KEY

public static final ConfigKey<Double> YMAX_KEY
Config key for Y axis upper bound, before subranging.

### YSUBRANGE_KEY

public static final ConfigKey<Subrange> YSUBRANGE_KEY
Config key for Y axis subrange.

### YLOG_KEY

public static final ConfigKey<Boolean> YLOG_KEY
Config key for Y axis log scale flag.

### YFLIP_KEY

public static final ConfigKey<Boolean> YFLIP_KEY
Config key for Y axis flip flag.

### TLABEL_KEY

public static final ConfigKey<String> TLABEL_KEY
Config key for time axis text label.

### YLABEL_KEY

public static final ConfigKey<String> YLABEL_KEY
Config key for Y axis text label.

### T2FUNC_KEY

public static final ConfigKey<TimeJELFunction> T2FUNC_KEY
Config key for secondary time axis function.

### Y2FUNC_KEY

public static final ConfigKey<JELFunction> Y2FUNC_KEY
Config key for secondary Y axis function.

### T2LABEL_KEY

public static final ConfigKey<String> T2LABEL_KEY
Config key for secondary time axis text label.

### Y2LABEL_KEY

public static final ConfigKey<String> Y2LABEL_KEY
Config key for secondary Y axis text label.

### GRID_KEY

public static final ConfigKey<Boolean> GRID_KEY
Config key to determine if grid lines are drawn.

### TCROWD_KEY

public static final ConfigKey<Double> TCROWD_KEY
Config key to control tick mark crowding on time axis.

### YCROWD_KEY

public static final ConfigKey<Double> YCROWD_KEY
Config key to control tick mark crowding on Y axis.

### ORIENTATIONS_KEY

public static final ConfigKey<OrientationPolicy> ORIENTATIONS_KEY
Config key to control axis label orientation.

### TFORMAT_KEY

public static final ConfigKey<TimeFormat> TFORMAT_KEY
Config key to control time value formatting.

## Constructor Details

### TimeSurfaceFactory

public TimeSurfaceFactory()

## Method Details

### createSurface

public Surface createSurface(Rectangle plotBounds, TimeSurfaceFactory.Profile profile, TimeAspect aspect)
Description copied from interface: `SurfaceFactory`
Returns a new plot surface.

Specified by:
  `createSurface` in interface `SurfaceFactory<TimeSurfaceFactory.Profile, TimeAspect>`
Parameters:
  `plotBounds` - rectangle to containing actual plot data (not insets)
  `profile` - configuration object defining plot style
  `aspect` - configuration object defining plot viewpoint
Returns:
  new plot surface

### getProfileKeys

public ConfigKey<?>[] getProfileKeys()
Description copied from interface: `SurfaceFactory`
Returns the configuration keys used to configure profile for this surface factory. The returned keys are used in the map supplied to the `createProfile` method.

Specified by:
  `getProfileKeys` in interface `SurfaceFactory<TimeSurfaceFactory.Profile, TimeAspect>`
Returns:
  profile configuration keys

### createProfile

public TimeSurfaceFactory.Profile createProfile(ConfigMap config)
Description copied from interface: `SurfaceFactory`
Creates a profile that can be used when creating a plot surface. The keys that are significant in the supplied config map are those returned by `getProfileKeys`. The return value can be used as input to `createSurface` and other methods in this class.

Specified by:
  `createProfile` in interface `SurfaceFactory<TimeSurfaceFactory.Profile, TimeAspect>`
Parameters:
  `config` - map of profile configuration items
Returns:
  factory-specific plot surface profile

### getAspectKeys

public ConfigKey<?>[] getAspectKeys()
Description copied from interface: `SurfaceFactory`
Returns the configuration keys that may be used to configure aspect for this surface factory. The returned keys are used in the map supplied to the `useRanges` and `createAspect` methods.

Specified by:
  `getAspectKeys` in interface `SurfaceFactory<TimeSurfaceFactory.Profile, TimeAspect>`
Returns:
  aspect configuration keys

### useRanges

public boolean useRanges(TimeSurfaceFactory.Profile profile, ConfigMap config)
Description copied from interface: `SurfaceFactory`
Indicates whether ranges should be provided to generate an aspect. If true, it is beneficial to pass the result of `readRanges` to `createAspect` alongside the arguments of this method. If false, any such ranges will be ignored.

Specified by:
  `useRanges` in interface `SurfaceFactory<TimeSurfaceFactory.Profile, TimeAspect>`
Parameters:
  `profile` - surface configuration profile
  `config` - configuration map that may contain keys from `getAspectKeys`
Returns:
  true iff calculated ranges will be of use

### createAspect

public TimeAspect createAspect(TimeSurfaceFactory.Profile profile, ConfigMap config, Range[] ranges)
Description copied from interface: `SurfaceFactory`
Creates an aspect from configuration information. The ranges argument will be used only if `useRanges` returns true. It is legal to give the ranges argument as null in any case. In all cases, the returned value must be non-null and usable by `createSurface`.

Specified by:
  `createAspect` in interface `SurfaceFactory<TimeSurfaceFactory.Profile, TimeAspect>`
Parameters:
  `profile` - surface configuration profile
  `config` - configuration map that may contain keys from `getAspectKeys`
  `ranges` - range data filled in from layers, or null
Returns:
  new aspect

### getAspectConfig

public ConfigMap getAspectConfig(Surface surf)
Description copied from interface: `SurfaceFactory`
Returns a ConfigMap that corresponds to the configuration of the given surface, which must have been created by this factory. The intention is that supplying the returned config items to this object's `createAspect` method with the right profile should come up with approximately the same surface, preferably without reference to any supplied ranges.

The returned config items should be optimised for presentation to the user, so that for instance decimal values are reported to a reasonable level of precision. Because of this, and perhaps for other reasons related to implementation, a surface resulting from feeding the returned config back to this factory may not be identical to the supplied surface, so round-tripping is not guaranteed to be exact.

Specified by:
  `getAspectConfig` in interface `SurfaceFactory<TimeSurfaceFactory.Profile, TimeAspect>`
Parameters:
  `surf` - plot surface; if it was not created by this factory, behaviour is undefined
Returns:
  config map populated with items that should approximately reproduce the supplied surface

### readRanges

public Range[] readRanges(TimeSurfaceFactory.Profile profile, PlotLayer[] layers, DataStore dataStore)
Description copied from interface: `SurfaceFactory`
Provides the ranges that may be passed to `createAspect`. There is only any point calling this if `useRanges` returns true.

Specified by:
  `readRanges` in interface `SurfaceFactory<TimeSurfaceFactory.Profile, TimeAspect>`
Parameters:
  `profile` - surface configuration profile
  `layers` - plot layers to be plotted
  `dataStore` - contains actual data
Returns:
  data ranges covered by the given layers filled in from data

### getNavigatorKeys

public ConfigKey<?>[] getNavigatorKeys()
Description copied from interface: `SurfaceFactory`
Returns the configuration keys that may be used to configure a navigator for use with this surface factory. The returned keys are used in the map supplied to the `SurfaceFactory.createNavigator(ConfigMap)` method.

Specified by:
  `getNavigatorKeys` in interface `SurfaceFactory<TimeSurfaceFactory.Profile, TimeAspect>`
Returns:
  navigator configuration keys

### createNavigator

public Navigator<TimeAspect> createNavigator(ConfigMap navConfig)
Description copied from interface: `SurfaceFactory`
Creates a navigator from configuration information. The returned value will be non-null.

Specified by:
  `createNavigator` in interface `SurfaceFactory<TimeSurfaceFactory.Profile, TimeAspect>`
Parameters:
  `navConfig` - configuration map that may contain keys from `getNavigatorKeys`
Returns:
  navigator for use with surfaces produced by this factory

### getPlotMetric

public PlotMetric getPlotMetric()
Description copied from interface: `SurfaceFactory`
Returns an object that can assess distances between graphic positions on the plot surface. If no such metric exists, null may be returned.

Specified by:
  `getPlotMetric` in interface `SurfaceFactory<TimeSurfaceFactory.Profile, TimeAspect>`
Returns:
  plot metric, or null