1 /*
2  * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 package javax.swing.plaf.synth;
26 
27 import javax.swing.JComponent;
28 
29 /**
30  * Factory used for obtaining <code>SynthStyle</code>s.  Each of the
31  * Synth <code>ComponentUI</code>s will call into the current
32  * <code>SynthStyleFactory</code> to obtain a <code>SynthStyle</code>
33  * for each of the distinct regions they have.
34  * <p>
35  * The following example creates a custom <code>SynthStyleFactory</code>
36  * that returns a different style based on the <code>Region</code>:
37  * <pre>
38  * class MyStyleFactory extends SynthStyleFactory {
39  *     public SynthStyle getStyle(JComponent c, Region id) {
40  *         if (id == Region.BUTTON) {
41  *             return buttonStyle;
42  *         }
43  *         else if (id == Region.TREE) {
44  *             return treeStyle;
45  *         }
46  *         return defaultStyle;
47  *     }
48  * }
49  * SynthLookAndFeel laf = new SynthLookAndFeel();
50  * UIManager.setLookAndFeel(laf);
51  * SynthLookAndFeel.setStyleFactory(new MyStyleFactory());
52  * </pre>
53  *
54  * @see SynthLookAndFeel
55  * @see SynthStyle
56  *
57  * @since 1.5
58  * @author Scott Violet
59  */
60 public abstract class SynthStyleFactory {
61     /**
62      * Creates a <code>SynthStyleFactory</code>.
63      */
SynthStyleFactory()64     public SynthStyleFactory() {
65     }
66 
67     /**
68      * Returns the style for the specified Component.
69      *
70      * @param c Component asking for
71      * @param id Region identifier
72      * @return SynthStyle for region.
73      */
getStyle(JComponent c, Region id)74     public abstract SynthStyle getStyle(JComponent c, Region id);
75 }
76