The NChartBrushScale class provides scale that transforms values into brushes like a step mapping function. More...
Public Member Functions | |
| NChartBrushScale (NChartBrush[] brushes, Number[] values) | |
| Create new instance of NChartBrushScale with arrays of brushes and values. More... | |
| NChartBrush[] | getBrushes () |
| Array of brushes. | |
| Number[] | getValues () |
| Array of values. | |
| NChartBrush | brushForValue (Number value) |
| Get value for brush. More... | |
| boolean | isGradient () |
| Flag determining if scale can return gradient colors. More... | |
| void | setGradient (boolean isGradient) |
| For details see isGradient(). | |
| boolean | isLogarithmic () |
| Flag determining if the scale is linear (false) or logarithmic (true). More... | |
| void | setLogarithmic (boolean isLogarithmic) |
| For details see isLogarithmic(). | |
| double | getLogarithmBase () |
| Logarithm base. More... | |
| void | setLogarithmBase (double logarithmBase) |
| For details see getLogarithmBase(). | |
| boolean | isStrict () |
| Strict brush range flag. More... | |
| void | setStrict (boolean isStrict) |
| For details see isStrict(). | |
Static Public Member Functions | |
| static NChartBrushScale | linearBrushScale (NChartBrush[] brushes, double minValue, double maxValue) |
| Create new instance of NChartBrushScale with linear space of values. More... | |
| static NChartBrushScale | logarithmicBrushScale (NChartBrush[] brushes, double minValue, double maxValue, double logarithmBase) |
| Create new instance of NChartBrushScale with logarithmic space of values. More... | |
Detailed Description
The NChartBrushScale class provides scale that transforms values into brushes like a step mapping function.
The scale contains array of reference values and array of brushes. It returns brush for given value according to these arrays:
brushs[n]
values[n - 1]
...
brushs[4]
values[3]
brushs[3]
values[2]
brushs[2]
values[1]
brushs[1]
values[0]
brushs[0]
This is equivalent to the following pseudo code:
if value <= values[0] return brushes[0];
if value > values[i] and value <= values[i + 1] return brush[i + 1];
if value > values[last] return brush[last]
So the array of brushes should contain n elements and array of values should contain n - 1. Values should be sorted (NChartBrushScale does not sort them automatically). If they are not, it can lead to strange results. If brush index goes out of range, null is returned.
Constructor & Destructor Documentation
|
inline |
Create new instance of NChartBrushScale with arrays of brushes and values.
- Parameters
-
brushes - array of brushes represented with NChartBrush values - array of values represented with Number
Member Function Documentation
|
inline |
Get value for brush.
- Parameters
-
value - value to get brush for.
- Returns
- brush for given value.
|
inline |
Logarithm base.
Takes effect if isLogarithmic() is true only. The default value is 10.
|
inline |
Flag determining if scale can return gradient colors.
The default value is true.
The gradient scale assumes that the array of brushes contains instances of NChartSolidColorBrush and linearly interpolates colors that correspond to the neighbor values.
|
inline |
Flag determining if the scale is linear (false) or logarithmic (true).
The default value is false.
|
inline |
Strict brush range flag.
The default value is false. Strict brush range (true in this property) means, that if value is less than value[0] or bigger than value[n - 1], clear (transparent) brush is returned. Otherwise (false in this property), brushes[0] and brushes[n] respectively is returned.
|
inlinestatic |
Create new instance of NChartBrushScale with linear space of values.
- Parameters
-
brushes - array of brushes represented with NChartBrush minValue - minimal value maxValue - maximal value
- Returns
- a new instance of NChartBrushScale
|
inlinestatic |
Create new instance of NChartBrushScale with logarithmic space of values.
- Parameters
-
brushes - array of brushes represented with NChartBrush minValue - minimal value maxValue - maximal value logarithmBase - logarithm base
- Returns
- a new instance of NChartBrushScale
