J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 1997-1998 Sun Microsystems, Inc. All Rights Reserved. |
| 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 |
| 7 | * published by the Free Software Foundation. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun in the LICENSE file that accompanied this code. |
| 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 | * |
| 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any questions. |
| 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 | /** |
| 41 | * Returns the Rectangle enclosing the label portion that the |
| 42 | * last item in path will be drawn into. Will return null if |
| 43 | * any component in path is currently valid. |
| 44 | */ |
| 45 | public abstract Rectangle getPathBounds(JTree tree, TreePath path); |
| 46 | |
| 47 | /** |
| 48 | * Returns the path for passed in row. If row is not visible |
| 49 | * null is returned. |
| 50 | */ |
| 51 | public abstract TreePath getPathForRow(JTree tree, int row); |
| 52 | |
| 53 | /** |
| 54 | * Returns the row that the last item identified in path is visible |
| 55 | * at. Will return -1 if any of the elements in path are not |
| 56 | * currently visible. |
| 57 | */ |
| 58 | public abstract int getRowForPath(JTree tree, TreePath path); |
| 59 | |
| 60 | /** |
| 61 | * Returns the number of rows that are being displayed. |
| 62 | */ |
| 63 | public abstract int getRowCount(JTree tree); |
| 64 | |
| 65 | /** |
| 66 | * Returns the path to the node that is closest to x,y. If |
| 67 | * there is nothing currently visible this will return null, otherwise |
| 68 | * it'll always return a valid path. If you need to test if the |
| 69 | * returned object is exactly at x, y you should get the bounds for |
| 70 | * the returned path and test x, y against that. |
| 71 | */ |
| 72 | public abstract TreePath getClosestPathForLocation(JTree tree, int x, |
| 73 | int y); |
| 74 | |
| 75 | /** |
| 76 | * Returns true if the tree is being edited. The item that is being |
| 77 | * edited can be returned by getEditingPath(). |
| 78 | */ |
| 79 | public abstract boolean isEditing(JTree tree); |
| 80 | |
| 81 | /** |
| 82 | * Stops the current editing session. This has no effect if the |
| 83 | * tree isn't being edited. Returns true if the editor allows the |
| 84 | * editing session to stop. |
| 85 | */ |
| 86 | public abstract boolean stopEditing(JTree tree); |
| 87 | |
| 88 | /** |
| 89 | * Cancels the current editing session. This has no effect if the |
| 90 | * tree isn't being edited. Returns true if the editor allows the |
| 91 | * editing session to stop. |
| 92 | */ |
| 93 | public abstract void cancelEditing(JTree tree); |
| 94 | |
| 95 | /** |
| 96 | * Selects the last item in path and tries to edit it. Editing will |
| 97 | * fail if the CellEditor won't allow it for the selected item. |
| 98 | */ |
| 99 | public abstract void startEditingAtPath(JTree tree, TreePath path); |
| 100 | |
| 101 | /** |
| 102 | * Returns the path to the element that is being edited. |
| 103 | */ |
| 104 | public abstract TreePath getEditingPath(JTree tree); |
| 105 | } |