Class CubeSurfaceFactory
- java.lang.Object
-
- uk.ac.starlink.ttools.plot2.geom.CubeSurfaceFactory
-
- All Implemented Interfaces:
SurfaceFactory<CubeSurfaceFactory.Profile,CubeAspect>
public class CubeSurfaceFactory extends java.lang.Object implements SurfaceFactory<CubeSurfaceFactory.Profile,CubeAspect>
Surface factory for 3-d plotting.This can be used in one of two modes (determined at construction time), isotropic and non-isotropic. In isotropic mode, the scaling on each of the 3 axes is the same, and in non-isotropic mode they can vary independently of each other. The profile and aspect configuration keys (that is, the user interface) are different according to which mode is in effect, but the actual surfaces generated are the same either way, undistinguished instances of
CubeSurface.- Since:
- 20 Feb 2013
- Author:
- Mark Taylor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCubeSurfaceFactory.ProfileProfile class which defines fixed configuration items for an isotropic or non-isotropic CubeSurface.
-
Field Summary
Fields Modifier and Type Field Description static ConfigKey<java.lang.Boolean>FRAME_KEYConfig key for whether to draw axis wire frame.static doubleISO_CENTER_TOLERANCEProportional auto-ranging isotropic snap-to-origin threshold.static ConfigKey<java.lang.Double>ISOCROWD_KEYConfig key for isotropic tick mark crowding.static ConfigKey<java.lang.Double>PHI_KEYConfig key for first Euler angle of rotation, units of degrees.static ConfigKey<java.lang.Double>PSI_KEYConfig key for third Euler angle of rotation, units of degrees.static ConfigKey<java.lang.Double>SCALE_KEYConfig key for cube edge length (isotropic only).static ConfigKey<java.lang.Double>THETA_KEYConfig key for second Euler angle of rotation, units of degrees.static ConfigKey<java.lang.Double>XC_KEYConfig key for X axis central position key (isotropic only).static ConfigKey<java.lang.Double>XCROWD_KEYConfig key for X axis tick mark crowding.static ConfigKey<java.lang.Boolean>XFLIP_KEYConfig key for X axis flip flag.static ConfigKey<java.lang.String>XLABEL_KEYConfig key for X axis text label.static ConfigKey<java.lang.Boolean>XLOG_KEYConfig key for X axis log scale flag.static ConfigKey<java.lang.Double>XMAX_KEYConfig key for X axis upper bound, before subranging.static ConfigKey<java.lang.Double>XMIN_KEYConfig key for X axis lower bound, before subranging.static ConfigKey<java.lang.Double>XOFF_KEYConfig key for graphics X offset, units of 1/2 screen size.static ConfigKey<Subrange>XSUBRANGE_KEYConfig key for X axis subrange.static ConfigKey<java.lang.Double>YC_KEYConfig key for Y axis central position key (isotropic only).static ConfigKey<java.lang.Double>YCROWD_KEYConfig key for Y axis tick mark crowding.static ConfigKey<java.lang.Boolean>YFLIP_KEYConfig key for Y axis flip flag.static ConfigKey<java.lang.String>YLABEL_KEYConfig key for Y axis text label.static ConfigKey<java.lang.Boolean>YLOG_KEYConfig key for Y axis log scale flag.static ConfigKey<java.lang.Double>YMAX_KEYConfig key for Y axis upper bound, before subranging.static ConfigKey<java.lang.Double>YMIN_KEYConfig key for Y axis lower bound, before subranging.static ConfigKey<java.lang.Double>YOFF_KEYConfig key for graphics Y offset, units of 1/2 screen size.static ConfigKey<Subrange>YSUBRANGE_KEYConfig key for Y axis subrange.static ConfigKey<java.lang.Double>ZC_KEYConfig key for Z axis central position key (isotropic only).static ConfigKey<java.lang.Double>ZCROWD_KEYConfig key for Z axis tick mark crowding.static ConfigKey<java.lang.Boolean>ZFLIP_KEYConfig key for Z axis flip flag.static ConfigKey<java.lang.String>ZLABEL_KEYConfig key for Z axis text label.static ConfigKey<java.lang.Boolean>ZLOG_KEYConfig key for Z axis log scale flag.static ConfigKey<java.lang.Double>ZMAX_KEYConfig key for Z axis upper bound, before subranging.static ConfigKey<java.lang.Double>ZMIN_KEYConfig key for Z axis lower bound, before subranging.static ConfigKey<java.lang.Double>ZOOM_KEYConfig key for zoom factor.static ConfigKey<Subrange>ZSUBRANGE_KEYConfig key for Z axis subrange.
-
Constructor Summary
Constructors Constructor Description CubeSurfaceFactory(boolean isIso)Constructs an isotropic or non-isotropic cube surface factory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CubeAspectcreateAspect(CubeSurfaceFactory.Profile profile, ConfigMap config, Range[] ranges)Creates an aspect from configuration information.Navigator<CubeAspect>createNavigator(ConfigMap navConfig)Creates a navigator from configuration information.CubeSurfaceFactory.ProfilecreateProfile(ConfigMap config)Creates a profile that can be used when creating a plot surface.SurfacecreateSurface(java.awt.Rectangle plotBounds, CubeSurfaceFactory.Profile profile, CubeAspect aspect)Returns a new plot surface.static double[]eulerToRotationDegrees(double[] eulers)Converts three ZXZ Euler angles to a rotation matrix.ConfigMapgetAspectConfig(Surface surface)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.PlotMetricgetPlotMetric()Returns null.ConfigKey<?>[]getProfileKeys()Returns the configuration keys used to configure profile for this surface factory.static double[]getRotation(ConfigMap config)Reads the intended rotation matrix from a configuration map.Range[]readRanges(CubeSurfaceFactory.Profile profile, PlotLayer[] layers, DataStore dataStore)Provides the ranges that may be passed tocreateAspect.static double[]rotationToEulerDegrees(double[] rotmat)Converts rotation matrix to three ZXZ Euler angles in degrees.booleanuseRanges(CubeSurfaceFactory.Profile profile, ConfigMap config)Indicates whether ranges should be provided to generate an aspect.
-
-
-
Field Detail
-
XLOG_KEY
public static final ConfigKey<java.lang.Boolean> XLOG_KEY
Config key for X axis log scale flag.
-
YLOG_KEY
public static final ConfigKey<java.lang.Boolean> YLOG_KEY
Config key for Y axis log scale flag.
-
ZLOG_KEY
public static final ConfigKey<java.lang.Boolean> ZLOG_KEY
Config key for Z axis log scale flag.
-
XFLIP_KEY
public static final ConfigKey<java.lang.Boolean> XFLIP_KEY
Config key for X axis flip flag.
-
YFLIP_KEY
public static final ConfigKey<java.lang.Boolean> YFLIP_KEY
Config key for Y axis flip flag.
-
ZFLIP_KEY
public static final ConfigKey<java.lang.Boolean> ZFLIP_KEY
Config key for Z axis flip flag.
-
XLABEL_KEY
public static final ConfigKey<java.lang.String> XLABEL_KEY
Config key for X axis text label.
-
YLABEL_KEY
public static final ConfigKey<java.lang.String> YLABEL_KEY
Config key for Y axis text label.
-
ZLABEL_KEY
public static final ConfigKey<java.lang.String> ZLABEL_KEY
Config key for Z axis text label.
-
FRAME_KEY
public static final ConfigKey<java.lang.Boolean> FRAME_KEY
Config key for whether to draw axis wire frame.
-
XCROWD_KEY
public static final ConfigKey<java.lang.Double> XCROWD_KEY
Config key for X axis tick mark crowding.
-
YCROWD_KEY
public static final ConfigKey<java.lang.Double> YCROWD_KEY
Config key for Y axis tick mark crowding.
-
ZCROWD_KEY
public static final ConfigKey<java.lang.Double> ZCROWD_KEY
Config key for Z axis tick mark crowding.
-
ISOCROWD_KEY
public static final ConfigKey<java.lang.Double> ISOCROWD_KEY
Config key for isotropic tick mark crowding.
-
XMIN_KEY
public static final ConfigKey<java.lang.Double> XMIN_KEY
Config key for X axis lower bound, before subranging.
-
XMAX_KEY
public static final ConfigKey<java.lang.Double> XMAX_KEY
Config key for X axis upper bound, before subranging.
-
YMIN_KEY
public static final ConfigKey<java.lang.Double> YMIN_KEY
Config key for Y axis lower bound, before subranging.
-
YMAX_KEY
public static final ConfigKey<java.lang.Double> YMAX_KEY
Config key for Y axis upper bound, before subranging.
-
ZMIN_KEY
public static final ConfigKey<java.lang.Double> ZMIN_KEY
Config key for Z axis lower bound, before subranging.
-
ZMAX_KEY
public static final ConfigKey<java.lang.Double> ZMAX_KEY
Config key for Z axis upper bound, before subranging.
-
XC_KEY
public static final ConfigKey<java.lang.Double> XC_KEY
Config key for X axis central position key (isotropic only).
-
YC_KEY
public static final ConfigKey<java.lang.Double> YC_KEY
Config key for Y axis central position key (isotropic only).
-
ZC_KEY
public static final ConfigKey<java.lang.Double> ZC_KEY
Config key for Z axis central position key (isotropic only).
-
SCALE_KEY
public static final ConfigKey<java.lang.Double> SCALE_KEY
Config key for cube edge length (isotropic only).
-
PHI_KEY
public static final ConfigKey<java.lang.Double> PHI_KEY
Config key for first Euler angle of rotation, units of degrees.
-
THETA_KEY
public static final ConfigKey<java.lang.Double> THETA_KEY
Config key for second Euler angle of rotation, units of degrees.
-
PSI_KEY
public static final ConfigKey<java.lang.Double> PSI_KEY
Config key for third Euler angle of rotation, units of degrees.
-
ZOOM_KEY
public static final ConfigKey<java.lang.Double> ZOOM_KEY
Config key for zoom factor.
-
XOFF_KEY
public static final ConfigKey<java.lang.Double> XOFF_KEY
Config key for graphics X offset, units of 1/2 screen size.
-
YOFF_KEY
public static final ConfigKey<java.lang.Double> YOFF_KEY
Config key for graphics Y offset, units of 1/2 screen size.
-
ISO_CENTER_TOLERANCE
public static final double ISO_CENTER_TOLERANCE
Proportional auto-ranging isotropic snap-to-origin threshold.- See Also:
- Constant Field Values
-
-
Method Detail
-
createSurface
public Surface createSurface(java.awt.Rectangle plotBounds, CubeSurfaceFactory.Profile profile, CubeAspect aspect)
Description copied from interface:SurfaceFactoryReturns a new plot surface.- Specified by:
createSurfacein interfaceSurfaceFactory<CubeSurfaceFactory.Profile,CubeAspect>- 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
public ConfigKey<?>[] getProfileKeys()
Description copied from interface:SurfaceFactoryReturns the configuration keys used to configure profile for this surface factory. The returned keys are used in the map supplied to thecreateProfilemethod.- Specified by:
getProfileKeysin interfaceSurfaceFactory<CubeSurfaceFactory.Profile,CubeAspect>- Returns:
- profile configuration keys
-
createProfile
public CubeSurfaceFactory.Profile createProfile(ConfigMap config)
Description copied from interface:SurfaceFactoryCreates 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 tocreateSurfaceand other methods in this class.- Specified by:
createProfilein interfaceSurfaceFactory<CubeSurfaceFactory.Profile,CubeAspect>- Parameters:
config- map of profile configuration items- Returns:
- factory-specific plot surface profile
-
getAspectKeys
public ConfigKey<?>[] getAspectKeys()
Description copied from interface:SurfaceFactoryReturns the configuration keys that may be used to configure aspect for this surface factory. The returned keys are used in the map supplied to theuseRangesandcreateAspectmethods.- Specified by:
getAspectKeysin interfaceSurfaceFactory<CubeSurfaceFactory.Profile,CubeAspect>- Returns:
- aspect configuration keys
-
useRanges
public boolean useRanges(CubeSurfaceFactory.Profile profile, ConfigMap config)
Description copied from interface:SurfaceFactoryIndicates whether ranges should be provided to generate an aspect. If true, it is beneficial to pass the result ofreadRangestocreateAspectalongside the arguments of this method. If false, any such ranges will be ignored.- Specified by:
useRangesin interfaceSurfaceFactory<CubeSurfaceFactory.Profile,CubeAspect>- Parameters:
profile- surface configuration profileconfig- configuration map that may contain keys fromgetAspectKeys- Returns:
- true iff calculated ranges will be of use
-
createAspect
public CubeAspect createAspect(CubeSurfaceFactory.Profile profile, ConfigMap config, Range[] ranges)
Description copied from interface:SurfaceFactoryCreates an aspect from configuration information. The ranges argument will be used only ifuseRangesreturns 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:
createAspectin interfaceSurfaceFactory<CubeSurfaceFactory.Profile,CubeAspect>- Parameters:
profile- surface configuration profileconfig- configuration map that may contain keys fromgetAspectKeysranges- range data filled in from layers, or null- Returns:
- new aspect
-
getAspectConfig
public ConfigMap getAspectConfig(Surface surface)
Description copied from interface:SurfaceFactoryReturns 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'screateAspectmethod 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:
getAspectConfigin interfaceSurfaceFactory<CubeSurfaceFactory.Profile,CubeAspect>- Parameters:
surface- 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(CubeSurfaceFactory.Profile profile, PlotLayer[] layers, DataStore dataStore)
Description copied from interface:SurfaceFactoryProvides the ranges that may be passed tocreateAspect. There is only any point calling this ifuseRangesreturns true.- Specified by:
readRangesin interfaceSurfaceFactory<CubeSurfaceFactory.Profile,CubeAspect>- 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
-
getNavigatorKeys
public ConfigKey<?>[] getNavigatorKeys()
Description copied from interface:SurfaceFactoryReturns 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 theSurfaceFactory.createNavigator(uk.ac.starlink.ttools.plot2.config.ConfigMap)method.- Specified by:
getNavigatorKeysin interfaceSurfaceFactory<CubeSurfaceFactory.Profile,CubeAspect>- Returns:
- navigator configuration keys
-
createNavigator
public Navigator<CubeAspect> createNavigator(ConfigMap navConfig)
Description copied from interface:SurfaceFactoryCreates a navigator from configuration information. The returned value will be non-null.- Specified by:
createNavigatorin interfaceSurfaceFactory<CubeSurfaceFactory.Profile,CubeAspect>- Parameters:
navConfig- configuration map that may contain keys fromgetNavigatorKeys- Returns:
- navigator for use with surfaces produced by this factory
-
getPlotMetric
public PlotMetric getPlotMetric()
Returns null.- Specified by:
getPlotMetricin interfaceSurfaceFactory<CubeSurfaceFactory.Profile,CubeAspect>- Returns:
- plot metric, or null
-
getRotation
public static double[] getRotation(ConfigMap config)
Reads the intended rotation matrix from a configuration map.- Parameters:
config- config map- Returns:
- 9-element rotation matrix
-
eulerToRotationDegrees
public static double[] eulerToRotationDegrees(double[] eulers)
Converts three ZXZ Euler angles to a rotation matrix.- Parameters:
eulers- 1, 2 or 3-element array giving Euler angles phi, theta, psi in degrees; if fewer elements than 3, later angles are assumed zero- Returns:
- 9-element rotation matrix
-
rotationToEulerDegrees
public static double[] rotationToEulerDegrees(double[] rotmat)
Converts rotation matrix to three ZXZ Euler angles in degrees. May lose some accuracy near theta=0. Note the result is not unique.- Parameters:
rotmat- 9-element rotation matrix- Returns:
- 3-element array giving phi, theta, psi in degrees
-
-