1. /*
  2. * @(#)ColorType.java 1.9 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.java.swing.plaf.gtk;
  8. /**
  9. * A typesafe enumeration of colors that can be fetched from a style.
  10. *
  11. * @version 1.9, 01/23/03
  12. * @author Scott Violet
  13. */
  14. class ColorType {
  15. /**
  16. * ColorType for the foreground of a region.
  17. */
  18. public static final ColorType FOREGROUND = new ColorType("Foreground");
  19. /**
  20. * ColorType for the background of a region.
  21. */
  22. public static final ColorType BACKGROUND = new ColorType("Background");
  23. /**
  24. * ColorType for the foreground of a region.
  25. */
  26. public static final ColorType TEXT_FOREGROUND = new ColorType(
  27. "TextForeground");
  28. /**
  29. * ColorType for the background of a region.
  30. */
  31. public static final ColorType TEXT_BACKGROUND =new ColorType(
  32. "TextBackground");
  33. /**
  34. * ColorType for the focus.
  35. */
  36. public static final ColorType FOCUS = new ColorType("Focus");
  37. public static final int MAX_COUNT;
  38. private static int nextID;
  39. private String description;
  40. private int index;
  41. static {
  42. MAX_COUNT = Math.max(FOREGROUND.getID(), Math.max(
  43. BACKGROUND.getID(), FOCUS.getID())) + 1;
  44. }
  45. /**
  46. * Creates a new ColorType with the specified description.
  47. *
  48. * @param description String description of the ColorType.
  49. */
  50. protected ColorType(String description) {
  51. this.description = description;
  52. synchronized(ColorType.class) {
  53. this.index = nextID++;
  54. }
  55. }
  56. /**
  57. * Returns a unique id, as an integer, for this ColorType.
  58. *
  59. * @return a unique id, as an integer, for this ColorType.
  60. */
  61. public final int getID() {
  62. return index;
  63. }
  64. public String toString() {
  65. return description;
  66. }
  67. }