1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
/* * @(#)MetalTheme.java 1.29 06/07/12 * * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package javax.swing.plaf.metal; import javax.swing.plaf.*; import javax.swing.*; /** * {@code MetalTheme} provides the color palette and fonts used by * the Java Look and Feel. * <p> * {@code MetalTheme} is abstract, see {@code DefaultMetalTheme} and * {@code OceanTheme} for concrete implementations. * <p> * {@code MetalLookAndFeel} maintains the current theme that the * the {@code ComponentUI} implementations for metal use. Refer to * {@link MetalLookAndFeel#setCurrentTheme * MetalLookAndFeel.setCurrentTheme(MetalTheme)} for details on changing * the current theme. * <p> * {@code MetalTheme} provides a number of public methods for getting * colors. These methods are implemented in terms of a * handful of protected abstract methods. A subclass need only override * the protected abstract methods ({@code getPrimary1}, * {@code getPrimary2}, {@code getPrimary3}, {@code getSecondary1}, * {@code getSecondary2}, and {@code getSecondary3}); although a subclass * may override the other public methods for more control over the set of * colors that are used. * <p> * Concrete implementations of {@code MetalTheme} must return {@code non-null} * values from all methods. While the behavior of returning {@code null} is * not specified, returning {@code null} will result in incorrect behavior. * <p> * It is strongly recommended that subclasses return completely opaque colors. * To do otherwise may result in rendering problems, such as visual garbage. * * @see DefaultMetalTheme * @see OceanTheme * @see MetalLookAndFeel#setCurrentTheme * * @version 1.29 07/12/06 * @author Steve Wilson */ public abstract class MetalTheme { // Contants identifying the various Fonts that are Theme can support static final int CONTROL_TEXT_FONT = 0; static final int SYSTEM_TEXT_FONT = 1; static final int USER_TEXT_FONT = 2; static final int MENU_TEXT_FONT = 3; static final int WINDOW_TITLE_FONT = 4; static final int SUB_TEXT_FONT = 5; static ColorUIResource white = new ColorUIResource( 255, 255, 255 ); private static ColorUIResource black = new ColorUIResource( 0, 0, 0 ); /** * Returns the name of this theme. * * @return the name of this theme */ public abstract String getName(); /** * Returns the primary 1 color. * * @return the primary 1 color */ protected abstract ColorUIResource getPrimary1(); // these are blue in Metal Default Theme /** * Returns the primary 2 color. * * @return the primary 2 color */ protected abstract ColorUIResource getPrimary2(); /** * Returns the primary 3 color. * * @return the primary 3 color */ protected abstract ColorUIResource getPrimary3(); /** * Returns the secondary 1 color. * * @return the secondary 1 color */ protected abstract ColorUIResource getSecondary1(); // these are gray in Metal Default Theme /** * Returns the secondary 2 color. * * @return the secondary 2 color */ protected abstract ColorUIResource getSecondary2(); /** * Returns the secondary 3 color. * * @return the secondary 3 color */ protected abstract ColorUIResource getSecondary3(); /** * Returns the control text font. * * @return the control text font */ public abstract FontUIResource getControlTextFont(); /** * Returns the system text font. * * @return the system text font */ public abstract FontUIResource getSystemTextFont(); /** * Returns the user text font. * * @return the user text font */ public abstract FontUIResource getUserTextFont(); /** * Returns the menu text font. * * @return the menu text font */ public abstract FontUIResource getMenuTextFont(); /** * Returns the window title font. * * @return the window title font */ public abstract FontUIResource getWindowTitleFont(); /** * Returns the sub-text font. * * @return the sub-text font */ public abstract FontUIResource getSubTextFont(); /** * Returns the white color. This returns opaque white * ({@code 0xFFFFFFFF}). * * @return the white color */ protected ColorUIResource getWhite() { return white; } /** * Returns the black color. This returns opaque black * ({@code 0xFF000000}). * * @return the black color */ protected ColorUIResource getBlack() { return black; } /** * Returns the focus color. This returns the value of * {@code getPrimary2()}. * * @return the focus color */ public ColorUIResource getFocusColor() { return getPrimary2(); } /** * Returns the desktop color. This returns the value of * {@code getPrimary2()}. * * @return the desktop color */ public ColorUIResource getDesktopColor() { return getPrimary2(); } /** * Returns the control color. This returns the value of * {@code getSecondary3()}. * * @return the control color */ public ColorUIResource getControl() { return getSecondary3(); } /** * Returns the control shadow color. This returns * the value of {@code getSecondary2()}. * * @return the control shadow color */ public ColorUIResource getControlShadow() { return getSecondary2(); } /** * Returns the control dark shadow color. This returns * the value of {@code getSecondary1()}. * * @return the control dark shadow color */ public ColorUIResource getControlDarkShadow() { return getSecondary1(); } /** * Returns the control info color. This returns * the value of {@code getBlack()}. * * @return the control info color */ public ColorUIResource getControlInfo() { return getBlack(); } /** * Returns the control highlight color. This returns * the value of {@code getWhite()}. * * @return the control highlight color */ public ColorUIResource getControlHighlight() { return getWhite(); } /** * Returns the control disabled color. This returns * the value of {@code getSecondary2()}. * * @return the control disabled color */ public ColorUIResource getControlDisabled() { return getSecondary2(); } /** * Returns the primary control color. This returns * the value of {@code getPrimary3()}. * * @return the primary control color */ public ColorUIResource getPrimaryControl() { return getPrimary3(); } /** * Returns the primary control shadow color. This returns * the value of {@code getPrimary2()}. * * @return the primary control shadow color */ public ColorUIResource getPrimaryControlShadow() { return getPrimary2(); } /** * Returns the primary control dark shadow color. This * returns the value of {@code getPrimary1()}. * * @return the primary control dark shadow color */ public ColorUIResource getPrimaryControlDarkShadow() { return getPrimary1(); } /** * Returns the primary control info color. This * returns the value of {@code getBlack()}. * * @return the primary control info color */ public ColorUIResource getPrimaryControlInfo() { return getBlack(); } /** * Returns the primary control highlight color. This * returns the value of {@code getWhite()}. * * @return the primary control highlight color */ public ColorUIResource getPrimaryControlHighlight() { return getWhite(); } /** * Returns the system text color. This returns the value of * {@code getBlack()}. * * @return the system text color */ public ColorUIResource getSystemTextColor() { return getBlack(); } /** * Returns the control text color. This returns the value of * {@code getControlInfo()}. * * @return the control text color */ public ColorUIResource getControlTextColor() { return getControlInfo(); } /** * Returns the inactive control text color. This returns the value of * {@code getControlDisabled()}. * * @return the inactive control text color */ public ColorUIResource getInactiveControlTextColor() { return getControlDisabled(); } /** * Returns the inactive system text color. This returns the value of * {@code getSecondary2()}. * * @return the inactive system text color */ public ColorUIResource getInactiveSystemTextColor() { return getSecondary2(); } /** * Returns the user text color. This returns the value of * {@code getBlack()}. * * @return the user text color */ public ColorUIResource getUserTextColor() { return getBlack(); } /** * Returns the text highlight color. This returns the value of * {@code getPrimary3()}. * * @return the text highlight color */ public ColorUIResource getTextHighlightColor() { return getPrimary3(); } /** * Returns the highlighted text color. This returns the value of * {@code getControlTextColor()}. * * @return the highlighted text color */ public ColorUIResource getHighlightedTextColor() { return getControlTextColor(); } /** * Returns the window background color. This returns the value of * {@code getWhite()}. * * @return the window background color */ public ColorUIResource getWindowBackground() { return getWhite(); } /** * Returns the window title background color. This returns the value of * {@code getPrimary3()}. * * @return the window title background color */ public ColorUIResource getWindowTitleBackground() { return getPrimary3(); } /** * Returns the window title foreground color. This returns the value of * {@code getBlack()}. * * @return the window title foreground color */ public ColorUIResource getWindowTitleForeground() { return getBlack(); } /** * Returns the window title inactive background color. This * returns the value of {@code getSecondary3()}. * * @return the window title inactive background color */ public ColorUIResource getWindowTitleInactiveBackground() { return getSecondary3(); } /** * Returns the window title inactive foreground color. This * returns the value of {@code getBlack()}. * * @return the window title inactive foreground color */ public ColorUIResource getWindowTitleInactiveForeground() { return getBlack(); } /** * Returns the menu background color. This * returns the value of {@code getSecondary3()}. * * @return the menu background color */ public ColorUIResource getMenuBackground() { return getSecondary3(); } /** * Returns the menu foreground color. This * returns the value of {@code getBlack()}. * * @return the menu foreground color */ public ColorUIResource getMenuForeground() { return getBlack(); } /** * Returns the menu selected background color. This * returns the value of {@code getPrimary2()}. * * @return the menu selected background color */ public ColorUIResource getMenuSelectedBackground() { return getPrimary2(); } /** * Returns the menu selected foreground color. This * returns the value of {@code getBlack()}. * * @return the menu selected foreground color */ public ColorUIResource getMenuSelectedForeground() { return getBlack(); } /** * Returns the menu disabled foreground color. This * returns the value of {@code getSecondary2()}. * * @return the menu disabled foreground color */ public ColorUIResource getMenuDisabledForeground() { return getSecondary2(); } /** * Returns the separator background color. This * returns the value of {@code getWhite()}. * * @return the separator background color */ public ColorUIResource getSeparatorBackground() { return getWhite(); } /** * Returns the separator foreground color. This * returns the value of {@code getPrimary1()}. * * @return the separator foreground color */ public ColorUIResource getSeparatorForeground() { return getPrimary1(); } /** * Returns the accelerator foreground color. This * returns the value of {@code getPrimary1()}. * * @return the accelerator foreground color */ public ColorUIResource getAcceleratorForeground() { return getPrimary1(); } /** * Returns the accelerator selected foreground color. This * returns the value of {@code getBlack()}. * * @return the accelerator selected foreground color */ public ColorUIResource getAcceleratorSelectedForeground() { return getBlack(); } /** * Adds values specific to this theme to the defaults table. This method * is invoked when the look and feel defaults are obtained from * {@code MetalLookAndFeel}. * <p> * This implementation does nothing; it is provided for subclasses * that wish to customize the defaults table. * * @param table the {@code UIDefaults} to add the values to * * @see MetalLookAndFeel#getDefaults */ public void addCustomEntriesToTable(UIDefaults table) {} /** * This is invoked when a MetalLookAndFeel is installed and about to * start using this theme. When we can add API this should be nuked * in favor of DefaultMetalTheme overriding addCustomEntriesToTable. */ void install() { } /** * Returns true if this is a theme provided by the core platform. */ boolean isSystemTheme() { return false; } }