Search in sources :

Example 16 with RichStyle

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");
}
Also used : RichStyle(limelight.styles.RichStyle)

Example 17 with RichStyle

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;
}
Also used : Matcher(java.util.regex.Matcher) RichStyle(limelight.styles.RichStyle)

Example 18 with RichStyle

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());
}
Also used : Opts(limelight.util.Opts) RichStyle(limelight.styles.RichStyle) Scene(limelight.ui.model.Scene) Test(org.junit.Test)

Example 19 with RichStyle

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));
}
Also used : HashMap(java.util.HashMap) RichStyle(limelight.styles.RichStyle) Test(org.junit.Test)

Example 20 with RichStyle

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));
}
Also used : RichStyle(limelight.styles.RichStyle) Test(org.junit.Test)

Aggregations

RichStyle (limelight.styles.RichStyle)21 Test (org.junit.Test)9 Scene (limelight.ui.model.Scene)3 HashMap (java.util.HashMap)2 StyleObserver (limelight.styles.StyleObserver)2 Opts (limelight.util.Opts)2 TextLayout (java.awt.font.TextLayout)1 AttributedString (java.text.AttributedString)1 Matcher (java.util.regex.Matcher)1 LimelightException (limelight.LimelightException)1 FakeScene (limelight.ui.model.FakeScene)1 MockStage (limelight.ui.model.MockStage)1 StyledText (limelight.ui.text.StyledText)1 StyledTextParser (limelight.ui.text.StyledTextParser)1