info.bioinfweb.treegraph.gui.dialogs.datatable
Class NodeDataTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by info.bioinfweb.treegraph.gui.dialogs.datatable.NodeDataTableModel
All Implemented Interfaces:
Serializable, TableModel

public class NodeDataTableModel
extends AbstractTableModel

This table model allows to display all branch and node data in a table. The unique node names, the node names and the branch lengths are always listed. Furthermore the table can contain labels and hidden data with a specified ID where ervery ID gets its own column.

Additionally every second column contains information about the data type (decimal or string) of the listes data which can also be edited if the data structure allows it. (Therefore the data type of unique names and branch lengths cannot be changed.)

Author:
Ben Stöver
See Also:
Serialized Form

Field Summary
private  Vector<NodeDataAdapter> adapters
           
static int COL_BRANCH_LENGTH_DATA_TYPE
           
static int COL_UNIQUE_NAME_DATA_TYPE
           
private  Document document
           
private  Vector<Node> nodes
           
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
NodeDataTableModel()
           
 
Method Summary
 void assignTree(Node root)
          Assigns the node data in the subtree under root to this model.
 void copyColumn(boolean includeLeafs, NodeDataAdapter src, NodeDataAdapter dest)
           
private  void copySubtree(Node root, boolean includeLeafs, NodeDataAdapter src, NodeDataAdapter dest)
           
 void deleteColumn(int col)
           
 void deleteOutsideInterval(int col, double upperBorder, double lowerBorder)
           
private  void deleteOutsideIntervalSubtree(Node root, NodeDataAdapter adapter, double upperBorder, double lowerBorder)
           
private  void deleteSubtree(Node root, NodeDataAdapter adapter)
           
private  void fillAdapterList(Node root)
           
private  void fillNodeList(Node root)
           
 NodeDataAdapter getAdapter(int col)
           
 Class<?> getColumnClass(int col)
           
 int getColumnCount()
           
 String getColumnName(int col)
           
 Document getDocument()
           
 int getRowCount()
           
 ConcretePaintableElement getTreeElement(int row, int col)
           
 Object getValueAt(int row, int col)
           
 boolean importData(NodeDataAdapter[] adapters, String[][] data)
           
 boolean isCellEditable(int row, int col)
           
 void registerChange()
           
 void rescaleColumn(int col, NodeDataCalculator calculator)
           
private  void rescaleSubtree(Node root, NodeDataAdapter adapter, NodeDataCalculator calculator)
           
 void setDataType(int col, boolean decimal)
           
private  void setDataTypeInSubtree(Node root, TextElementDataAdapter adapter, boolean decimal)
           
 void setValueAt(Object value, int row, int col)
           
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COL_UNIQUE_NAME_DATA_TYPE

public static final int COL_UNIQUE_NAME_DATA_TYPE
See Also:
Constant Field Values

COL_BRANCH_LENGTH_DATA_TYPE

public static final int COL_BRANCH_LENGTH_DATA_TYPE
See Also:
Constant Field Values

adapters

private Vector<NodeDataAdapter> adapters

nodes

private Vector<Node> nodes

document

private Document document
Constructor Detail

NodeDataTableModel

public NodeDataTableModel()
Method Detail

getDocument

public Document getDocument()

fillAdapterList

private void fillAdapterList(Node root)

fillNodeList

private void fillNodeList(Node root)

assignTree

public void assignTree(Node root)
Assigns the node data in the subtree under root to this model. Previous values are deleted.

Parameters:
root - - the root od the tree to fetch the data from

registerChange

public void registerChange()

copySubtree

private void copySubtree(Node root,
                         boolean includeLeafs,
                         NodeDataAdapter src,
                         NodeDataAdapter dest)

copyColumn

public void copyColumn(boolean includeLeafs,
                       NodeDataAdapter src,
                       NodeDataAdapter dest)

deleteSubtree

private void deleteSubtree(Node root,
                           NodeDataAdapter adapter)

deleteColumn

public void deleteColumn(int col)

rescaleSubtree

private void rescaleSubtree(Node root,
                            NodeDataAdapter adapter,
                            NodeDataCalculator calculator)

rescaleColumn

public void rescaleColumn(int col,
                          NodeDataCalculator calculator)

deleteOutsideIntervalSubtree

private void deleteOutsideIntervalSubtree(Node root,
                                          NodeDataAdapter adapter,
                                          double upperBorder,
                                          double lowerBorder)

deleteOutsideInterval

public void deleteOutsideInterval(int col,
                                  double upperBorder,
                                  double lowerBorder)

importData

public boolean importData(NodeDataAdapter[] adapters,
                          String[][] data)
Parameters:
adapters -
data -
Returns:
true, if all data has been imported, false, if one or more unique node name was not found in the current tree

setDataTypeInSubtree

private void setDataTypeInSubtree(Node root,
                                  TextElementDataAdapter adapter,
                                  boolean decimal)

setDataType

public void setDataType(int col,
                        boolean decimal)

getTreeElement

public ConcretePaintableElement getTreeElement(int row,
                                               int col)

getColumnClass

public Class<?> getColumnClass(int col)
Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel

getColumnName

public String getColumnName(int col)
Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel

isCellEditable

public boolean isCellEditable(int row,
                              int col)
Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel

getColumnCount

public int getColumnCount()

getRowCount

public int getRowCount()

getValueAt

public Object getValueAt(int row,
                         int col)

setValueAt

public void setValueAt(Object value,
                       int row,
                       int col)
Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel

getAdapter

public NodeDataAdapter getAdapter(int col)