Package uk.ac.starlink.ttools.plot2.geom
Class PlaneSurfaceFactory
java.lang.Object
uk.ac.starlink.ttools.plot2.geom.PlaneSurfaceFactory
- All Implemented Interfaces:
SurfaceFactory<PlaneSurfaceFactory.Profile,
PlaneAspect>
public class PlaneSurfaceFactory
extends Object
implements SurfaceFactory<PlaneSurfaceFactory.Profile,PlaneAspect>
Surface factory for flat 2-d plotting.
- Since:
- 19 Feb 2013
- Author:
- Mark Taylor
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Specifies configuration options for the PlaneSurfaceFactory.static class
Profile class which defines fixed configuration items for a PlaneSurface. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PlaneSurfaceFactory.Config
Default configuration for plane surface factory.Config key to determine if grid lines are drawn.static final ConfigKey<boolean[]>
Config key to select which axes navigation actions will operate on.static final ConfigKey<JELFunction>
Config key for secondary X axis function.Config key for secondary X axis text label.Config key to anchor X axis during zooms.Config key to control tick mark crowding on X axis.Config key for X axis flip flag.Config key for X axis text label.Config key for X axis log scale flag.Config key for X axis upper bound, before subranging.Config key for X axis lower bound, before subranging.Config key for X axis subrange.Config key for axis aspect ratio fix.static final ConfigKey<JELFunction>
Config key for secondary Y axis function.Config key for secondary Y axis text label.Config key to anchor Y axis during zooms.Config key to control tick mark crowding on Y axis.Config key for Y axis flip flag.Config key for Y axis text label.Config key for Y axis log scale flag.Config key for Y axis upper bound, before subranging.Config key for Y axis lower bound, before subranging.Config key for Y axis subrange. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a PlaneSurfaceFactory with default characteristics.Constructs a PlaneSurfaceFactory with configurable characteristics. -
Method Summary
Modifier and TypeMethodDescriptioncreateAspect
(PlaneSurfaceFactory.Profile profile, ConfigMap config, Range[] ranges) Creates an aspect from configuration information.createAxisAnchorKey
(String axname, boolean dflt) Creates a config key for determining whether a named axis is to be anchored at a data value of zero.createAxisCrowdKey
(String axname) Creates a config key for determining tickmark crowding on a named axis.createAxisFlipKey
(String axname) Creates a config key for determining whether a named Cartesian axis is to be reversed.createAxisLimitKey
(String axname, boolean isMax) Creates a config key for fixing a minimum or maximum limit for a named axis.createAxisLogKey
(String axname) Creates a config key for determining whether a named Cartesian axis is logarithmic or linear.createAxisSubrangeKey
(String axname) Creates a config key for selecting a subrange on a named Cartesian axis.createNavigator
(ConfigMap navConfig) Creates a navigator from configuration information.createProfile
(ConfigMap config) Creates a profile that can be used when creating a plot surface.static ConfigKey<JELFunction>
createSecondaryAxisFunctionKey
(String primaryAxisName) Creates a config key for a secondary axis function.createSecondaryAxisLabelKey
(String primaryAxisName) Returns a labelling config key for a secondary axis.createSurface
(Rectangle plotBounds, PlaneSurfaceFactory.Profile profile, PlaneAspect aspect) Returns a new plot surface.getAspectConfig
(Surface surf) Returns a ConfigMap that corresponds to the configuration of the given surface, which must have been created by this factory.ConfigKey<?>[]
Returns the configuration keys that may be used to configure aspect for this surface factory.static double[]
Utility method to determine actual axis limits based on requested high/low values and a subrange.static double[]
getLimits
(ConfigMap config, ConfigKey<Double> minKey, ConfigKey<Double> maxKey, ConfigKey<Subrange> subrangeKey, boolean isLog, Range range) Utility method to interrogate axis range configuration variables and work out the actual range to use on a given Cartesian axis.ConfigKey<?>[]
Returns the configuration keys that may be used to configure a navigator for use with this surface factory.Returns an object that can assess distances between graphic positions on the plot surface.ConfigKey<?>[]
Returns the configuration keys used to configure profile for this surface factory.XyKeyPair<?>[]
Returns a list of those keys which apply equally to the X and Y axes.Range[]
readRanges
(PlaneSurfaceFactory.Profile profile, PlotLayer[] layers, DataStore dataStore) Provides the ranges that may be passed tocreateAspect
.boolean
useRanges
(PlaneSurfaceFactory.Profile profile, ConfigMap config) Indicates whether ranges should be provided to generate an aspect.
-
Field Details
-
XMIN_KEY
Config key for X axis lower bound, before subranging. -
XMAX_KEY
Config key for X axis upper bound, before subranging. -
XSUBRANGE_KEY
Config key for X axis subrange. -
YMIN_KEY
Config key for Y axis lower bound, before subranging. -
YMAX_KEY
Config key for Y axis upper bound, before subranging. -
YSUBRANGE_KEY
Config key for Y axis subrange. -
XLOG_KEY
Config key for X axis log scale flag. -
YLOG_KEY
Config key for Y axis log scale flag. -
XFLIP_KEY
Config key for X axis flip flag. -
YFLIP_KEY
Config key for Y axis flip flag. -
XLABEL_KEY
Config key for X axis text label. -
YLABEL_KEY
Config key for Y axis text label. -
X2FUNC_KEY
Config key for secondary X axis function. -
Y2FUNC_KEY
Config key for secondary Y axis function. -
X2LABEL_KEY
Config key for secondary X axis text label. -
Y2LABEL_KEY
Config key for secondary Y axis text label. -
XYFACTOR_KEY
Config key for axis aspect ratio fix. -
GRID_KEY
Config key to determine if grid lines are drawn. -
XCROWD_KEY
Config key to control tick mark crowding on X axis. -
YCROWD_KEY
Config key to control tick mark crowding on Y axis. -
NAVAXES_KEY
Config key to select which axes navigation actions will operate on. -
XANCHOR_KEY
Config key to anchor X axis during zooms. -
YANCHOR_KEY
Config key to anchor Y axis during zooms. -
DFLT_CONFIG
Default configuration for plane surface factory.
-
-
Constructor Details
-
PlaneSurfaceFactory
public PlaneSurfaceFactory()Constructs a PlaneSurfaceFactory with default characteristics. -
PlaneSurfaceFactory
Constructs a PlaneSurfaceFactory with configurable characteristics.- Parameters:
config
- configuration options
-
-
Method Details
-
createSurface
public Surface createSurface(Rectangle plotBounds, PlaneSurfaceFactory.Profile profile, PlaneAspect aspect) Description copied from interface:SurfaceFactory
Returns a new plot surface.- Specified by:
createSurface
in interfaceSurfaceFactory<PlaneSurfaceFactory.Profile,
PlaneAspect> - Parameters:
plotBounds
- rectangle to containing actual plot data (not insets)profile
- configuration object defining plot styleaspect
- configuration object defining plot viewpoint- Returns:
- new plot surface
-
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 thecreateProfile
method.- Specified by:
getProfileKeys
in interfaceSurfaceFactory<PlaneSurfaceFactory.Profile,
PlaneAspect> - Returns:
- profile configuration keys
-
createProfile
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 bygetProfileKeys
. The return value can be used as input tocreateSurface
and other methods in this class.- Specified by:
createProfile
in interfaceSurfaceFactory<PlaneSurfaceFactory.Profile,
PlaneAspect> - Parameters:
config
- map of profile configuration items- Returns:
- factory-specific plot surface profile
-
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 theuseRanges
andcreateAspect
methods.- Specified by:
getAspectKeys
in interfaceSurfaceFactory<PlaneSurfaceFactory.Profile,
PlaneAspect> - Returns:
- aspect configuration keys
-
useRanges
Description copied from interface:SurfaceFactory
Indicates whether ranges should be provided to generate an aspect. If true, it is beneficial to pass the result ofreadRanges
tocreateAspect
alongside the arguments of this method. If false, any such ranges will be ignored.- Specified by:
useRanges
in interfaceSurfaceFactory<PlaneSurfaceFactory.Profile,
PlaneAspect> - Parameters:
profile
- surface configuration profileconfig
- configuration map that may contain keys fromgetAspectKeys
- Returns:
- true iff calculated ranges will be of use
-
createAspect
public PlaneAspect createAspect(PlaneSurfaceFactory.Profile profile, ConfigMap config, Range[] ranges) Description copied from interface:SurfaceFactory
Creates an aspect from configuration information. The ranges argument will be used only ifuseRanges
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 bycreateSurface
.- Specified by:
createAspect
in interfaceSurfaceFactory<PlaneSurfaceFactory.Profile,
PlaneAspect> - Parameters:
profile
- surface configuration profileconfig
- configuration map that may contain keys fromgetAspectKeys
ranges
- range data filled in from layers, or null- Returns:
- new aspect
-
getAspectConfig
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'screateAspect
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 interfaceSurfaceFactory<PlaneSurfaceFactory.Profile,
PlaneAspect> - 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(PlaneSurfaceFactory.Profile profile, PlotLayer[] layers, DataStore dataStore) Description copied from interface:SurfaceFactory
Provides the ranges that may be passed tocreateAspect
. There is only any point calling this ifuseRanges
returns true.- Specified by:
readRanges
in interfaceSurfaceFactory<PlaneSurfaceFactory.Profile,
PlaneAspect> - Parameters:
profile
- surface configuration profilelayers
- plot layers to be plotteddataStore
- contains actual data- Returns:
- data ranges covered by the given layers filled in from data
-
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 interfaceSurfaceFactory<PlaneSurfaceFactory.Profile,
PlaneAspect> - Returns:
- plot metric, or null
-
getXyKeyPairs
Returns a list of those keys which apply equally to the X and Y axes.- Returns:
- paired X/Y key objects
-
createAxisAnchorKey
Creates a config key for determining whether a named axis is to be anchored at a data value of zero.- Parameters:
axname
- axis namedflt
- anchor default value- Returns:
- config key
-
createAxisLimitKey
Creates a config key for fixing a minimum or maximum limit for a named axis.- Parameters:
axname
- axis nameisMax
- true for upper limit, false for lower limit- Returns:
- new config key
-
createAxisLogKey
Creates a config key for determining whether a named Cartesian axis is logarithmic or linear.- Parameters:
axname
- axis name- Returns:
- new config key, true for log scaling
-
createAxisFlipKey
Creates a config key for determining whether a named Cartesian axis is to be reversed.- Parameters:
axname
- axis name- Returns:
- new config key, true if sense is reversed
-
createAxisSubrangeKey
Creates a config key for selecting a subrange on a named Cartesian axis.- Parameters:
axname
- axis name- Returns:
- new config key
-
createAxisCrowdKey
Creates a config key for determining tickmark crowding on a named axis.- Parameters:
axname
- axis name- Returns:
- new config key for dimensionless crowding figure
-
createSecondaryAxisFunctionKey
Creates a config key for a secondary axis function.- Parameters:
primaryAxisName
- name of primary axis, for instance "X"- Returns:
- new config key
-
createSecondaryAxisLabelKey
Returns a labelling config key for a secondary axis.- Parameters:
primaryAxisName
- name of primary axis to which the secondary axis relates- Returns:
- new key
-
getLimits
public static double[] getLimits(ConfigMap config, ConfigKey<Double> minKey, ConfigKey<Double> maxKey, ConfigKey<Subrange> subrangeKey, boolean isLog, Range range) Utility method to interrogate axis range configuration variables and work out the actual range to use on a given Cartesian axis. If not enough information is supplied to determine the definite range, null is returned.- Parameters:
config
- config map containing config valuesminKey
- config key giving axis lower bound before subrangingmaxKey
- config key giving axis upper bound before subrangingsubrangeKey
- config key giving subrange valueisLog
- true for logarithmic axis, false for linearrange
- data range on axis; may be partially populated or null- Returns:
- 2-element array giving definite axis (lower,upper) bounds, or null
-
getLimits
public static double[] getLimits(double lo, double hi, Subrange subrange, boolean isLog, Range range) Utility method to determine actual axis limits based on requested high/low values and a subrange. If not enough information is supplied to determine the definite range, null is returned.- Parameters:
lo
- requested lower bound before subranging, may be NaNhi
- requested upper bound before subranging, may be NaNsubrange
- requested subrangeisLog
- true for logarithmic axis, false for linearrange
- actual data range on axis; may be partially populated or null- Returns:
- 2-element array giving definite axis (lower,upper) bounds, or null
-