net.sf.jtreemap.swing
Class JTreeMap

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by net.sf.jtreemap.swing.JTreeMap
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class JTreeMap
extends javax.swing.JComponent

JComponent who represents each element of a tree in a rectangle of more or less big size according to its importance in the tree.

A tree structure may includes more or less important elements. For example, in a tree structure of files, there can be files of big size. Then it can be interesting to know which repertory is the most important on a hard disk.

Moreover, we can add a code color which makes it possible to introduce new information into the representation of the tree structure.

So, in a JTreeMap, you can see the size and the value of an element in a tree.

See Also:
TreeMapNode, Serialized Form
 

Nested Class Summary
protected  class JTreeMap.HandleMouseClick
          Listener which listens for double click to navigate one level down.
protected  class JTreeMap.HandleMouseMotion
          Listener who define the active leaf and set the tooltip text.
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JTreeMap(TreeMapNode root)
          Constructor of JTreeMap.
JTreeMap(TreeMapNode root, javax.swing.JTree treeView)
          Constructor of JTreeMap.
JTreeMap(TreeMapNode root, SplitStrategy strategy, javax.swing.JTree treeView, java.lang.String weightPrefix, java.lang.String valuePrefix, boolean showWeight)
          Constructor of JTreeMap.
JTreeMap(TreeMapNode root, SplitStrategy strategy, java.lang.String weightPrefix, java.lang.String valuePrefix, boolean showWeight)
          Constructor of JTreeMap.
 
Method Summary
 void calculatePositions()
          calculate the postitions for the displayed root.
 javax.swing.JToolTip createToolTip()
           
protected  void draw(java.awt.Graphics g, TreeMapNode item)
          draw the item.
protected  void drawLabel(java.awt.Graphics g, TreeMapNode item)
          write the label in the middle of the item.
protected  void drawLabels(java.awt.Graphics g, TreeMapNode item)
          Draw all the labels to draw.
 TreeMapNode getActiveLeaf()
          get the active leaf (the one under the mouse).
 ColorProvider getColorProvider()
          get the ColorProvider.
 TreeMapNode getDisplayedRoot()
          get the displayed root.
 TreeMapNode getRoot()
          get the root.
 SplitStrategy getStrategy()
          get the SplitStrategy.
 java.awt.Point getToolTipLocation(java.awt.event.MouseEvent event)
           
 javax.swing.JTree getTreeView()
           
protected  void paintComponent(java.awt.Graphics g)
           
protected  void reveal(java.awt.Graphics g, TreeMapNode item)
          reveal the item.
 void setActiveLeaf(TreeMapNode newActiveLeaf)
          set the active leaf.
 void setBorder(javax.swing.border.Border border)
           
 void setColorProvider(ColorProvider newColorProvider)
          set the ColorProvider.
 void setDisplayedRoot(TreeMapNode newDisplayedRoot)
          set the displayed root.
 void setRoot(TreeMapNode newRoot)
          set the new root.
 void setStrategy(SplitStrategy newStrat)
          set the new strategy.
 void setToolTipBuilder(IToolTipBuilder toolTipBuilder)
          Set the builder of the toolTip.
 void setTreeView(javax.swing.JTree treeView)
           
 void setZoomKeepProportion(boolean keepProportion)
          When you zoom the jTreeMap, you have the choice to keep proportions or not.
 void unzoom()
          Undo the zoom to display the root.
 void zoom(TreeMapNode dest)
          Zoom the JTreeMap to the dest node.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JTreeMap

public JTreeMap(TreeMapNode root)
Constructor of JTreeMap.
The chosen strategy is SplitSquarified.
The chosen color provider is UniqueColorProvider.

Parameters:
root - the root of the tree to display
See Also:
SplitSquarified, UniqueColorProvider

JTreeMap

public JTreeMap(TreeMapNode root,
                javax.swing.JTree treeView)
Constructor of JTreeMap.
The chosen strategy is SplitSquarified.
The chosen color provider is UniqueColorProvider.

Parameters:
root - the root of the tree to display
treeView - The tree representation of the hierarchical data.
See Also:
SplitSquarified, UniqueColorProvider

JTreeMap

public JTreeMap(TreeMapNode root,
                SplitStrategy strategy,
                javax.swing.JTree treeView,
                java.lang.String weightPrefix,
                java.lang.String valuePrefix,
                boolean showWeight)
Constructor of JTreeMap.
The chosen color provider is UniqueColorProvider.

Parameters:
root - the root of the tree to display
strategy - the split strategy
treeView - The tree representation of the hierarchical data.
See Also:
UniqueColorProvider

JTreeMap

public JTreeMap(TreeMapNode root,
                SplitStrategy strategy,
                java.lang.String weightPrefix,
                java.lang.String valuePrefix,
                boolean showWeight)
Constructor of JTreeMap.
The chosen color provider is UniqueColorProvider.

Parameters:
root - the root of the tree to display
strategy - the split strategy
See Also:
UniqueColorProvider
Method Detail

calculatePositions

public void calculatePositions()
calculate the postitions for the displayed root.
The positions of the root must be calculated first.


createToolTip

public javax.swing.JToolTip createToolTip()
Overrides:
createToolTip in class javax.swing.JComponent

draw

protected void draw(java.awt.Graphics g,
                    TreeMapNode item)
draw the item.

Parameters:
g - Graphics where you have to draw
item - item to draw

drawLabel

protected void drawLabel(java.awt.Graphics g,
                         TreeMapNode item)
write the label in the middle of the item.
You have first to define the font of the Graphics.
You may override this method to change the position or the color of the label.

Parameters:
g - Graphics where you have to draw
item - TreeMapNode to draw

drawLabels

protected void drawLabels(java.awt.Graphics g,
                          TreeMapNode item)
Draw all the labels to draw.
You may override this method to draw the labels you want.
For exemples, all the leaves, or all the first level children, or all of them...

Parameters:
g - Graphics where you have to draw
item - TreeMapNode to draw

getActiveLeaf

public TreeMapNode getActiveLeaf()
get the active leaf (the one under the mouse).

Returns:
Returns the activeLeaf.

getColorProvider

public ColorProvider getColorProvider()
get the ColorProvider.

Returns:
the ColorProvider

getDisplayedRoot

public TreeMapNode getDisplayedRoot()
get the displayed root.

This may be not the root of the jTreeMap. After a zoom, the displayed root can be the root of an under-tree.

Returns:
the displayed root

getRoot

public TreeMapNode getRoot()
get the root.

Returns:
the root

getStrategy

public SplitStrategy getStrategy()
get the SplitStrategy.

Returns:
the SplitStrategy

getToolTipLocation

public java.awt.Point getToolTipLocation(java.awt.event.MouseEvent event)
Overrides:
getToolTipLocation in class javax.swing.JComponent

paintComponent

protected void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

reveal

protected void reveal(java.awt.Graphics g,
                      TreeMapNode item)
reveal the item.

Parameters:
g - Graphics where you have to draw
item - TreeMapNode to reveal

setActiveLeaf

public void setActiveLeaf(TreeMapNode newActiveLeaf)
set the active leaf.

Parameters:
newActiveLeaf - the new active leaf

setBorder

public void setBorder(javax.swing.border.Border border)
Overrides:
setBorder in class javax.swing.JComponent

setColorProvider

public void setColorProvider(ColorProvider newColorProvider)
set the ColorProvider.

Parameters:
newColorProvider - the new ColorPorvider

setDisplayedRoot

public void setDisplayedRoot(TreeMapNode newDisplayedRoot)
set the displayed root.

This may be not the root of the jTreeMap. After a zoom, the displayed root can be the root of an under-tree.

Parameters:
newDisplayedRoot - new DiplayedRoot

setRoot

public void setRoot(TreeMapNode newRoot)
set the new root.

Parameters:
newRoot - the new root to set

setStrategy

public void setStrategy(SplitStrategy newStrat)
set the new strategy.

Parameters:
newStrat - the new strategy to set

setToolTipBuilder

public void setToolTipBuilder(IToolTipBuilder toolTipBuilder)
Set the builder of the toolTip.

Parameters:
toolTipBuilder - The toolTipBuilder to set.

setZoomKeepProportion

public void setZoomKeepProportion(boolean keepProportion)
When you zoom the jTreeMap, you have the choice to keep proportions or not.

Parameters:
keepProportion - true if you want to keep proportions, else false

unzoom

public void unzoom()
Undo the zoom to display the root.


zoom

public void zoom(TreeMapNode dest)
Zoom the JTreeMap to the dest node.

Parameters:
dest - node we want to zoom

getTreeView

public javax.swing.JTree getTreeView()

setTreeView

public void setTreeView(javax.swing.JTree treeView)