jdk/src/java.desktop/share/classes/javax/swing/plaf/TreeUI.java
author ddehaven
Tue, 19 Aug 2014 10:32:16 -0700
changeset 26037 508779ce6619
parent 26013 jdk/src/share/classes/javax/swing/plaf/TreeUI.java@83b99f14245f
parent 25859 jdk/src/share/classes/javax/swing/plaf/TreeUI.java@3317bb8137f4
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
26013
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
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: 2
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: 2
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: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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.plaf;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.Rectangle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.swing.JTree;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.swing.tree.TreePath;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * Pluggable look and feel interface for JTree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * @author Rob Davis
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * @author Scott Violet
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
public abstract class TreeUI extends ComponentUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    /**
26013
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    41
     * Returns the Rectangle enclosing the label portion that the
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    42
     * last item in path will be drawn into.  Will return null if
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    43
     * any component in path is currently valid.
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    44
     *
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    45
     * @param tree the {@code JTree} for {@code path}
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    46
     * @param path the {@code TreePath} identifying the node
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    47
     * @return the {@code Rectangle} enclosing the label portion that the
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    48
     *         last item in path will be drawn into, {@code null} if any
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    49
     *         component in path is currently valid.
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    50
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    public abstract Rectangle getPathBounds(JTree tree, TreePath path);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    /**
26013
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    54
     * Returns the path for passed in row.  If row is not visible
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    55
     * null is returned.
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    56
     *
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    57
     * @param tree a {@code JTree} object
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    58
     * @param row an integer specifying a row
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    59
     * @return the {@code path} for {@code row} or {@code null} if {@code row}
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    60
     *         is not visible
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    61
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    public abstract TreePath getPathForRow(JTree tree, int row);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    /**
26013
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    65
     * Returns the row that the last item identified in path is visible
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    66
     * at.  Will return -1 if any of the elements in path are not
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    67
     * currently visible.
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    68
     *
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    69
     * @param tree the {@code JTree} for {@code path}
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    70
     * @param path the {@code TreePath} object to look in
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    71
     * @return an integer specifying the row at which the last item
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    72
     *         identified is visible, -1 if any of the elements in
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    73
     *         {@code path} are not currently visible
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    74
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    public abstract int getRowForPath(JTree tree, TreePath path);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
26013
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    78
     * Returns the number of rows that are being displayed.
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    79
     *
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    80
     * @param tree the {@code JTree} for which to count rows
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    81
     * @return an integer specifying the number of row being displayed
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    82
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    public abstract int getRowCount(JTree tree);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    /**
26013
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    86
     * Returns the path to the node that is closest to x,y.  If
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    87
     * there is nothing currently visible this will return null, otherwise
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    88
     * it'll always return a valid path.  If you need to test if the
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    89
     * returned object is exactly at x, y you should get the bounds for
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    90
     * the returned path and test x, y against that.
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    91
     *
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    92
     * @param tree a {@code JTree} object
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    93
     * @param x an integer giving the number of pixels horizontally from the
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    94
     *        left edge of the display area
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    95
     * @param y an integer giving the number of pixels vertically from the top
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    96
     *        of the display area, minus any top margin
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    97
     * @return the {@code TreePath} node closest to {@code x,y} or {@code null}
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    98
     *         if there is nothing currently visible
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
    99
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    public abstract TreePath getClosestPathForLocation(JTree tree, int x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                                                       int y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /**
26013
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   104
     * Returns true if the tree is being edited.  The item that is being
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   105
     * edited can be returned by getEditingPath().
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   106
     *
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   107
     * @param tree a {@code JTree} object
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   108
     * @return true if {@code tree} is being edited
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   109
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public abstract boolean isEditing(JTree tree);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    /**
26013
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   113
     * Stops the current editing session.  This has no effect if the
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   114
     * tree isn't being edited.  Returns true if the editor allows the
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   115
     * editing session to stop.
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   116
     *
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   117
     * @param tree a {@code JTree} object
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   118
     * @return true if the editor allows the editing session to stop
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   119
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    public abstract boolean stopEditing(JTree tree);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /**
26013
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   123
     * Cancels the current editing session. This has no effect if the
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   124
     * tree isn't being edited.
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   125
     *
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   126
     * @param tree a {@code JTree} object
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   127
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    public abstract void cancelEditing(JTree tree);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    /**
26013
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   131
     * Selects the last item in path and tries to edit it.  Editing will
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   132
     * fail if the CellEditor won't allow it for the selected item.
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   133
     *
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   134
     * @param tree the {@code JTree} being edited
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   135
     * @param path the {@code TreePath} to be edited
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   136
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    public abstract void startEditingAtPath(JTree tree, TreePath path);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * Returns the path to the element that is being edited.
26013
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   141
     *
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   142
     * @param tree the {@code JTree} for which to return a path
83b99f14245f 8042284: Add block tags for @return and @param to swing plaf classes
ssides
parents: 5506
diff changeset
   143
     * @return a {@code TreePath} containing the path to {@code tree}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    public abstract TreePath getEditingPath(JTree tree);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
}