use of limelight.styles.RichStyle in project limelight by slagyr.
the class TextPanelTest method createStyles.
private void createStyles() {
root.setStyles(new HashMap<String, RichStyle>());
RichStyle myStyle = new RichStyle();
root.getStyles().put("my_style", myStyle);
myStyle.setFontFace("Helvetica");
myStyle.setFontStyle("bold");
myStyle.setFontSize("20");
myStyle.setTextColor("red");
RichStyle myOtherStyle = new RichStyle();
root.getStyles().put("my_other_style", myOtherStyle);
myOtherStyle.setFontFace("Cuneiform");
myOtherStyle.setFontStyle("italic");
myOtherStyle.setFontSize("19");
myOtherStyle.setTextColor("blue");
RichStyle sizeOnlyStyle = new RichStyle();
root.getStyles().put("size_only_style", sizeOnlyStyle);
sizeOnlyStyle.setFontSize("25");
}
use of limelight.styles.RichStyle in project limelight by slagyr.
the class StyledTextParser method parse.
private LinkedList<StyledText> parse(String text, RichStyle parentStyle, LinkedList<String> styleNames, LinkedList<StyledText> list) {
Matcher matcher = TAG_REGEX.matcher(text);
int index = 0;
while (matcher.find()) {
//for(int i = 0; i < matcher.groupCount(); i++)
//System.err.println("matcher.group("+i+") = " + matcher.group(i));
handleUndecoratedText(parentStyle, styleNames, list, text.substring(index, matcher.start()));
String styleName = matcher.group(1);
String attributeContent = matcher.group(2);
String content = matcher.group(3);
RichStyle style = buildStyle(attributeContent);
styleNames.addFirst(styleName);
parse(content, style, styleNames, list);
styleNames.removeFirst();
index = matcher.end();
}
handleUndecoratedText(parentStyle, styleNames, list, text.substring(index));
return list;
}
use of limelight.styles.RichStyle in project limelight by slagyr.
the class JavaProductionTest method loadEmptyStylesForScene.
@Test
public void loadEmptyStylesForScene() throws Exception {
final Scene scene = production.loadScene("aScene", new Opts());
final Map<String, RichStyle> styles = production.loadStyles(scene, new HashMap<String, RichStyle>());
assertEquals(0, styles.size());
}
use of limelight.styles.RichStyle in project limelight by slagyr.
the class XmlTest method loadStylesWithAnExtension.
@Test
public void loadStylesWithAnExtension() throws Exception {
fs.createTextFile("/styles.xml", "<styles><one width='100'/><two extends='one' height='200'/></styles>");
final HashMap<String, RichStyle> styles = new HashMap<String, RichStyle>();
Xml.toStyles("/styles.xml", styles, new HashMap<String, RichStyle>());
assertEquals(2, styles.size());
final RichStyle one = styles.get("one");
final RichStyle two = styles.get("two");
assertEquals("100", two.getWidth());
assertEquals("200", two.getHeight());
assertEquals(true, two.hasExtension(one));
}
use of limelight.styles.RichStyle in project limelight by slagyr.
the class XmlTest method loadStyleWithExtensionFromExtendableMap.
@Test
public void loadStyleWithExtensionFromExtendableMap() throws Exception {
fs.createTextFile("/extensions.xml", "<styles><one width='100'/></styles>");
final Map<String, RichStyle> extensions = Xml.toStyles("/extensions.xml", new HashMap<String, RichStyle>(), new HashMap<String, RichStyle>());
fs.createTextFile("/styles.xml", "<styles><two extends='one' height='200'/></styles>");
final Map<String, RichStyle> styles = Xml.toStyles("/styles.xml", new HashMap<String, RichStyle>(), extensions);
final RichStyle one = extensions.get("one");
final RichStyle two = styles.get("two");
assertEquals("100", two.getWidth());
assertEquals("200", two.getHeight());
assertEquals(true, two.hasExtension(one));
}
Aggregations