Search in sources :

Example 1 with Scene

use of limelight.ui.model.Scene in project limelight by slagyr.

the class BackgroundPainter method paint.

public void paint(Graphics2D graphics, PaintablePanel panel) {
    Style style = panel.getStyle();
    Border border = panel.getBorderShaper();
    Shape insideBorder = border.getShapeInsideBorder();
    Color backgroundColor = style.getCompiledBackgroundColor().getColor();
    if (style.getCompiledGradient().isOn())
        GradientPainter.instance.paint(graphics, panel);
    else {
        if (backgroundColor.getAlpha() > 0) {
            graphics.setColor(backgroundColor);
            graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            graphics.fill(insideBorder);
            graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
        }
    }
    NoneableValue<StringValue> backgroundImageAttribute = style.getCompiledBackgroundImage();
    if (!backgroundImageAttribute.isNone()) {
        try {
            Box borderFrame = panel.getBorderedBounds();
            Scene rootPanel = panel.getRoot();
            // TODO MDM - getting a NullPointer here. The Panel was removed from the scene in between the start of the paint cycle and here.
            if (rootPanel == null)
                return;
            ImageCache cache = rootPanel.getImageCache();
            Image image = cache.getImage(backgroundImageAttribute.getAttribute().getValue());
            Graphics2D borderedGraphics = (Graphics2D) graphics.create(borderFrame.x, borderFrame.y, borderFrame.width, borderFrame.height);
            style.getCompiledBackgroundImageFillStrategy().fill(borderedGraphics, image, style.getCompiledBackgroundImageX(), style.getCompiledBackgroundImageY());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : ImageCache(limelight.ui.model.ImageCache) Style(limelight.styles.Style) Box(limelight.util.Box) IOException(java.io.IOException) StringValue(limelight.styles.abstrstyling.StringValue) Scene(limelight.ui.model.Scene)

Example 2 with Scene

use of limelight.ui.model.Scene 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 Scene

use of limelight.ui.model.Scene in project limelight by slagyr.

the class JavaProductionTest method loadsScene.

@Test
public void loadsScene() throws Exception {
    final Scene result = production.loadScene("aScene", Opts.with("name", "aScene"));
    assertEquals(ScenePanel.class, result.getClass());
    ScenePanel scene = (ScenePanel) result;
    assertEquals(JavaScene.class, scene.getProxy().getClass());
    scene.illuminate();
    assertEquals("aScene", scene.getName());
}
Also used : ScenePanel(limelight.ui.model.ScenePanel) Scene(limelight.ui.model.Scene) Test(org.junit.Test)

Example 4 with Scene

use of limelight.ui.model.Scene 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 Scene

use of limelight.ui.model.Scene in project limelight by slagyr.

the class ProductionTest method openSceneWithNoActiveStage.

@Test
public void openSceneWithNoActiveStage() throws Exception {
    production.loadProduction();
    final MockStage stage = (MockStage) production.getTheater().getDefaultStage();
    Scene scene = new FakeScene();
    production.stubbedScene = scene;
    production.openScene("scenePath", Util.toMap());
    assertEquals("scenePath", production.loadedScenePath);
    assertEquals(scene, stage.getScene());
    assertEquals(true, stage.opened);
}
Also used : MockStage(limelight.ui.model.MockStage) FakeScene(limelight.ui.model.FakeScene) Scene(limelight.ui.model.Scene) FakeScene(limelight.ui.model.FakeScene) Test(org.junit.Test)

Aggregations

Scene (limelight.ui.model.Scene)14 Test (org.junit.Test)10 FakeScene (limelight.ui.model.FakeScene)7 MockStage (limelight.ui.model.MockStage)5 RichStyle (limelight.styles.RichStyle)3 RadioButtonGroup (limelight.ui.RadioButtonGroup)3 FakePropProxy (limelight.model.api.FakePropProxy)2 PropPanel (limelight.ui.model.PropPanel)2 Opts (limelight.util.Opts)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Player (limelight.model.api.Player)1 Style (limelight.styles.Style)1 StringValue (limelight.styles.abstrstyling.StringValue)1 StageActivatedEvent (limelight.ui.events.stage.StageActivatedEvent)1 ImageCache (limelight.ui.model.ImageCache)1 ScenePanel (limelight.ui.model.ScenePanel)1 Box (limelight.util.Box)1