Package uk.ac.starlink.ttools.plot
Class Shaders
- java.lang.Object
-
- uk.ac.starlink.ttools.plot.Shaders
-
public class Shaders extends java.lang.ObjectProvides some implementations of theShaderinterface.Many other lookup tables are available. See for instance http://www.ncl.ucar.edu/Document/Graphics/color_table_gallery.shtml. The utility class
LutStealis available to help turn these into lut files that can be used here.- Since:
- 5 Jun 2007
- Author:
- Mark Taylor
-
-
Field Summary
Fields Modifier and Type Field Description static ShaderBLACK_WHITEInterpolates between black (0) and white (1).static ShaderBREWER_BRBGColorBrewer diverging brown-blue-green shader.static ShaderBREWER_BUGNColorBrewer sequential blue-green shader.static ShaderBREWER_BUPUColorBrewer sequential blue-purple shader.static ShaderBREWER_ORRDColorBrewer sequential orange-red shader.static ShaderBREWER_PIYGColorBrewer diverging pink-green shader.static ShaderBREWER_PUBUColorBrewer sequential purple-blue shader.static ShaderBREWER_PURDColorBrewer sequential purple-red shader.static ShaderBREWER_RDBUColorBrewer diverging red-blue shader.static ShaderCUBEHELIXStandard cubehelix shader.static ShaderCUBEHELIX2Enhanced hue cubehelix shader.static ShaderCUBEHELIX3Lurid cubehelix shader.static ShaderCYAN_MAGENTAInterpolates between cyan (0) and magenta (1).static ShaderDFLT_GRID_SHADERShader used by default for the transverse axis of non-absolute ramps.static ShaderFADE_BLACKShader which interpolates between the base colour and black.static ShaderFADE_WHITEShader which interpolates between the base colour and white.static ShaderFIX_BLUEFixes blue level at parameter value.static ShaderFIX_GREENFixes green level at parameter value.static ShaderFIX_HUEShader which fixes hue.static ShaderFIX_INTENSITYShader which sets intensity.static ShaderFIX_REDFixes red level at parameter value.static ShaderFIX_UFixes U in YUV colour space.static ShaderFIX_VFixes V in YUV colour space.static ShaderFIX_YFixes Y in YUV colour space.static ShaderHCL_POLARHue-chroma-luminance cyclic shader.static ShaderHSV_HFixes H in HSV colour space.static ShaderHSV_SFixes S in HSV colour space.static ShaderHSV_VFixes V in HSV colour space.static ShaderLUT_ACCENTShader based on lookup table Accent.static ShaderLUT_AIPS0Shader based on lookup table Aips0.static ShaderLUT_BACKGRShader based on lookup table Backgr.static ShaderLUT_BRGShader copied from Matplotlib BRG lookup table.static ShaderLUT_CIVIDISCividis shader derived from DOI:10.1371/journal.pone.0199239.static ShaderLUT_COLDShader based on lookup table Cold.static ShaderLUT_COLORShader based on lookup table Color.static ShaderLUT_GLNEMO2Shader copied from glNemo2 application.static ShaderLUT_GNUPLOTShader copied from Matplotlib Gnuplot lookup table.static ShaderLUT_GNUPLOT2Shader copied from Matplotlib Gnuplot2 lookup table.static ShaderLUT_HEATShader based on lookup table Heat.static ShaderLUT_HOTCOLDDiverging hot-cold shader provided by Daniel Michalik.static ShaderLUT_IDL2Shader based on lookup table IDL2.static ShaderLUT_IDL4Shader based on lookup table IDL4.static ShaderLUT_ISOPHOTShader based on lookup table Isophot.static ShaderLUT_LIGHTShader based on lookup table Light.static ShaderLUT_MANYCOLShader based on lookup table Manycol.static ShaderLUT_MPL2INFERNOShader copied from Matplotlib 2.0 Inferno lookup table.static ShaderLUT_MPL2MAGMAShader copied from Matplotlib 2.0 Magma lookup table.static ShaderLUT_MPL2PLASMAShader copied from Matplotlib 2.0 Plasma lookup table.static ShaderLUT_MPL2VIRIDISShader copied from Matplotlib 2.0 Viridis lookup table.static ShaderLUT_PAINBOWPainbow shader scraped from https://xkcd.com/2537/.static ShaderLUT_PAIREDShader copied from Matplotlib Paired lookup table.static ShaderLUT_PASTELShader based on lookup table Pastel.static ShaderLUT_RAINBOWShader based on lookup table Rainbow.static ShaderLUT_RAINBOW3Shader copied from Matplotlib gist_rainbow lookup table.static ShaderLUT_RAMPShader based on lookup table Ramp.static ShaderLUT_RANDOMShader based on lookup table Random.static ShaderLUT_REALShader based on lookup table Real.static ShaderLUT_SET1Shader copied from Matplotlib Set1 lookup table.static Shader[]LUT_SHADERSSelection of lookup table-based shaders.static ShaderLUT_SMOOTHShader based on lookup table Smooth.static ShaderLUT_SPECXB2YShader copied from SPECX blue2yellow lookup table.static ShaderLUT_STAIRCASEShader based on lookup table Staircase.static ShaderLUT_STANDARDShader based on lookup table Standard.static java.lang.StringLUTFILES_PROPERTYProperty containing a File.pathSeparator-separated list of text files containing custom lookup tables.static ShaderNULLShader which does nothing.static ShaderRED_BLUEInterpolates between red (0) and blue (1).static ShaderSCALE_BLUEScales blue level by parameter value.static ShaderSCALE_GREENScales green level by parameter value.static ShaderSCALE_HScales H in HSV colour space.static ShaderSCALE_INTENSITYShader which scales intensity.static ShaderSCALE_REDScales red level by parameter value.static ShaderSCALE_SScales S in HSV colour space.static ShaderSCALE_VScales V in HSV colour space.static ShaderSCALE_YScales Y in YUV colour space.static ShaderSRON_RAINBOWRainbow shader copied from SRON technical note SRON/EPS/TN/09-002.static ShaderTRANSPARENCYScales alpha channel by parameter value.static ShaderWHITE_BLACKInterpolates between white (0) and black (1).
-
Constructor Summary
Constructors Constructor Description Shaders()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ShaderapplyShader(Shader shader, java.awt.Color baseColor, int nsample)Creates a shader by applying an existing shader to a given base colour.static javax.swing.Iconcreate2dIcon(Shader xShader, Shader yShader, boolean xFirst, java.awt.Color baseColor, int width, int height, int xpad, int ypad)Constructs an icon which represents two shaders in two dimensions.static ShadercreateFixedShader(java.lang.String name, java.awt.Color color)Creates a shader which always returns a fixed colour regardless of the supplied parameter.static ShadercreateInterpolationShader(java.lang.String name, java.awt.Color[] colors)Constructs a shader which interpolates between a sequence of colours.static ShadercreateInterpolationShader(java.lang.String name, java.awt.Color color0, java.awt.Color color1)Constructs a shader which interpolates smoothly between two colours.static ShadercreateMaskShader(java.lang.String name, float minMask, float maxMask, boolean sense)Creates a shader which for each value either does nothing to a colour or turns it completely transparent.static javax.swing.IconcreateShaderIcon(Shader shader, boolean horizontal, int width, int height, int xpad, int ypad)Returns an icon which displays a shader in action, using a default grid shader if required.static javax.swing.IconcreateShaderIcon(Shader shader, Shader gridShader, boolean horizontal, int width, int height, int xpad, int ypad)Returns an icon which displays a shader in action, using an explicitly provided grid shader.static Shaderfade(Shader shader, float scaleAlpha)Returns a shader which scales the alpha value of all its colours by a given constant.static Shader[]getCustomShaders()Returns an array of any custom shaders specified by theLUTFILES_PROPERTYproperty.static Shaderinvert(Shader shader)Returns a shader which runs in the opposite direction to a given one.static booleanisTransparent(Shader shader)Indicates whether the given shader object is capable of introducing transparency into a colour (modifying rgba[3] from 1 to a lower value).static Shaderquantise(Shader shader, double nlevel)Returns a shader which splits the colour map into a set of discrete levels.static Shaderrename(Shader shader, java.lang.String name)Returns a shader which delegates all behaviour to a supplied base instance, except it has a given name.static Shaderstretch(Shader shader, float frac0, float frac1)Returns a shader which corresponds to a sub-range of a given shader.
-
-
-
Field Detail
-
LUTFILES_PROPERTY
public static final java.lang.String LUTFILES_PROPERTY
Property containing a File.pathSeparator-separated list of text files containing custom lookup tables. Each line should contain three space-separated floating point values between zero and one giving the Red, Green and Blue components of a colour.- See Also:
getCustomShaders(), Constant Field Values
-
FIX_RED
public static final Shader FIX_RED
Fixes red level at parameter value.
-
FIX_GREEN
public static final Shader FIX_GREEN
Fixes green level at parameter value.
-
FIX_BLUE
public static final Shader FIX_BLUE
Fixes blue level at parameter value.
-
SCALE_RED
public static final Shader SCALE_RED
Scales red level by parameter value.
-
SCALE_GREEN
public static final Shader SCALE_GREEN
Scales green level by parameter value.
-
SCALE_BLUE
public static final Shader SCALE_BLUE
Scales blue level by parameter value.
-
FIX_Y
public static final Shader FIX_Y
Fixes Y in YUV colour space.
-
FIX_U
public static final Shader FIX_U
Fixes U in YUV colour space.
-
FIX_V
public static final Shader FIX_V
Fixes V in YUV colour space.
-
SCALE_Y
public static final Shader SCALE_Y
Scales Y in YUV colour space.
-
HSV_H
public static final Shader HSV_H
Fixes H in HSV colour space.
-
HSV_S
public static final Shader HSV_S
Fixes S in HSV colour space.
-
HSV_V
public static final Shader HSV_V
Fixes V in HSV colour space.
-
SCALE_H
public static final Shader SCALE_H
Scales H in HSV colour space.
-
SCALE_S
public static final Shader SCALE_S
Scales S in HSV colour space.
-
SCALE_V
public static final Shader SCALE_V
Scales V in HSV colour space.
-
RED_BLUE
public static final Shader RED_BLUE
Interpolates between red (0) and blue (1).
-
CYAN_MAGENTA
public static final Shader CYAN_MAGENTA
Interpolates between cyan (0) and magenta (1).
-
WHITE_BLACK
public static final Shader WHITE_BLACK
Interpolates between white (0) and black (1).
-
BLACK_WHITE
public static final Shader BLACK_WHITE
Interpolates between black (0) and white (1).
-
SRON_RAINBOW
public static final Shader SRON_RAINBOW
Rainbow shader copied from SRON technical note SRON/EPS/TN/09-002.
-
CUBEHELIX
public static final Shader CUBEHELIX
Standard cubehelix shader.
-
CUBEHELIX2
public static final Shader CUBEHELIX2
Enhanced hue cubehelix shader.
-
CUBEHELIX3
public static final Shader CUBEHELIX3
Lurid cubehelix shader.
-
LUT_AIPS0
public static final Shader LUT_AIPS0
Shader based on lookup table Aips0.
-
LUT_BACKGR
public static final Shader LUT_BACKGR
Shader based on lookup table Backgr.
-
LUT_COLOR
public static final Shader LUT_COLOR
Shader based on lookup table Color.
-
LUT_HEAT
public static final Shader LUT_HEAT
Shader based on lookup table Heat.
-
LUT_IDL2
public static final Shader LUT_IDL2
Shader based on lookup table IDL2.
-
LUT_IDL4
public static final Shader LUT_IDL4
Shader based on lookup table IDL4.
-
LUT_ISOPHOT
public static final Shader LUT_ISOPHOT
Shader based on lookup table Isophot.
-
LUT_LIGHT
public static final Shader LUT_LIGHT
Shader based on lookup table Light.
-
LUT_MANYCOL
public static final Shader LUT_MANYCOL
Shader based on lookup table Manycol.
-
LUT_PASTEL
public static final Shader LUT_PASTEL
Shader based on lookup table Pastel.
-
LUT_RAINBOW
public static final Shader LUT_RAINBOW
Shader based on lookup table Rainbow.
-
LUT_RAMP
public static final Shader LUT_RAMP
Shader based on lookup table Ramp.
-
LUT_RANDOM
public static final Shader LUT_RANDOM
Shader based on lookup table Random.
-
LUT_REAL
public static final Shader LUT_REAL
Shader based on lookup table Real.
-
LUT_SMOOTH
public static final Shader LUT_SMOOTH
Shader based on lookup table Smooth.
-
LUT_STAIRCASE
public static final Shader LUT_STAIRCASE
Shader based on lookup table Staircase.
-
LUT_STANDARD
public static final Shader LUT_STANDARD
Shader based on lookup table Standard.
-
LUT_ACCENT
public static final Shader LUT_ACCENT
Shader based on lookup table Accent.
-
LUT_COLD
public static final Shader LUT_COLD
Shader based on lookup table Cold.
-
LUT_GLNEMO2
public static final Shader LUT_GLNEMO2
Shader copied from glNemo2 application.
-
LUT_GNUPLOT
public static final Shader LUT_GNUPLOT
Shader copied from Matplotlib Gnuplot lookup table.
-
LUT_GNUPLOT2
public static final Shader LUT_GNUPLOT2
Shader copied from Matplotlib Gnuplot2 lookup table.
-
LUT_SPECXB2Y
public static final Shader LUT_SPECXB2Y
Shader copied from SPECX blue2yellow lookup table.
-
LUT_BRG
public static final Shader LUT_BRG
Shader copied from Matplotlib BRG lookup table.
-
LUT_PAIRED
public static final Shader LUT_PAIRED
Shader copied from Matplotlib Paired lookup table.
-
LUT_RAINBOW3
public static final Shader LUT_RAINBOW3
Shader copied from Matplotlib gist_rainbow lookup table.
-
LUT_SET1
public static final Shader LUT_SET1
Shader copied from Matplotlib Set1 lookup table.
-
LUT_MPL2MAGMA
public static final Shader LUT_MPL2MAGMA
Shader copied from Matplotlib 2.0 Magma lookup table.
-
LUT_MPL2INFERNO
public static final Shader LUT_MPL2INFERNO
Shader copied from Matplotlib 2.0 Inferno lookup table.
-
LUT_MPL2PLASMA
public static final Shader LUT_MPL2PLASMA
Shader copied from Matplotlib 2.0 Plasma lookup table.
-
LUT_MPL2VIRIDIS
public static final Shader LUT_MPL2VIRIDIS
Shader copied from Matplotlib 2.0 Viridis lookup table.
-
LUT_HOTCOLD
public static final Shader LUT_HOTCOLD
Diverging hot-cold shader provided by Daniel Michalik.
-
LUT_CIVIDIS
public static final Shader LUT_CIVIDIS
Cividis shader derived from DOI:10.1371/journal.pone.0199239.
-
LUT_PAINBOW
public static final Shader LUT_PAINBOW
Painbow shader scraped from https://xkcd.com/2537/. Thanks Randall.
-
LUT_SHADERS
public static final Shader[] LUT_SHADERS
Selection of lookup table-based shaders.
-
BREWER_BUGN
public static final Shader BREWER_BUGN
ColorBrewer sequential blue-green shader.
-
BREWER_BUPU
public static final Shader BREWER_BUPU
ColorBrewer sequential blue-purple shader.
-
BREWER_ORRD
public static final Shader BREWER_ORRD
ColorBrewer sequential orange-red shader.
-
BREWER_PUBU
public static final Shader BREWER_PUBU
ColorBrewer sequential purple-blue shader.
-
BREWER_PURD
public static final Shader BREWER_PURD
ColorBrewer sequential purple-red shader.
-
BREWER_RDBU
public static final Shader BREWER_RDBU
ColorBrewer diverging red-blue shader.
-
BREWER_PIYG
public static final Shader BREWER_PIYG
ColorBrewer diverging pink-green shader.
-
BREWER_BRBG
public static final Shader BREWER_BRBG
ColorBrewer diverging brown-blue-green shader.
-
HCL_POLAR
public static final Shader HCL_POLAR
Hue-chroma-luminance cyclic shader. Got from hclwizard.org with parameters: qualitative, H1=0 H2=351, N=40, C1=90, L1=60
-
DFLT_GRID_SHADER
public static final Shader DFLT_GRID_SHADER
Shader used by default for the transverse axis of non-absolute ramps.
-
NULL
public static final Shader NULL
Shader which does nothing.
-
TRANSPARENCY
public static final Shader TRANSPARENCY
Scales alpha channel by parameter value.
-
FIX_INTENSITY
public static final Shader FIX_INTENSITY
Shader which sets intensity.
-
SCALE_INTENSITY
public static final Shader SCALE_INTENSITY
Shader which scales intensity.
-
FADE_BLACK
public static final Shader FADE_BLACK
Shader which interpolates between the base colour and black.
-
FADE_WHITE
public static final Shader FADE_WHITE
Shader which interpolates between the base colour and white.
-
FIX_HUE
public static final Shader FIX_HUE
Shader which fixes hue.
-
-
Method Detail
-
createInterpolationShader
public static Shader createInterpolationShader(java.lang.String name, java.awt.Color color0, java.awt.Color color1)
Constructs a shader which interpolates smoothly between two colours.- Parameters:
name- namecolor0- colour corresponding to parameter value 0color1- colour corresponding to parameter value 1- Returns:
- shader
-
createInterpolationShader
public static Shader createInterpolationShader(java.lang.String name, java.awt.Color[] colors)
Constructs a shader which interpolates between a sequence of colours. The shading is defined by a sequence of linear segments.- Parameters:
name- namecolors- sequence of colours; value 0 corresponds to the first colour and value 1 corresponds to the last- Returns:
- shader
-
createFixedShader
public static Shader createFixedShader(java.lang.String name, java.awt.Color color)
Creates a shader which always returns a fixed colour regardless of the supplied parameter.- Parameters:
name- shader namecolor- fixed output colour- Returns:
- fixed colour shader
-
createMaskShader
public static Shader createMaskShader(java.lang.String name, float minMask, float maxMask, boolean sense)
Creates a shader which for each value either does nothing to a colour or turns it completely transparent. The pass range is specified by a minimum and maximum value and a sense.- Parameters:
name- shader nameminMask- minimum value (exclusive) for rangemaxMask- maximum value (exclusive) for rangesense- if true, values outside the range are transparent, if false, values within the range are transparent
-
getCustomShaders
public static Shader[] getCustomShaders()
Returns an array of any custom shaders specified by theLUTFILES_PROPERTYproperty.- Returns:
- array of zero or more custom shaders
-
invert
public static Shader invert(Shader shader)
Returns a shader which runs in the opposite direction to a given one.- Parameters:
shader- base shader- Returns:
- inverted version
-
fade
public static Shader fade(Shader shader, float scaleAlpha)
Returns a shader which scales the alpha value of all its colours by a given constant.- Parameters:
shader- input shaderscaleAlpha- alpha scaling factor, in range 0..1- Returns:
- fading shader; same as input if
scaleAlpha==1
-
rename
public static Shader rename(Shader shader, java.lang.String name)
Returns a shader which delegates all behaviour to a supplied base instance, except it has a given name.- Parameters:
shader- base shadername- new name- Returns:
- new shader
-
stretch
public static Shader stretch(Shader shader, float frac0, float frac1)
Returns a shader which corresponds to a sub-range of a given shader.- Parameters:
shader- base shaderfrac0- parameter value in base shader corresponding to value 0 in this one (must be in range 0-1)frac1- parameter value in base shader corresponding to value 1 in this one (must be in range 0-1)- Returns:
- new shader
-
quantise
public static Shader quantise(Shader shader, double nlevel)
Returns a shader which splits the colour map into a set of discrete levels.- Parameters:
shader- base shadernlevel- number of discrete colour levels required- Returns:
- new shader
-
applyShader
public static Shader applyShader(Shader shader, java.awt.Color baseColor, int nsample)
Creates a shader by applying an existing shader to a given base colour. This only does useful work if the existing shader is non-absolute.- Parameters:
shader- shader to apply (presumably non-absolute)baseColor- colour to which the shader will be appliednsample- number of samples in the lookup table- Returns:
- new absolute shader
-
create2dIcon
public static javax.swing.Icon create2dIcon(Shader xShader, Shader yShader, boolean xFirst, java.awt.Color baseColor, int width, int height, int xpad, int ypad)
Constructs an icon which represents two shaders in two dimensions.- Parameters:
xShader- shader for X directionyShader- shader for Y directionxFirst- true if X shader is to be applied firstbaseColor- base colour for the shaders to work onwidth- total width of the iconheight- total height of the iconxpad- internal padding in the X directionypad- internal padding in the Y direction- Returns:
- icon
-
createShaderIcon
public static javax.swing.Icon createShaderIcon(Shader shader, Shader gridShader, boolean horizontal, int width, int height, int xpad, int ypad)
Returns an icon which displays a shader in action, using an explicitly provided grid shader.- Parameters:
shader- shader to illustrategridShader- defines the pixels along the transverse direction of the shader; ignored (may be null) for absolute shadershorizontal- true for shading running horizontally, false for verticallywidth- total icon width in pixelsheight- total icon height in pixelsxpad- internal padding in the X directionypad- internal padding in the Y direction- Returns:
- icon
-
createShaderIcon
public static javax.swing.Icon createShaderIcon(Shader shader, boolean horizontal, int width, int height, int xpad, int ypad)
Returns an icon which displays a shader in action, using a default grid shader if required.- Parameters:
shader- shader to illustratehorizontal- true for shading running horizontally, false for verticallywidth- total icon width in pixelsheight- total icon height in pixelsxpad- internal padding in the X directionypad- internal padding in the Y direction- Returns:
- icon
-
isTransparent
public static boolean isTransparent(Shader shader)
Indicates whether the given shader object is capable of introducing transparency into a colour (modifying rgba[3] from 1 to a lower value).- Parameters:
shader- shader to test- Returns:
- true if shader adjusts transparency or is null
-
-