net.sf.taverna.t2.partition
Class RootPartition<ItemType extends java.lang.Comparable>

java.lang.Object
  extended by net.sf.taverna.t2.partition.Partition<ItemType,java.lang.Object,java.lang.Object>
      extended by net.sf.taverna.t2.partition.RootPartition<ItemType>
Type Parameters:
ItemType - all items added to this partition must cast to this type
All Implemented Interfaces:
javax.swing.tree.TreeModel

public class RootPartition<ItemType extends java.lang.Comparable>
extends Partition<ItemType,java.lang.Object,java.lang.Object>
implements javax.swing.tree.TreeModel

Subclass of Partition acting as the public access point for the partition structure. Exposes a TreeModel for use with a UI.

Author:
Tom Oinn

Constructor Summary
RootPartition(java.util.List<PartitionAlgorithm<?>> pa, PropertyExtractorRegistry per)
          Build a new empty root partition with the specified list of partition algorithm implementations used to recursively allocate new data items to the sub-partitions below this one on addition
 
Method Summary
 void addOrUpdateItem(ItemType item)
          Add a new item to the partition structure.
 void addTreeModelListener(javax.swing.event.TreeModelListener l)
           
 java.lang.Object getChild(java.lang.Object parent, int index)
           
 int getChildCount(java.lang.Object parent)
           
 int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
           
 PropertyExtractorRegistry getPropertyExtractorRegistry()
           
 java.lang.Object getRoot()
           
 SetModelChangeListener<ItemType> getSetModelChangeListener()
          The root partition comes with a convenience implementation of SetModelChangeListener which can be used to attach it to a compliant instance of SetModel (assuming the item types match).
 boolean isLeaf(java.lang.Object node)
           
 void removeItem(ItemType item)
          Remove an item from the partition structure, if this leaves any partitions with zero item count they are removed as well to keep things tidy.
 void removeTreeModelListener(javax.swing.event.TreeModelListener l)
           
 void setPartitionAlgorithmList(java.util.List<PartitionAlgorithm<?>> pa)
          Alter the list of partition algorithms which drive the construction of the partitions.
 void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
           
 
Methods inherited from class net.sf.taverna.t2.partition.Partition
getChildPartitionOrder, getChildren, getItemCount, getMembers, getParent, getPartitionAlgorithms, getPartitionPath, getPartitionValue, setChildPartitionOrder, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RootPartition

public RootPartition(java.util.List<PartitionAlgorithm<?>> pa,
                     PropertyExtractorRegistry per)
Build a new empty root partition with the specified list of partition algorithm implementations used to recursively allocate new data items to the sub-partitions below this one on addition

Parameters:
pa -
Method Detail

getSetModelChangeListener

public SetModelChangeListener<ItemType> getSetModelChangeListener()
The root partition comes with a convenience implementation of SetModelChangeListener which can be used to attach it to a compliant instance of SetModel (assuming the item types match). This allows the SetModel to act as the backing data store for the partition - as Query and the various subset / set union operators also implement this it provides a relatively simple mechanism to link multiple sets of data to this partition.


setPartitionAlgorithmList

public void setPartitionAlgorithmList(java.util.List<PartitionAlgorithm<?>> pa)
Alter the list of partition algorithms which drive the construction of the partitions. Calling this effectively forces a complete rebuild of the tree structure which is an expensive operation so be careful when you use it.

Parameters:
pa - a new list of PartitionAlgorithmSPI instances to use as the basis for the partition structure.

addOrUpdateItem

public void addOrUpdateItem(ItemType item)
Add a new item to the partition structure. If the item already exists this is interpreted as a request to reclassify according to properties which may have changed. This is not the same as a reclassification due to modification of the partition algorithm list, and just refers to the specified item. If the item exists already and its classification is changed the model will be notified with a removal event from the previous location and the item will be added as usual immediately afterwards.


removeItem

public void removeItem(ItemType item)
Remove an item from the partition structure, if this leaves any partitions with zero item count they are removed as well to keep things tidy.

Parameters:
item - the item to remove from the partition structure. If this isn't present in the structure this method does nothing along the lines of the collections API.

getChild

public java.lang.Object getChild(java.lang.Object parent,
                                 int index)
Specified by:
getChild in interface javax.swing.tree.TreeModel

getChildCount

public int getChildCount(java.lang.Object parent)
Specified by:
getChildCount in interface javax.swing.tree.TreeModel

getIndexOfChild

public int getIndexOfChild(java.lang.Object parent,
                           java.lang.Object child)
Specified by:
getIndexOfChild in interface javax.swing.tree.TreeModel

getRoot

public java.lang.Object getRoot()
Specified by:
getRoot in interface javax.swing.tree.TreeModel

isLeaf

public boolean isLeaf(java.lang.Object node)
Specified by:
isLeaf in interface javax.swing.tree.TreeModel

removeTreeModelListener

public void removeTreeModelListener(javax.swing.event.TreeModelListener l)
Specified by:
removeTreeModelListener in interface javax.swing.tree.TreeModel

addTreeModelListener

public void addTreeModelListener(javax.swing.event.TreeModelListener l)
Specified by:
addTreeModelListener in interface javax.swing.tree.TreeModel

valueForPathChanged

public void valueForPathChanged(javax.swing.tree.TreePath path,
                                java.lang.Object newValue)
Specified by:
valueForPathChanged in interface javax.swing.tree.TreeModel

getPropertyExtractorRegistry

public PropertyExtractorRegistry getPropertyExtractorRegistry()