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
26 package com.sun.javafx.scene.layout.region;
27
28 import javafx.geometry.Side;
29 import javafx.scene.layout.BackgroundPosition;
30 import javafx.scene.text.Font;
31 import javafx.css.ParsedValue;
32 import com.sun.javafx.css.Size;
33 import com.sun.javafx.css.SizeUnits;
34 import com.sun.javafx.css.StyleConverterImpl;
35
36 /**
37 * Given four Sizes from the Parser, this converter will produce a BackgroundPosition object.
38 */
39 public final class BackgroundPositionConverter extends StyleConverterImpl<ParsedValue[], BackgroundPosition> {
40 private static final BackgroundPositionConverter BACKGROUND_POSITION_CONVERTER =
41 new BackgroundPositionConverter();
42
43 public static BackgroundPositionConverter getInstance() {
44 return BACKGROUND_POSITION_CONVERTER;
45 }
46
47 // Disallow instantiation
48 private BackgroundPositionConverter() { }
49
50 @Override
51 public BackgroundPosition convert(ParsedValue<ParsedValue[], BackgroundPosition> value, Font font) {
52 ParsedValue[] positions = value.getValue();
53
54 // The parser gives us 4 values, none of them null
55 final Size top = (Size)positions[0].convert(font);
56 final Size right = (Size)positions[1].convert(font);
57 final Size bottom = (Size)positions[2].convert(font);
58 final Size left = (Size)positions[3].convert(font);
59
|
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
26 package com.sun.javafx.scene.layout.region;
27
28 import javafx.geometry.Side;
29 import javafx.scene.layout.BackgroundPosition;
30 import javafx.scene.text.Font;
31 import javafx.css.ParsedValue;
32 import javafx.css.Size;
33 import javafx.css.SizeUnits;
34 import javafx.css.StyleConverter;
35
36 /**
37 * Given four Sizes from the Parser, this converter will produce a BackgroundPosition object.
38 */
39 public final class BackgroundPositionConverter extends StyleConverter<ParsedValue[], BackgroundPosition> {
40 private static final BackgroundPositionConverter BACKGROUND_POSITION_CONVERTER =
41 new BackgroundPositionConverter();
42
43 public static BackgroundPositionConverter getInstance() {
44 return BACKGROUND_POSITION_CONVERTER;
45 }
46
47 // Disallow instantiation
48 private BackgroundPositionConverter() { }
49
50 @Override
51 public BackgroundPosition convert(ParsedValue<ParsedValue[], BackgroundPosition> value, Font font) {
52 ParsedValue[] positions = value.getValue();
53
54 // The parser gives us 4 values, none of them null
55 final Size top = (Size)positions[0].convert(font);
56 final Size right = (Size)positions[1].convert(font);
57 final Size bottom = (Size)positions[2].convert(font);
58 final Size left = (Size)positions[3].convert(font);
59
|