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.*;
28 import javax.swing.plaf.FontUIResource;
29 import java.awt.Font;
30 import java.util.*;
31 import java.util.regex.*;
32 import sun.swing.plaf.synth.*;
33 import sun.swing.BakedArrayList;
34
35 /**
36 * Factory used for obtaining styles. Supports associating a style based on
37 * the name of the component as returned by <code>Component.getName()</code>,
38 * and the <code>Region</code> associated with the <code>JComponent</code>.
39 * Lookup is done using regular expressions.
40 *
41 * @author Scott Violet
42 */
43 class DefaultSynthStyleFactory extends SynthStyleFactory {
44 /**
45 * Used to indicate the lookup should be done based on Component name.
46 */
47 public static final int NAME = 0;
48 /**
49 * Used to indicate the lookup should be done based on region.
50 */
51 public static final int REGION = 1;
52
53 /**
54 * List containing set of StyleAssociations used in determining matching
55 * styles.
56 */
57 private List<StyleAssociation> _styles;
58 /**
119 cacheStyle(matches, style);
120 }
121 }
122 return style;
123 }
124
125 /**
126 * Returns the style to use if there are no matching styles.
127 */
128 private SynthStyle getDefaultStyle() {
129 if (_defaultStyle == null) {
130 _defaultStyle = new DefaultSynthStyle();
131 ((DefaultSynthStyle)_defaultStyle).setFont(
132 new FontUIResource(Font.DIALOG, Font.PLAIN,12));
133 }
134 return _defaultStyle;
135 }
136
137 /**
138 * Fetches any styles that match the passed into arguments into
139 * <code>matches</code>.
140 */
141 private void getMatchingStyles(List<SynthStyle> matches, JComponent c,
142 Region id) {
143 String idName = id.getLowerCaseName();
144 String cName = c.getName();
145
146 if (cName == null) {
147 cName = "";
148 }
149 for (int counter = _styles.size() - 1; counter >= 0; counter--){
150 StyleAssociation sa = _styles.get(counter);
151 String path;
152
153 if (sa.getID() == NAME) {
154 path = cName;
155 }
156 else {
157 path = idName;
158 }
159
|
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.*;
28 import javax.swing.plaf.FontUIResource;
29 import java.awt.Font;
30 import java.util.*;
31 import java.util.regex.*;
32 import sun.swing.plaf.synth.*;
33 import sun.swing.BakedArrayList;
34
35 /**
36 * Factory used for obtaining styles. Supports associating a style based on
37 * the name of the component as returned by {@code Component.getName()},
38 * and the {@code Region} associated with the {@code JComponent}.
39 * Lookup is done using regular expressions.
40 *
41 * @author Scott Violet
42 */
43 class DefaultSynthStyleFactory extends SynthStyleFactory {
44 /**
45 * Used to indicate the lookup should be done based on Component name.
46 */
47 public static final int NAME = 0;
48 /**
49 * Used to indicate the lookup should be done based on region.
50 */
51 public static final int REGION = 1;
52
53 /**
54 * List containing set of StyleAssociations used in determining matching
55 * styles.
56 */
57 private List<StyleAssociation> _styles;
58 /**
119 cacheStyle(matches, style);
120 }
121 }
122 return style;
123 }
124
125 /**
126 * Returns the style to use if there are no matching styles.
127 */
128 private SynthStyle getDefaultStyle() {
129 if (_defaultStyle == null) {
130 _defaultStyle = new DefaultSynthStyle();
131 ((DefaultSynthStyle)_defaultStyle).setFont(
132 new FontUIResource(Font.DIALOG, Font.PLAIN,12));
133 }
134 return _defaultStyle;
135 }
136
137 /**
138 * Fetches any styles that match the passed into arguments into
139 * {@code matches}.
140 */
141 private void getMatchingStyles(List<SynthStyle> matches, JComponent c,
142 Region id) {
143 String idName = id.getLowerCaseName();
144 String cName = c.getName();
145
146 if (cName == null) {
147 cName = "";
148 }
149 for (int counter = _styles.size() - 1; counter >= 0; counter--){
150 StyleAssociation sa = _styles.get(counter);
151 String path;
152
153 if (sa.getID() == NAME) {
154 path = cName;
155 }
156 else {
157 path = idName;
158 }
159
|