fri.gui.swing.polytreetable
Class TreeIndentIcon

java.lang.Object
  |
  +--fri.gui.swing.polytreetable.TreeIndentIcon
All Implemented Interfaces:
javax.swing.Icon

public class TreeIndentIcon
extends java.lang.Object
implements javax.swing.Icon

Paint icons to render a tree expand control, a leaf/folder the tree level indent. It can be used for children (left indent) and parents (right indent).

Author:
Ritzberger Fritz
See Also:
PolyTreeTableCellRenderer

Field Summary
static int ICON_GAP
           
 
Constructor Summary
TreeIndentIcon()
          Create an Icon that must be set by setObject from another TreeIndentIcon.
TreeIndentIcon(javax.swing.Icon one, javax.swing.Icon two, int indent, boolean leftIndent)
          Create an Icon that renders two other Icons and indents them from left or right by a fixed offset.
 
Method Summary
 int getIconHeight()
          Returns Math.max() of both Icons.
 int getIconWidth()
          Returns width of both Icons plus indent + TreeIndentIcon.ICON_GAP.
 void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
          Delegates to both Icons and indents them.
 void setIndent(int indent)
          Set the indent for a specific tree level.
 void setObject(TreeIndentIcon icon)
          Set the values of this icon to another.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ICON_GAP

public static int ICON_GAP
Constructor Detail

TreeIndentIcon

public TreeIndentIcon()
Create an Icon that must be set by setObject from another TreeIndentIcon.


TreeIndentIcon

public TreeIndentIcon(javax.swing.Icon one,
                      javax.swing.Icon two,
                      int indent,
                      boolean leftIndent)
Create an Icon that renders two other Icons and indents them from left or right by a fixed offset.

Parameters:
one - left Icon (expand control), can be null
two - right Icon (folder icon), can be null
indent - pixel offset to the left or rigth of both Icons
leftIndent - true if it is a left indent, else false
Method Detail

setIndent

public void setIndent(int indent)
Set the indent for a specific tree level.


getIconHeight

public int getIconHeight()
Returns Math.max() of both Icons.

Specified by:
getIconHeight in interface javax.swing.Icon

getIconWidth

public int getIconWidth()
Returns width of both Icons plus indent + TreeIndentIcon.ICON_GAP.

Specified by:
getIconWidth in interface javax.swing.Icon

paintIcon

public void paintIcon(java.awt.Component c,
                      java.awt.Graphics g,
                      int x,
                      int y)
Delegates to both Icons and indents them.

Specified by:
paintIcon in interface javax.swing.Icon

setObject

public void setObject(TreeIndentIcon icon)
Set the values of this icon to another. This is needed for the CellEditor to remember its values without creating a new icon, as the renderers icon could paint before the editor icon.