Holger's
Java API

com.antelmann.math
Class DataMatrix<T>

java.lang.Object
  extended by com.antelmann.math.DataMatrix<T>
Type Parameters:
T - the type of Objects that are processed by this grid
All Implemented Interfaces:
Addable<DataMatrix<T>>, Serializable, Cloneable

public class DataMatrix<T>
extends Object
implements Cloneable, Addable<DataMatrix<T>>, Serializable

provides aggregated multidimensional data based on a DataParser

Since:
02/12/09
Author:
Holger Antelmann
See Also:
DataParser, DataMatrixGraphics, TimeDataGrid, CounterMap, DataMap, Serialized Form

Constructor Summary
DataMatrix(DataParser<? super T> parser)
           
DataMatrix(DataParser<? super T> parser, Filter<? super T> filter)
           
DataMatrix(TimeDataGrid<T> grid)
           
 
Method Summary
 DataMatrix<T> add(DataMatrix<T> other)
          adds this instance to the other given one and returns the result; this entry itself remains untouched
 void addData(DataMatrix<?> other)
          adds the data map to this instance (like add(DataMatrix), only that it is applied to this instance)
 void addData(Enumeration<? extends T> e)
          loads the data by parsing the given Enumeration and extracting the relevant values through the parser
 void addData(Enumeration<? extends T> e, Monitor mon)
          min and max from the given Monitor remain untouched; a disabled Monitor will lead to a break
 void addData(T... entries)
           
 void addEntry(T entry)
           
 boolean addMatrix(DataMatrix<? super T> matrix)
           
 void addPropertyChangeListener(PropertyChangeListener listener)
          allows to be notified when new data is loaded or cleared; the property key on the event is 'data'
 DataPoint addRawData(List<Object> vector, Number n)
          allows to directly add a value with a pre-defined data vector; additional matrixes are not effected
protected  DataPoint addRawData(List<Object> vector, Number n, boolean validate)
          allows to directly add a value with a pre-defined data vector; additional matrixes are not effected
 DataPoint addRawData(Number n, Object... vector)
          allows to directly add a value with a pre-defined data vector
 DataMatrix<T> aggregate(int... axises)
          allows to reduce the vector to a dimension defined by the given axises
 DataMatrix<T> aggregate(String... axises)
           
 HashMap<List<Object>,DataPoint> aggregatedDataMap(int... axises)
          calculates a new data map based on the given reduced vector
 DataMatrix<T> aggregateTopAxisValues(int axis, Object remainderKey, int maxEntries, DataPoint.ValueType type)
          allows to aggregate the vector towards a given number of entries along a given axis
 DataMatrix<T> aggregateTopAxisValues(String axis, Object remainderKey, int maxEntries, DataPoint.ValueType type)
           
 TableModel asTableModel(String rowAxisTitle, int rowAxis, int columnAxis, DataPoint.ValueType type)
           
 void clearData()
           
 DataMatrix<T> clone()
           
 DataMatrix<? super T> getAdditionalMatrix(int number)
           
 Collection<DataMatrix<? super T>> getAdditionalMatrixes()
          returns an unmodifiable view of the additional matrixes
 String[] getAxisNames()
           
 HashMap<Object,BigDecimal> getAxisTopValues(int axis, DataPoint.ValueType type, int maxEntries, Object remainderKey)
           
 HashMap<Object,BigDecimal> getAxisTopValues(String axis, DataPoint.ValueType type, int maxEntries, Object remainderKey)
           
 HashMap<Object,DataPoint> getAxisTotals(int axis)
           
 HashMap<Object,DataPoint> getAxisTotals(String axisName)
           
 Set<?> getAxisValues(int axis)
           
 Set<?> getAxisValues(String axisName)
           
 Map<List<Object>,DataPoint> getDataMap()
          provides an unmodifiable view of the embedded data
 DataPoint getDataPoint(List<?> vector)
           
 DataPoint getDataPoint(Object... vector)
           
 Filter<? super T> getFilter()
           
 int getIndexForAxis(String axisName)
           
 int getNumberOfAdditionalMatrixes()
           
 DataParser<? super T> getParser()
           
 List<Object> getPathFor(T entry)
           
 PropertyChangeListener[] getPropertyChangeListeners()
           
 DataPoint getTotal()
           
 DataPoint getTotal(int axis, Object axisValue)
           
static boolean isCompatible(DataParser<?> p1, DataParser<?> p2)
           
static
<T extends DBEntry>
void
loadMatrix(DataMatrix<T> matrix, DBClassStore<? extends T> store, Filter<? super T> filter, Monitor mon)
          min, max of the given logger must be set explicitly
protected  void processElement(T entry)
          processes the given entry on this and the additional matrixes.
 void removeAllAdditionalMatrixes()
           
 boolean removeMatrix(DataMatrix<? super T> matrix)
           
 void removePropertyChangeListener(PropertyChangeListener listener)
           
 void setFilter(Filter<? super T> filter)
           
protected  DataPoint setRawData(List<Object> vector, DataPoint dp)
          allows to directly set a DataPoint with a pre-defined data vector; additional matrixes are not effected
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataMatrix

public DataMatrix(DataParser<? super T> parser)

DataMatrix

public DataMatrix(DataParser<? super T> parser,
                  Filter<? super T> filter)

DataMatrix

public DataMatrix(TimeDataGrid<T> grid)
Method Detail

clone

public DataMatrix<T> clone()
Overrides:
clone in class Object

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
allows to be notified when new data is loaded or cleared; the property key on the event is 'data'


removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)

getPropertyChangeListeners

public PropertyChangeListener[] getPropertyChangeListeners()

getAxisNames

public String[] getAxisNames()

getParser

public DataParser<? super T> getParser()

getFilter

public Filter<? super T> getFilter()

setFilter

public void setFilter(Filter<? super T> filter)

add

public DataMatrix<T> add(DataMatrix<T> other)
Description copied from interface: Addable
adds this instance to the other given one and returns the result; this entry itself remains untouched

Specified by:
add in interface Addable<DataMatrix<T>>

addData

public void addData(DataMatrix<?> other)
adds the data map to this instance (like add(DataMatrix), only that it is applied to this instance)


getAdditionalMatrix

public DataMatrix<? super T> getAdditionalMatrix(int number)

getAdditionalMatrixes

public Collection<DataMatrix<? super T>> getAdditionalMatrixes()
returns an unmodifiable view of the additional matrixes


addMatrix

public boolean addMatrix(DataMatrix<? super T> matrix)

removeMatrix

public boolean removeMatrix(DataMatrix<? super T> matrix)

removeAllAdditionalMatrixes

public void removeAllAdditionalMatrixes()

getNumberOfAdditionalMatrixes

public int getNumberOfAdditionalMatrixes()

clearData

public void clearData()

getDataMap

public Map<List<Object>,DataPoint> getDataMap()
provides an unmodifiable view of the embedded data


loadMatrix

public static <T extends DBEntry> void loadMatrix(DataMatrix<T> matrix,
                                                  DBClassStore<? extends T> store,
                                                  Filter<? super T> filter,
                                                  Monitor mon)
                       throws DatabaseException
min, max of the given logger must be set explicitly

Throws:
DatabaseException

addEntry

public void addEntry(T entry)

addData

public void addData(T... entries)

addData

public void addData(Enumeration<? extends T> e)
loads the data by parsing the given Enumeration and extracting the relevant values through the parser


addData

public void addData(Enumeration<? extends T> e,
                    Monitor mon)
min and max from the given Monitor remain untouched; a disabled Monitor will lead to a break


processElement

protected void processElement(T entry)
processes the given entry on this and the additional matrixes. The data here is processed by summing up the relevant number for each date/group pair.


getPathFor

public List<Object> getPathFor(T entry)

addRawData

public DataPoint addRawData(Number n,
                            Object... vector)
allows to directly add a value with a pre-defined data vector


addRawData

public DataPoint addRawData(List<Object> vector,
                            Number n)
                     throws IllegalArgumentException
allows to directly add a value with a pre-defined data vector; additional matrixes are not effected

Throws:
IllegalArgumentException

addRawData

protected DataPoint addRawData(List<Object> vector,
                               Number n,
                               boolean validate)
                        throws IllegalArgumentException
allows to directly add a value with a pre-defined data vector; additional matrixes are not effected

Throws:
IllegalArgumentException

setRawData

protected DataPoint setRawData(List<Object> vector,
                               DataPoint dp)
                        throws IllegalArgumentException
allows to directly set a DataPoint with a pre-defined data vector; additional matrixes are not effected

Throws:
IllegalArgumentException

getDataPoint

public DataPoint getDataPoint(Object... vector)

getDataPoint

public DataPoint getDataPoint(List<?> vector)

getTotal

public DataPoint getTotal(int axis,
                          Object axisValue)

getTotal

public DataPoint getTotal()

getIndexForAxis

public int getIndexForAxis(String axisName)

getAxisValues

public Set<?> getAxisValues(String axisName)

getAxisValues

public Set<?> getAxisValues(int axis)

aggregate

public DataMatrix<T> aggregate(String... axises)

aggregate

public DataMatrix<T> aggregate(int... axises)
allows to reduce the vector to a dimension defined by the given axises

See Also:
aggregatedDataMap(int...)

aggregatedDataMap

public HashMap<List<Object>,DataPoint> aggregatedDataMap(int... axises)
calculates a new data map based on the given reduced vector

See Also:
aggregate(int...)

aggregateTopAxisValues

public DataMatrix<T> aggregateTopAxisValues(String axis,
                                            Object remainderKey,
                                            int maxEntries,
                                            DataPoint.ValueType type)

aggregateTopAxisValues

public DataMatrix<T> aggregateTopAxisValues(int axis,
                                            Object remainderKey,
                                            int maxEntries,
                                            DataPoint.ValueType type)
allows to aggregate the vector towards a given number of entries along a given axis


getAxisTotals

public HashMap<Object,DataPoint> getAxisTotals(String axisName)

getAxisTotals

public HashMap<Object,DataPoint> getAxisTotals(int axis)

getAxisTopValues

public HashMap<Object,BigDecimal> getAxisTopValues(String axis,
                                                   DataPoint.ValueType type,
                                                   int maxEntries,
                                                   Object remainderKey)

getAxisTopValues

public HashMap<Object,BigDecimal> getAxisTopValues(int axis,
                                                   DataPoint.ValueType type,
                                                   int maxEntries,
                                                   Object remainderKey)

asTableModel

public TableModel asTableModel(String rowAxisTitle,
                               int rowAxis,
                               int columnAxis,
                               DataPoint.ValueType type)

isCompatible

public static boolean isCompatible(DataParser<?> p1,
                                   DataParser<?> p2)


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads