lt.monarch.chart.models
Class DataModelUtil

java.lang.Object
  extended by lt.monarch.chart.models.DataModelUtil

public abstract class DataModelUtil
extends java.lang.Object

Data model conversion utilities.


Constructor Summary
Constructor and Description
DataModelUtil()
           
 
Method Summary
Modifier and Type Method and Description
static java.util.ArrayList<?> convert(java.util.Collection<?> data)
          Converts from this type of list to appropriate array: ArrayList list = new ArrayList(); list.add(new Object[] { "Lemons", null }); list.add(new Object[] { "Oranges", new Double(10) }); list.add(new Object[] { "Bananas", new Double(40) }); list.add(new Object[] { "Apples", new Double(20) }); list.add(new Object[] { "Nuts", new Double(30) });
static java.lang.Object[][] convert(java.lang.Object[][] data)
          Converts from this type of array to appropriate array for a data model (rotation transformation):
static void copy(ChartDataModel from, ChartDataModel to)
          Copies data from one chart data model to another.
static void copy(MetaDataModel from, MetaDataModel to, ChartDataModel fromDataModel)
          Copies data from one chart data model to another.
static void copyIndexed(ChartDataModel from, ChartDataModel to, java.util.List<java.lang.Integer> indicies)
          Copies indexed data from one chart data model to another.
static void copyIndexed(MetaDataModel from, MetaDataModel to, ChartDataModel fromDataModel, java.util.List<java.lang.Integer> indicies)
          Copies data from one chart data model to another.
static void generateSequenceData(DataColumnType[] columnTypes, double seqStart, double seqStep, int seqCount, ChartDataModel model)
          Generates sequential data (for all columns the same)
static java.util.List<java.lang.Object> getColumnData(DataColumnType valType, AbstractDataModel model)
          Gets the column data for the specified data type
static java.util.Hashtable<java.lang.Object,java.lang.Number> getIndexedData(AbstractDataModel model)
          Gets the frequencies for the KEY column.
static void logBase(double logBase, DataModel model)
          All data elements are replaced with such values: Math.log(x + base)
static void normalize(DataModel model, DataColumnType column, double min, double max)
          Normalizes each value, by assuming, that the minimum and maximum values, are the ones, provided as parameters.
static void normalize(MatrixDataModel model)
          Normalizes each value.
static ChartDataModel sliceArrayDataModel(ChartDataModel model, boolean sliceByRow, java.lang.Object sliceThrough)
          Slices given Array ChartDataModel into a 2D ChartModel.
static MetaDataModel sliceArrayMetaModel(MetaDataModel metaModel, ChartDataModel model, boolean sliceByRow, java.lang.Object sliceThrough)
          Slices given 3D MetaDataModel into a 2D MetaDataModel.
static ChartDataModel sliceMatrixDataModel(ChartDataModel matrixModel, boolean sliceByRow, int index)
          Slices given Matrix ChartDataModel into a 2D ChartModel.
static void soften3x3(MatrixDataModel matrix)
          Softens the matrix be averaging it using 3x3 grid
static void soften5x5(MatrixDataModel matrix)
          Softens the matrix be averaging it using 5x5 grid
static void swapDataColumns(DataColumnType valType1, DataColumnType valType2, AbstractDataModel model)
          Swaps data columns
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataModelUtil

public DataModelUtil()
Method Detail

convert

public static java.util.ArrayList<?> convert(java.util.Collection<?> data)
Converts from this type of list to appropriate array: ArrayList list = new ArrayList(); list.add(new Object[] { "Lemons", null }); list.add(new Object[] { "Oranges", new Double(10) }); list.add(new Object[] { "Bananas", new Double(40) }); list.add(new Object[] { "Apples", new Double(20) }); list.add(new Object[] { "Nuts", new Double(30) });

Parameters:
data - list to convert
Returns:
converted ArrayList

swapDataColumns

public static void swapDataColumns(DataColumnType valType1,
                                   DataColumnType valType2,
                                   AbstractDataModel model)
Swaps data columns

Parameters:
valType1 - 1st column data type
valType2 - 2nd column data type
model - data model where to swap columns

getColumnData

public static java.util.List<java.lang.Object> getColumnData(DataColumnType valType,
                                                             AbstractDataModel model)
Gets the column data for the specified data type

Parameters:
valType - data value type (specifies the column)
model - data model
Returns:
data column of specified data type

getIndexedData

public static java.util.Hashtable<java.lang.Object,java.lang.Number> getIndexedData(AbstractDataModel model)
Gets the frequencies for the KEY column. Also if some VALUE is present it adds up value frequencies for the KEY column.

Parameters:
model - data model
Returns:
KEY column with it's frequencies

generateSequenceData

public static void generateSequenceData(DataColumnType[] columnTypes,
                                        double seqStart,
                                        double seqStep,
                                        int seqCount,
                                        ChartDataModel model)
Generates sequential data (for all columns the same)

Parameters:
seqStart - sequence start
seqStep - sequence step
seqCount - sequence count
model - data model

convert

public static java.lang.Object[][] convert(java.lang.Object[][] data)
Converts from this type of array to appropriate array for a data model (rotation transformation):

Parameters:
data - array of objects
Returns:
converts objects list

soften3x3

public static void soften3x3(MatrixDataModel matrix)
Softens the matrix be averaging it using 3x3 grid

Parameters:
matrix - data matrix

soften5x5

public static void soften5x5(MatrixDataModel matrix)
Softens the matrix be averaging it using 5x5 grid

Parameters:
matrix - data matrix

logBase

public static void logBase(double logBase,
                           DataModel model)
All data elements are replaced with such values: Math.log(x + base)

Parameters:
logBase - log base
model - chart data model

normalize

public static void normalize(MatrixDataModel model)
Normalizes each value. First minimum and maximum values in the data model are determined. Then every value is adjusted to fit in range [0,1].

For array data model each column is normalized separately.

Parameters:
model - chart data model

normalize

public static void normalize(DataModel model,
                             DataColumnType column,
                             double min,
                             double max)
Normalizes each value, by assuming, that the minimum and maximum values, are the ones, provided as parameters.

Parameters:
model - chart data model
column - column type to normalize
min - assumed minimum value
max - assumed maximum value

copyIndexed

public static void copyIndexed(ChartDataModel from,
                               ChartDataModel to,
                               java.util.List<java.lang.Integer> indicies)
Copies indexed data from one chart data model to another. Works only with ARRAY data models.

Parameters:
from - model from which to copy.
to - model where to copy.
indicies - list of model point indices.
Throws:
UnsupportedOperationException.

copy

public static void copy(ChartDataModel from,
                        ChartDataModel to)
Copies data from one chart data model to another. Works only with ARRAY data models.

Parameters:
from - model from which to copy.
to - model where to copy.
Throws:
UnsupportedOperationException.

copyIndexed

public static void copyIndexed(MetaDataModel from,
                               MetaDataModel to,
                               ChartDataModel fromDataModel,
                               java.util.List<java.lang.Integer> indicies)
Copies data from one chart data model to another. Works only with ARRAY data models.

Parameters:
from - model from which to copy.
to - model where to copy.
Throws:
UnsupportedOperationException.

copy

public static void copy(MetaDataModel from,
                        MetaDataModel to,
                        ChartDataModel fromDataModel)
Copies data from one chart data model to another. Works only with ARRAY data models.

Parameters:
from - model from which to copy.
to - model where to copy.
Throws:
UnsupportedOperationException.

sliceMatrixDataModel

public static ChartDataModel sliceMatrixDataModel(ChartDataModel matrixModel,
                                                  boolean sliceByRow,
                                                  int index)
Slices given Matrix ChartDataModel into a 2D ChartModel.

Parameters:
matrixModel - 3D ChartDataModel.
sliceByRow - if slice is should be taken for row, it is taken for column otherwise.
index - index of row or column whose slice we want.
Returns:
2D ChartDataModel.

sliceArrayDataModel

public static ChartDataModel sliceArrayDataModel(ChartDataModel model,
                                                 boolean sliceByRow,
                                                 java.lang.Object sliceThrough)
Slices given Array ChartDataModel into a 2D ChartModel.

Parameters:
model - 3D ChartDataModel.
sliceByRow - if slice is should be taken for row, it is taken for column otherwise.
sliceThrough - row or column value through which to splice.
Returns:
2D ChartDataModel.

sliceArrayMetaModel

public static MetaDataModel sliceArrayMetaModel(MetaDataModel metaModel,
                                                ChartDataModel model,
                                                boolean sliceByRow,
                                                java.lang.Object sliceThrough)
Slices given 3D MetaDataModel into a 2D MetaDataModel.

Parameters:
metaModel - 3D MetaDataModel.
model - 3D ChartDataModel.
sliceByRow - if slice is should be taken for row, it is taken for column otherwise.
sliceThrough - row or column value through which to splice.
Returns:
2D MetaDataModel.