org.geotoolkit.gui.swing
Class TreeTableModelAdapter

Object
  extended by AbstractTreeTableModel
      extended by TreeTableModelAdapter
All Implemented Interfaces:
TreeModel, TreeTableModel

public class TreeTableModelAdapter
extends AbstractTreeTableModel

A TreeTableModel using the Geotk TreeTableNode. This is called "Adapter" because it adapts a Geotk TreeTableNode for use with SwingX TreeTableNode.

Since:
3.04
Version:
3.04
Author:
Martin Desruisseaux (Geomatys)
Module:
display/geotk-widgets-swing (download)    View source code for this class

Field Summary
 
Fields inherited from class AbstractTreeTableModel
modelSupport, root
 
Constructor Summary
TreeTableModelAdapter()
          Creates a new tree table model with no root.
TreeTableModelAdapter(TreeTableNode root)
          Creates a new tree table model having the given root.
 
Method Summary
 TreeNode getChild(Object node, int index)
          Returns the child of the given node at index index in the node's child array.
 int getChildCount(Object node)
          Returns the number of children of parent.
 Class<?> getColumnClass(int column)
          Returns the most specific superclass for all the cell values in the column.
 int getColumnCount()
          Returns the number of columns in the model.
 int getIndexOfChild(Object node, Object child)
          Returns the index of the given child in the given node.
 TreeTableNode getRoot()
          Returns the root of the tree.
 Object getValueAt(Object node, int column)
          Gets the value for the given node at given column.
 boolean isLeaf(Object node)
          Returns true if the given node is a leaf.
 void setRoot(TreeTableNode root)
          Sets a new root for this table model.
 void setValueAt(Object value, Object node, int column)
          Sets the value for the given node at the given column index.
 
Methods inherited from class AbstractTreeTableModel
addTreeModelListener, getColumnName, getHierarchicalColumn, getTreeModelListeners, isCellEditable, removeTreeModelListener, valueForPathChanged
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeTableModelAdapter

public TreeTableModelAdapter()
Creates a new tree table model with no root. The setRoot method must be invoked before this instance can be used.


TreeTableModelAdapter

public TreeTableModelAdapter(TreeTableNode root)
Creates a new tree table model having the given root.

Parameters:
root - The root of the tree table model.
Method Detail

getRoot

public TreeTableNode getRoot()
Returns the root of the tree.

Specified by:
getRoot in interface TreeModel
Overrides:
getRoot in class AbstractTreeTableModel
Returns:
The root of the tree.

setRoot

public void setRoot(TreeTableNode root)
Sets a new root for this table model.

Parameters:
root - The new root.

getColumnCount

public int getColumnCount()
Returns the number of columns in the model. The number of columns shall include the column used for displaying the tree.

Returns:
The number of columns in the model.

getColumnClass

public Class<?> getColumnClass(int column)
Returns the most specific superclass for all the cell values in the column.

Specified by:
getColumnClass in interface TreeTableModel
Overrides:
getColumnClass in class AbstractTreeTableModel
Parameters:
column - The index of the column.
Returns:
The common ancestor class of the object values in the model.

getValueAt

public Object getValueAt(Object node,
                         int column)
Gets the value for the given node at given column.

Parameters:
node - The node whose value is to be queried.
column - The column whose value is to be queried.
Returns:
The value at the specified cell, or null if none.
Throws:
IllegalArgumentException - If the given node is not an instance of TreeTableNode.

setValueAt

public void setValueAt(Object value,
                       Object node,
                       int column)
Sets the value for the given node at the given column index.

Specified by:
setValueAt in interface TreeTableModel
Overrides:
setValueAt in class AbstractTreeTableModel
Parameters:
value - The new value.
node - The node whose value is to be changed.
column - The column whose value is to be changed.
Throws:
IllegalArgumentException - If the given node is not an instance of TreeTableNode.

isLeaf

public boolean isLeaf(Object node)
Returns true if the given node is a leaf.

Specified by:
isLeaf in interface TreeModel
Overrides:
isLeaf in class AbstractTreeTableModel
Parameters:
node - A node in the tree.
Returns:
true if the given node is a leaf.
Throws:
IllegalArgumentException - If the given node is not an instance of TreeTableNode.

getChildCount

public int getChildCount(Object node)
Returns the number of children of parent. Returns 0 if the node is a leaf or if it has no children.

Parameters:
node - The parent node in the tree.
Returns:
The number of children of the given node.
Throws:
IllegalArgumentException - If the given node is not an instance of TreeTableNode.

getChild

public TreeNode getChild(Object node,
                         int index)
Returns the child of the given node at index index in the node's child array.

Parameters:
node - The parent node in the tree.
index - Index of the child to get.
Returns:
The child at the given index.
Throws:
IllegalArgumentException - If the given node is not an instance of TreeTableNode.

getIndexOfChild

public int getIndexOfChild(Object node,
                           Object child)
Returns the index of the given child in the given node. If either the node or the child is null, or if the node or the child don't belong to this tree model, returns -1.

Parameters:
node - A note in the tree.
child - The node we are interested in.
Returns:
The index of the child in the node, or -1.


Copyright © 2009-2013 Geotoolkit.org. All Rights Reserved.