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().
 
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

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.
double com.nchart3d.NChart.NChartBrushScale.getLogarithmBase ( )
inline

Logarithm base.

Takes effect if isLogarithmic() is true only. The default value is 10.

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.

boolean com.nchart3d.NChart.NChartBrushScale.isLogarithmic ( )
inline

Flag determining if the scale is linear (false) or logarithmic (true).

The default value is false.

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

static NChartBrushScale com.nchart3d.NChart.NChartBrushScale.linearBrushScale ( NChartBrush[]  brushes,
double  minValue,
double  maxValue 
)
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
static NChartBrushScale com.nchart3d.NChart.NChartBrushScale.logarithmicBrushScale ( NChartBrush[]  brushes,
double  minValue,
double  maxValue,
double  logarithmBase 
)
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