01: package net.xoetrope.optional.resources;
02:
03: import java.awt.Font;
04: import net.xoetrope.xui.style.XStyle;
05:
06: /**
07: * A helper for conversion of xstyles to some more useful types.
08: * <p> Copyright (c) Xoetrope Ltd., 2002-2004</p>
09: * <p> $Revision: 1.1 $</p>
10: * <p> License: see License.txt</p>
11: */
12: public class StyleHelper {
13: public static Font getFont(XStyle style) {
14: String fontface = style.getStyleAsString(style.FONT_FACE);
15: int fontsize = style.getStyleAsInt(style.FONT_SIZE);
16: int fontitalic = style.getStyleAsInt(style.FONT_ITALIC);
17: int fontweight = style.getStyleAsInt(style.FONT_WEIGHT);
18: int fontStyle = 0;
19: if (fontweight == 1)
20: fontStyle = Font.BOLD;
21: if (fontitalic == 1)
22: fontStyle = fontStyle | Font.ITALIC;
23:
24: return new Font(fontface, fontStyle, fontsize);
25: }
26: }
|