fri.gui.swing.polytreetable
Class AbstractPolyTreeTableModel

java.lang.Object
  |
  +--fri.gui.swing.polytreetable.AbstractPolyTreeTableModel
All Implemented Interfaces:
PolyTreeTableModel
Direct Known Subclasses:
DefaultPolyTreeTableModel

public abstract class AbstractPolyTreeTableModel
extends java.lang.Object
implements PolyTreeTableModel

An abstract implementation of the PolyTreeTableModel interface that provides display methods (but no edit methods).

Author:
Ritzberger Fritz
See Also:
PolyTreeTableModel, DefaultPolyTreeTableModel

Field Summary
protected  boolean asksAllowsChildren
          If this is true, model.isChildLeaf() calls node.getAllowsChildren() instead of node.isChildLeaf() when isChildLeaf() is messaged.
protected  boolean asksAllowsParents
          If this is true, model.isParentLeaf() calls node.getAllowsParents() instead of node.isParentLeaf() when isParentLeaf() is messaged.
protected  PolyTreeNode startNode
          The start node that was passed to the constructor.
 
Constructor Summary
AbstractPolyTreeTableModel(PolyTreeNode startNode)
          Create a model with given start node and asking for allows parents/children.
AbstractPolyTreeTableModel(PolyTreeNode startNode, boolean asksAllowsParents, boolean asksAllowsChildren)
          Create a model with given start node and the parents/children properties.
 
Method Summary
 boolean getAsksAllowsChildren()
          Returns true if this model calls node.getAllowsChildren() when isChildLeaf(node) is called.
 boolean getAsksAllowsParents()
          Returns true if this model calls node.getAllowsParents() when isParentLeaf(node) is called.
 PolyTreeNode getChild(PolyTreeNode parent, int index)
          Returns the child of parent at index index.
 int getChildCount(PolyTreeNode parent)
          Returns the number of children of parent.
 int getIndexOfChild(PolyTreeNode node, PolyTreeNode child)
          Returns the index of child in node.
 int getIndexOfParent(PolyTreeNode node, PolyTreeNode parent)
          Returns the index of parent in node.
 PolyTreeNode getParent(PolyTreeNode child, int index)
          Returns the parent of child at index index.
 int getParentCount(PolyTreeNode child)
          Returns the number of parents of child.
 PolyTreeNode getStartNode()
          Returns the start node that was set in constructor.
 boolean isCellEditable(PolyTreeNode node, int column)
          Delegates to node.isCellEditable() if node is instanceof DefaultPolyTreeNode, else returns always true.
 boolean isChildLeaf(PolyTreeNode node)
          Returns true if the passed node has no children or does not allow children.
 boolean isParentLeaf(PolyTreeNode node)
          Returns true if the passed node has no parents or does not allow parents.
 void setAsksAllowsChildren(boolean asksAllowsChildren)
          If set to true, isChildLeaf() will call node.getAllowsChildren(), else node.isChildLeaf() is called.
 void setAsksAllowsParents(boolean asksAllowsParents)
          If set to true, isParentLeaf() will call node.getAllowsParents(), else node.isParentLeaf() is called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface fri.gui.swing.polytreetable.PolyTreeTableModel
getColumnClass, getColumnCount, getColumnName, getValueAt, setValueAt
 

Field Detail

asksAllowsParents

protected boolean asksAllowsParents
If this is true, model.isParentLeaf() calls node.getAllowsParents() instead of node.isParentLeaf() when isParentLeaf() is messaged.


asksAllowsChildren

protected boolean asksAllowsChildren
If this is true, model.isChildLeaf() calls node.getAllowsChildren() instead of node.isChildLeaf() when isChildLeaf() is messaged.


startNode

protected PolyTreeNode startNode
The start node that was passed to the constructor.

Constructor Detail

AbstractPolyTreeTableModel

public AbstractPolyTreeTableModel(PolyTreeNode startNode)
Create a model with given start node and asking for allows parents/children. This differs from DefaultTreeModel that defaults asksAllowsChildren to false!


AbstractPolyTreeTableModel

public AbstractPolyTreeTableModel(PolyTreeNode startNode,
                                  boolean asksAllowsParents,
                                  boolean asksAllowsChildren)
Create a model with given start node and the parents/children properties.

Method Detail

getStartNode

public PolyTreeNode getStartNode()
Returns the start node that was set in constructor. This always stays the same (even if the view "lead term" changes) and is needed just for construction, as every node of the model can become start node (without model changes). Setting a new "lead term" programmatically means setting a new model.
This method is used by PolyTreeView when providing the model.

Specified by:
getStartNode in interface PolyTreeTableModel

setAsksAllowsParents

public void setAsksAllowsParents(boolean asksAllowsParents)
If set to true, isParentLeaf() will call node.getAllowsParents(), else node.isParentLeaf() is called.


getAsksAllowsParents

public boolean getAsksAllowsParents()
Returns true if this model calls node.getAllowsParents() when isParentLeaf(node) is called.


setAsksAllowsChildren

public void setAsksAllowsChildren(boolean asksAllowsChildren)
If set to true, isChildLeaf() will call node.getAllowsChildren(), else node.isChildLeaf() is called.


getAsksAllowsChildren

public boolean getAsksAllowsChildren()
Returns true if this model calls node.getAllowsChildren() when isChildLeaf(node) is called.


isCellEditable

public boolean isCellEditable(PolyTreeNode node,
                              int column)
Delegates to node.isCellEditable() if node is instanceof DefaultPolyTreeNode, else returns always true.

Specified by:
isCellEditable in interface PolyTreeTableModel

getParent

public PolyTreeNode getParent(PolyTreeNode child,
                              int index)
Returns the parent of child at index index. Delegates to PolyTreeNode.

Specified by:
getParent in interface PolyTreeTableModel
Parameters:
child - a node in the tree, obtained from this data source
Returns:
the parent of child at index index

getChild

public PolyTreeNode getChild(PolyTreeNode parent,
                             int index)
Returns the child of parent at index index. Delegates to PolyTreeNode.

Specified by:
getChild in interface PolyTreeTableModel
Parameters:
parent - a node in the tree, obtained from this data source
Returns:
the child of parent at index index

getParentCount

public int getParentCount(PolyTreeNode child)
Returns the number of parents of child. Returns 0 if the node has no parents, i.e. it is an entry node to the polyhierarchy. Delegates to PolyTreeNode.

Specified by:
getParentCount in interface PolyTreeTableModel
Parameters:
child - a node in the tree, obtained from this data source
Returns:
the number of parents of the node child

getChildCount

public int getChildCount(PolyTreeNode parent)
Returns the number of children of parent. Returns 0 if the node has no children, i.e. it is an entry node to the polyhierarchy. Delegates to PolyTreeNode.

Specified by:
getChildCount in interface PolyTreeTableModel
Parameters:
parent - a node in the tree, obtained from this data source
Returns:
the number of children of the node parent

getIndexOfParent

public int getIndexOfParent(PolyTreeNode node,
                            PolyTreeNode parent)
Returns the index of parent in node.

Specified by:
getIndexOfParent in interface PolyTreeTableModel

getIndexOfChild

public int getIndexOfChild(PolyTreeNode node,
                           PolyTreeNode child)
Returns the index of child in node.

Specified by:
getIndexOfChild in interface PolyTreeTableModel

isParentLeaf

public boolean isParentLeaf(PolyTreeNode node)
Returns true if the passed node has no parents or does not allow parents.

Specified by:
isParentLeaf in interface PolyTreeTableModel

isChildLeaf

public boolean isChildLeaf(PolyTreeNode node)
Returns true if the passed node has no children or does not allow children.

Specified by:
isChildLeaf in interface PolyTreeTableModel