lt.monarch.chart.spc.math
Class ValuesCalculator

java.lang.Object
  extended by lt.monarch.chart.spc.math.ValuesCalculator
Direct Known Subclasses:
BoxWhiskerValuesCalculator, ControlValuesCalculator, HistogramValuesCalculator, LinePlotValuesCalculator, ParetoValuesCalculator, ScatterValuesCalculator

public abstract class ValuesCalculator
extends java.lang.Object

Base class for chart values calculators. Implements basic calculation functions.


Field Summary
Modifier and Type Field and Description
protected static java.lang.String nullName
           
 
Constructor Summary
Constructor and Description
ValuesCalculator()
          Base constructor.
 
Method Summary
Modifier and Type Method and Description
protected  double average(ChartDataModel dataModel)
          Calculates average of all values in the data model.
protected  ChartDataModel fill(double[] values, ChartDataModel srcModel)
          Constructs data model from the array of numbers.
protected  void fill(double[] values, ChartDataModel srcModel, ChartDataModel dstModel)
          Fills given data model from the array of numbers.
protected  void fillColumn(ChartDataModel srcModel, ChartDataModel dstModel, int column)
          Fills given data model with a specified column from the source data model.
protected  ChartDataModel fillColumn(ChartDataModel srcModel, int column)
          Fills chart data model with a specified column from the source data model.
protected  ChartDataModel fillConstant(java.lang.Object value, ChartDataModel srcModel)
          Fills the data model with the constant value.
 void fillConstant(java.lang.Object value, ChartDataModel srcModel, ChartDataModel dstModel)
          Fills the data model with the constant value.
protected  double getAverage(ChartDataModel dataModel)
          Calculates average value of values in the data model.
protected  double getc4(int n)
          Gets c4 value, dependent from size.
protected  double getColumn(int no, java.lang.Object value)
          Gets a value form a specified column in a sample.
protected  double getd2(int n)
          Gets d2 value, dependent from size.
protected  double getd3(int n)
          Gets d3 value, dependent from size.
protected  double getD3(int n)
          Gets D3 value, dependent from size.
protected  double getD4(int n)
          Gets D4 value, dependent from size.
static java.lang.Double getDouble(java.lang.Object value)
          Converts number,string to double
protected  double getE(int subgroupSize)
          Gets e value, dependent from subgroup size.
protected  double getF(int subgroupSize)
          Gets f value, dependent from subgroup size.
protected  double getG(int n)
          Gets g value, dependent from size.
protected  double getH(int n)
          Gets h value, dependent from size.
static boolean isEmpty(java.lang.Object value)
          Checks if the value is empty (null of empty string)
protected  boolean isNconstant(ChartDataModel dataModel)
          Checks if data contains constant samples count (in all sample sets).
protected abstract  void validateDataModel(ChartDataModel dataModel)
          Validates data model.
protected  void validateDataModel(ChartDataModel dataModel, int minColumns, int maxColumns)
          Deprecated. 
protected  void validateDataModel(java.lang.String name, ChartDataModel dataModel, java.lang.Integer minColumns, java.lang.Integer maxColumns, java.lang.Integer minRows, java.lang.Integer maxRows)
          Validates data model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nullName

protected static final java.lang.String nullName
See Also:
Constant Field Values
Constructor Detail

ValuesCalculator

public ValuesCalculator()
Base constructor.

Method Detail

isNconstant

protected boolean isNconstant(ChartDataModel dataModel)
Checks if data contains constant samples count (in all sample sets).

Parameters:
dataModel - input data model.

getColumn

protected double getColumn(int no,
                           java.lang.Object value)
                    throws DataFormatException
Gets a value form a specified column in a sample.

Parameters:
no - column number.
value - data sample.
Returns:
column value
Throws:
DataFormatException - when the input data are invalid.

getAverage

protected double getAverage(ChartDataModel dataModel)
                     throws DataFormatException
Calculates average value of values in the data model.

Parameters:
dataModel - input data model
Returns:
average value
Throws:
DataFormatException - then data model is empty or does not contain numbers.

average

protected double average(ChartDataModel dataModel)
                  throws DataFormatException
Calculates average of all values in the data model.

Parameters:
dataModel - input data model.
Returns:
average value.
Throws:
DataFormatException - when the input data are invalid.

fillColumn

protected ChartDataModel fillColumn(ChartDataModel srcModel,
                                    int column)
Fills chart data model with a specified column from the source data model.

Parameters:
srcModel - source data model.
column - column number
Returns:
new data model with the filled column.

fillColumn

protected void fillColumn(ChartDataModel srcModel,
                          ChartDataModel dstModel,
                          int column)
Fills given data model with a specified column from the source data model.

Parameters:
srcModel - source data model.
dstModel - data model filled with the keys and a constant values.
column - column number

fill

protected ChartDataModel fill(double[] values,
                              ChartDataModel srcModel)
                       throws DataFormatException
Constructs data model from the array of numbers.

Parameters:
values - source values
srcModel - source model (for key values)
Returns:
destination model filled with the keys from the source model and values from the array.
Throws:
DataFormatException - then source values array or source model is null.

fill

protected void fill(double[] values,
                    ChartDataModel srcModel,
                    ChartDataModel dstModel)
             throws DataFormatException
Fills given data model from the array of numbers.

Parameters:
values - source values
srcModel - source model (for key values)
dstModel - data model filled with the keys from the source model and values from the array.
Throws:
DataFormatException - then source values array or source model is null.

fillConstant

protected ChartDataModel fillConstant(java.lang.Object value,
                                      ChartDataModel srcModel)
Fills the data model with the constant value. Takes keys from input model and adds then to the new model and uses the value as a value for new data model.

Parameters:
value - the value to fill in.
srcModel - source data model.
Returns:
new data model filled with the keys and a constant values.

fillConstant

public void fillConstant(java.lang.Object value,
                         ChartDataModel srcModel,
                         ChartDataModel dstModel)
Fills the data model with the constant value. Takes keys from input model and adds then to the new model and uses the value as a value for new data model.

Parameters:
value - the value to fill in.
srcModel - source data model.
dstModel - data model filled with the keys and a constant values.

getE

protected double getE(int subgroupSize)
               throws DataFormatException
Gets e value, dependent from subgroup size.

Parameters:
subgroupSize - subgroup size
Returns:
e value
Throws:
DataFormatException - then 'e' does not contain value with the given key

getF

protected double getF(int subgroupSize)
               throws DataFormatException
Gets f value, dependent from subgroup size.

Parameters:
subgroupSize - subgroup size
Returns:
f value
Throws:
DataFormatException - then 'f' does not contain value with the given key

getG

protected double getG(int n)
               throws DataFormatException
Gets g value, dependent from size.

Parameters:
n - size
Returns:
g value
Throws:
DataFormatException - then 'g' does not contain value with the given key

getH

protected double getH(int n)
               throws DataFormatException
Gets h value, dependent from size.

Parameters:
n - size
Returns:
h value
Throws:
DataFormatException - then 'h' does not contain value with the given key

getd2

protected double getd2(int n)
                throws DataFormatException
Gets d2 value, dependent from size.

Parameters:
n - size
Returns:
d2 value
Throws:
DataFormatException - then 'd2' does not contain value with the given key

getc4

protected double getc4(int n)
                throws DataFormatException
Gets c4 value, dependent from size.

Parameters:
n - size
Returns:
c4 value
Throws:
DataFormatException - then 'c4' does not contain value with the given key

getd3

protected double getd3(int n)
                throws DataFormatException
Gets d3 value, dependent from size.

Parameters:
n - size
Returns:
d3 value
Throws:
DataFormatException - then 'd3' does not contain value with the given key

getD3

protected double getD3(int n)
                throws DataFormatException
Gets D3 value, dependent from size. (D3 = 1-3d3/d2 D4 = 1 +3d3/d2)

Parameters:
n - size
Returns:
D3 value
Throws:
DataFormatException - then 'D3' does not contain value with the given key

getD4

protected double getD4(int n)
                throws DataFormatException
Gets D4 value, dependent from size.

Parameters:
n - size
Returns:
D4 value
Throws:
DataFormatException - then 'D4' does not contain value with the given key

validateDataModel

protected void validateDataModel(java.lang.String name,
                                 ChartDataModel dataModel,
                                 java.lang.Integer minColumns,
                                 java.lang.Integer maxColumns,
                                 java.lang.Integer minRows,
                                 java.lang.Integer maxRows)
                          throws DataFormatException
Validates data model.

Parameters:
name - data model name.
dataModel - data model to validate.
minColumns - the minimum count of columns required in the data model.
maxColumns - the maximum count of columns required in the data model.
minRows - the minimum count of rows required in the data model.
maxRows - the maximum count of rows required in the data model.
Throws:
DataFormatException - when the input model does not satisfy constraints.

validateDataModel

@Deprecated
protected void validateDataModel(ChartDataModel dataModel,
                                            int minColumns,
                                            int maxColumns)
                          throws DataFormatException
Deprecated. 

Throws:
DataFormatException

getDouble

public static java.lang.Double getDouble(java.lang.Object value)
                                  throws DataFormatException
Converts number,string to double

Parameters:
value - number in some format (string, number, integer, ...)
Returns:
double value.
Throws:
DataFormatException - when conversion is not possible (ex.: text string).

isEmpty

public static boolean isEmpty(java.lang.Object value)
Checks if the value is empty (null of empty string)

Parameters:
value - input value.
Returns:
true when value is empty.

validateDataModel

protected abstract void validateDataModel(ChartDataModel dataModel)
                                   throws DataFormatException
Validates data model. Checks if it satisfies chart type requirements.

Parameters:
dataModel - input chart data model.
Throws:
DataFormatException - when the data is invalid.