adavid.awt
Class ImageTNodeRenderer

java.lang.Object
  |
  +--adavid.awt.ImageTNodeRenderer

public class ImageTNodeRenderer
extends java.lang.Object
implements TNodeRenderer

default tree renderer, with image


Field Summary
protected static java.awt.Dimension dim
          dimension of the rendered image
static int DIR_ONLY
          the modes
static int FILES_AND_DIR
          the modes
static int FILES_ONLY
          the modes
static ImageTNodeRenderer INSTANCE
          the shared instance of this class ; shared since its only purpose is to draw an image ; I adopt here a weak programming model, namely the icons are assumed not to be modified by a process while the instance is rendering them, or updating the size information.
static java.lang.String path$icons
          the path of the default icons, so that Bundle finds them
static int[] pictx
           
static int[] picty
           
static int SIZE
          constants to draw the triangle
static java.awt.Image TreeLeaf
          the icons to be drawn
static java.awt.Image TreeLeafSelected
          the icons to be drawn
static java.awt.Image TreeNode
           
static java.awt.Image TreeOpen
           
static java.awt.Image TreeOpenSelected
           
static java.awt.Image TreeSelected
           
 
Constructor Summary
protected ImageTNodeRenderer()
          protected in order not to be called directly and still allow extension
  ImageTNodeRenderer(int mode)
          and a configurable renderer
 
Method Summary
 int getHeight()
          the dimension taken by the rendered image and triangle ; updateDim() is assumed to be called before ; has to be done explicitely if one changes one icon
 int getWidth()
           
static void lookDim(java.awt.Image img, java.awt.Dimension checkDim)
          update the dimension if the needed size is bigger than this dimension
 void paint(TNode c, java.awt.Graphics g, boolean isExpanded, boolean isSelected, boolean isLeaf)
          we render the node here: draw the icon and the triangle note that the TNode chooses the color of the triangle
static void updateDim()
          update the size information of the icons
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final ImageTNodeRenderer INSTANCE
the shared instance of this class ; shared since its only purpose is to draw an image ; I adopt here a weak programming model, namely the icons are assumed not to be modified by a process while the instance is rendering them, or updating the size information. The icons should be set before. If this is not the case, it is easy to extend this class and use a "synchronized(..)" on the instance, which can serve as a lock, and use the methods of this class

FILES_AND_DIR

public static int FILES_AND_DIR
the modes

FILES_ONLY

public static int FILES_ONLY
the modes

DIR_ONLY

public static int DIR_ONLY
the modes

SIZE

public static final int SIZE
constants to draw the triangle

pictx

public static final int[] pictx

picty

public static final int[] picty

dim

protected static java.awt.Dimension dim
dimension of the rendered image

path$icons

public static java.lang.String path$icons
the path of the default icons, so that Bundle finds them

TreeLeaf

public static java.awt.Image TreeLeaf
the icons to be drawn

TreeLeafSelected

public static java.awt.Image TreeLeafSelected
the icons to be drawn

TreeNode

public static java.awt.Image TreeNode

TreeSelected

public static java.awt.Image TreeSelected

TreeOpen

public static java.awt.Image TreeOpen

TreeOpenSelected

public static java.awt.Image TreeOpenSelected
Constructor Detail

ImageTNodeRenderer

protected ImageTNodeRenderer()
protected in order not to be called directly and still allow extension

ImageTNodeRenderer

public ImageTNodeRenderer(int mode)
and a configurable renderer
Method Detail

updateDim

public static void updateDim()
update the size information of the icons

lookDim

public static void lookDim(java.awt.Image img,
                           java.awt.Dimension checkDim)
update the dimension if the needed size is bigger than this dimension

paint

public void paint(TNode c,
                  java.awt.Graphics g,
                  boolean isExpanded,
                  boolean isSelected,
                  boolean isLeaf)
we render the node here: draw the icon and the triangle note that the TNode chooses the color of the triangle
Specified by:
paint in interface TNodeRenderer
Tags copied from interface: TNodeRenderer
Parameters:
node - the node to be repainted
g - Graphics object to repaint the node
expanded - state of the node
selected - state of the node
leaf - nature of the node

getHeight

public int getHeight()
the dimension taken by the rendered image and triangle ; updateDim() is assumed to be called before ; has to be done explicitely if one changes one icon
Specified by:
getHeight in interface TNodeRenderer
Tags copied from interface: TNodeRenderer
Returns:
the height of the painted zone, icon or whatever, not the whole tree node!

getWidth

public int getWidth()
Specified by:
getWidth in interface TNodeRenderer
Tags copied from interface: TNodeRenderer
Returns:
the width of the painted zone, icon or whatever, not the whole tree node!