infovis.column
Class DoubleColumn

java.lang.Object
  extended by infovis.utils.ChangeManager
      extended by infovis.column.AbstractColumn
          extended by infovis.column.BasicColumn
              extended by infovis.column.LiteralColumn
                  extended by infovis.column.DoubleColumn
All Implemented Interfaces:
IntComparator, Column, NumberColumn, Metadata, Constants, RowComparator, Serializable
Direct Known Subclasses:
FunctionColumn

public class DoubleColumn
extends LiteralColumn

A column of double values, implemented by Colt DoubleArrayList.

Version:
$Revision: 1.20 $
Author:
Jean-Daniel Fekete
See Also:
Serialized Form
InfoVis factory arguments:
ColumnFactory "double" DENSE, ColumnFactory "real" DENSE

Field Summary
 
Fields inherited from class infovis.column.AbstractColumn
MODIFIED_ALL, MODIFIED_NONE
 
Fields inherited from interface infovis.metadata.Constants
CONTRIBUTOR, COVERAGE, CREATOR, DATE, DESCRITION, FORMAT, IDENTIFIER, LANGUAGE, PUBLISHER, RELATION, RIGHTS, SOURCE, SUBJECT, TITLE, TYPE
 
Constructor Summary
DoubleColumn(String name)
          Creates a new DoubleColumn object.
DoubleColumn(String name, DoubleArrayList value)
          Creates a new DoubleColumn object backed on a Colt DoubleArrayList.
DoubleColumn(String name, int reserve)
          Creates a new DoubleColumn object.
 
Method Summary
 void add(double element)
          Adds a new element in the column.
 double addExtend(int index, double value)
          Adds the value of the column at the specified row with the specified value.
 int capacity()
          Returns the current capacity of this column.
 void clear()
          Removes all of the elements from this column. The Column will be empty after this call returns. WARNING: if there is an associated format that maintains a status, such as a CategoricalFormat, it is not cleared so results may not be what you expected. The CategoricalFormat can be cleared explicitely if needed.
 void ensureCapacity(int minCapacity)
          Increases the capacity of this column, if necessary, to ensure that it can hold at least the number of values specified by the minimum capacity argument.
 void fill(double val)
          Fills the column with the specified value.
static DoubleColumn findColumn(Table t, String name)
          Returns a column as a DoubleColumn from a table, creating it if needed.
 String format(double v)
          Returns the string representation of a value according to the current format.
 double get(int index)
          Returns the element at the specified position in this column.
static DoubleColumn getColumn(Table t, int index)
          Returns a column as a DoubleColumn from a Table.
static DoubleColumn getColumn(Table t, String name)
          Returns a column as a DoubleColumn from a Table.
 double getDoubleAt(int row)
          Returns the value as a double
 int getIntAt(int row)
          Returns the value as an int
 long getLongAt(int row)
          Returns the value as a long
 double getMax()
          Returns the maximum value of this column.
 double getMin()
          Returns the minum value of this column.
 String getValueAt(int i)
          Returns the String representation of the element at the specified position in this column or null if the element is undefined.
 Class getValueClass()
          Returns the class of the elements.
 DoubleArrayList getValueReference()
          Returns the DoubleArrayList backing the implementation of the column (USE WITH CARE).
 double parse(String v)
          Parse a string and return the value for the column.
 double round(double value)
          Returns the rounded value according to the semantics of this number value.
 void set(int index, double element)
          Replaces the element at the specified position in this column with the specified element.
 void setDoubleAt(int row, double v)
          Sets the value as a double
 void setExtend(int index, double element)
          Replaces the element at the specified position in this column with the specified element, growing the column if necessary.
 void setSize(int newSize)
          Sets the sizeColumn of this column.
 void setValueAt(int i, String v)
          Replaces the element at the specified position in this column with the element specified in its String representation or sets if undefined if the element is null It will be read and translated using the Format.
 int size()
          Returns the number of elements in this column.
 double[] toArray()
          Returns the array of double values used by the column.
 double[] toArray(double[] a)
          Returns the array of double values copied from the column.
 
Methods inherited from class infovis.column.LiteralColumn
compare, compareValues, getDoubleMax, getDoubleMin, getFloatAt, getNumberColumn, hasUndefinedValue, isValueUndefined, setFloatAt, setIntAt, setLongAt, setValueUndefined, trimUndefined
 
Methods inherited from class infovis.column.BasicColumn
addValue, addValueOrNull, firstValidRow, getClientProperty, getFormat, getMaxIndex, getMetadata, getMinIndex, getName, isEmpty, isInternal, iterator, lastValidRow, setFormat, setName, setValueOrNullAt, toString
 
Methods inherited from class infovis.column.AbstractColumn
addChangeListener, computeValueMap, computeValueMap, equalObj, equals, getLastModifiedRow
 
Methods inherited from class infovis.utils.ChangeManager
disableNotify, enableNotify, getModCount, removeChangeListener
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface infovis.Column
addChangeListener, addValue, addValueOrNull, disableNotify, enableNotify, getFormat, getMaxIndex, getMinIndex, getName, isEmpty, isInternal, iterator, removeChangeListener, setFormat, setName, setValueOrNullAt
 
Methods inherited from interface infovis.Metadata
getClientProperty, getMetadata
 
Methods inherited from interface cern.colt.function.IntComparator
equals
 

Constructor Detail

DoubleColumn

public DoubleColumn(String name)
Creates a new DoubleColumn object.

Parameters:
name - the column name.

DoubleColumn

public DoubleColumn(String name,
                    DoubleArrayList value)
Creates a new DoubleColumn object backed on a Colt DoubleArrayList.

Parameters:
name - the column name.
value - the value list which will be used, not copied.

DoubleColumn

public DoubleColumn(String name,
                    int reserve)
Creates a new DoubleColumn object.

Parameters:
name - the column name.
reserve - the initial capacity.
Method Detail

clear

public void clear()
Removes all of the elements from this column. The Column will be empty after this call returns. WARNING: if there is an associated format that maintains a status, such as a CategoricalFormat, it is not cleared so results may not be what you expected. The CategoricalFormat can be cleared explicitely if needed.

Specified by:
clear in interface Column
Overrides:
clear in class LiteralColumn
See Also:
Call clear after clearing the subclass contents since this method fires the notifications.

get

public double get(int index)
Returns the element at the specified position in this column.

Parameters:
index - index of element to return.
Returns:
the element at the specified position in this column.

set

public void set(int index,
                double element)
Replaces the element at the specified position in this column with the specified element.

Parameters:
index - index of element to replace.
element - element to be stored at the specified position.

setExtend

public void setExtend(int index,
                      double element)
Replaces the element at the specified position in this column with the specified element, growing the column if necessary.

Parameters:
index - index of element to replace.
element - element to be stored at the specified position.

addExtend

public double addExtend(int index,
                        double value)
Adds the value of the column at the specified row with the specified value.

Parameters:
index - the row index
value - the value to add
Returns:
the new value.

getMin

public double getMin()
Returns the minum value of this column.

Returns:
the minum value of this column.

getMax

public double getMax()
Returns the maximum value of this column.

Returns:
the maximum value of this column.

add

public void add(double element)
Adds a new element in the column.

Parameters:
element - the element.

fill

public void fill(double val)
Fills the column with the specified value.

Parameters:
val - the value

parse

public double parse(String v)
             throws ParseException
Parse a string and return the value for the column.

Parameters:
v - the string representation of the value
Returns:
the value
Throws:
ParseException - if the value cannot be parsed

format

public String format(double v)
Returns the string representation of a value according to the current format.

Parameters:
v - the value
Returns:
the string representation.

getValueAt

public String getValueAt(int i)
Description copied from interface: Column
Returns the String representation of the element at the specified position in this column or null if the element is undefined. The representation is generated by the current format.

Parameters:
i - index of element representation to return.
Returns:
the String representation of element at the specified position in this column or null if the element is undefined.
See Also:
Column.getValueAt(int)

setValueAt

public void setValueAt(int i,
                       String v)
                throws ParseException
Description copied from interface: Column
Replaces the element at the specified position in this column with the element specified in its String representation or sets if undefined if the element is null It will be read and translated using the Format. A null value sets the value to undefined. The column is extended if needed.

Parameters:
i - index of element to replace.
v - element to be stored at the specified position.
Throws:
ParseException - if the specified string cannot be parsed.
See Also:
Column.setValueAt(int, String)

getColumn

public static DoubleColumn getColumn(Table t,
                                     int index)
Returns a column as a DoubleColumn from a Table.

Parameters:
t - the Table
index - index in the Table
Returns:
a DoubleColumn or null if no such column exists or the column is not a DoubleColumn.

getColumn

public static DoubleColumn getColumn(Table t,
                                     String name)
Returns a column as a DoubleColumn from a Table.

Parameters:
t - the Table
name - the column name.
Returns:
a DoubleColumn or null if no such column exists or the column is not a DoubleColumn.

findColumn

public static DoubleColumn findColumn(Table t,
                                      String name)
Returns a column as a DoubleColumn from a table, creating it if needed.

Parameters:
t - the Table
name - the column name.
Returns:
a column as a DoubleColumn from a table,

getValueClass

public Class getValueClass()
Returns the class of the elements.

Specified by:
getValueClass in interface Column
Specified by:
getValueClass in class BasicColumn
Returns:
the class of the elements.

getDoubleAt

public double getDoubleAt(int row)
Returns the value as a double

Specified by:
getDoubleAt in interface NumberColumn
Specified by:
getDoubleAt in class LiteralColumn
Parameters:
row - the row
Returns:
the value as a double

getIntAt

public int getIntAt(int row)
Returns the value as an int

Specified by:
getIntAt in interface NumberColumn
Overrides:
getIntAt in class LiteralColumn
Parameters:
row - the row
Returns:
the value as an int

getLongAt

public long getLongAt(int row)
Returns the value as a long

Specified by:
getLongAt in interface NumberColumn
Overrides:
getLongAt in class LiteralColumn
Parameters:
row - the row
Returns:
the value as a long

setDoubleAt

public void setDoubleAt(int row,
                        double v)
Sets the value as a double

Specified by:
setDoubleAt in interface NumberColumn
Specified by:
setDoubleAt in class LiteralColumn
Parameters:
row - the row
v - the value as a double

round

public double round(double value)
Returns the rounded value according to the semantics of this number value.

Specified by:
round in interface NumberColumn
Overrides:
round in class LiteralColumn
Parameters:
value - the value to round
Returns:
the rounded value according to the semantics of this number value.

toArray

public double[] toArray(double[] a)
Returns the array of double values copied from the column.

Parameters:
a - an array of double with at least the column size or null.
Returns:
the array of doubles values copied from the column.

toArray

public double[] toArray()
Returns the array of double values used by the column. BEWARE! no copy is done for performance reasons and the array should only be read. It may become out of sync with the column if the column is resized.

Returns:
the array of double values used by the column.

capacity

public int capacity()
Returns the current capacity of this column.

Returns:
the current capacity .

ensureCapacity

public void ensureCapacity(int minCapacity)
Increases the capacity of this column, if necessary, to ensure that it can hold at least the number of values specified by the minimum capacity argument.

Parameters:
minCapacity - the desired minimum capacity.

size

public int size()
Returns the number of elements in this column.

Returns:
the number of elements in this column.

setSize

public void setSize(int newSize)
Sets the sizeColumn of this column. If the new sizeColumn is greater than the current sizeColumn, new 0 items are added to the end of the column. If the new sizeColumn is less than the current sizeColumn, all components at index newSize and greater are discarded.

Specified by:
setSize in interface Column
Overrides:
setSize in class LiteralColumn
Parameters:
newSize - the new sizeColumn of this column.

getValueReference

public DoubleArrayList getValueReference()
Returns the DoubleArrayList backing the implementation of the column (USE WITH CARE).

Returns:
the DoubleArrayList backing the implementation of the column.


Copyright 2005 by Jean-Daniel Fekete and INRIA, France All rights reserved.