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-- |
2 | 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 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package javax.swing.plaf; |
|
27 |
||
28 |
import java.awt.Rectangle; |
|
29 |
import javax.swing.JTree; |
|
30 |
import javax.swing.tree.TreePath; |
|
31 |
||
32 |
/** |
|
33 |
* Pluggable look and feel interface for JTree. |
|
34 |
* |
|
35 |
* @author Rob Davis |
|
36 |
* @author Scott Violet |
|
37 |
*/ |
|
38 |
public abstract class TreeUI extends ComponentUI |
|
39 |
{ |
|
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 | 51 |
public abstract Rectangle getPathBounds(JTree tree, TreePath path); |
52 |
||
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 | 62 |
public abstract TreePath getPathForRow(JTree tree, int row); |
63 |
||
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 | 75 |
public abstract int getRowForPath(JTree tree, TreePath path); |
76 |
||
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 | 83 |
public abstract int getRowCount(JTree tree); |
84 |
||
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 | 100 |
public abstract TreePath getClosestPathForLocation(JTree tree, int x, |
101 |
int y); |
|
102 |
||
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 | 110 |
public abstract boolean isEditing(JTree tree); |
111 |
||
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 | 120 |
public abstract boolean stopEditing(JTree tree); |
121 |
||
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 | 128 |
public abstract void cancelEditing(JTree tree); |
129 |
||
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 | 137 |
public abstract void startEditingAtPath(JTree tree, TreePath path); |
138 |
||
139 |
/** |
|
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 | 144 |
*/ |
145 |
public abstract TreePath getEditingPath(JTree tree); |
|
146 |
} |