Imported GNU Classpath 0.90
[official-gcc.git] / libjava / classpath / javax / swing / plaf / metal / MetalTreeUI.java
blob3ea37c82f18aeedad793967fd7034e795c08ca77
1 /* MetalTreeUI.java
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax.swing.plaf.metal;
41 import gnu.classpath.NotImplementedException;
43 import java.awt.Graphics;
44 import java.awt.Insets;
45 import java.awt.Rectangle;
47 import javax.swing.JComponent;
48 import javax.swing.JTree;
49 import javax.swing.tree.TreePath;
50 import javax.swing.plaf.ComponentUI;
51 import javax.swing.plaf.basic.BasicTreeUI;
53 /**
54 * A UI delegate for the {@link JTree} component.
56 public class MetalTreeUI extends BasicTreeUI
58 /**
59 * Constructs a new instance of <code>MetalTreeUI</code>.
61 public MetalTreeUI()
63 super();
66 /**
67 * Returns a new instance of <code>MetalTreeUI</code>.
69 * @param component the component for which we return an UI instance
71 * @return A new instance of <code>MetalTreeUI</code>.
73 public static ComponentUI createUI(JComponent component)
75 return new MetalTreeUI();
78 /**
79 * The horizontal element of legs between nodes starts at the right of the
80 * left-hand side of the child node by default. This method makes the
81 * leg end before that.
83 protected int getHorizontalLegBuffer()
85 return super.getHorizontalLegBuffer();
88 /**
89 * Configures the specified component appropriate for the look and feel.
90 * This method is invoked when the ComponentUI instance is being installed
91 * as the UI delegate on the specified component. This method should completely
92 * configure the component for the look and feel, including the following:
93 * 1. Install any default property values for color, fonts, borders, icons,
94 * opacity, etc. on the component. Whenever possible, property values
95 * initialized by the client program should not be overridden.
96 * 2. Install a LayoutManager on the component if necessary.
97 * 3. Create/add any required sub-components to the component.
98 * 4. Create/install event listeners on the component.
99 * 5. Create/install a PropertyChangeListener on the component in order
100 * to detect and respond to component property changes appropriately.
101 * 6. Install keyboard UI (mnemonics, traversal, etc.) on the component.
102 * 7. Initialize any appropriate instance data.
104 public void installUI(JComponent c)
106 // TODO: What to do here, if anything?
107 super.installUI(c);
111 * Reverses configuration which was done on the specified component during
112 * installUI. This method is invoked when this UIComponent instance is being
113 * removed as the UI delegate for the specified component. This method should
114 * undo the configuration performed in installUI, being careful to leave the
115 * JComponent instance in a clean state (no extraneous listeners,
116 * look-and-feel-specific property objects, etc.). This should include
117 * the following:
118 * 1. Remove any UI-set borders from the component.
119 * 2. Remove any UI-set layout managers on the component.
120 * 3. Remove any UI-added sub-components from the component.
121 * 4. Remove any UI-added event/property listeners from the component.
122 * 5. Remove any UI-installed keyboard UI from the component.
123 * 6. Nullify any allocated instance data objects to allow for GC.
125 public void uninstallUI(JComponent c)
127 // TODO: What to do here?
128 super.uninstallUI(c);
132 * This function converts between the string passed into the client
133 * property and the internal representation (currently an int).
135 * @param lineStyleFlag - String representation
137 protected void decodeLineStyle(Object lineStyleFlag)
138 throws NotImplementedException
140 // FIXME: not implemented
144 * Checks if the location is in expand control.
146 * @param row - current row
147 * @param rowLevel - current level
148 * @param mouseX - current x location of the mouse click
149 * @param mouseY - current y location of the mouse click
151 protected boolean isLocationInExpandControl(int row, int rowLevel,
152 int mouseX, int mouseY)
154 return super.isLocationInExpandControl(tree.getPathForRow(row),
155 mouseX, mouseY);
159 * Paints the specified component appropriate for the look and feel.
160 * This method is invoked from the ComponentUI.update method when the
161 * specified component is being painted. Subclasses should override this
162 * method and use the specified Graphics object to render the content of
163 * the component.
165 * @param g - the current graphics configuration.
166 * @param c - the current component to draw
168 public void paint(Graphics g, JComponent c)
170 // Calls BasicTreeUI's paint since it takes care of painting all
171 // types of icons.
172 super.paint(g, c);
176 * Paints the horizontal separators.
178 * @param g - the current graphics configuration.
179 * @param c - the current component to draw
181 protected void paintHorizontalSeparators(Graphics g, JComponent c)
182 throws NotImplementedException
184 // FIXME: not implemented
189 * Paints the vertical part of the leg. The receiver should NOT modify
190 * clipBounds, insets.
192 * @param g - the current graphics configuration.
193 * @param clipBounds -
194 * @param insets -
195 * @param path - the current path
197 protected void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds,
198 Insets insets, TreePath path)
200 super.paintVerticalPartOfLeg(g, clipBounds, insets, path);
204 * Paints the horizontal part of the leg. The receiver should NOT \
205 * modify clipBounds, or insets.
206 * NOTE: parentRow can be -1 if the root is not visible.
208 protected void paintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds,
209 Insets insets, Rectangle bounds,
210 TreePath path, int row,
211 boolean isExpanded, boolean hasBeenExpanded,
212 boolean isLeaf)
214 super.paintHorizontalPartOfLeg(g, clipBounds, insets, bounds, path, row,
215 isExpanded, hasBeenExpanded, isLeaf);