unbboolean.gui
Class CSGTreeModel

java.lang.Object
  |
  +--unbboolean.gui.CSGTreeModel
All Implemented Interfaces:
javax.swing.tree.TreeModel

public class CSGTreeModel
extends java.lang.Object
implements javax.swing.tree.TreeModel

Tree model based on the CSGSolid structure

Author:
Danilo Balby Silva Castanheira(danbalby@yahoo.com)

Constructor Summary
CSGTreeModel(CSGSolid root)
          Constructs a CSGTreeModel with the given root.
 
Method Summary
 void addTreeModelListener(javax.swing.event.TreeModelListener l)
          Sets a listener for changes into the model
 java.lang.Object getChild(java.lang.Object parent, int index)
          Gets a child of a given parent in a given index
 int getChildCount(java.lang.Object parent)
          Gets the number of children of a give parent (2 for CompoundSolid and 0 for PrimitiveSolid)
 int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
          Gets the index of a child of a given parent
 java.lang.Object getRoot()
          Gets the tree root
 boolean isLeaf(java.lang.Object node)
          Returns if a given object is a tree leaf (if it is a CompoundSolid object, is a node, otherwise is a leaf)
 void removeTreeModelListener(javax.swing.event.TreeModelListener l)
          Removes a listener for changes into the model
 void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
          Unimplemented method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSGTreeModel

public CSGTreeModel(CSGSolid root)
Constructs a CSGTreeModel with the given root.

Parameters:
root - tree root
Method Detail

getRoot

public java.lang.Object getRoot()
Gets the tree root

Specified by:
getRoot in interface javax.swing.tree.TreeModel
Returns:
tree root (a CSGSolid object).

getChild

public java.lang.Object getChild(java.lang.Object parent,
                                 int index)
Gets a child of a given parent in a given index

Specified by:
getChild in interface javax.swing.tree.TreeModel
Parameters:
parent - parent whose child is to be found
index - index of the child to be found
Returns:
required child, null if parameters are invalid for this model

getChildCount

public int getChildCount(java.lang.Object parent)
Gets the number of children of a give parent (2 for CompoundSolid and 0 for PrimitiveSolid)

Specified by:
getChildCount in interface javax.swing.tree.TreeModel
Parameters:
parent - parent whose number of children is to be found
Returns:
number of children of the given parent

isLeaf

public boolean isLeaf(java.lang.Object node)
Returns if a given object is a tree leaf (if it is a CompoundSolid object, is a node, otherwise is a leaf)

Specified by:
isLeaf in interface javax.swing.tree.TreeModel
Parameters:
node - test node
Returns:
true if node is a leaf, false otherwise

getIndexOfChild

public int getIndexOfChild(java.lang.Object parent,
                           java.lang.Object child)
Gets the index of a child of a given parent

Specified by:
getIndexOfChild in interface javax.swing.tree.TreeModel
Parameters:
parent - parent of the child whose index is required
child - child whose index is required
Returns:
child index, -1 if the parameters are invalid for this model

addTreeModelListener

public void addTreeModelListener(javax.swing.event.TreeModelListener l)
Sets a listener for changes into the model

Specified by:
addTreeModelListener in interface javax.swing.tree.TreeModel
Parameters:
l - listener to be set

removeTreeModelListener

public void removeTreeModelListener(javax.swing.event.TreeModelListener l)
Removes a listener for changes into the model

Specified by:
removeTreeModelListener in interface javax.swing.tree.TreeModel
Parameters:
l - listener to be removed

valueForPathChanged

public void valueForPathChanged(javax.swing.tree.TreePath path,
                                java.lang.Object newValue)
Unimplemented method.

Specified by:
valueForPathChanged in interface javax.swing.tree.TreeModel