1 30 31 package com.jgoodies.looks.plastic; 32 33 import java.awt.Color ; 34 import java.awt.Font ; 35 36 import javax.swing.plaf.ColorUIResource ; 37 import javax.swing.plaf.FontUIResource ; 38 import javax.swing.plaf.metal.DefaultMetalTheme ; 39 40 46 public abstract class PlasticTheme extends DefaultMetalTheme { 47 48 50 public static final Color DARKEN_START = new Color (0, 0, 0, 0); 51 public static final Color DARKEN_STOP = new Color (0, 0, 0, 64); 52 public static final Color LT_DARKEN_STOP = new Color (0, 0, 0, 32); 53 public static final Color BRIGHTEN_START = new Color (255, 255, 255, 0); 54 public static final Color BRIGHTEN_STOP = new Color (255, 255, 255, 128); 55 public static final Color LT_BRIGHTEN_STOP = new Color (255, 255, 255, 64); 56 57 protected static final ColorUIResource WHITE = 58 new ColorUIResource (255, 255, 255); 59 60 protected static final ColorUIResource BLACK = new ColorUIResource (0, 0, 0); 61 62 protected FontUIResource titleFont; 63 protected FontUIResource controlFont; 64 protected FontUIResource systemFont; 65 protected FontUIResource userFont; 66 protected FontUIResource smallFont; 67 68 70 protected ColorUIResource getBlack() { 71 return BLACK; 72 } 73 74 protected ColorUIResource getWhite() { 75 return WHITE; 76 } 77 78 public ColorUIResource getSystemTextColor() { 79 return getControlInfo(); 80 } 81 82 public ColorUIResource getTitleTextColor() { 83 return getPrimary1(); 84 } 85 86 public ColorUIResource getMenuForeground() { 87 return getControlInfo(); 88 } 89 90 public ColorUIResource getMenuItemBackground() { 91 return getMenuBackground(); 92 } 93 94 public ColorUIResource getMenuItemSelectedBackground() { 95 return getMenuSelectedBackground(); 96 } 97 98 public ColorUIResource getMenuItemSelectedForeground() { 99 return getMenuSelectedForeground(); 100 } 101 102 public ColorUIResource getSimpleInternalFrameForeground() { 103 return getWhite(); 104 } 105 106 public ColorUIResource getSimpleInternalFrameBackground() { 107 return getPrimary1(); 108 } 109 110 public ColorUIResource getToggleButtonCheckColor() { 111 return getPrimary1(); 112 } 113 114 116 public FontUIResource getTitleTextFont() { 117 119 if (titleFont == null) { 120 titleFont = 121 new FontUIResource ( 122 Font.getFont( 123 "swing.plaf.metal.controlFont", 124 new Font ("Dialog", Font.BOLD, 12))); 125 } 126 return titleFont; 127 } 128 129 public FontUIResource getControlTextFont() { 130 return getFont(); 131 } 132 133 public FontUIResource getMenuTextFont() { 134 return getFont(); 135 } 136 137 public FontUIResource getSubTextFont() { 138 if (smallFont == null) { 139 smallFont = 140 new FontUIResource ( 141 Font.getFont( 142 "swing.plaf.metal.smallFont", 143 new Font ("Dialog", Font.PLAIN, 10))); 144 } 145 return smallFont; 146 } 147 148 public FontUIResource getSystemTextFont() { 149 if (systemFont == null) { 150 systemFont = 151 new FontUIResource ( 152 Font.getFont( 153 "swing.plaf.metal.systemFont", 154 new Font ("Dialog", Font.PLAIN, 12))); 155 } 156 return systemFont; 157 } 158 159 public FontUIResource getUserTextFont() { 160 if (userFont == null) { 161 userFont = 162 new FontUIResource ( 163 Font.getFont( 164 "swing.plaf.metal.userFont", 165 new Font ("Dialog", Font.PLAIN, 12))); 166 } 167 return userFont; 168 } 169 170 public FontUIResource getWindowTitleFont() { 171 return getFont(); 172 } 173 174 175 177 protected FontUIResource getFont() { 178 if (null == controlFont) 179 controlFont = new FontUIResource (getFont0()); 180 181 return controlFont; 182 } 183 184 protected Font getFont0() { 185 Font font = Font.getFont("swing.plaf.metal.controlFont"); 186 return font != null 187 ? font.deriveFont(Font.PLAIN) 188 : new Font ("Dialog", Font.PLAIN, 12); 189 } 190 191 192 194 199 public boolean equals(Object o) { 200 if (this == o) 201 return true; 202 if (o == null) 203 return false; 204 return getClass().equals(o.getClass()); 205 } 206 207 208 213 public int hashCode() { 214 return getClass().hashCode(); 215 } 216 217 218 } | Popular Tags |