uk.ac.starlink.ttools.plot2.geom
Class PlaneSurfaceFactory

java.lang.Object
  extended by 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
static class PlaneSurfaceFactory.Profile
          Profile class which defines fixed configuration items for a PlaneSurface.
 
Field Summary
static ConfigKey<Boolean> GRID_KEY
          Config key to determine if grid lines are drawn.
static ConfigKey<boolean[]> NAVAXES_KEY
          Config key to select which axes navigation actions will operate on.
static ConfigKey<Boolean> XANCHOR_KEY
          Config key to anchor X axis during zooms.
static ConfigKey<Double> XCROWD_KEY
          Config key to control tick mark crowding on X axis.
static ConfigKey<Boolean> XFLIP_KEY
          Config key for X axis flip flag.
static ConfigKey<String> XLABEL_KEY
          Config key for X axis text label.
static ConfigKey<Boolean> XLOG_KEY
          Config key for X axis log scale flag.
static ConfigKey<Double> XMAX_KEY
          Config key for X axis upper bound, before subranging.
static ConfigKey<Double> XMIN_KEY
          Config key for X axis lower bound, before subranging.
static ConfigKey<Subrange> XSUBRANGE_KEY
          Config key for X axis subrange.
static ConfigKey<Double> XYFACTOR_KEY
          Config key for axis aspect ratio fix.
static ConfigKey<Boolean> YANCHOR_KEY
          Config key to anchor Y axis during zooms.
static ConfigKey<Double> YCROWD_KEY
          Config key to control tick mark crowding on Y axis.
static ConfigKey<Boolean> YFLIP_KEY
          Config key for Y axis flip flag.
static ConfigKey<String> YLABEL_KEY
          Config key for Y axis text label.
static ConfigKey<Boolean> YLOG_KEY
          Config key for Y axis log scale flag.
static ConfigKey<Double> YMAX_KEY
          Config key for Y axis upper bound, before subranging.
static ConfigKey<Double> YMIN_KEY
          Config key for Y axis lower bound, before subranging.
static ConfigKey<Subrange> YSUBRANGE_KEY
          Config key for Y axis subrange.
 
Constructor Summary
PlaneSurfaceFactory()
           
 
Method Summary
 PlaneAspect createAspect(PlaneSurfaceFactory.Profile profile, ConfigMap config, Range[] ranges)
          Creates an aspect from configuration information.
static ConfigKey<Boolean> 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.
static ConfigKey<Double> createAxisCrowdKey(String axname)
          Creates a config key for determining tickmark crowding on a named axis.
static ConfigKey<Boolean> createAxisFlipKey(String axname)
          Creates a config key for determining whether a named Cartesian axis is to be reversed.
static ConfigKey<Double> createAxisLimitKey(String axname, boolean isMax)
          Creates a config key for fixing a minimum or maximum limit for a named axis.
static ConfigKey<Boolean> createAxisLogKey(String axname)
          Creates a config key for determining whether a named Cartesian axis is logarithmic or linear.
static ConfigKey<Subrange> createAxisSubrangeKey(String axname)
          Creates a config key for selecting a subrange on a named Cartesian axis.
 Navigator<PlaneAspect> createNavigator(ConfigMap navConfig)
          Creates a navigator from configuration information.
 PlaneSurfaceFactory.Profile createProfile(ConfigMap config)
          Creates a profile that can be used when creating a plot surface.
 Surface createSurface(Rectangle plotBounds, PlaneSurfaceFactory.Profile profile, PlaneAspect aspect)
          Returns a new plot surface.
 ConfigKey[] getAspectKeys()
          Returns the configuration keys that may be used to configure aspect for this surface factory.
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[] getNavigatorKeys()
          Returns the configuration keys that may be used to configure a navigator for use with this surface factory.
 ConfigKey[] getProfileKeys()
          Returns the configuration keys used to configure profile for this surface factory.
 Range[] readRanges(PlaneSurfaceFactory.Profile profile, PlotLayer[] layers, DataStore dataStore)
          Provides the ranges that may be passed to createAspect.
 boolean useRanges(PlaneSurfaceFactory.Profile profile, ConfigMap config)
          Indicates whether ranges should be provided to generate an aspect.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XMIN_KEY

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


XMAX_KEY

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


XSUBRANGE_KEY

public static final ConfigKey<Subrange> XSUBRANGE_KEY
Config key for X 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.


XLOG_KEY

public static final ConfigKey<Boolean> XLOG_KEY
Config key for X axis log scale flag.


YLOG_KEY

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


XFLIP_KEY

public static final ConfigKey<Boolean> XFLIP_KEY
Config key for X axis flip flag.


YFLIP_KEY

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


XLABEL_KEY

public static final ConfigKey<String> XLABEL_KEY
Config key for X axis text label.


YLABEL_KEY

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


XYFACTOR_KEY

public static final ConfigKey<Double> XYFACTOR_KEY
Config key for axis aspect ratio fix.


GRID_KEY

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


XCROWD_KEY

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


YCROWD_KEY

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


NAVAXES_KEY

public static final ConfigKey<boolean[]> NAVAXES_KEY
Config key to select which axes navigation actions will operate on.


XANCHOR_KEY

public static final ConfigKey<Boolean> XANCHOR_KEY
Config key to anchor X axis during zooms.


YANCHOR_KEY

public static final ConfigKey<Boolean> YANCHOR_KEY
Config key to anchor Y axis during zooms.

Constructor Detail

PlaneSurfaceFactory

public PlaneSurfaceFactory()
Method Detail

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 interface SurfaceFactory<PlaneSurfaceFactory.Profile,PlaneAspect>
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<PlaneSurfaceFactory.Profile,PlaneAspect>
Returns:
profile configuration keys

createProfile

public PlaneSurfaceFactory.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<PlaneSurfaceFactory.Profile,PlaneAspect>
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<PlaneSurfaceFactory.Profile,PlaneAspect>
Returns:
aspect configuration keys

useRanges

public boolean useRanges(PlaneSurfaceFactory.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<PlaneSurfaceFactory.Profile,PlaneAspect>
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 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 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<PlaneSurfaceFactory.Profile,PlaneAspect>
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

readRanges

public Range[] readRanges(PlaneSurfaceFactory.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<PlaneSurfaceFactory.Profile,PlaneAspect>
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(uk.ac.starlink.ttools.plot2.config.ConfigMap) method.

Specified by:
getNavigatorKeys in interface SurfaceFactory<PlaneSurfaceFactory.Profile,PlaneAspect>
Returns:
navigator configuration keys

createNavigator

public Navigator<PlaneAspect> 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<PlaneSurfaceFactory.Profile,PlaneAspect>
Parameters:
navConfig - configuration map that may contain keys from getNavigatorKeys
Returns:
navigator for use with surfaces produced by this factory

createAxisAnchorKey

public static ConfigKey<Boolean> 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.

Parameters:
axname - axis name
dflt - anchor default value
Returns:
config key

createAxisLimitKey

public static ConfigKey<Double> createAxisLimitKey(String axname,
                                                   boolean isMax)
Creates a config key for fixing a minimum or maximum limit for a named axis.

Parameters:
axname - axis name
isMax - true for upper limit, false for lower limit
Returns:
new config key

createAxisLogKey

public static ConfigKey<Boolean> createAxisLogKey(String axname)
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

public static ConfigKey<Boolean> createAxisFlipKey(String axname)
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

public static ConfigKey<Subrange> createAxisSubrangeKey(String axname)
Creates a config key for selecting a subrange on a named Cartesian axis.

Parameters:
axname - axis name
Returns:
new config key

createAxisCrowdKey

public static ConfigKey<Double> createAxisCrowdKey(String axname)
Creates a config key for determining tickmark crowding on a named axis.

Parameters:
axname - axis name
Returns:
new config key for dimensionless crowding figure

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 values
minKey - config key giving axis lower bound before subranging
maxKey - config key giving axis upper bound before subranging
subrangeKey - config key giving subrange value
isLog - true for logarithmic axis, false for linear
range - data range on axis; may be partially populated or null
Returns:
2-element array giving definite axis (lower,upper) bounds, or null


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.