Package org.jzy3d.colors.colormaps
Class AbstractColorMap
- java.lang.Object
-
- org.jzy3d.colors.colormaps.AbstractColorMap
-
- All Implemented Interfaces:
IColorMap
- Direct Known Subclasses:
ColorMapGrayscale
,ColorMapHotCold
,ColorMapRainbow
,ColorMapRainbowNoBorder
,ColorMapRBG
,ColorMapRedAndGreen
,ColorMapWhiteBlue
,ColorMapWhiteGreen
,ColorMapWhiteRed
public abstract class AbstractColorMap extends Object implements IColorMap
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
direction
protected SpaceTransformer
spaceTransformer
-
Constructor Summary
Constructors Constructor Description AbstractColorMap()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description double
colorComponentAbsolute(double value, double bLeft, double bRight, double tLeft, double tRight)
Defines a simple function for a color.double
colorComponentRelative(double value, double center, double topwidth, double bottomwidth)
Return the influence of a color, by comparing the input value to the color spectrum.double
colorComponentRelativeNoLeftBorder(double value, double center, double topwidth, double bottomwidth)
double
colorComponentRelativeNoRightBorder(double value, double center, double topwidth, double bottomwidth)
abstract Color
getColor(double x, double y, double z, double zMin, double zMax)
Color
getColor(IColorMappable colorable, double z)
Color
getColor(IColorMappable colorable, double x, double y, double z)
Computes the color of aIColorMappable
object according to the Z value of each of its components.boolean
getDirection()
SpaceTransformer
getSpaceTransformer()
protected double
processRelativeZValue(double z, double zMin, double zMax)
Compute a value in [0;1] to pick a color in a [0;1] color range.void
setDirection(boolean isStandard)
Indicates if the colormap use the standard or reverted color directionvoid
setSpaceTransformer(SpaceTransformer transformer)
-
-
-
Field Detail
-
direction
protected boolean direction
-
spaceTransformer
protected SpaceTransformer spaceTransformer
-
-
Method Detail
-
getColor
public abstract Color getColor(double x, double y, double z, double zMin, double zMax)
-
setDirection
public void setDirection(boolean isStandard)
Description copied from interface:IColorMap
Indicates if the colormap use the standard or reverted color direction- Specified by:
setDirection
in interfaceIColorMap
-
getDirection
public boolean getDirection()
- Specified by:
getDirection
in interfaceIColorMap
- Returns:
- the colormap direction: true if standard, false if reverted.
-
getColor
public Color getColor(IColorMappable colorable, double x, double y, double z)
Description copied from interface:IColorMap
Computes the color of aIColorMappable
object according to the Z value of each of its components.
-
processRelativeZValue
protected double processRelativeZValue(double z, double zMin, double zMax)
Compute a value in [0;1] to pick a color in a [0;1] color range. Basically normalize the z value in its original range to the color range.- Returns:
- (z - zMin) / (zMax - zMin) OR (zMax - z) / (zMax - zMin) OR 1 OR 0
-
getColor
public Color getColor(IColorMappable colorable, double z)
-
colorComponentRelative
public double colorComponentRelative(double value, double center, double topwidth, double bottomwidth)
Description copied from interface:IColorMap
Return the influence of a color, by comparing the input value to the color spectrum. The design of a colormap implies defining the influence of each base color (red, green, and blue) over the range of input data. For this reason, the value given to this function is a number between 0 and 1, indicating the position of the input value in the colormap. Any value standing outside of colormap boundaries should have the "maximal" or "minimal" color. Exemple: A rainbow colormap is a progressive transition from blue, to green and red. The mix between these 3 colors, may be expressed by the definition of 3 functions:blue green red /-------\/-------\/-------\ / /\ /\ \ / / \ / \ \ / / \ / \ \ |----------------|----------------| 0 0.5 1
float blue = (float) colorComponentRelative( rel_value, 0.25, 0.25, 0.75 ); float green = (float) colorComponentRelative( rel_value, 0.50, 0.25, 0.75 ); float red = (float) colorComponentRelative( rel_value, 0.75, 0.25, 0.75 ); return new Color4f( red, green, blue, 1.0f );
- Specified by:
colorComponentRelative
in interfaceIColorMap
- Returns:
- color influence.
-
colorComponentRelativeNoLeftBorder
public double colorComponentRelativeNoLeftBorder(double value, double center, double topwidth, double bottomwidth)
-
colorComponentRelativeNoRightBorder
public double colorComponentRelativeNoRightBorder(double value, double center, double topwidth, double bottomwidth)
-
colorComponentAbsolute
public double colorComponentAbsolute(double value, double bLeft, double bRight, double tLeft, double tRight)
Description copied from interface:IColorMap
Defines a simple function for a color. Between bLeft and tLeft, as well as tRight and bRight, the output value is a linear interpolation between 0 and 1.tLeft tRight /-----------\ / \ / \ -------|-----------------|-------- bLeft bRight
- Specified by:
colorComponentAbsolute
in interfaceIColorMap
bLeft
- under this value, the color is 0bRight
- up to this value, the color is 0tLeft
- from this value until @link tRight, the color is 1tRight
- from @link tLeft until this value, the color is 1- Returns:
- color
-
getSpaceTransformer
public SpaceTransformer getSpaceTransformer()
- Specified by:
getSpaceTransformer
in interfaceIColorMap
-
setSpaceTransformer
public void setSpaceTransformer(SpaceTransformer transformer)
- Specified by:
setSpaceTransformer
in interfaceIColorMap
-
-