Package cnuphys.magfield
Class ColorScaleModel
java.lang.Object
cnuphys.magfield.ColorScaleModel
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionColorScaleModel
(double[] values, Color[] colors) This creates a ColorScaleModel for converting a value into a color.ColorScaleModel
(String comment, double[] values, Color[] colors) This creates a ColorScaleModel for converting a value into a color.ColorScaleModel
(String comment, double[] values, Color[] colors, int precision, int numberOfRows) This creates a ColorScaleModel for converting a value into a color. -
Method Summary
Modifier and TypeMethodDescriptiongetColor
(double value) Given a value, returns the corresponding color.getColor
(double value, boolean useColorInterpolation) Given a value, returns the corresponding color.Color[]
Get the color array.Get the comment of the color scale.double
Get the maximum value of the values array.double
Get the minimum value of the values array.int
int
Get the precision used for display.Get the too-big color.Get the too-small color.double[]
Get the values array.void
setTooBigColor
(Color tooBigColor) void
setTooSmallColor
(Color tooSmallColor)
-
Field Details
-
colors
The array of colors -
values
protected double[] valuesThe array of values
-
-
Constructor Details
-
ColorScaleModel
This creates a ColorScaleModel for converting a value into a color. The values array should be sorted in ascending order. In any rate, it will be. Ideally, there is one more entry in the values array, so that each color fits in the space between 2 values. However, this is not a requirement. It will still give sensible results. Also, the value array is NOT assumed to be equally spaced.- Parameters:
values
- the array of values.colors
- the array of colors.
-
ColorScaleModel
This creates a ColorScaleModel for converting a value into a color. The values array should be sorted in ascending order. In any rate, it will be. Ideally, there is one more entry in the values array, so that each color fits in the space between 2 values. However, this is not a requirement. It will still give sensible results. Also, the value array is NOT assumed to be equally spaced.- Parameters:
comment
- an extra comment.values
- the array of values.colors
- the array of colors.
-
ColorScaleModel
public ColorScaleModel(String comment, double[] values, Color[] colors, int precision, int numberOfRows) This creates a ColorScaleModel for converting a value into a color. The values array should be sorted in ascending order. In any rate, it will be. Ideally, there is one more entry in the values array, so that each color fits in the space between 2 values. However, this is not a requirement. It will still give sensible results. Also, the value array is NOT assumed to be equally spaced.- Parameters:
comment
- an extra comment.values
- the array of values.colors
- the array of colors.precision
- the number of decimals to display. Use 0 for integers.numberOfRows
- the number of rows to us displaying the colors.
-
-
Method Details
-
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.
-
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.useColorInterpolation
- iftrue
, use color interpolation.- Returns:
- the color corresponding to the value.
-
getMinValue
public double getMinValue()Get the minimum value of the values array.- Returns:
- the minimum value of the values array.
-
getMaxValue
public double getMaxValue()Get the maximum value of the values array.- Returns:
- the maximum value of the values array.
-
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.
-
getValues
public double[] getValues()Get the values array.- Returns:
- the values array.
-
getComment
Get the comment of the color scale.- Returns:
- the color scale comment.
-
getPrecision
public int getPrecision()Get the precision used for display.- Returns:
- the precision used for display.
-
getNumberOfRows
public int getNumberOfRows()- Returns:
- the numberOfRows
-
setTooSmallColor
- Parameters:
tooSmallColor
- the tooSmallColor to set
-
setTooBigColor
- Parameters:
tooBigColor
- the tooBigColor to set
-