GNU Classpath (0.20) | |
Frames | No Frames |
1: /* MetalTreeUI.java 2: Copyright (C) 2005 Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 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. 10: 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. 15: 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. 20: 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. 25: 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. */ 37: 38: 39: package javax.swing.plaf.metal; 40: 41: import java.awt.Graphics; 42: import java.awt.Insets; 43: import java.awt.Rectangle; 44: 45: import javax.swing.JComponent; 46: import javax.swing.JTree; 47: import javax.swing.tree.TreePath; 48: import javax.swing.plaf.ComponentUI; 49: import javax.swing.plaf.basic.BasicTreeUI; 50: 51: /** 52: * A UI delegate for the {@link JTree} component. 53: */ 54: public class MetalTreeUI extends BasicTreeUI 55: { 56: /** 57: * Constructs a new instance of <code>MetalTreeUI</code>. 58: */ 59: public MetalTreeUI() 60: { 61: super(); 62: } 63: 64: /** 65: * Returns a new instance of <code>MetalTreeUI</code>. 66: * 67: * @param component the component for which we return an UI instance 68: * 69: * @return A new instance of <code>MetalTreeUI</code>. 70: */ 71: public static ComponentUI createUI(JComponent component) 72: { 73: return new MetalTreeUI(); 74: } 75: 76: /** 77: * The horizontal element of legs between nodes starts at the right of the 78: * left-hand side of the child node by default. This method makes the 79: * leg end before that. 80: */ 81: protected int getHorizontalLegBuffer() 82: { 83: return super.getHorizontalLegBuffer(); 84: } 85: 86: /** 87: * Configures the specified component appropriate for the look and feel. 88: * This method is invoked when the ComponentUI instance is being installed 89: * as the UI delegate on the specified component. This method should completely 90: * configure the component for the look and feel, including the following: 91: * 1. Install any default property values for color, fonts, borders, icons, 92: * opacity, etc. on the component. Whenever possible, property values 93: * initialized by the client program should not be overridden. 94: * 2. Install a LayoutManager on the component if necessary. 95: * 3. Create/add any required sub-components to the component. 96: * 4. Create/install event listeners on the component. 97: * 5. Create/install a PropertyChangeListener on the component in order 98: * to detect and respond to component property changes appropriately. 99: * 6. Install keyboard UI (mnemonics, traversal, etc.) on the component. 100: * 7. Initialize any appropriate instance data. 101: */ 102: public void installUI(JComponent c) 103: { 104: // TODO: What to do here, if anything? 105: super.installUI(c); 106: } 107: 108: /** 109: * Reverses configuration which was done on the specified component during 110: * installUI. This method is invoked when this UIComponent instance is being 111: * removed as the UI delegate for the specified component. This method should 112: * undo the configuration performed in installUI, being careful to leave the 113: * JComponent instance in a clean state (no extraneous listeners, 114: * look-and-feel-specific property objects, etc.). This should include 115: * the following: 116: * 1. Remove any UI-set borders from the component. 117: * 2. Remove any UI-set layout managers on the component. 118: * 3. Remove any UI-added sub-components from the component. 119: * 4. Remove any UI-added event/property listeners from the component. 120: * 5. Remove any UI-installed keyboard UI from the component. 121: * 6. Nullify any allocated instance data objects to allow for GC. 122: */ 123: public void uninstallUI(JComponent c) 124: { 125: // TODO: What to do here? 126: super.uninstallUI(c); 127: } 128: 129: /** 130: * This function converts between the string passed into the client 131: * property and the internal representation (currently an int). 132: * 133: * @param lineStyleFlag - String representation 134: */ 135: protected void decodeLineStyle(Object lineStyleFlag) 136: { 137: // FIXME: not implemented 138: } 139: 140: /** 141: * Checks if the location is in expand control. 142: * 143: * @param row - current row 144: * @param rowLevel - current level 145: * @param mouseX - current x location of the mouse click 146: * @param mouseY - current y location of the mouse click 147: */ 148: protected boolean isLocationInExpandControl(int row, int rowLevel, 149: int mouseX, int mouseY) 150: { 151: return super.isLocationInExpandControl(tree.getPathForRow(row), 152: mouseX, mouseY); 153: } 154: 155: /** 156: * Paints the specified component appropriate for the look and feel. 157: * This method is invoked from the ComponentUI.update method when the 158: * specified component is being painted. Subclasses should override this 159: * method and use the specified Graphics object to render the content of 160: * the component. 161: * 162: * @param g - the current graphics configuration. 163: * @param c - the current component to draw 164: */ 165: public void paint(Graphics g, JComponent c) 166: { 167: // Calls BasicTreeUI's paint since it takes care of painting all 168: // types of icons. 169: super.paint(g, c); 170: } 171: 172: /** 173: * Paints the horizontal separators. 174: * 175: * @param g - the current graphics configuration. 176: * @param c - the current component to draw 177: */ 178: protected void paintHorizontalSeparators(Graphics g, JComponent c) 179: { 180: // FIXME: not implemented 181: } 182: 183: 184: /** 185: * Paints the vertical part of the leg. The receiver should NOT modify 186: * clipBounds, insets. 187: * 188: * @param g - the current graphics configuration. 189: * @param clipBounds - 190: * @param insets - 191: * @param path - the current path 192: */ 193: protected void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, 194: Insets insets, TreePath path) 195: { 196: super.paintVerticalPartOfLeg(g, clipBounds, insets, path); 197: } 198: 199: /** 200: * Paints the horizontal part of the leg. The receiver should NOT \ 201: * modify clipBounds, or insets. 202: * NOTE: parentRow can be -1 if the root is not visible. 203: */ 204: protected void paintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds, 205: Insets insets, Rectangle bounds, 206: TreePath path, int row, 207: boolean isExpanded, boolean hasBeenExpanded, 208: boolean isLeaf) 209: { 210: super.paintHorizontalPartOfLeg(g, clipBounds, insets, bounds, path, row, 211: isExpanded, hasBeenExpanded, isLeaf); 212: } 213: }
GNU Classpath (0.20) |