net.sf.jtreemap.ktreemap
Class KTreeMap

java.lang.Object
  extended by org.eclipse.swt.widgets.Widget
      extended by org.eclipse.swt.widgets.Control
          extended by org.eclipse.swt.widgets.Scrollable
              extended by org.eclipse.swt.widgets.Composite
                  extended by org.eclipse.swt.widgets.Canvas
                      extended by net.sf.jtreemap.ktreemap.KTreeMap
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable

public class KTreeMap
extends org.eclipse.swt.widgets.Canvas

Widget 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 KTreeMap, you can see the size and the value of an element in a tree.

See Also:
TreeMapNode
 

Nested Class Summary
protected  class KTreeMap.HandleMouseMotion
          Listener who define the active leaf and set the tooltip text.
 
Field Summary
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
KTreeMap(org.eclipse.swt.widgets.Composite parent, int style, TreeMapNode root)
          Constructor of JTreeMap.
KTreeMap(org.eclipse.swt.widgets.Composite parent, int style, TreeMapNode root, SplitStrategy strategy)
          Constructor of JTreeMap.
 
Method Summary
 void calculatePositions()
          calculate the postitions for the displayed root.
 void dispose()
           
protected  void draw(org.eclipse.swt.graphics.GC gc, TreeMapNode item)
          draw the item.
protected  void drawLabel(org.eclipse.swt.graphics.GC gc, TreeMapNode item)
          write the label in the middle of the item.
protected  void drawLabels(org.eclipse.swt.graphics.GC gc, TreeMapNode item)
          Draw all the labels to draw.
 TreeMapNode getActiveLeaf()
          get the active leaf (the one under the mouse).
 ITreeMapColorProvider getColorProvider()
           
 org.eclipse.swt.graphics.Point getCursorPosition()
           
 TreeMapNode getDisplayedRoot()
          get the displayed root.
 TreeMapNode getRoot()
          get the root.
 SplitStrategy getStrategy()
          get the SplitStrategy.
 ITreeMapProvider getTreeMapProvider()
          get the IColorLabelProvider.
protected  void reveal(org.eclipse.swt.graphics.GC gc, TreeMapNode item)
          reveal the item.
 void setActiveLeaf(TreeMapNode newActiveLeaf)
          set the active leaf.
 void setColorProvider(ITreeMapColorProvider 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 setTreeMapProvider(ITreeMapProvider newColorProvider)
          set the ColorProvider.
 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 org.eclipse.swt.widgets.Canvas
drawBackground, getCaret, scroll, setCaret, setFont
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, computeSize, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KTreeMap

public KTreeMap(org.eclipse.swt.widgets.Composite parent,
                int style,
                TreeMapNode root)
Constructor of JTreeMap.
The chosen strategy is SplitSquarified.

Parameters:
parent - parent Composite
style - style
root - the root of the tree to display
See Also:
SplitSquarified

KTreeMap

public KTreeMap(org.eclipse.swt.widgets.Composite parent,
                int style,
                TreeMapNode root,
                SplitStrategy strategy)
Constructor of JTreeMap.
The chosen color provider is UniqueColorProvider.

Parameters:
parent - parent Composite
style - style
root - the root of the tree to display
strategy - the split strategy
Method Detail

calculatePositions

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


dispose

public void dispose()
Overrides:
dispose in class org.eclipse.swt.widgets.Widget

getActiveLeaf

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

Returns:
Returns the activeLeaf.

getColorProvider

public ITreeMapColorProvider getColorProvider()
Returns:
the colorProvider

getCursorPosition

public org.eclipse.swt.graphics.Point getCursorPosition()
Returns:
the cursorPosition

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

getTreeMapProvider

public ITreeMapProvider getTreeMapProvider()
get the IColorLabelProvider.

Returns:
the IColorLabelProvider

setActiveLeaf

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

Parameters:
newActiveLeaf - the new active leaf

setColorProvider

public void setColorProvider(ITreeMapColorProvider colorProvider)
Parameters:
colorProvider - the colorProvider to set

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

setTreeMapProvider

public void setTreeMapProvider(ITreeMapProvider newColorProvider)
set the ColorProvider.

Parameters:
newColorProvider - the new ColorPorvider

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

draw

protected void draw(org.eclipse.swt.graphics.GC gc,
                    TreeMapNode item)
draw the item.

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

drawLabel

protected void drawLabel(org.eclipse.swt.graphics.GC gc,
                         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:
gc - Graphics where you have to draw
item - TreeMapNode to draw

drawLabels

protected void drawLabels(org.eclipse.swt.graphics.GC gc,
                          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:
gc - Graphics where you have to draw
item - TreeMapNode to draw

reveal

protected void reveal(org.eclipse.swt.graphics.GC gc,
                      TreeMapNode item)
reveal the item.

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