| Method from javax.swing.tree.DefaultTreeCellRenderer Detail: |
protected void firePropertyChange(String propertyName,
Object oldValue,
Object newValue) {
// Strings get interned...
if (propertyName == "text"
|| ((propertyName == "font" || propertyName == "foreground")
&& oldValue != newValue
&& getClientProperty(javax.swing.plaf.basic.BasicHTML.propertyKey) != null)) {
super.firePropertyChange(propertyName, oldValue, newValue);
}
}
|
public void firePropertyChange(String propertyName,
byte oldValue,
byte newValue) {
}
|
public void firePropertyChange(String propertyName,
char oldValue,
char newValue) {
}
|
public void firePropertyChange(String propertyName,
short oldValue,
short newValue) {
}
|
public void firePropertyChange(String propertyName,
int oldValue,
int newValue) {
}
|
public void firePropertyChange(String propertyName,
long oldValue,
long newValue) {
}
|
public void firePropertyChange(String propertyName,
float oldValue,
float newValue) {
}
|
public void firePropertyChange(String propertyName,
double oldValue,
double newValue) {
}
|
public void firePropertyChange(String propertyName,
boolean oldValue,
boolean newValue) {
}
|
public Color getBackgroundNonSelectionColor() {
return backgroundNonSelectionColor;
}
Returns the background color to be used for non selected nodes. |
public Color getBackgroundSelectionColor() {
return backgroundSelectionColor;
}
Returns the color to use for the background if node is selected. |
public Color getBorderSelectionColor() {
return borderSelectionColor;
}
Returns the color the border is drawn. |
public Icon getClosedIcon() {
return closedIcon;
}
Returns the icon used to represent non-leaf nodes that are not
expanded. |
public Icon getDefaultClosedIcon() {
return UIManager.getIcon("Tree.closedIcon");
}
Returns the default icon, for the current laf, that is used to
represent non-leaf nodes that are not expanded. |
public Icon getDefaultLeafIcon() {
return UIManager.getIcon("Tree.leafIcon");
}
Returns the default icon, for the current laf, that is used to
represent leaf nodes. |
public Icon getDefaultOpenIcon() {
return UIManager.getIcon("Tree.openIcon");
}
Returns the default icon, for the current laf, that is used to
represent non-leaf nodes that are expanded. |
public Font getFont() {
Font font = super.getFont();
if (font == null && tree != null) {
// Strive to return a non-null value, otherwise the html support
// will typically pick up the wrong font in certain situations.
font = tree.getFont();
}
return font;
}
Gets the font of this component. |
public Icon getLeafIcon() {
return leafIcon;
}
Returns the icon used to represent leaf nodes. |
public Icon getOpenIcon() {
return openIcon;
}
Returns the icon used to represent non-leaf nodes that are expanded. |
public Dimension getPreferredSize() {
Dimension retDimension = super.getPreferredSize();
if(retDimension != null)
retDimension = new Dimension(retDimension.width + 3,
retDimension.height);
return retDimension;
}
Overrides JComponent.getPreferredSize to
return slightly wider preferred size value. |
public Color getTextNonSelectionColor() {
return textNonSelectionColor;
}
Returns the color the text is drawn with when the node isn't selected. |
public Color getTextSelectionColor() {
return textSelectionColor;
}
Returns the color the text is drawn with when the node is selected. |
public Component getTreeCellRendererComponent(JTree tree,
Object value,
boolean sel,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus) {
String stringValue = tree.convertValueToText(value, sel,
expanded, leaf, row, hasFocus);
this.tree = tree;
this.hasFocus = hasFocus;
setText(stringValue);
Color fg = null;
isDropCell = false;
JTree.DropLocation dropLocation = tree.getDropLocation();
if (dropLocation != null
&& dropLocation.getChildIndex() == -1
&& tree.getRowForPath(dropLocation.getPath()) == row) {
Color col = UIManager.getColor("Tree.dropCellForeground");
if (col != null) {
fg = col;
} else {
fg = getTextSelectionColor();
}
isDropCell = true;
} else if (sel) {
fg = getTextSelectionColor();
} else {
fg = getTextNonSelectionColor();
}
setForeground(fg);
// There needs to be a way to specify disabled icons.
if (!tree.isEnabled()) {
setEnabled(false);
if (leaf) {
setDisabledIcon(getLeafIcon());
} else if (expanded) {
setDisabledIcon(getOpenIcon());
} else {
setDisabledIcon(getClosedIcon());
}
}
else {
setEnabled(true);
if (leaf) {
setIcon(getLeafIcon());
} else if (expanded) {
setIcon(getOpenIcon());
} else {
setIcon(getClosedIcon());
}
}
setComponentOrientation(tree.getComponentOrientation());
selected = sel;
return this;
}
Configures the renderer based on the passed in components.
The value is set from messaging the tree with
convertValueToText, which ultimately invokes
toString on value.
The foreground color is set based on the selection and the icon
is set based on the leaf and expanded
parameters. |
public void invalidate() {
}
|
public void paint(Graphics g) {
Color bColor;
if (isDropCell) {
bColor = UIManager.getColor("Tree.dropCellBackground");
if (bColor == null) {
bColor = getBackgroundSelectionColor();
}
} else if (selected) {
bColor = getBackgroundSelectionColor();
} else {
bColor = getBackgroundNonSelectionColor();
if (bColor == null) {
bColor = getBackground();
}
}
int imageOffset = -1;
if(bColor != null) {
Icon currentI = getIcon();
imageOffset = getLabelStart();
g.setColor(bColor);
if(getComponentOrientation().isLeftToRight()) {
g.fillRect(imageOffset, 0, getWidth() - imageOffset,
getHeight());
} else {
g.fillRect(0, 0, getWidth() - imageOffset,
getHeight());
}
}
if (hasFocus) {
if (drawsFocusBorderAroundIcon) {
imageOffset = 0;
}
else if (imageOffset == -1) {
imageOffset = getLabelStart();
}
if(getComponentOrientation().isLeftToRight()) {
paintFocus(g, imageOffset, 0, getWidth() - imageOffset,
getHeight(), bColor);
} else {
paintFocus(g, 0, 0, getWidth() - imageOffset, getHeight(), bColor);
}
}
super.paint(g);
}
Paints the value. The background is filled based on selected. |
public void repaint() {
}
|
public void repaint(Rectangle r) {
}
|
public void repaint(long tm,
int x,
int y,
int width,
int height) {
}
|
public void revalidate() {
}
|
public void setBackground(Color color) {
if(color instanceof ColorUIResource)
color = null;
super.setBackground(color);
}
Subclassed to map ColorUIResources to null. If
color is null, or a ColorUIResource, this
has the effect of letting the background color of the JTree show
through. On the other hand, if color is non-null, and not
a ColorUIResource, the background becomes
color. |
public void setBackgroundNonSelectionColor(Color newColor) {
backgroundNonSelectionColor = newColor;
}
Sets the background color to be used for non selected nodes. |
public void setBackgroundSelectionColor(Color newColor) {
backgroundSelectionColor = newColor;
}
Sets the color to use for the background if node is selected. |
public void setBorderSelectionColor(Color newColor) {
borderSelectionColor = newColor;
}
Sets the color to use for the border. |
public void setClosedIcon(Icon newIcon) {
closedIcon = newIcon;
}
Sets the icon used to represent non-leaf nodes that are not expanded. |
public void setFont(Font font) {
if(font instanceof FontUIResource)
font = null;
super.setFont(font);
}
Subclassed to map FontUIResources to null. If
font is null, or a FontUIResource, this
has the effect of letting the font of the JTree show
through. On the other hand, if font is non-null, and not
a FontUIResource, the font becomes font. |
public void setLeafIcon(Icon newIcon) {
leafIcon = newIcon;
}
Sets the icon used to represent leaf nodes. |
public void setOpenIcon(Icon newIcon) {
openIcon = newIcon;
}
Sets the icon used to represent non-leaf nodes that are expanded. |
public void setTextNonSelectionColor(Color newColor) {
textNonSelectionColor = newColor;
}
Sets the color the text is drawn with when the node isn't selected. |
public void setTextSelectionColor(Color newColor) {
textSelectionColor = newColor;
}
Sets the color the text is drawn with when the node is selected. |
public void updateUI() {
super.updateUI();
// To avoid invoking new methods from the constructor, the
// inited field is first checked. If inited is false, the constructor
// has not run and there is no point in checking the value. As
// all look and feels have a non-null value for these properties,
// a null value means the developer has specifically set it to
// null. As such, if the value is null, this does not reset the
// value.
if (!inited || (getLeafIcon() instanceof UIResource)) {
setLeafIcon(UIManager.getIcon("Tree.leafIcon"));
}
if (!inited || (getClosedIcon() instanceof UIResource)) {
setClosedIcon(UIManager.getIcon("Tree.closedIcon"));
}
if (!inited || (getOpenIcon() instanceof UIManager)) {
setOpenIcon(UIManager.getIcon("Tree.openIcon"));
}
if (!inited || (getTextSelectionColor() instanceof UIResource)) {
setTextSelectionColor(
UIManager.getColor("Tree.selectionForeground"));
}
if (!inited || (getTextNonSelectionColor() instanceof UIResource)) {
setTextNonSelectionColor(
UIManager.getColor("Tree.textForeground"));
}
if (!inited || (getBackgroundSelectionColor() instanceof UIResource)) {
setBackgroundSelectionColor(
UIManager.getColor("Tree.selectionBackground"));
}
if (!inited ||
(getBackgroundNonSelectionColor() instanceof UIResource)) {
setBackgroundNonSelectionColor(
UIManager.getColor("Tree.textBackground"));
}
if (!inited || (getBorderSelectionColor() instanceof UIResource)) {
setBorderSelectionColor(
UIManager.getColor("Tree.selectionBorderColor"));
}
Object value = UIManager.get("Tree.drawsFocusBorderAroundIcon");
drawsFocusBorderAroundIcon = (value != null && ((Boolean)value).
booleanValue());
value = UIManager.get("Tree.drawDashedFocusIndicator");
drawDashedFocusIndicator = (value != null && ((Boolean)value).
booleanValue());
}
|
public void validate() {
}
|