com.nchart3d.NChart.NChartBrushScale Class Reference

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().
 
float getGradientSharpness ()
 Sharpness of gradient, [0;1]. More...
 
void setGradientSharpness (float gradientSharpness)
 For details see getGradientSharpness().
 

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

com.nchart3d.NChart.NChartBrushScale.NChartBrushScale ( NChartBrush[]  brushes,
Number[]  values 
)
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

NChartBrush com.nchart3d.NChart.NChartBrushScale.brushForValue ( Number  value)
inline

Get value for brush.

Parameters
value- value to get brush for.
Returns
brush for given value.
float com.nchart3d.NChart.NChartBrushScale.getGradientSharpness ( )
inline

Sharpness of gradient, [0;1].

0 means very smooth color transition, 1 means very sharp one. The default value is 0.2. This value has effect if isGradient flag is set to true only.

boolean com.nchart3d.NChart.NChartBrushScale.isGradient ( )
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.