Package cnuphys.splot.plot
Class ColorScaleModel
java.lang.Object
cnuphys.splot.plot.ColorScaleModel
Used for color scales, such as on magnetic field plots
- Author:
- heddle
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionColorScaleModel
(double minVal, double maxVal, Color[] colors) This creates a ColorScaleModel for converting a value into a color. -
Method Summary
Modifier and TypeMethodDescriptionstatic ColorScaleModel
Get a standard blue to red colors scalegetAlphaColor
(double value, int alpha) Get a color via getColor but add an alpha valuegetColor
(double value) Given a value, returns the corresponding color.Color[]
Get the color array.Get the too-big color.Get the too-small color.void
setTooBigColor
(Color tooBigColor) void
setTooSmallColor
(Color tooSmallColor)
-
Field Details
-
_colors
The array of colors
-
-
Constructor Details
-
ColorScaleModel
This creates a ColorScaleModel for converting a value into a color.- Parameters:
minVal
- the minimum value;maxVal
- the maximum value the array of colors.
-
-
Method Details
-
blueToRed
Get a standard blue to red colors scale- Returns:
- a standard blue to red color scale
-
getAlphaColor
Get a color via getColor but add an alpha value- Parameters:
value
- the valuealpha
- the alpha value [0..255]- Returns:
- the color corresponding to the value.
-
getColor
Given a value, returns the corresponding color. Example:values: {0, 2, 4, 6, 8}
colors: {R, G, B, Y}
then
value = 1.77 -> R
value = -1 -> tooSmallColor
value = 8.01 -> tooBigColor
value = 4 (exactly) -> G
- Parameters:
value
- the for which we want the color.- Returns:
- the color corresponding to the value.
-
getColors
Get the color array.- Returns:
- the color array.
-
getTooBigColor
Get the too-big color.- Returns:
- the color used for a "too big" value.
-
getTooSmallColor
Get the too-small color.- Returns:
- the color used for a "too small" value.
-
setTooSmallColor
- Parameters:
tooSmallColor
- the tooSmallColor to set
-
setTooBigColor
- Parameters:
tooBigColor
- the tooBigColor to set
-