Search in sources :

Example 1 with RichStyle

use of limelight.styles.RichStyle in project limelight by slagyr.

the class StyledText method setupStyles.

public void setupStyles(Map<String, RichStyle> styleMap, RichStyle defaultStyle, StyleObserver observer) {
    if (style.hasObserver(observer))
        return;
    for (String styleName : styleNames) {
        RichStyle extension = styleMap.get(styleName);
        if (extension != null)
            style.addExtension(extension);
    }
    style.addExtension(defaultStyle);
    style.addObserver(observer);
}
Also used : RichStyle(limelight.styles.RichStyle)

Example 2 with RichStyle

use of limelight.styles.RichStyle in project limelight by slagyr.

the class JavaProductionTest method loadRealStylesForScene.

@Test
public void loadRealStylesForScene() throws Exception {
    fs.createTextFile("/testProduction/aScene/styles.xml", "<styles><high x='0' y='99' float='on'/><far x='99' y='0' float='off'/></styles>");
    final Scene scene = production.loadScene("aScene", Opts.with("name", "aScene", "path", "aScene"));
    final Map<String, RichStyle> styles = production.loadStyles(scene, new HashMap<String, RichStyle>());
    assertEquals(2, styles.size());
    final RichStyle high = styles.get("high");
    assertEquals("0", high.getX());
    assertEquals("99", high.getY());
    assertEquals("on", high.getFloat());
    final RichStyle far = styles.get("far");
    assertEquals("99", far.getX());
    assertEquals("0", far.getY());
    assertEquals("off", far.getFloat());
}
Also used : RichStyle(limelight.styles.RichStyle) Scene(limelight.ui.model.Scene) Test(org.junit.Test)

Example 3 with RichStyle

use of limelight.styles.RichStyle in project limelight by slagyr.

the class XmlTest method checkMultipleExtensions.

private void checkMultipleExtensions() {
    final HashMap<String, RichStyle> styles = new HashMap<String, RichStyle>();
    Xml.toStyles("/styles.xml", styles, new HashMap<String, RichStyle>());
    assertEquals(3, styles.size());
    final RichStyle one = styles.get("one");
    final RichStyle two = styles.get("two");
    final RichStyle three = styles.get("three");
    assertEquals("100", three.getWidth());
    assertEquals("200", three.getHeight());
    assertEquals(true, three.hasExtension(one));
    assertEquals(true, three.hasExtension(two));
}
Also used : HashMap(java.util.HashMap) RichStyle(limelight.styles.RichStyle)

Example 4 with RichStyle

use of limelight.styles.RichStyle in project limelight by slagyr.

the class ProductionTest method openSceneLoadsStylesExtendingProductionStyles.

@Test
public void openSceneLoadsStylesExtendingProductionStyles() throws Exception {
    production.loadProduction();
    production.getTheater().add(new MockStage("mock"));
    production.getStyles().put("newStyle", new RichStyle());
    Scene scene = new FakeScene();
    production.stubbedScene = scene;
    production.openScene("scenePath", "mock", Util.toMap());
    assertEquals(HashMap.class, scene.getStyles().getClass());
    assertEquals(true, scene.getStyles().containsKey("limelight_builtin_curtains"));
    assertEquals(true, scene.getStyles().containsKey("newStyle"));
}
Also used : RichStyle(limelight.styles.RichStyle) MockStage(limelight.ui.model.MockStage) FakeScene(limelight.ui.model.FakeScene) Scene(limelight.ui.model.Scene) FakeScene(limelight.ui.model.FakeScene) Test(org.junit.Test)

Example 5 with RichStyle

use of limelight.styles.RichStyle in project limelight by slagyr.

the class StyledTextTest method shouldBuildStyles.

@Test
public void shouldBuildStyles() throws Exception {
    makeSampleStyles();
    StyleObserver observer = new MockStyleObserver();
    styledText = new StyledText("Some Text", "fizz", "bang");
    styledText.setupStyles(styles, defaultStyle, observer);
    RichStyle style = styledText.getStyle();
    assertSame(style1, style.getExtention(0));
    assertSame(style2, style.getExtention(1));
    assertSame(defaultStyle, style.getExtention(2));
    assertEquals(true, style.hasObserver(observer));
}
Also used : RichStyle(limelight.styles.RichStyle) StyleObserver(limelight.styles.StyleObserver) 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