prefuse.data
Class CascadedTable

java.lang.Object
  extended by prefuse.data.tuple.AbstractTupleSet
      extended by prefuse.data.Table
          extended by prefuse.data.CascadedTable
All Implemented Interfaces:
java.util.EventListener, ColumnListener, TupleSet
Direct Known Subclasses:
VisualTable

public class CascadedTable
extends Table

Table subclass featuring a "cascaded" table design - a CascadedTable can have a parent table, from which it inherits a potentially filtered set of rows and columns. Child tables may override the columns of the parent by having a column of the same name as that of the parent, in which case the parent's column will not be accessible.

Table rows of the parent table can be selectively included by providing a Predicate that filters the parent rows. Columns of the parent table can be selectively included by providing a ColumnProjection indicating the columns to include.

Tuple instances backed by a CascadedTable will be not be equivalent to the tuples backed by the parent table. However, setting a value in a CascadedTable that is inherited from a parent table will update the value in the parent table.

Author:
jeffrey heer

Nested Class Summary
 
Nested classes/interfaces inherited from class prefuse.data.Table
Table.ColumnEntry
 
Field Summary
protected  ColumnProjection m_colFilter
          ColumnProjection determining which columns of the parent table are included in this table.
protected  prefuse.data.CascadedTable.Listener m_listener
          An internal listener class
protected  Table m_parent
          Cascaded parent table
protected  java.util.ArrayList m_pnames
          List of included parent column names
protected  Predicate m_rowFilter
          Selection Predicate determining which rows of the parent table are included in this table.
 
Fields inherited from class prefuse.data.Table
m_columns, m_entries, m_lastCol, m_listeners, m_modCount, m_names, m_rows, m_schema, m_tuples
 
Fields inherited from interface prefuse.data.tuple.TupleSet
EMPTY_ARRAY
 
Constructor Summary
protected CascadedTable()
          Create a CascadedTable without a backing parent table.
protected CascadedTable(java.lang.Class tupleType)
          Create a CascadedTable without a backing parent table.
  CascadedTable(Table parent)
          Create a new CascadedTable.
  CascadedTable(Table parent, ColumnProjection colFilter)
          Create a new CascadedTable.
  CascadedTable(Table parent, Predicate rowFilter)
          Create a new CascadedTable.
  CascadedTable(Table parent, Predicate rowFilter, ColumnProjection colFilter)
          Create a new CascadedTable.
protected CascadedTable(Table parent, Predicate rowFilter, ColumnProjection colFilter, java.lang.Class tupleType)
          Create a new CascadedTable.
 
Method Summary
protected  int addCascadedRow(int prow)
          Internal method for adding a new cascaded row backed by the given parent row.
 int addRow()
          Add a row to this table.
 void addRows(int nrows)
          Add a given number of rows to this table.
protected  void filterColumns()
          Determines which columns are inherited from the backing parent table.
 void filterRows()
          Manually trigger a re-filtering of the rows of this table.
 int getChildRow(int prow)
          Given a row in the parent table, return the corresponding row, if any, in this table.
 Column getColumn(int col)
          Get the column at the given column number.
 int getColumnCount()
          Get the number of columns / data fields in this table.
 java.lang.String getColumnName(int col)
          Get the data field name of the column at the given column number.
protected  java.util.Iterator getColumnNames()
          Internal method that returns an iterator over column names
 int getColumnNumber(Column col)
          Get the column number for the given Column instance.
 ColumnProjection getColumnProjection()
          Get the ColumnProjection determining which columns of the parent table are included in this one.
 int getLocalColumnCount()
          Get the number of columns explicitly stored by this table (i.e., all columns that are not inherited from the parent table).
 int getParentRow(int row)
          Given a row in this table, return the corresponding row in the parent table.
 Table getParentTable()
          Get the parent table from which this cascaded table inherits values.
 Predicate getRowFilter()
          Gets ths Predicate determining which rows of the parent table are included in this one.
protected  boolean hasColumn(java.lang.String name)
          Internal method indicating if the given data field is included as a data column.
protected  void invalidateSchema()
          Invalidates this table's cached schema.
protected  boolean removeCascadedRow(int row)
          Internal method for removing a cascaded row from this table.
 boolean removeRow(int row)
          Removes a row from this table.
 void setColumnProjection(ColumnProjection colFilter)
          Sets the ColumnProjection determining which columns of the parent table are included in this one.
 void setRowFilter(Predicate rowFilter)
          Sets the Predicate determining which rows of the parent table are included in this one.
 
Methods inherited from class prefuse.data.Table
addColumn, addColumn, addColumn, addColumn, addColumn, addConstantColumn, addTableListener, addTuple, canGet, canGetBoolean, canGetDate, canGetDouble, canGetFloat, canGetInt, canGetLong, canGetString, canSet, canSetBoolean, canSetDate, canSetDouble, canSetFloat, canSetInt, canSetLong, canSetString, clear, columnChanged, columnChanged, columnChanged, columnChanged, columnChanged, columnChanged, columnChanged, containsTuple, fireTableEvent, get, get, getBoolean, getBoolean, getColumn, getColumnNumber, getColumnRow, getColumns, getColumnType, getColumnType, getDate, getDate, getDefault, getDouble, getDouble, getFloat, getFloat, getIndex, getIndex, getInt, getInt, getLong, getLong, getMaximumRow, getMetadata, getMinimumRow, getModificationCount, getRowCount, getSchema, getString, getString, getTableRow, getTuple, getTupleCount, handleColumnChanged, index, isAddColumnSupported, isCellEditable, isValidRow, iterator, iterator, rangeSortedBy, rangeSortedBy, rangeSortedBy, rangeSortedBy, rangeSortedBy, remove, removeAllTableListeners, removeColumn, removeColumn, removeColumn, removeIndex, removeTableListener, removeTuple, renumberColumns, revertToDefault, rows, rows, rows, rowsSortedBy, select, set, set, setBoolean, setBoolean, setDate, setDate, setDouble, setDouble, setFloat, setFloat, setInt, setInt, setLong, setLong, setString, setString, setTuple, setTupleManager, toString, tuples, tuples, tuplesReversed, updateRowCount
 
Methods inherited from class prefuse.data.tuple.AbstractTupleSet
addColumns, addPropertyChangeListener, addPropertyChangeListener, addTupleSetListener, fireTupleEvent, fireTupleEvent, fireTupleEvent, getClientProperty, putClientProperty, removePropertyChangeListener, removePropertyChangeListener, removeTupleSetListener, tuples, tuples
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_parent

protected Table m_parent
Cascaded parent table


m_pnames

protected java.util.ArrayList m_pnames
List of included parent column names


m_colFilter

protected ColumnProjection m_colFilter
ColumnProjection determining which columns of the parent table are included in this table.


m_rowFilter

protected Predicate m_rowFilter
Selection Predicate determining which rows of the parent table are included in this table.


m_listener

protected prefuse.data.CascadedTable.Listener m_listener
An internal listener class

Constructor Detail

CascadedTable

public CascadedTable(Table parent)
Create a new CascadedTable. By default all rows and columns of the parent table are included in this one.

Parameters:
parent - the parent Table to use

CascadedTable

public CascadedTable(Table parent,
                     Predicate rowFilter)
Create a new CascadedTable. By default all columns of the parent table are included in this one.

Parameters:
parent - the parent Table to use
rowFilter - a Predicate determining which rows of the parent table to include in this one.

CascadedTable

public CascadedTable(Table parent,
                     ColumnProjection colFilter)
Create a new CascadedTable. By default all rows of the parent table are included in this one.

Parameters:
parent - the parent Table to use
colFilter - a ColumnProjection determining which columns of the parent table to include in this one.

CascadedTable

public CascadedTable(Table parent,
                     Predicate rowFilter,
                     ColumnProjection colFilter)
Create a new CascadedTable.

Parameters:
parent - the parent Table to use
rowFilter - a Predicate determining which rows of the parent table to include in this one.
colFilter - a ColumnProjection determining which columns of the parent table to include in this one.

CascadedTable

protected CascadedTable(Table parent,
                        Predicate rowFilter,
                        ColumnProjection colFilter,
                        java.lang.Class tupleType)
Create a new CascadedTable.

Parameters:
parent - the parent Table to use
rowFilter - a Predicate determining which rows of the parent table to include in this one.
colFilter - a ColumnProjection determining which columns of the parent table to include in this one.
tupleType - the class type of the Tuple instances to use

CascadedTable

protected CascadedTable()
Create a CascadedTable without a backing parent table.


CascadedTable

protected CascadedTable(java.lang.Class tupleType)
Create a CascadedTable without a backing parent table.

Parameters:
tupleType - the class type of the Tuple instances to use
Method Detail

filterColumns

protected void filterColumns()
Determines which columns are inherited from the backing parent table.


filterRows

public void filterRows()
Manually trigger a re-filtering of the rows of this table. If the filtering predicate concerns only items within this table, calling this method should be unnecessary. It is only when the filtering predicate references data outside of this table that a manual re-filtering request may be necessary. For example, filtering valid edges of a graph from a pool of candidate edges will depend on the available nodes.

See Also:
ValidEdgePredicate

getColumnProjection

public ColumnProjection getColumnProjection()
Get the ColumnProjection determining which columns of the parent table are included in this one.

Returns:
the ColumnProjection of this CascadedTable

setColumnProjection

public void setColumnProjection(ColumnProjection colFilter)
Sets the ColumnProjection determining which columns of the parent table are included in this one.

Parameters:
colFilter - a ColumnProjection determining which columns of the parent table to include in this one.

getRowFilter

public Predicate getRowFilter()
Gets ths Predicate determining which rows of the parent table are included in this one.

Returns:
the row filtering Predicate of this CascadedTable

setRowFilter

public void setRowFilter(Predicate rowFilter)
Sets the Predicate determining which rows of the parent table are included in this one.

Parameters:
rowFilter - a Predicate determining which rows of the parent table to include in this one.

getColumnCount

public int getColumnCount()
Description copied from class: Table
Get the number of columns / data fields in this table.

Overrides:
getColumnCount in class Table
Returns:
the number of columns
See Also:
Table.getColumnCount()

getLocalColumnCount

public int getLocalColumnCount()
Get the number of columns explicitly stored by this table (i.e., all columns that are not inherited from the parent table).

Returns:
the number of locally stored columns

getParentTable

public Table getParentTable()
Get the parent table from which this cascaded table inherits values.

Returns:
the parent table

getParentRow

public int getParentRow(int row)
Given a row in this table, return the corresponding row in the parent table.

Parameters:
row - a row in this table
Returns:
the corresponding row in the parent table

getChildRow

public int getChildRow(int prow)
Given a row in the parent table, return the corresponding row, if any, in this table.

Parameters:
prow - a row in the parent table
Returns:
the corresponding row in this table, or -1 if the given parent row is not inherited by this table

addRow

public int addRow()
Description copied from class: Table
Add a row to this table. All data columns will be notified and will take on the appropriate default values for the added row.

Overrides:
addRow in class Table
Returns:
the row number of the newly added row
See Also:
Table.addRow()

addRows

public void addRows(int nrows)
Description copied from class: Table
Add a given number of rows to this table. All data columns will be notified and will take on the appropriate default values for the added rows.

Overrides:
addRows in class Table
Parameters:
nrows - the number of rows to add.
See Also:
Table.addRows(int)

removeRow

public boolean removeRow(int row)
Description copied from class: Table
Removes a row from this table.

Overrides:
removeRow in class Table
Parameters:
row - the row to delete
Returns:
true if the row was successfully deleted, false if the row was already invalid
See Also:
Table.removeRow(int)

addCascadedRow

protected int addCascadedRow(int prow)
Internal method for adding a new cascaded row backed by the given parent row.

Parameters:
prow - the parent row to inherit
Returns:
the row number ofr the newly added row in this table

removeCascadedRow

protected boolean removeCascadedRow(int row)
Internal method for removing a cascaded row from this table.

Parameters:
row - the row to remove
Returns:
true if the row was successfully removed, false otherwise

getColumnName

public java.lang.String getColumnName(int col)
Description copied from class: Table
Get the data field name of the column at the given column number.

Overrides:
getColumnName in class Table
Parameters:
col - the column number
Returns:
the data field name of the column
See Also:
Table.getColumnName(int)

getColumnNumber

public int getColumnNumber(Column col)
Description copied from class: Table
Get the column number for the given Column instance.

Overrides:
getColumnNumber in class Table
Parameters:
col - the Column instance to lookup
Returns:
the column number of the column, or -1 if the name is not found
See Also:
Table.getColumnNumber(prefuse.data.column.Column)

getColumn

public Column getColumn(int col)
Description copied from class: Table
Get the column at the given column number.

Overrides:
getColumn in class Table
Parameters:
col - the column number
Returns:
the Column instance
See Also:
Table.getColumn(int)

hasColumn

protected boolean hasColumn(java.lang.String name)
Description copied from class: Table
Internal method indicating if the given data field is included as a data column.

Overrides:
hasColumn in class Table
See Also:
Table.hasColumn(java.lang.String)

getColumnNames

protected java.util.Iterator getColumnNames()
Description copied from class: Table
Internal method that returns an iterator over column names

Overrides:
getColumnNames in class Table
Returns:
an iterator over column name
See Also:
Table.getColumnNames()

invalidateSchema

protected void invalidateSchema()
Invalidates this table's cached schema. This method should be called whenever columns are added or removed from this table.

Overrides:
invalidateSchema in class Table


Copyright © 2007 Regents of the University of California