Package uk.ac.starlink.ttools.plot
Class Shaders
java.lang.Object
uk.ac.starlink.ttools.plot.Shaders
Provides some implementations of the
Shader
interface.
Many other lookup tables are available.
See for instance
http://www.ncl.ucar.edu/Document/Graphics/color_table_gallery.shtml.
The utility class LutSteal
is available to help turn these into
lut files that can be used here.
- Since:
- 5 Jun 2007
- Author:
- Mark Taylor
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Shader
Interpolates between black (0) and white (1).static final Shader
ColorBrewer diverging brown-blue-green shader.static final Shader
ColorBrewer sequential blue-green shader.static final Shader
ColorBrewer sequential blue-purple shader.static final Shader
ColorBrewer sequential orange-red shader.static final Shader
ColorBrewer diverging pink-green shader.static final Shader
ColorBrewer sequential purple-blue shader.static final Shader
ColorBrewer sequential purple-red shader.static final Shader
ColorBrewer diverging red-blue shader.static final Shader
Standard cubehelix shader.static final Shader
Enhanced hue cubehelix shader.static final Shader
Lurid cubehelix shader.static final Shader
Interpolates between cyan (0) and magenta (1).static final Shader
Shader used by default for the transverse axis of non-absolute ramps.static final Shader
Shader which interpolates between the base colour and black.static final Shader
Shader which interpolates between the base colour and white.static final Shader
Fixes blue level at parameter value.static final Shader
Fixes green level at parameter value.static final Shader
Shader which fixes hue.static final Shader
Shader which sets intensity.static final Shader
Fixes red level at parameter value.static final Shader
Fixes U in YUV colour space.static final Shader
Fixes V in YUV colour space.static final Shader
Fixes Y in YUV colour space.static final Shader
Hue-chroma-luminance cyclic shader.static final Shader
Fixes H in HSV colour space.static final Shader
Fixes S in HSV colour space.static final Shader
Fixes V in HSV colour space.static final Shader
Shader based on lookup table Accent.static final Shader
Shader based on lookup table Aips0.static final Shader
Shader based on lookup table Backgr.static final Shader
Shader copied from Matplotlib BRG lookup table.static final Shader
Bubblegum sequential shader from CMasher.static final Shader
Chroma sequential shader from CMasher.static final Shader
Cividis shader derived from DOI:10.1371/journal.pone.0199239.static final Shader
Shader based on lookup table Cold.static final Shader
Shader based on lookup table Color.static final Shader
Cosmic sequential shader from CMasher.static final Shader
Ember sequential shader from CMasher.static final Shader
Gem sequential shader from CMasher.static final Shader
Shader copied from glNemo2 application.static final Shader
Shader copied from Matplotlib Gnuplot lookup table.static final Shader
Shader copied from Matplotlib Gnuplot2 lookup table.static final Shader
Gothic sequential shader from CMasher.static final Shader
Guppy diverging shader from CMasher.static final Shader
Shader based on lookup table Heat.static final Shader
Diverging hot-cold shader provided by Daniel Michalik.static final Shader
Iceburn diverging shader from CMasher.static final Shader
Shader based on lookup table IDL2.static final Shader
Shader based on lookup table IDL4.static final Shader
Infinity cyclic shader from CMasher.static final Shader
Shader based on lookup table Isophot.static final Shader
Shader based on lookup table Light.static final Shader
Shader based on lookup table Manycol.static final Shader
Shader copied from Matplotlib 2.0 Inferno lookup table.static final Shader
Shader copied from Matplotlib 2.0 Magma lookup table.static final Shader
Shader copied from Matplotlib 2.0 Plasma lookup table.static final Shader
Shader copied from Matplotlib 2.0 Viridis lookup table.static final Shader
Neon sequential shader from CMasher.static final Shader
Painbow shader scraped from https://xkcd.com/2537/.static final Shader
Shader copied from Matplotlib Paired lookup table.static final Shader
Shader based on lookup table Pastel.static final Shader
Pride diverging shader from CMasher.static final Shader
Shader based on lookup table Rainbow.static final Shader
Shader copied from Matplotlib gist_rainbow lookup table.static final Shader
Rainforest sequential shader from CMasher.static final Shader
Shader based on lookup table Ramp.static final Shader
Shader based on lookup table Random.static final Shader
Shader based on lookup table Real.static final Shader
Redshift diverging shader from CMasher.static final Shader
Shader copied from Matplotlib Set1 lookup table.static final Shader[]
Selection of lookup table-based shaders.static final Shader
Shader based on lookup table Smooth.static final Shader
Shader copied from SPECX blue2yellow lookup table.static final Shader
Shader based on lookup table Staircase.static final Shader
Shader based on lookup table Standard.static final Shader
Tropical sequential shader from CMasher.static final Shader
Voltage sequential shader from CMasher.static final String
Property containing a File.pathSeparator-separated list of text files containing custom lookup tables.static final Shader
Shader which does nothing.static final Shader
Interpolates between red (0) and blue (1).static final Shader
Scales blue level by parameter value.static final Shader
Scales green level by parameter value.static final Shader
Scales H in HSV colour space.static final Shader
Shader which scales intensity.static final Shader
Scales red level by parameter value.static final Shader
Scales S in HSV colour space.static final Shader
Scales V in HSV colour space.static final Shader
Scales Y in YUV colour space.static final Shader
Rainbow shader copied from SRON technical note SRON/EPS/TN/09-002.static final Shader
Scales alpha channel by parameter value.static final Shader
Interpolates between white (0) and black (1). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Shader
applyShader
(Shader shader, Color baseColor, int nsample) Creates a shader by applying an existing shader to a given base colour.static Icon
create2dIcon
(Shader xShader, Shader yShader, boolean xFirst, Color baseColor, int width, int height, int xpad, int ypad) Constructs an icon which represents two shaders in two dimensions.static Shader
createFixedShader
(String name, Color color) Creates a shader which always returns a fixed colour regardless of the supplied parameter.static Shader
createInterpolationShader
(String name, Color[] colors) Constructs a shader which interpolates between a sequence of colours.static Shader
createInterpolationShader
(String name, Color color0, Color color1) Constructs a shader which interpolates smoothly between two colours.static Shader
createMaskShader
(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 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.static 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.static Shader
Returns a shader which scales the alpha value of all its colours by a given constant.static Shader[]
Returns an array of any custom shaders specified by theLUTFILES_PROPERTY
property.static Shader
Returns a shader which runs in the opposite direction to a given one.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).static Shader
Returns a shader which splits the colour map into a set of discrete levels.static Shader
Returns a shader which delegates all behaviour to a supplied base instance, except it has a given name.static Shader
Returns a shader which corresponds to a sub-range of a given shader.
-
Field Details
-
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:
-
FIX_RED
Fixes red level at parameter value. -
FIX_GREEN
Fixes green level at parameter value. -
FIX_BLUE
Fixes blue level at parameter value. -
SCALE_RED
Scales red level by parameter value. -
SCALE_GREEN
Scales green level by parameter value. -
SCALE_BLUE
Scales blue level by parameter value. -
FIX_Y
Fixes Y in YUV colour space. -
FIX_U
Fixes U in YUV colour space. -
FIX_V
Fixes V in YUV colour space. -
SCALE_Y
Scales Y in YUV colour space. -
HSV_H
Fixes H in HSV colour space. -
HSV_S
Fixes S in HSV colour space. -
HSV_V
Fixes V in HSV colour space. -
SCALE_H
Scales H in HSV colour space. -
SCALE_S
Scales S in HSV colour space. -
SCALE_V
Scales V in HSV colour space. -
RED_BLUE
Interpolates between red (0) and blue (1). -
CYAN_MAGENTA
Interpolates between cyan (0) and magenta (1). -
WHITE_BLACK
Interpolates between white (0) and black (1). -
BLACK_WHITE
Interpolates between black (0) and white (1). -
SRON_RAINBOW
Rainbow shader copied from SRON technical note SRON/EPS/TN/09-002. -
CUBEHELIX
Standard cubehelix shader. -
CUBEHELIX2
Enhanced hue cubehelix shader. -
CUBEHELIX3
Lurid cubehelix shader. -
LUT_AIPS0
Shader based on lookup table Aips0. -
LUT_BACKGR
Shader based on lookup table Backgr. -
LUT_COLOR
Shader based on lookup table Color. -
LUT_HEAT
Shader based on lookup table Heat. -
LUT_IDL2
Shader based on lookup table IDL2. -
LUT_IDL4
Shader based on lookup table IDL4. -
LUT_ISOPHOT
Shader based on lookup table Isophot. -
LUT_LIGHT
Shader based on lookup table Light. -
LUT_MANYCOL
Shader based on lookup table Manycol. -
LUT_PASTEL
Shader based on lookup table Pastel. -
LUT_RAINBOW
Shader based on lookup table Rainbow. -
LUT_RAMP
Shader based on lookup table Ramp. -
LUT_RANDOM
Shader based on lookup table Random. -
LUT_REAL
Shader based on lookup table Real. -
LUT_SMOOTH
Shader based on lookup table Smooth. -
LUT_STAIRCASE
Shader based on lookup table Staircase. -
LUT_STANDARD
Shader based on lookup table Standard. -
LUT_ACCENT
Shader based on lookup table Accent. -
LUT_COLD
Shader based on lookup table Cold. -
LUT_GLNEMO2
Shader copied from glNemo2 application. -
LUT_GNUPLOT
Shader copied from Matplotlib Gnuplot lookup table. -
LUT_GNUPLOT2
Shader copied from Matplotlib Gnuplot2 lookup table. -
LUT_SPECXB2Y
Shader copied from SPECX blue2yellow lookup table. -
LUT_BRG
Shader copied from Matplotlib BRG lookup table. -
LUT_PAIRED
Shader copied from Matplotlib Paired lookup table. -
LUT_RAINBOW3
Shader copied from Matplotlib gist_rainbow lookup table. -
LUT_SET1
Shader copied from Matplotlib Set1 lookup table. -
LUT_MPL2MAGMA
Shader copied from Matplotlib 2.0 Magma lookup table. -
LUT_MPL2INFERNO
Shader copied from Matplotlib 2.0 Inferno lookup table. -
LUT_MPL2PLASMA
Shader copied from Matplotlib 2.0 Plasma lookup table. -
LUT_MPL2VIRIDIS
Shader copied from Matplotlib 2.0 Viridis lookup table. -
LUT_HOTCOLD
Diverging hot-cold shader provided by Daniel Michalik. -
LUT_CIVIDIS
Cividis shader derived from DOI:10.1371/journal.pone.0199239. -
LUT_PAINBOW
Painbow shader scraped from https://xkcd.com/2537/. Thanks Randall. -
LUT_GUPPY
Guppy diverging shader from CMasher. -
LUT_ICEBURN
Iceburn diverging shader from CMasher. -
LUT_REDSHIFT
Redshift diverging shader from CMasher. -
LUT_PRIDE
Pride diverging shader from CMasher. -
LUT_INFINITY
Infinity cyclic shader from CMasher. -
LUT_COSMIC
Cosmic sequential shader from CMasher. -
LUT_EMBER
Ember sequential shader from CMasher. -
LUT_GOTHIC
Gothic sequential shader from CMasher. -
LUT_RAINFOREST
Rainforest sequential shader from CMasher. -
LUT_VOLTAGE
Voltage sequential shader from CMasher. -
LUT_BUBBLEGUM
Bubblegum sequential shader from CMasher. -
LUT_GEM
Gem sequential shader from CMasher. -
LUT_CHROMA
Chroma sequential shader from CMasher. -
LUT_NEON
Neon sequential shader from CMasher. -
LUT_TROPICAL
Tropical sequential shader from CMasher. -
LUT_SHADERS
Selection of lookup table-based shaders. -
BREWER_BUGN
ColorBrewer sequential blue-green shader. -
BREWER_BUPU
ColorBrewer sequential blue-purple shader. -
BREWER_ORRD
ColorBrewer sequential orange-red shader. -
BREWER_PUBU
ColorBrewer sequential purple-blue shader. -
BREWER_PURD
ColorBrewer sequential purple-red shader. -
BREWER_RDBU
ColorBrewer diverging red-blue shader. -
BREWER_PIYG
ColorBrewer diverging pink-green shader. -
BREWER_BRBG
ColorBrewer diverging brown-blue-green 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
Shader used by default for the transverse axis of non-absolute ramps. -
NULL
Shader which does nothing. -
TRANSPARENCY
Scales alpha channel by parameter value. -
FIX_INTENSITY
Shader which sets intensity. -
SCALE_INTENSITY
Shader which scales intensity. -
FADE_BLACK
Shader which interpolates between the base colour and black. -
FADE_WHITE
Shader which interpolates between the base colour and white. -
FIX_HUE
Shader which fixes hue.
-
-
Constructor Details
-
Shaders
public Shaders()
-
-
Method Details
-
createInterpolationShader
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
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
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
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
Returns an array of any custom shaders specified by theLUTFILES_PROPERTY
property.- Returns:
- array of zero or more custom shaders
-
invert
Returns a shader which runs in the opposite direction to a given one.- Parameters:
shader
- base shader- Returns:
- inverted version
-
fade
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
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
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
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
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 Icon create2dIcon(Shader xShader, Shader yShader, boolean xFirst, 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 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 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
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
-