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