|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnextapp.echo.AbstractComponent
nextapp.echo.Label
echopoint.tree.DefaultTreeCellRenderer
public class DefaultTreeCellRenderer
Used to display an entry in a tree. If the tree cell value is a DefaultMutableTreeNode and its user object is a Component then the DefaultTreeCellRenderer will return null on getTreeCellRenderText and return the Component in getTreeCellRendererComponent.
Otherwise it will "cast" the cell value to a String via toString() and return a Label via the getTreeCellRenderText method. It uses the Tree's TreeIcon object to obtain an icon for "parent" and "leaf" nodes.
You can derived your own TreeCellRenderer
class from this one and
specify your own icons for each node if you wish.
Note that this class also has Style support so you can set appearance attributes via a Style object or the EchoPoint CSS support.
Nested Class Summary | |
---|---|
static class |
DefaultTreeCellRenderer.NestedStyleInfo
Nested public static StyleInfo class. |
Field Summary | |
---|---|
static java.lang.String |
STYLE_BACKGROUND_NON_SELECTION_COLOR
A style constant for the Background Non Selection Color property. |
static java.lang.String |
STYLE_BACKGROUND_SELECTION_COLOR
A style constant for the Background Selection Color property. |
static java.lang.String |
STYLE_TEXT_NON_SELECTION_COLOR
A style constant for the Text Non Selection Color property. |
static java.lang.String |
STYLE_TEXT_SELECTION_COLOR
A style constant for the Text Selection Color property. |
Constructor Summary | |
---|---|
DefaultTreeCellRenderer()
Creates a new instance of DefaultTreeCellRenderer. |
Method Summary | |
---|---|
void |
applyStyle(Style style)
Sets stylistic properties of this component based on a Style
object. |
Color |
getBackgroundNonSelectionColor()
Returns the background color to be used for non selected nodes. |
Color |
getBackgroundSelectionColor()
Returns the color to use for the background if node is selected. |
Color |
getTextNonSelectionColor()
Returns the color the text is drawn with when the node isn't selected. |
Color |
getTextSelectionColor()
Returns the color the text is drawn with when the node is selected. |
Component |
getTreeCellRendererComponent(Tree tree,
java.lang.Object node,
boolean selected,
boolean expanded,
boolean leaf)
If the value is a Component then it will be returned as is, otherwise it returns null. |
Label |
getTreeCellRendererText(Tree tree,
java.lang.Object node,
boolean sel,
boolean expanded,
boolean leaf)
Configures the renderer based on the passed in parameters. |
java.lang.Object |
set(java.lang.reflect.Field field,
java.lang.Object newValue)
Called to save the old value of a field, set in a new value and return the old value of a field. |
void |
setBackgroundNonSelectionColor(Color newColor)
Sets the background color to be used for non selected nodes. |
void |
setBackgroundSelectionColor(Color newColor)
Sets the color to use for the background if node is selected. |
void |
setTextNonSelectionColor(Color newColor)
Sets the color the text is drawn with when the node isn't selected. |
void |
setTextSelectionColor(Color newColor)
Sets the color the text is drawn with when the node is selected. |
Methods inherited from class nextapp.echo.Label |
---|
getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextMargin, getText, getVerticalAlignment, getVerticalTextPosition, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextMargin, setText, setVerticalAlignment, setVerticalTextPosition |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String STYLE_BACKGROUND_NON_SELECTION_COLOR
nextapp.echo.Color.
public static final java.lang.String STYLE_BACKGROUND_SELECTION_COLOR
nextapp.echo.Color.
public static final java.lang.String STYLE_TEXT_NON_SELECTION_COLOR
nextapp.echo.Color.
public static final java.lang.String STYLE_TEXT_SELECTION_COLOR
nextapp.echo.Color.
Constructor Detail |
---|
public DefaultTreeCellRenderer()
Method Detail |
---|
public void applyStyle(Style style)
Component
Style
object. The version of this method in Component
will set
foreground and background colors and the font from the style if they are
present. Components should override this method if they allow more
properties to be set from a style object, and should call
super.applyStyle() if necessary.
applyStyle
in interface Component
applyStyle
in class Label
style
- The style object from which to retrieve properties for this
Component
.Component.applyStyle(nextapp.echo.Style)
public Color getBackgroundNonSelectionColor()
public Color getBackgroundSelectionColor()
public Color getTextNonSelectionColor()
public Color getTextSelectionColor()
public Component getTreeCellRendererComponent(Tree tree, java.lang.Object node, boolean selected, boolean expanded, boolean leaf)
getTreeCellRendererComponent
in interface TreeCellRenderer
public Label getTreeCellRendererText(Tree tree, java.lang.Object node, boolean sel, boolean expanded, boolean leaf)
leaf
and expanded
.
The same Label object is returned for each call to this method. The Tree rendering code uses only the public properties of the return Label. In fact since DefaultTreeCellRenderer is derived from Label it simply returns itself.
getTreeCellRendererText
in interface TreeCellRenderer
public void setBackgroundNonSelectionColor(Color newColor)
public void setBackgroundSelectionColor(Color newColor)
public void setTextNonSelectionColor(Color newColor)
public void setTextSelectionColor(Color newColor)
public java.lang.Object set(java.lang.reflect.Field field, java.lang.Object newValue) throws java.lang.Exception
ReflectionSetter
public Object set(Field f, Object newValue) throws Exception { Object oldValue = f.get(this); f.set(this,newValue); return oldValue; }
set
in interface ReflectionSetter
field
- - the field to be setnewValue
- - the new value to be set
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.NullPointerException
java.lang.Exception
ReflectionSetter.set(Field, Object)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |