jdk/src/java.desktop/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java
author chegar
Sun, 17 Aug 2014 15:54:13 +0100
changeset 25859 3317bb8137f4
parent 24495 jdk/src/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java@a5c854a00679
child 32865 f9cb6e427f9e
permissions -rw-r--r--
8054834: Modular Source Code Reviewed-by: alanb, chegar, ihse, mduigou Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 21244
diff changeset
     2
 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2658
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2658
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2658
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2658
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2658
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.swing.tree;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
    28
import java.awt.Color;
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
    29
import java.awt.Component;
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
    30
import java.awt.Dimension;
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
    31
import java.awt.Font;
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
    32
import java.awt.Graphics;
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
    33
import java.awt.Insets;
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
    34
import java.awt.Rectangle;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.swing.plaf.ColorUIResource;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.swing.plaf.FontUIResource;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import javax.swing.plaf.UIResource;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import javax.swing.plaf.basic.BasicGraphicsUtils;
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
    39
import javax.swing.Icon;
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
    40
import javax.swing.JLabel;
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
    41
import javax.swing.JTree;
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
    42
import javax.swing.LookAndFeel;
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
    43
import javax.swing.UIManager;
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
    44
import javax.swing.border.EmptyBorder;
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
    45
import sun.swing.DefaultLookup;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * Displays an entry in a tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <code>DefaultTreeCellRenderer</code> is not opaque and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * unless you subclass paint you should not change this.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * See <a
20455
f6f9a0c2796b 8020688: Broken links in documentation at http://docs.oracle.com/javase/6/docs/api/index.
mcherkas
parents: 20169
diff changeset
    52
 href="http://docs.oracle.com/javase/tutorial/uiswing/components/tree.html">How to Use Trees</a>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * in <em>The Java Tutorial</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * for examples of customizing node display using this class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * The set of icons and colors used by {@code DefaultTreeCellRenderer}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * can be configured using the various setter methods. The value for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * each property is initialized from the defaults table. When the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * look and feel changes ({@code updateUI} is invoked), any properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * that have a value of type {@code UIResource} are refreshed from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * defaults table. The following table lists the mapping between
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * {@code DefaultTreeCellRenderer} property and defaults table key:
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 11812
diff changeset
    63
 * <table border="1" cellpadding="1" cellspacing="0" summary="">
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *   <tr valign="top"  align="left">
21244
7c2ac5ca05a2 8026021: more fix of javadoc errors and warnings reported by doclint, see the description
cl
parents: 20458
diff changeset
    65
 *     <th style="background-color:#CCCCFF" align="left">Property:
7c2ac5ca05a2 8026021: more fix of javadoc errors and warnings reported by doclint, see the description
cl
parents: 20458
diff changeset
    66
 *     <th style="background-color:#CCCCFF" align="left">Key:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *   <tr><td>"leafIcon"<td>"Tree.leafIcon"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *   <tr><td>"closedIcon"<td>"Tree.closedIcon"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *   <tr><td>"openIcon"<td>"Tree.openIcon"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *   <tr><td>"textSelectionColor"<td>"Tree.selectionForeground"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *   <tr><td>"textNonSelectionColor"<td>"Tree.textForeground"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *   <tr><td>"backgroundSelectionColor"<td>"Tree.selectionBackground"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *   <tr><td>"backgroundNonSelectionColor"<td>"Tree.textBackground"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *   <tr><td>"borderSelectionColor"<td>"Tree.selectionBorderColor"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * <strong><a name="override">Implementation Note:</a></strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * This class overrides
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * <code>invalidate</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * <code>validate</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * <code>revalidate</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * <code>repaint</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * <code>firePropertyChange</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * solely to improve performance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * If not overridden, these frequently called methods would execute code paths
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * that are unnecessary for the default tree cell renderer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * If you write your own renderer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * take care to weigh the benefits and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * drawbacks of overriding these methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * the same version of Swing.  As of 1.4, support for long term storage
20458
f2423fb3fd19 8025840: Fix all the doclint warnings about trademark
cl
parents: 20455
diff changeset
    98
 * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * @author Rob Davis
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * @author Ray Ryan
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * @author Scott Violet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 */
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 21244
diff changeset
   106
@SuppressWarnings("serial") // Same-version serialization only
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    /** Last tree the renderer was painted in. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    private JTree tree;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    /** Is the value currently selected. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    protected boolean selected;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /** True if has focus. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    protected boolean hasFocus;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /** True if draws focus border around icon as well. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    private boolean drawsFocusBorderAroundIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    /** If true, a dashed line is drawn as the focus indicator. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    private boolean drawDashedFocusIndicator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    // If drawDashedFocusIndicator is true, the following are used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * Background color of the tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    private Color treeBGColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * Color to draw the focus indicator in, determined from the background.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    private Color focusBGColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    // Icons
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /** Icon used to show non-leaf nodes that aren't expanded. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    transient protected Icon closedIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    /** Icon used to show leaf nodes. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    transient protected Icon leafIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    /** Icon used to show non-leaf nodes that are expanded. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    transient protected Icon openIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    // Colors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    /** Color to use for the foreground for selected nodes. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    protected Color textSelectionColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    /** Color to use for the foreground for non-selected nodes. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    protected Color textNonSelectionColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    /** Color to use for the background when a node is selected. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    protected Color backgroundSelectionColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    /** Color to use for the background when the node isn't selected. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    protected Color backgroundNonSelectionColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    /** Color to use for the focus indicator when the node has focus. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    protected Color borderSelectionColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    private boolean isDropCell;
11812
fc06525cb345 7142955: DefaultTreeCellRenderer doesn't honor 'Tree.rendererFillBackground' LAF property
rupashka
parents: 5506
diff changeset
   159
    private boolean fillBackground;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * Set to true after the constructor has run.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    private boolean inited;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * Creates a {@code DefaultTreeCellRenderer}. Icons and text color are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * determined from the {@code UIManager}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    public DefaultTreeCellRenderer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        inited = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @since 1.7
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    public void updateUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        super.updateUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        // To avoid invoking new methods from the constructor, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        // inited field is first checked. If inited is false, the constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        // has not run and there is no point in checking the value. As
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        // all look and feels have a non-null value for these properties,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        // a null value means the developer has specifically set it to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        // null. As such, if the value is null, this does not reset the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        // value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        if (!inited || (getLeafIcon() instanceof UIResource)) {
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   189
            setLeafIcon(DefaultLookup.getIcon(this, ui, "Tree.leafIcon"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        if (!inited || (getClosedIcon() instanceof UIResource)) {
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   192
            setClosedIcon(DefaultLookup.getIcon(this, ui, "Tree.closedIcon"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        }
24154
1c6c9e47c9a0 6612752: Incorrect getOpenIcon() instanceof in the DefaultTreeCellRenderer
alexsch
parents: 22574
diff changeset
   194
        if (!inited || (getOpenIcon() instanceof UIResource)) {
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   195
            setOpenIcon(DefaultLookup.getIcon(this, ui, "Tree.openIcon"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        if (!inited || (getTextSelectionColor() instanceof UIResource)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            setTextSelectionColor(
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   199
                    DefaultLookup.getColor(this, ui, "Tree.selectionForeground"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        if (!inited || (getTextNonSelectionColor() instanceof UIResource)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            setTextNonSelectionColor(
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   203
                    DefaultLookup.getColor(this, ui, "Tree.textForeground"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        if (!inited || (getBackgroundSelectionColor() instanceof UIResource)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            setBackgroundSelectionColor(
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   207
                    DefaultLookup.getColor(this, ui, "Tree.selectionBackground"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        if (!inited ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                (getBackgroundNonSelectionColor() instanceof UIResource)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            setBackgroundNonSelectionColor(
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   212
                    DefaultLookup.getColor(this, ui, "Tree.textBackground"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        if (!inited || (getBorderSelectionColor() instanceof UIResource)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            setBorderSelectionColor(
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   216
                    DefaultLookup.getColor(this, ui, "Tree.selectionBorderColor"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        }
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   218
        drawsFocusBorderAroundIcon = DefaultLookup.getBoolean(
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   219
                this, ui, "Tree.drawsFocusBorderAroundIcon", false);
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   220
        drawDashedFocusIndicator = DefaultLookup.getBoolean(
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   221
                this, ui, "Tree.drawDashedFocusIndicator", false);
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   222
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   223
        fillBackground = DefaultLookup.getBoolean(this, ui, "Tree.rendererFillBackground", true);
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   224
        Insets margins = DefaultLookup.getInsets(this, ui, "Tree.rendererMargins");
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   225
        if (margins != null) {
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   226
            setBorder(new EmptyBorder(margins.top, margins.left,
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   227
                    margins.bottom, margins.right));
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   228
        }
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   229
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   230
        setName("Tree.cellRenderer");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
      * Returns the default icon, for the current laf, that is used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
      * represent non-leaf nodes that are expanded.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   237
      *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   238
      * @return the default icon, for the current laf, that is used to
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   239
      *         represent non-leaf nodes that are expanded.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    public Icon getDefaultOpenIcon() {
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   242
        return DefaultLookup.getIcon(this, ui, "Tree.openIcon");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
      * Returns the default icon, for the current laf, that is used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
      * represent non-leaf nodes that are not expanded.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   248
      *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   249
      * @return the default icon, for the current laf, that is used to
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   250
      *         represent non-leaf nodes that are not expanded.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    public Icon getDefaultClosedIcon() {
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   253
        return DefaultLookup.getIcon(this, ui, "Tree.closedIcon");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
      * Returns the default icon, for the current laf, that is used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
      * represent leaf nodes.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   259
      *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   260
      * @return the default icon, for the current laf, that is used to
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   261
      *         represent leaf nodes.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    public Icon getDefaultLeafIcon() {
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   264
        return DefaultLookup.getIcon(this, ui, "Tree.leafIcon");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
      * Sets the icon used to represent non-leaf nodes that are expanded.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   269
      *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   270
      * @param newIcon the icon to be used for expanded non-leaf nodes
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    public void setOpenIcon(Icon newIcon) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        openIcon = newIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
      * Returns the icon used to represent non-leaf nodes that are expanded.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   278
      *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   279
      * @return the icon used to represent non-leaf nodes that are expanded
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    public Icon getOpenIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        return openIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
      * Sets the icon used to represent non-leaf nodes that are not expanded.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   287
      *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   288
      * @param newIcon the icon to be used for not expanded non-leaf nodes
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    public void setClosedIcon(Icon newIcon) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        closedIcon = newIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
      * Returns the icon used to represent non-leaf nodes that are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
      * expanded.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   297
      *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   298
      * @return the icon used to represent non-leaf nodes that are not
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   299
      *         expanded
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    public Icon getClosedIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        return closedIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
      * Sets the icon used to represent leaf nodes.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   307
      *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   308
      * @param newIcon icon to be used for leaf nodes
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    public void setLeafIcon(Icon newIcon) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        leafIcon = newIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
      * Returns the icon used to represent leaf nodes.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   316
      *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   317
      * @return the icon used to represent leaf nodes
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    public Icon getLeafIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        return leafIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
      * Sets the color the text is drawn with when the node is selected.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   325
      *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   326
      * @param newColor color to be used for text when the node is selected
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    public void setTextSelectionColor(Color newColor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        textSelectionColor = newColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
      * Returns the color the text is drawn with when the node is selected.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   334
      *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   335
      * @return the color the text is drawn with when the node is selected
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    public Color getTextSelectionColor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        return textSelectionColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
      * Sets the color the text is drawn with when the node isn't selected.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   343
      *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   344
      * @param newColor color to be used for text when the node isn't selected
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    public void setTextNonSelectionColor(Color newColor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        textNonSelectionColor = newColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
      * Returns the color the text is drawn with when the node isn't selected.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   352
      *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   353
      * @return the color the text is drawn with when the node isn't selected.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    public Color getTextNonSelectionColor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        return textNonSelectionColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
      * Sets the color to use for the background if node is selected.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   361
      *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   362
      * @param newColor to be used for the background if the node is selected
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    public void setBackgroundSelectionColor(Color newColor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        backgroundSelectionColor = newColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
      * Returns the color to use for the background if node is selected.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   371
      *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   372
      * @return the color to use for the background if node is selected
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    public Color getBackgroundSelectionColor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        return backgroundSelectionColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
      * Sets the background color to be used for non selected nodes.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   380
      *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   381
      * @param newColor color to be used for the background for non selected nodes
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    public void setBackgroundNonSelectionColor(Color newColor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        backgroundNonSelectionColor = newColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
      * Returns the background color to be used for non selected nodes.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   389
      *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   390
      * @return the background color to be used for non selected nodes.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    public Color getBackgroundNonSelectionColor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        return backgroundNonSelectionColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
      * Sets the color to use for the border.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   398
      *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   399
      * @param newColor color to be used for the border
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    public void setBorderSelectionColor(Color newColor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        borderSelectionColor = newColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
      * Returns the color the border is drawn.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   407
      *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 24154
diff changeset
   408
      * @return the color the border is drawn
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    public Color getBorderSelectionColor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        return borderSelectionColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * Subclassed to map <code>FontUIResource</code>s to null. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * <code>font</code> is null, or a <code>FontUIResource</code>, this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * has the effect of letting the font of the JTree show
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * through. On the other hand, if <code>font</code> is non-null, and not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * a <code>FontUIResource</code>, the font becomes <code>font</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    public void setFont(Font font) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        if(font instanceof FontUIResource)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            font = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        super.setFont(font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * Gets the font of this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * @return this component's font; if a font has not been set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * for this component, the font of its parent is returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    public Font getFont() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        Font font = super.getFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        if (font == null && tree != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            // Strive to return a non-null value, otherwise the html support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            // will typically pick up the wrong font in certain situations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            font = tree.getFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        return font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * Subclassed to map <code>ColorUIResource</code>s to null. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * <code>color</code> is null, or a <code>ColorUIResource</code>, this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * has the effect of letting the background color of the JTree show
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * through. On the other hand, if <code>color</code> is non-null, and not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * a <code>ColorUIResource</code>, the background becomes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * <code>color</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    public void setBackground(Color color) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        if(color instanceof ColorUIResource)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            color = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        super.setBackground(color);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
      * Configures the renderer based on the passed in components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
      * The value is set from messaging the tree with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
      * <code>convertValueToText</code>, which ultimately invokes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
      * <code>toString</code> on <code>value</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
      * The foreground color is set based on the selection and the icon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
      * is set based on the <code>leaf</code> and <code>expanded</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
      * parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    public Component getTreeCellRendererComponent(JTree tree, Object value,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                                                  boolean sel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                                                  boolean expanded,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                                                  boolean leaf, int row,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                                                  boolean hasFocus) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        String         stringValue = tree.convertValueToText(value, sel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                                          expanded, leaf, row, hasFocus);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        this.tree = tree;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        this.hasFocus = hasFocus;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        setText(stringValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        Color fg = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        isDropCell = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        JTree.DropLocation dropLocation = tree.getDropLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        if (dropLocation != null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                && dropLocation.getChildIndex() == -1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                && tree.getRowForPath(dropLocation.getPath()) == row) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   486
            Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            if (col != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                fg = col;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                fg = getTextSelectionColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            isDropCell = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        } else if (sel) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            fg = getTextSelectionColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
            fg = getTextNonSelectionColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        setForeground(fg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   502
        Icon icon = null;
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   503
        if (leaf) {
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   504
            icon = getLeafIcon();
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   505
        } else if (expanded) {
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   506
            icon = getOpenIcon();
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   507
        } else {
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   508
            icon = getClosedIcon();
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   509
        }
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   510
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        if (!tree.isEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
            setEnabled(false);
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   513
            LookAndFeel laf = UIManager.getLookAndFeel();
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   514
            Icon disabledIcon = laf.getDisabledIcon(tree, icon);
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   515
            if (disabledIcon != null) icon = disabledIcon;
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   516
            setDisabledIcon(icon);
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   517
        } else {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
            setEnabled(true);
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   519
            setIcon(icon);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        setComponentOrientation(tree.getComponentOrientation());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        selected = sel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
      * Paints the value.  The background is filled based on selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    public void paint(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        Color bColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        if (isDropCell) {
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   535
            bColor = DefaultLookup.getColor(this, ui, "Tree.dropCellBackground");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
            if (bColor == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                bColor = getBackgroundSelectionColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        } else if (selected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
            bColor = getBackgroundSelectionColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
            bColor = getBackgroundNonSelectionColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
            if (bColor == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                bColor = getBackground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        int imageOffset = -1;
2658
43e06bc950ec 6591875: Nimbus Swing Look and Feel
peterz
parents: 2
diff changeset
   549
        if (bColor != null && fillBackground) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
            imageOffset = getLabelStart();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
            g.setColor(bColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
            if(getComponentOrientation().isLeftToRight()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                g.fillRect(imageOffset, 0, getWidth() - imageOffset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
                           getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                g.fillRect(0, 0, getWidth() - imageOffset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                           getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        if (hasFocus) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
            if (drawsFocusBorderAroundIcon) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                imageOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
            else if (imageOffset == -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                imageOffset = getLabelStart();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
            if(getComponentOrientation().isLeftToRight()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                paintFocus(g, imageOffset, 0, getWidth() - imageOffset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                           getHeight(), bColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                paintFocus(g, 0, 0, getWidth() - imageOffset, getHeight(), bColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        super.paint(g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    private void paintFocus(Graphics g, int x, int y, int w, int h, Color notColor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        Color       bsColor = getBorderSelectionColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        if (bsColor != null && (selected || !drawDashedFocusIndicator)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
            g.setColor(bsColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
            g.drawRect(x, y, w - 1, h - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        if (drawDashedFocusIndicator && notColor != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            if (treeBGColor != notColor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                treeBGColor = notColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                focusBGColor = new Color(~notColor.getRGB());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            g.setColor(focusBGColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
            BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    private int getLabelStart() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        Icon currentI = getIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
        if(currentI != null && getText() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
            return currentI.getIconWidth() + Math.max(0, getIconTextGap() - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     * Overrides <code>JComponent.getPreferredSize</code> to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     * return slightly wider preferred size value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
    public Dimension getPreferredSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        Dimension        retDimension = super.getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        if(retDimension != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
            retDimension = new Dimension(retDimension.width + 3,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                                         retDimension.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        return retDimension;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    * Overridden for performance reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    * See the <a href="#override">Implementation Note</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    * for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    public void validate() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    * Overridden for performance reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    * See the <a href="#override">Implementation Note</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    * for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    public void invalidate() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    * Overridden for performance reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    * See the <a href="#override">Implementation Note</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    * for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    public void revalidate() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    * Overridden for performance reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    * See the <a href="#override">Implementation Note</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    * for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    public void repaint(long tm, int x, int y, int width, int height) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    * Overridden for performance reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    * See the <a href="#override">Implementation Note</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
    * for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    public void repaint(Rectangle r) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    * Overridden for performance reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    * See the <a href="#override">Implementation Note</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    * for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    public void repaint() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    * Overridden for performance reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    * See the <a href="#override">Implementation Note</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    * for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        // Strings get interned...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        if (propertyName == "text"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                || ((propertyName == "font" || propertyName == "foreground")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                    && oldValue != newValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
                    && getClientProperty(javax.swing.plaf.basic.BasicHTML.propertyKey) != null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
            super.firePropertyChange(propertyName, oldValue, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    * Overridden for performance reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
    * See the <a href="#override">Implementation Note</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    * for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    public void firePropertyChange(String propertyName, byte oldValue, byte newValue) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
    * Overridden for performance reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
    * See the <a href="#override">Implementation Note</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
    * for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    public void firePropertyChange(String propertyName, char oldValue, char newValue) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    * Overridden for performance reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
    * See the <a href="#override">Implementation Note</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    * for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
    public void firePropertyChange(String propertyName, short oldValue, short newValue) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    * Overridden for performance reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    * See the <a href="#override">Implementation Note</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    * for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    public void firePropertyChange(String propertyName, int oldValue, int newValue) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
    * Overridden for performance reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    * See the <a href="#override">Implementation Note</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
    * for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    public void firePropertyChange(String propertyName, long oldValue, long newValue) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
    * Overridden for performance reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
    * See the <a href="#override">Implementation Note</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    * for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
    public void firePropertyChange(String propertyName, float oldValue, float newValue) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    * Overridden for performance reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    * See the <a href="#override">Implementation Note</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    * for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
    public void firePropertyChange(String propertyName, double oldValue, double newValue) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
    * Overridden for performance reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    * See the <a href="#override">Implementation Note</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    * for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
}