diff --git a/topcat/src/main/uk/ac/starlink/topcat/plot2/ShaderControl.java b/topcat/src/main/uk/ac/starlink/topcat/plot2/ShaderControl.java index 9f3dde6919..c92168c54c 100644 --- a/topcat/src/main/uk/ac/starlink/topcat/plot2/ShaderControl.java +++ b/topcat/src/main/uk/ac/starlink/topcat/plot2/ShaderControl.java @@ -14,6 +14,7 @@ import uk.ac.starlink.ttools.plot2.AuxScale; import uk.ac.starlink.ttools.plot2.Captioner; import uk.ac.starlink.ttools.plot2.PlotLayer; +import uk.ac.starlink.ttools.plot2.PlotUtil; import uk.ac.starlink.ttools.plot2.ShadeAxis; import uk.ac.starlink.ttools.plot2.ShadeAxisFactory; import uk.ac.starlink.ttools.plot2.Subrange; @@ -82,7 +83,10 @@ public void actionPerformed( ActionEvent evt ) { } ); rangeSpecifier_.addActionListener( forwarder ); - addSpecifierTab( "Map", new ConfigSpecifier( RAMP_KEYS.getKeys() ) ); + ConfigKey[] shaderKeys = + PlotUtil.arrayConcat( RAMP_KEYS.getKeys(), + new ConfigKey[] { StyleKeys.AUX_NULLCOLOR } ); + addSpecifierTab( "Map", new ConfigSpecifier( shaderKeys ) ); addSpecifierTab( "Ramp", axisSpecifier ); addSpecifierTab( "Range", rangeSpecifier_ ); } @@ -139,7 +143,8 @@ public boolean isLog() { Captioner captioner = StyleKeys.CAPTIONER.createValue( configger_.getConfig() ); RampKeySet.Ramp ramp = RAMP_KEYS.createValue( config ); - return ramp.createShadeAxisFactory( captioner, label, crowd ); + return RampKeySet + .createShadeAxisFactory( ramp, captioner, label, crowd ); } public boolean isLog() { diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/RampKeySet.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/RampKeySet.java index 018e7d0200..193aa3cd3e 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/RampKeySet.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/RampKeySet.java @@ -1,6 +1,5 @@ package uk.ac.starlink.ttools.plot2.config; -import java.awt.Color; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -25,139 +24,160 @@ public class RampKeySet implements KeySet { private final ConfigKey shaderKey_; - private final ConfigKey subrangeKey_; + private final ConfigKey shadeclipKey_; private final ConfigKey flipKey_; private final OptionConfigKey scalingKey_; - private final ConfigKey nullcolorKey_; + private final ConfigKey dataclipKey_; + private final ConfigKey[] keys_; /** * Constructor. * - * @param axname short form of axis name - * @param axName long form of axis name + * @param axname short form of axis name, used in text parameter names + * @param axName long form of axis name, used in descriptions + * @param shaders array of preset shader options + * @param dfltScaling default scaling function + * @param hasDataclip true iff a data subrange key is to be included */ - public RampKeySet( String axname, String axName ) { + public RampKeySet( String axname, String axName, Shader[] shaders, + Scaling dfltScaling, boolean hasDataclip ) { + List keyList = new ArrayList(); + List shaderList = new ArrayList(); + shaderList.addAll( Arrays.asList( shaders ) ); + shaderList.addAll( Arrays.asList( Shaders.getCustomShaders() ) ); shaderKey_ = new ShaderConfigKey( new ConfigMeta( axname + "map", axName + " Shader" ) .setShortDescription( "Color map for " + axName + " shading" ) .setXmlDescription( new String[] { - "

Color map used for " + axName + " axis shading.", + "

Color map used for", + axName, + "axis shading.", "

", } ) - , createAuxShaders(), Shaders.LUT_RAINBOW + , shaderList.toArray( new Shader[ 0 ] ), shaderList.get( 0 ) ).appendShaderDescription() .setOptionUsage(); + keyList.add( shaderKey_ ); - subrangeKey_ = + shadeclipKey_ = new SubrangeConfigKey( SubrangeConfigKey .createShaderClipMeta( axname, axName ) ); + keyList.add( shadeclipKey_ ); ConfigMeta flipMeta = new ConfigMeta( axname + "flip", "Shader Flip" ); flipMeta.setShortDescription( "Flip " + axName + " colour ramp?" ); flipMeta.setXmlDescription( new String[] { - "

If true, the colour map on the " + axName + " axis", - "will be reversed.", + "

If true, the colour map on the", + axName, + "axis will be reversed.", "

", } ); flipKey_ = new BooleanConfigKey( flipMeta ); + keyList.add( flipKey_ ); ConfigMeta scalingMeta = new ConfigMeta( axname + "func", "Scaling" ); scalingMeta.setShortDescription( axName + " scaling function" ); scalingMeta.setXmlDescription( new String[] { - "

Defines the way that values in the (possibly clipped)", - axname + " range are mapped to the selected colour ramp.", + "

Defines the way that values in the", + axName, + "range are mapped to the selected colour ramp.", "

", } ); scalingKey_ = new OptionConfigKey( scalingMeta, Scaling.class, Scaling.getStretchOptions(), - Scaling.LINEAR ); + dfltScaling ); scalingKey_.setOptionUsage(); scalingKey_.addOptionsXml(); + keyList.add( scalingKey_ ); - nullcolorKey_ = new ColorConfigKey( - ColorConfigKey.createColorMeta( axname + "nullcolor", "Null Color", - "points with a null value of the " - + axName + " coordinate" ) - .appendXmlDescription( new String[] { - "

If the value is null, then points with a null", - axName, - "value will not be plotted at all.", - "

", - } ) - , Color.GRAY, true ); + dataclipKey_ = + new SubrangeConfigKey( SubrangeConfigKey + .createAxisSubMeta( axname, axName ) ); + if ( hasDataclip ) { + keyList.add( dataclipKey_ ); + } + + keys_ = keyList.toArray( new ConfigKey[ 0 ] ); } public ConfigKey[] getKeys() { - return new ConfigKey[] { - shaderKey_, - subrangeKey_, - flipKey_, - scalingKey_, - nullcolorKey_, - }; + return keys_; } public Ramp createValue( ConfigMap config ) { - final Shader shader = StyleKeys.createShader( config, shaderKey_, - subrangeKey_, flipKey_ ); - final Scaling scaling = config.get( scalingKey_ ); - final Color nullcolor = config.get( nullcolorKey_ ); - final boolean isLog = scaling.isLogLike(); + + /* Determine configured shader instance. */ + Shader shader = config.get( shaderKey_ ); + Subrange shadeclip = config.get( shadeclipKey_ ); + boolean isFlip = config.get( flipKey_ ); + if ( ! Subrange.isIdentity( shadeclip ) ) { + shader = Shaders.stretch( shader, (float) shadeclip.getLow(), + (float) shadeclip.getHigh() ); + } + if ( isFlip ) { + shader = Shaders.invert( shader ); + } + + /* Determine configured scaling instance. */ + Scaling scaling = config.get( scalingKey_ ); + Subrange dataclip = config.get( dataclipKey_ ); + if ( ! Subrange.isIdentity( dataclip ) ) { + scaling = Scaling.subrangeScaling( scaling, dataclip ); + } + + /* Construct and return a Ramp instance. */ + final Shader shader0 = shader; + final Scaling scaling0 = scaling; return new Ramp() { public Shader getShader() { - return shader; + return shader0; } public Scaling getScaling() { - return scaling; + return scaling0; } - public Color getNullColor() { - return nullcolor; + }; + } + + /** + * Creates a ShadeAxisFactory for a given ramp. + * + * @param ramp ramp + * @param captioner shader ramp captioner + * @param label shader ramp label + * @param crowding tick crowding factor (1 is normal) + * @return new factory + */ + public static ShadeAxisFactory + createShadeAxisFactory( Ramp ramp, final Captioner captioner, + final String label, + final double crowding ) { + final Shader shader = ramp.getShader(); + final Scaling scaling = ramp.getScaling(); + final boolean isLog = scaling.isLogLike(); + return new ShadeAxisFactory() { + public boolean isLog() { + return isLog; } - public ShadeAxisFactory - createShadeAxisFactory( final Captioner captioner, - final String label, - final double crowding ) { - return new ShadeAxisFactory() { - public boolean isLog() { - return isLog; - } - public ShadeAxis createShadeAxis( Range range ) { - if ( range == null ) { - range = new Range(); - } - double[] bounds = range.getFiniteBounds( isLog ); - double lo = bounds[ 0 ]; - double hi = bounds[ 1 ]; - return new ShadeAxis( shader, scaling, lo, hi, - label, captioner, crowding ); - } - }; + public ShadeAxis createShadeAxis( Range range ) { + if ( range == null ) { + range = new Range(); + } + double[] bounds = range.getFiniteBounds( isLog ); + double lo = bounds[ 0 ]; + double hi = bounds[ 1 ]; + return new ShadeAxis( shader, scaling, lo, hi, + label, captioner, crowding ); } }; } /** - * Defines ramp characteristics. - * - *

Possibly the code could be simplified by combining the functions - * of this class and ShadeAxisFactory. + * Defines ramp characteristics by aggregating a Shader and a Scaling. */ public interface Ramp { - /** - * Creates a ShadeAxisFactory for this ramp. - * - * @param captioner shader ramp captioner - * @param label shader ramp label - * @param crowding tick crowding factor (1 is normal) - * @return new factory - */ - ShadeAxisFactory createShadeAxisFactory( Captioner captioner, - String label, - double crowding ); - /** * Returns this ramp's shader. * @@ -172,64 +192,5 @@ ShadeAxisFactory createShadeAxisFactory( Captioner captioner, * @return scaling */ Scaling getScaling(); - - /** - * Returns the colour in which items with no ramp data value - * should be painted. - * - * @return null colour; if null, blank values are not painted - */ - Color getNullColor(); - } - - /** - * Returns a list of shaders suitable for aux axis shading. - * - * @return shaders - */ - private static Shader[] createAuxShaders() { - List shaderList = new ArrayList(); - shaderList.addAll( Arrays.asList( new Shader[] { - Shaders.LUT_RAINBOW, - Shaders.LUT_GLNEMO2, - Shaders.LUT_PASTEL, - Shaders.LUT_ACCENT, - Shaders.LUT_GNUPLOT, - Shaders.LUT_GNUPLOT2, - Shaders.LUT_CUBEHELIX, - Shaders.LUT_SPECXB2Y, - Shaders.LUT_SET1, - Shaders.LUT_PAIRED, - Shaders.CYAN_MAGENTA, - Shaders.RED_BLUE, - Shaders.LUT_BRG, - Shaders.LUT_HEAT, - Shaders.LUT_COLD, - Shaders.LUT_LIGHT, - Shaders.LUT_COLOR, - Shaders.WHITE_BLACK, - Shaders.LUT_STANDARD, - Shaders.LUT_RAINBOW3, - Shaders.createMaskShader( "Mask", 0f, 1f, true ), - Shaders.FIX_HUE, - Shaders.TRANSPARENCY, - Shaders.FIX_INTENSITY, - Shaders.FIX_RED, - Shaders.FIX_GREEN, - Shaders.FIX_BLUE, - Shaders.HSV_H, - Shaders.HSV_S, - Shaders.HSV_V, - Shaders.FIX_Y, - Shaders.FIX_U, - Shaders.FIX_V, - Shaders.BREWER_BUGN, - Shaders.BREWER_BUPU, - Shaders.BREWER_ORRD, - Shaders.BREWER_PUBU, - Shaders.BREWER_PURD, - } ) ); - shaderList.addAll( Arrays.asList( Shaders.getCustomShaders() ) ); - return shaderList.toArray( new Shader[ 0 ] ); } } diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/StyleKeys.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/StyleKeys.java index 7bebd7a9f6..f29370a090 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/config/StyleKeys.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/config/StyleKeys.java @@ -38,7 +38,6 @@ public class StyleKeys { private static final MarkShape[] SHAPES = createShapes(); - private static final Shader[] DENSITY_SHADERS = createDensityShaders(); /** Config key for marker shape. */ public static final ConfigKey MARK_SHAPE = @@ -325,54 +324,9 @@ protected Icon getRendererIcon( Object form ) { new SubrangeConfigKey( SubrangeConfigKey .createAxisSubMeta( "aux", "Aux" ) ); - /** Config key for density shader colour map. */ - public static final ConfigKey DENSITY_SHADER = - new ShaderConfigKey( - new ConfigMeta( "densemap", "Density Shader" ) - .setShortDescription( "Color map for density shading" ) - .setXmlDescription( new String[] { - "

Color map used to indicate point density.", - "

", - } ) - , DENSITY_SHADERS, DENSITY_SHADERS[ 0 ] - ).appendShaderDescription() - .setOptionUsage(); - - /** Config key for restricting the range of a density shader colour map. */ - public static final ConfigKey DENSITY_SHADER_CLIP = - new SubrangeConfigKey( SubrangeConfigKey - .createShaderClipMeta( "dense", "Density" ) ); - - /** Config key for inverting the sense of a density shader colour map. */ - public static final ConfigKey DENSITY_SHADER_FLIP = - new BooleanConfigKey( - new ConfigMeta( "denseflip", "Shader Flip" ) - .setShortDescription( "Flip density colour map?" ) - .setXmlDescription( new String[] { - "

If true, the colour map used for shading points", - "according to density is reversed.", - "

", - } ) - , Boolean.FALSE ); - - /** Config key for density scaling. */ - public static final ConfigKey DENSITY_SCALING = - new OptionConfigKey( - new ConfigMeta( "densefunc", "Scaling" ) - .setShortDescription( "Density colour scaling function" ) - .setXmlDescription( new String[] { - "

Defines the way that values in the (possibly clipped)", - "density range are mapped to the selected colour ramp.", - "

", - } ) - , Scaling.class, Scaling.getStretchOptions() ) - .setOptionUsage() - .addOptionsXml(); - - /** Config key for density shader subrange. */ - public static final ConfigKey DENSITY_SUBRANGE = - new SubrangeConfigKey( SubrangeConfigKey - .createAxisSubMeta( "dense", "Density" ) ); + /** Config key for aux null colour. */ + public static final ConfigKey AUX_NULLCOLOR = + createNullColorKey( "aux", "Aux" ); private static final String SCALE_NAME = "scale"; private static final String AUTOSCALE_NAME = "autoscale"; @@ -522,7 +476,19 @@ protected Icon getRendererIcon( Object form ) { public static final CaptionerKeySet CAPTIONER = new CaptionerKeySet(); /** Config key set for global Aux axis colour ramp. */ - public static final RampKeySet AUX_RAMP = new RampKeySet( "aux", "Aux" ); + public static final RampKeySet AUX_RAMP = + new RampKeySet( "aux", "Aux", + createAuxShaders(), Scaling.LINEAR, false ); + + /** Config key set for density shading. */ + public static final RampKeySet DENSITY_RAMP = + new RampKeySet( "dense", "Density", + createDensityShaders(), Scaling.LOG, true ); + + /** Config key set for spectrogram shading. */ + public static final RampKeySet SPECTRO_RAMP = + new RampKeySet( "spectro", "Spectral", + createAuxShaders(), Scaling.LINEAR, true ); /** * Private constructor prevents instantiation. @@ -597,6 +563,30 @@ public static ConfigKey createAxisLabelKey( String axName ) { return new StringConfigKey( meta, axName ); } + /** + * Returns a key for acquiring a colour used in place of a shading ramp + * colour in case that the input data is null. + * + * @param axname short form of axis name, used in text parameter names + * @param axName long form of axis name, used in descriptions + * @return new key + */ + public static ConfigKey createNullColorKey( String axname, + String axName ) { + return new ColorConfigKey( + ColorConfigKey.createColorMeta( axname.toLowerCase() + "nullcolor", + "Null Color", + "points with a null value of the " + + axName + " coordinate" ) + .appendXmlDescription( new String[] { + "

If the value is null, then points with a null", + axName, + "value will not be plotted at all.", + "

", + } ) + , Color.GRAY, true ); + } + /** * Returns a config key for line thickness with a given default value. * @@ -619,51 +609,6 @@ public Specifier createSpecifier() { }; } - /** - * Obtains a shader from a config map given appropriate keys. - * - * @param config config map - * @param baseShaderKey key for extracting a shader - * @param clipKey key for extracting a clip range of a shader - * @param flipKey key for extracting shader flip flag - * @return shader with clip applied if appropriate - */ - public static Shader createShader( ConfigMap config, - ConfigKey baseShaderKey, - ConfigKey clipKey, - ConfigKey flipKey ) { - Shader shader = config.get( baseShaderKey ); - if ( shader == null ) { - return null; - } - Subrange clip = config.get( clipKey ); - if ( ! Subrange.isIdentity( clip ) ) { - shader = Shaders.stretch( shader, (float) clip.getLow(), - (float) clip.getHigh() ); - } - boolean isFlip = Boolean.TRUE.equals( config.get( flipKey ) ); - if ( isFlip ) { - shader = Shaders.invert( shader ); - } - return shader; - } - - /** - * Returns a scaling object from a config map given appropriate keys. - * - * @param config config map - * @param baseScalingKey key for scaling operation - * @param subrangeKey key for input value subrange - * @return scaling object ready for use - */ - public static Scaling createScaling( ConfigMap config, - ConfigKey baseScalingKey, - ConfigKey subrangeKey ) { - Scaling baseScaling = config.get( baseScalingKey ); - Subrange subrange = config.get( subrangeKey ); - return Scaling.subrangeScaling( baseScaling, subrange ); - } - /** * Creates a config key for a multipoint shape. * @@ -735,7 +680,7 @@ private static Shader[] createDensityShaders() { Shaders.RED_BLUE, Shaders.LUT_BRG, Shaders.invert( Shaders.LUT_HEAT ), - Shaders.invert( Shaders.LUT_COLD ), + Shaders.invert( Shaders.LUT_COLD ), Shaders.invert( Shaders.LUT_LIGHT ), Shaders.WHITE_BLACK, Shaders.SCALE_V, @@ -749,4 +694,52 @@ private static Shader[] createDensityShaders() { Shaders.BREWER_PURD, }; } + + /** + * Returns a list of shaders suitable for aux axis shading. + * + * @return shaders + */ + private static Shader[] createAuxShaders() { + return new Shader[] { + Shaders.LUT_RAINBOW, + Shaders.LUT_GLNEMO2, + Shaders.LUT_PASTEL, + Shaders.LUT_ACCENT, + Shaders.LUT_GNUPLOT, + Shaders.LUT_GNUPLOT2, + Shaders.LUT_CUBEHELIX, + Shaders.LUT_SPECXB2Y, + Shaders.LUT_SET1, + Shaders.LUT_PAIRED, + Shaders.CYAN_MAGENTA, + Shaders.RED_BLUE, + Shaders.LUT_BRG, + Shaders.LUT_HEAT, + Shaders.LUT_COLD, + Shaders.LUT_LIGHT, + Shaders.LUT_COLOR, + Shaders.WHITE_BLACK, + Shaders.LUT_STANDARD, + Shaders.LUT_RAINBOW3, + Shaders.createMaskShader( "Mask", 0f, 1f, true ), + Shaders.FIX_HUE, + Shaders.TRANSPARENCY, + Shaders.FIX_INTENSITY, + Shaders.FIX_RED, + Shaders.FIX_GREEN, + Shaders.FIX_BLUE, + Shaders.HSV_H, + Shaders.HSV_S, + Shaders.HSV_V, + Shaders.FIX_Y, + Shaders.FIX_U, + Shaders.FIX_V, + Shaders.BREWER_BUGN, + Shaders.BREWER_BUPU, + Shaders.BREWER_ORRD, + Shaders.BREWER_PUBU, + Shaders.BREWER_PURD, + }; + } } diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/ShapeMode.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/ShapeMode.java index 5899a3f585..bb298da4e2 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/ShapeMode.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/ShapeMode.java @@ -903,6 +903,8 @@ public Stamper createStamper( ConfigMap config ) { */ private static class CustomDensityMode extends AbstractDensityMode { + private static final RampKeySet RAMP_KEYS = StyleKeys.DENSITY_RAMP; + /** * Constructor. */ @@ -931,27 +933,19 @@ public String getModeDescription() { } public ConfigKey[] getConfigKeys() { - return new ConfigKey[] { - StyleKeys.COLOR, - StyleKeys.DENSITY_SHADER, - StyleKeys.DENSITY_SHADER_CLIP, - StyleKeys.DENSITY_SHADER_FLIP, - StyleKeys.DENSITY_SCALING, - StyleKeys.DENSITY_SUBRANGE, - }; + List keyList = new ArrayList(); + keyList.add( StyleKeys.COLOR ); + keyList.addAll( Arrays.asList( RAMP_KEYS.getKeys() ) ); + return keyList.toArray( new ConfigKey[ 0 ] ); } public Stamper createStamper( ConfigMap config ) { Color baseColor = config.get( StyleKeys.COLOR ); - Shader baseShader = - StyleKeys.createShader( config, StyleKeys.DENSITY_SHADER, - StyleKeys.DENSITY_SHADER_CLIP, - StyleKeys.DENSITY_SHADER_FLIP ); + RampKeySet.Ramp ramp = RAMP_KEYS.createValue( config ); + Shader baseShader = ramp.getShader(); Shader densityShader = Shaders.applyShader( baseShader, baseColor, COLOR_MAP_SIZE ); - Scaling scaling = - StyleKeys.createScaling( config, StyleKeys.DENSITY_SCALING, - StyleKeys.DENSITY_SUBRANGE ); + Scaling scaling = ramp.getScaling(); return new DensityStamper( densityShader, scaling ); } } @@ -964,7 +958,7 @@ private static class AuxShadingMode extends ShapeMode { private final boolean reportAuxKeys_; private static final AuxScale SCALE = AuxScale.COLOR; - private static final RampKeySet rampKeys_ = StyleKeys.AUX_RAMP; + private static final RampKeySet RAMP_KEYS = StyleKeys.AUX_RAMP; private static final String scaleName = SCALE.getName(); private static final FloatingCoord SHADE_COORD = FloatingCoord.createCoord( @@ -1016,8 +1010,9 @@ public String getModeDescription() { public ConfigKey[] getConfigKeys() { List list = new ArrayList(); if ( reportAuxKeys_ ) { - list.addAll( Arrays.asList( rampKeys_.getKeys() ) ); + list.addAll( Arrays.asList( RAMP_KEYS.getKeys() ) ); } + list.add( StyleKeys.AUX_NULLCOLOR ); if ( transparent_ ) { list.add( StyleKeys.AUX_OPAQUE ); } @@ -1025,10 +1020,10 @@ public ConfigKey[] getConfigKeys() { } public Stamper createStamper( ConfigMap config ) { - RampKeySet.Ramp ramp = rampKeys_.createValue( config ); + RampKeySet.Ramp ramp = RAMP_KEYS.createValue( config ); Shader shader = ramp.getShader(); Scaling scaling = ramp.getScaling(); - Color nullColor = ramp.getNullColor(); + Color nullColor = config.get( StyleKeys.AUX_NULLCOLOR ); double opaque = transparent_ ? config.get( StyleKeys.AUX_OPAQUE ) : 1; diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/SpectrogramPlotter.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/SpectrogramPlotter.java index ee7cabcbbe..94b8a36cd2 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/SpectrogramPlotter.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/layer/SpectrogramPlotter.java @@ -5,8 +5,10 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.geom.Point2D; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.swing.Icon; import uk.ac.starlink.ttools.gui.ResourceIcon; @@ -29,6 +31,7 @@ import uk.ac.starlink.ttools.plot2.config.ConfigKey; import uk.ac.starlink.ttools.plot2.config.ConfigMap; import uk.ac.starlink.ttools.plot2.config.RampKeySet; +import uk.ac.starlink.ttools.plot2.config.StyleKeys; import uk.ac.starlink.ttools.plot2.data.Coord; import uk.ac.starlink.ttools.plot2.data.CoordGroup; import uk.ac.starlink.ttools.plot2.data.DataSpec; @@ -63,8 +66,9 @@ public class SpectrogramPlotter private final int icSpectrum_; private static final AuxScale SPECTRO_SCALE = new AuxScale( "Spectral" ); - private static final RampKeySet RAMP_KEYS = - new RampKeySet( "spectro", "Spectro" ); + private static final RampKeySet RAMP_KEYS = StyleKeys.SPECTRO_RAMP; + private static final ConfigKey NULLCOLOR_KEY = + StyleKeys.createNullColorKey( "spectro", "Spectral" ); private static final ChannelGrid DEFAULT_CHANGRID = new AssumedChannelGrid(); private static final int MAX_SAMPLE = 100; @@ -173,14 +177,17 @@ public CoordGroup getCoordGroup() { } public ConfigKey[] getStyleKeys() { - return RAMP_KEYS.getKeys(); + List keyList = new ArrayList(); + keyList.addAll( Arrays.asList( RAMP_KEYS.getKeys() ) ); + keyList.add( NULLCOLOR_KEY ); + return keyList.toArray( new ConfigKey[ 0 ] ); } public SpectroStyle createStyle( ConfigMap config ) { RampKeySet.Ramp ramp = RAMP_KEYS.createValue( config ); Shader shader = ramp.getShader(); Scaling scaling = ramp.getScaling(); - Color nullColor = ramp.getNullColor(); + Color nullColor = config.get( NULLCOLOR_KEY ); ChannelGrid grid = DEFAULT_CHANGRID; return new SpectroStyle( shader, scaling, nullColor, grid ); } diff --git a/ttools/src/main/uk/ac/starlink/ttools/plot2/task/AbstractPlot2Task.java b/ttools/src/main/uk/ac/starlink/ttools/plot2/task/AbstractPlot2Task.java index 9dae30b586..3ec445ffa4 100644 --- a/ttools/src/main/uk/ac/starlink/ttools/plot2/task/AbstractPlot2Task.java +++ b/ttools/src/main/uk/ac/starlink/ttools/plot2/task/AbstractPlot2Task.java @@ -1465,7 +1465,8 @@ private ShadeAxisFactory createShadeAxisFactory( Environment env, /* Really, I should default this from the value of the first * layer aux data value. */ String label = auxlabelParam_.objectValue( env ); - return ramp.createShadeAxisFactory( captioner, label, crowd ); + return RampKeySet + .createShadeAxisFactory( ramp, captioner, label, crowd ); } /**