org.annotation.agschema.graphics.vtree.ui
Class BoundedSubtreeUI

java.lang.Object
  extended byjavax.swing.plaf.ComponentUI
      extended byorg.annotation.agschema.graphics.vtree.ui.VTreeUI
          extended byorg.annotation.agschema.graphics.vtree.ui.BoundedSubtreeUI
All Implemented Interfaces:
java.util.EventListener, java.beans.PropertyChangeListener, TreeMutationListener, VTreeExpansionListener, VTreeSelectionListener

public class BoundedSubtreeUI
extends VTreeUI
implements java.beans.PropertyChangeListener, TreeMutationListener, VTreeExpansionListener, VTreeSelectionListener

This UI draws each subtree in its own rectangle. The size of the rectangle is proportional to the number of leaves in the subtree, so the leaves appear evenly spaced. This implementation is optimized for speed, and uses memory proportional to the size of the tree being drawn.

TODO - Make a memory efficient counterpart to this.

Author:
nikhild

Nested Class Summary
 class BoundedSubtreeUI.BoundsTreeNode
           
 class BoundedSubtreeUI.NodeBoundsInfo
           
 class BoundedSubtreeUI.PaintingInfo
           
 class BoundedSubtreeUI.PaintingInfoPool
           
 
Constructor Summary
BoundedSubtreeUI()
          Creates a new instance of BoundedSubtreeUI
 
Method Summary
 void childAdded(javax.swing.tree.MutableTreeNode parent, int index)
           
 void childRemoved(javax.swing.tree.MutableTreeNode parent, javax.swing.tree.MutableTreeNode child, int oldChildIndex)
           
static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
           
 java.awt.Dimension getMaximumSize(javax.swing.JComponent c)
           
 java.awt.Dimension getMinimumSize(javax.swing.JComponent c)
           
 javax.swing.tree.TreeNode getNode(int x, int y)
           
 java.awt.Rectangle getNodeLocation(javax.swing.tree.TreeNode node)
           
 java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
           
 java.awt.Rectangle getSubtreeLocation(javax.swing.tree.TreeNode node)
           
 void installUI(javax.swing.JComponent c)
           
 void nodeAdded(VTreeSelectionModel model, javax.swing.tree.TreeNode node)
           
 void nodeCollapsed(VTreeExpansionState state, javax.swing.tree.TreeNode node)
          Notification that a node has collapsed, and from the perspective of viewing, it is now a leaf.
 void nodeExpanded(VTreeExpansionState state, javax.swing.tree.TreeNode node)
          Notification that a node has expanded, and from the perspective of viewing, all its children will be displayed.
 void nodeObjectChanged(javax.swing.tree.MutableTreeNode node, java.lang.Object oldUserObject)
           
 void nodeRemoved(VTreeSelectionModel model, javax.swing.tree.TreeNode node)
           
 void paint(java.awt.Graphics g, javax.swing.JComponent component)
           
 void propertyChange(java.beans.PropertyChangeEvent evt)
           
 void rootChanged(javax.swing.tree.TreeNode newRoot, javax.swing.tree.TreeNode oldRoot)
           
 void selectionCleared(VTreeSelectionModel model)
           
 void selectionInterpretationChanged(VTreeSelectionModel model, int oldInterpretation)
           
 void selectionModeChanged(VTreeSelectionModel model, int oldMode)
           
 void subtreeDamaged(javax.swing.tree.MutableTreeNode subtreeRoot)
           
 void uninstallUI(javax.swing.JComponent c)
           
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoundedSubtreeUI

public BoundedSubtreeUI()
Creates a new instance of BoundedSubtreeUI

Method Detail

createUI

public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)

getNodeLocation

public java.awt.Rectangle getNodeLocation(javax.swing.tree.TreeNode node)
Specified by:
getNodeLocation in class VTreeUI

getSubtreeLocation

public java.awt.Rectangle getSubtreeLocation(javax.swing.tree.TreeNode node)

getNode

public javax.swing.tree.TreeNode getNode(int x,
                                         int y)
Specified by:
getNode in class VTreeUI

paint

public void paint(java.awt.Graphics g,
                  javax.swing.JComponent component)

getPreferredSize

public java.awt.Dimension getPreferredSize(javax.swing.JComponent c)

getMinimumSize

public java.awt.Dimension getMinimumSize(javax.swing.JComponent c)

getMaximumSize

public java.awt.Dimension getMaximumSize(javax.swing.JComponent c)

installUI

public void installUI(javax.swing.JComponent c)

uninstallUI

public void uninstallUI(javax.swing.JComponent c)

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

childAdded

public void childAdded(javax.swing.tree.MutableTreeNode parent,
                       int index)
Specified by:
childAdded in interface TreeMutationListener

childRemoved

public void childRemoved(javax.swing.tree.MutableTreeNode parent,
                         javax.swing.tree.MutableTreeNode child,
                         int oldChildIndex)
Specified by:
childRemoved in interface TreeMutationListener

subtreeDamaged

public void subtreeDamaged(javax.swing.tree.MutableTreeNode subtreeRoot)
Specified by:
subtreeDamaged in interface TreeMutationListener

nodeObjectChanged

public void nodeObjectChanged(javax.swing.tree.MutableTreeNode node,
                              java.lang.Object oldUserObject)
Specified by:
nodeObjectChanged in interface TreeMutationListener

nodeCollapsed

public void nodeCollapsed(VTreeExpansionState state,
                          javax.swing.tree.TreeNode node)
Description copied from interface: VTreeExpansionListener
Notification that a node has collapsed, and from the perspective of viewing, it is now a leaf.

Specified by:
nodeCollapsed in interface VTreeExpansionListener
Parameters:
state - the expansion/collapse state of various nodes in the tree.
node - the node which has been collapsed

nodeExpanded

public void nodeExpanded(VTreeExpansionState state,
                         javax.swing.tree.TreeNode node)
Description copied from interface: VTreeExpansionListener
Notification that a node has expanded, and from the perspective of viewing, all its children will be displayed.

Specified by:
nodeExpanded in interface VTreeExpansionListener
Parameters:
state - the expansion/collapse state of various nodes in the tree.
node - the node which has been expanded.

nodeAdded

public void nodeAdded(VTreeSelectionModel model,
                      javax.swing.tree.TreeNode node)
Specified by:
nodeAdded in interface VTreeSelectionListener

nodeRemoved

public void nodeRemoved(VTreeSelectionModel model,
                        javax.swing.tree.TreeNode node)
Specified by:
nodeRemoved in interface VTreeSelectionListener

selectionCleared

public void selectionCleared(VTreeSelectionModel model)
Specified by:
selectionCleared in interface VTreeSelectionListener

selectionInterpretationChanged

public void selectionInterpretationChanged(VTreeSelectionModel model,
                                           int oldInterpretation)
Specified by:
selectionInterpretationChanged in interface VTreeSelectionListener

selectionModeChanged

public void selectionModeChanged(VTreeSelectionModel model,
                                 int oldMode)
Specified by:
selectionModeChanged in interface VTreeSelectionListener

rootChanged

public void rootChanged(javax.swing.tree.TreeNode newRoot,
                        javax.swing.tree.TreeNode oldRoot)
Specified by:
rootChanged in interface TreeMutationListener