1 /*
2 * Copyright (c) 2005, 2017, 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
286 }
287
288 //a list of the different types of states used by this style. This
289 //list may contain only "standard" states (those defined by Synth),
290 //or it may contain custom states, or it may contain only "standard"
291 //states but list them in a non-standard order.
292 List<State<?>> states = new ArrayList<>();
293 //a map of state name to code
294 Map<String,Integer> stateCodes = new HashMap<>();
295 //This is a list of runtime "state" context objects. These contain
296 //the values associated with each state.
297 List<RuntimeState> runtimeStates = new ArrayList<>();
298
299 //determine whether there are any custom states, or custom state
300 //order. If so, then read all those custom states and define the
301 //"values" stateTypes to be a non-null array.
302 //Otherwise, let the "values" stateTypes be null to indicate that
303 //there are no custom states or custom state ordering
304 String statesString = (String)defaults.get(prefix + ".States");
305 if (statesString != null) {
306 String s[] = statesString.split(",");
307 for (int i=0; i<s.length; i++) {
308 s[i] = s[i].trim();
309 if (!State.isStandardStateName(s[i])) {
310 //this is a non-standard state name, so look for the
311 //custom state associated with it
312 String stateName = prefix + "." + s[i];
313 State<?> customState = (State)defaults.get(stateName);
314 if (customState != null) {
315 states.add(customState);
316 }
317 } else {
318 states.add(State.getStandardState(s[i]));
319 }
320 }
321
322 //if there were any states defined, then set the stateTypes array
323 //to be non-null. Otherwise, leave it null (meaning, use the
324 //standard synth states).
325 if (states.size() > 0) {
326 values.stateTypes = states.toArray(new State<?>[states.size()]);
|
1 /*
2 * Copyright (c) 2005, 2018, 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
286 }
287
288 //a list of the different types of states used by this style. This
289 //list may contain only "standard" states (those defined by Synth),
290 //or it may contain custom states, or it may contain only "standard"
291 //states but list them in a non-standard order.
292 List<State<?>> states = new ArrayList<>();
293 //a map of state name to code
294 Map<String,Integer> stateCodes = new HashMap<>();
295 //This is a list of runtime "state" context objects. These contain
296 //the values associated with each state.
297 List<RuntimeState> runtimeStates = new ArrayList<>();
298
299 //determine whether there are any custom states, or custom state
300 //order. If so, then read all those custom states and define the
301 //"values" stateTypes to be a non-null array.
302 //Otherwise, let the "values" stateTypes be null to indicate that
303 //there are no custom states or custom state ordering
304 String statesString = (String)defaults.get(prefix + ".States");
305 if (statesString != null) {
306 String[] s = statesString.split(",");
307 for (int i=0; i<s.length; i++) {
308 s[i] = s[i].trim();
309 if (!State.isStandardStateName(s[i])) {
310 //this is a non-standard state name, so look for the
311 //custom state associated with it
312 String stateName = prefix + "." + s[i];
313 State<?> customState = (State)defaults.get(stateName);
314 if (customState != null) {
315 states.add(customState);
316 }
317 } else {
318 states.add(State.getStandardState(s[i]));
319 }
320 }
321
322 //if there were any states defined, then set the stateTypes array
323 //to be non-null. Otherwise, leave it null (meaning, use the
324 //standard synth states).
325 if (states.size() > 0) {
326 values.stateTypes = states.toArray(new State<?>[states.size()]);
|