1. /*
  2. * @(#)SynthStyleFactory.java 1.8 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.swing.plaf.synth;
  8. import java.awt.*;
  9. import java.util.*;
  10. import javax.swing.plaf.*;
  11. import javax.swing.*;
  12. /**
  13. * Factory used for obtaining <code>SynthStyle</code>s. Each of the
  14. * Synth <code>ComponentUI</code>s will call into the current
  15. * <code>SynthStyleFactory</code> to obtain a <code>SynthStyle</code>
  16. * for each of the distinct regions they have.
  17. * <p>
  18. * The following example creates a custom <code>SynthStyleFactory</code>
  19. * that returns a different style based on the <code>Region</code>:
  20. * <pre>
  21. * class MyStyleFactory extends SynthStyleFactory {
  22. * public SynthStyle getStyle(JComponent c, Region id) {
  23. * if (id == Region.BUTTON) {
  24. * return buttonStyle;
  25. * }
  26. * else if (id == Region.TREE) {
  27. * return treeStyle;
  28. * }
  29. * return defaultStyle;
  30. * }
  31. * }
  32. * SynthLookAndFeel laf = new SynthLookAndFeel();
  33. * UIManager.setLookAndFeel(laf);
  34. * SynthLookAndFeel.setStyleFactory(new MyStyleFactory());
  35. * </pre>
  36. *
  37. * @see SynthStyleFactory
  38. * @see SynthStyle
  39. *
  40. * @version 1.8, 12/19/03
  41. * @since 1.5
  42. * @author Scott Violet
  43. */
  44. public abstract class SynthStyleFactory {
  45. /**
  46. * Creates a <code>SynthStyleFactory</code>.
  47. */
  48. public SynthStyleFactory() {
  49. }
  50. /**
  51. * Returns the style for the specified Component.
  52. *
  53. * @param c Component asking for
  54. * @param id Region identifier
  55. * @return SynthStyle for region.
  56. */
  57. public abstract SynthStyle getStyle(JComponent c, Region id);
  58. }