1 7 8 package com.sun.java.swing.plaf.motif; 9 10 import javax.swing.*; 11 import javax.swing.plaf.*; 12 import javax.swing.tree.*; 13 import java.awt.*; 14 import java.awt.event.*; 15 import java.beans.*; 16 import java.io.*; 17 import java.util.*; 18 19 32 public class MotifTreeCellRenderer extends DefaultTreeCellRenderer 33 { 34 static final int LEAF_SIZE = 13; 35 static final Icon LEAF_ICON = new IconUIResource(new TreeLeafIcon()); 36 37 public MotifTreeCellRenderer() { 38 super(); 39 } 40 41 public static Icon loadLeafIcon() { 42 return LEAF_ICON; 43 } 44 45 55 public static class TreeLeafIcon implements Icon, Serializable { 56 57 Color bg; 58 Color shadow; 59 Color highlight; 60 61 public TreeLeafIcon() { 62 bg = UIManager.getColor("Tree.iconBackground"); 63 shadow = UIManager.getColor("Tree.iconShadow"); 64 highlight = UIManager.getColor("Tree.iconHighlight"); 65 } 66 67 public void paintIcon(Component c, Graphics g, int x, int y) { 68 g.setColor(bg); 69 70 y -= 3; 71 g.fillRect(x + 4, y + 7, 5, 5); 72 73 g.drawLine(x + 6, y + 6, x + 6, y + 6); 74 g.drawLine(x + 3, y + 9, x + 3, y + 9); 75 g.drawLine(x + 6, y + 12, x + 6, y + 12); 76 g.drawLine(x + 9, y + 9, x + 9, y + 9); 77 78 g.setColor(highlight); 79 g.drawLine(x + 2, y + 9, x + 5, y + 6); 80 g.drawLine(x + 3, y + 10, x + 5, y + 12); 81 82 g.setColor(shadow); 83 g.drawLine(x + 6, y + 13, x + 10, y + 9); 84 g.drawLine(x + 9, y + 8, x + 7, y + 6); 85 } 86 87 public int getIconWidth() { 88 return LEAF_SIZE; 89 } 90 91 public int getIconHeight() { 92 return LEAF_SIZE; 93 } 94 95 } 96 } 97 | Popular Tags |