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. 24 */ 25 26 package javax.swing.plaf.metal; 27 28 import javax.swing.*; 29 import javax.swing.event.*; 30 import java.awt.*; 31 import java.awt.event.*; 32 import java.beans.*; 33 import java.io.*; 34 import java.util.*; 35 import javax.swing.plaf.*; 36 import javax.swing.tree.*; 37 38 import javax.swing.plaf.basic.*; 39 40 /** 41 * The metal look and feel implementation of <code>TreeUI</code>. 42 * <p> 43 * <code>MetalTreeUI</code> allows for configuring how to 44 * visually render the spacing and delineation between nodes. The following 45 * hints are supported: 46 * 47 * <table summary="Descriptions of supported hints: Angled, Horizontal, and None"> 48 * <tr> 49 * <th><p style="text-align:left">Angled</p></th> 50 * <td>A line is drawn connecting the child to the parent. For handling 51 * of the root node refer to 52 * {@link javax.swing.JTree#setRootVisible} and 53 * {@link javax.swing.JTree#setShowsRootHandles}. 54 * </td> 55 * </tr> 56 * <tr> 57 * <th><p style="text-align:left">Horizontal</p></th> 58 * <td>A horizontal line is drawn dividing the children of the root node.</td> 59 * </tr> 60 * <tr> 61 * <th><p style="text-align:left">None</p></th> 62 * <td>Do not draw any visual indication between nodes.</td> 63 * </tr> 64 * </table> 65 * 66 * <p> 67 * As it is typically impractical to obtain the <code>TreeUI</code> from 68 * the <code>JTree</code> and cast to an instance of <code>MetalTreeUI</code> 69 * you enable this property via the client property 70 * <code>JTree.lineStyle</code>. For example, to switch to 71 * <code>Horizontal</code> style you would do: 72 * <code>tree.putClientProperty("JTree.lineStyle", "Horizontal");</code> 73 * <p> 74 * The default is <code>Angled</code>. 75 * 76 * @author Tom Santos 77 * @author Steve Wilson (value add stuff) 78 */ 79 public class MetalTreeUI extends BasicTreeUI { 80 81 private static Color lineColor; 82 83 private static final String LINE_STYLE = "JTree.lineStyle"; 84 85 private static final String LEG_LINE_STYLE_STRING = "Angled"; 86 private static final String HORIZ_STYLE_STRING = "Horizontal"; 87 private static final String NO_STYLE_STRING = "None"; 88 89 private static final int LEG_LINE_STYLE = 2; 90 private static final int HORIZ_LINE_STYLE = 1; 91 private static final int NO_LINE_STYLE = 0; 92 93 private int lineStyle = LEG_LINE_STYLE; 94 private PropertyChangeListener lineStyleListener = new LineListener(); | 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. 24 */ 25 26 package javax.swing.plaf.metal; 27 28 import javax.swing.*; 29 import javax.swing.event.*; 30 import java.awt.*; 31 import java.awt.event.*; 32 import java.beans.*; 33 import java.io.*; 34 import java.util.*; 35 import javax.swing.plaf.*; 36 import javax.swing.tree.*; 37 38 import javax.swing.plaf.basic.*; 39 40 /** 41 * The metal look and feel implementation of {@code TreeUI}. 42 * <p> 43 * {@code MetalTreeUI} allows for configuring how to 44 * visually render the spacing and delineation between nodes. The following 45 * hints are supported: 46 * 47 * <table summary="Descriptions of supported hints: Angled, Horizontal, and None"> 48 * <tr> 49 * <th><p style="text-align:left">Angled</p></th> 50 * <td>A line is drawn connecting the child to the parent. For handling 51 * of the root node refer to 52 * {@link javax.swing.JTree#setRootVisible} and 53 * {@link javax.swing.JTree#setShowsRootHandles}. 54 * </td> 55 * </tr> 56 * <tr> 57 * <th><p style="text-align:left">Horizontal</p></th> 58 * <td>A horizontal line is drawn dividing the children of the root node.</td> 59 * </tr> 60 * <tr> 61 * <th><p style="text-align:left">None</p></th> 62 * <td>Do not draw any visual indication between nodes.</td> 63 * </tr> 64 * </table> 65 * 66 * <p> 67 * As it is typically impractical to obtain the {@code TreeUI} from 68 * the {@code JTree} and cast to an instance of {@code MetalTreeUI} 69 * you enable this property via the client property 70 * {@code JTree.lineStyle}. For example, to switch to 71 * {@code Horizontal} style you would do: 72 * {@code tree.putClientProperty("JTree.lineStyle", "Horizontal");} 73 * <p> 74 * The default is {@code Angled}. 75 * 76 * @author Tom Santos 77 * @author Steve Wilson (value add stuff) 78 */ 79 public class MetalTreeUI extends BasicTreeUI { 80 81 private static Color lineColor; 82 83 private static final String LINE_STYLE = "JTree.lineStyle"; 84 85 private static final String LEG_LINE_STYLE_STRING = "Angled"; 86 private static final String HORIZ_STYLE_STRING = "Horizontal"; 87 private static final String NO_STYLE_STRING = "None"; 88 89 private static final int LEG_LINE_STYLE = 2; 90 private static final int HORIZ_LINE_STYLE = 1; 91 private static final int NO_LINE_STYLE = 0; 92 93 private int lineStyle = LEG_LINE_STYLE; 94 private PropertyChangeListener lineStyleListener = new LineListener(); |