Search in sources :

Example 1 with Style

use of limelight.styles.Style 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 Style

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

the class BorderPainter method paint.

public void paint(Graphics2D graphics, PaintablePanel panel) {
    Style style = panel.getStyle();
    Pen pen = new Pen(graphics);
    Border border = panel.getBorderShaper();
    if (border.hasTopBorder())
        pen.withColor(style.getCompiledTopBorderColor().getColor()).withStroke(border.getTopWidth()).withAntialiasing(false).draw(border.getTopLine());
    if (border.hasTopRightCorner())
        pen.withColor(style.getCompiledTopRightBorderColor().getColor()).withStroke(border.getTopRightWidth()).withAntialiasing(true).draw(border.getTopRightArc());
    if (border.hasRightBorder())
        pen.withColor(style.getCompiledRightBorderColor().getColor()).withStroke(border.getRightWidth()).withAntialiasing(false).draw(border.getRightLine());
    if (border.hasBottomRightCorner())
        pen.withColor(style.getCompiledBottomRightBorderColor().getColor()).withStroke(border.getBottomRightWidth()).withAntialiasing(true).draw(border.getBottomRightArc());
    if (border.hasBottomBorder())
        pen.withColor(style.getCompiledBottomBorderColor().getColor()).withStroke(border.getBottomWidth()).withAntialiasing(false).draw(border.getBottomLine());
    if (border.hasBottomLeftCorner())
        pen.withColor(style.getCompiledBottomLeftBorderColor().getColor()).withStroke(border.getBottomLeftWidth()).withAntialiasing(true).draw(border.getBottomLeftArc());
    if (border.hasLeftBorder())
        pen.withColor(style.getCompiledLeftBorderColor().getColor()).withStroke(border.getLeftWidth()).withAntialiasing(false).draw(border.getLeftLine());
    if (border.hasTopLeftCorner())
        pen.withColor(style.getCompiledTopLeftBorderColor().getColor()).withStroke(border.getTopLeftWidth()).withAntialiasing(true).draw(border.getTopLeftArc());
}
Also used : Pen(limelight.ui.Pen) Style(limelight.styles.Style)

Example 3 with Style

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

the class ScrollLayout method layoutRows.

public void layoutRows(PropPanel panel, Dimension consumeDimension, LinkedList<Row> rows, int dx, int dy) {
    Style style = panel.getStyle();
    int y = style.getCompiledVerticalAlignment().getY(consumeDimension.height, panel.getChildConsumableBounds());
    y = Math.max(0, y);
    y -= dy;
    for (Row row : rows) {
        int x = style.getCompiledHorizontalAlignment().getX(row.width, panel.getChildConsumableBounds());
        x = Math.max(0, x);
        x -= dx;
        row.layoutComponents(x, y, style.getCompiledVerticalAlignment());
        y += row.height;
    }
}
Also used : Style(limelight.styles.Style)

Example 4 with Style

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

the class TextPanelTextPainter method paint.

@Override
public void paint(Graphics2D graphics, limelight.ui.model.text.TextModel model) {
    if (!model.hasText())
        return;
    float y = model.getYOffset();
    Style style = model.getContainer().getStyle();
    graphics.setColor(style.getCompiledTextColor().getColor());
    for (TypedLayout line : model.getLines()) {
        int x = model.getXOffset(line);
        y += line.getAscent();
        line.draw(graphics, x, y);
        y += line.getDescent() + line.getLeading();
    }
}
Also used : TypedLayout(limelight.ui.text.TypedLayout) Style(limelight.styles.Style)

Example 5 with Style

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

the class BuiltInStylesTest method hasCurtains.

@Test
public void hasCurtains() throws Exception {
    Style curtains = styles.get("limelight_builtin_curtains");
    assertNotNull(curtains);
    assertEquals("on", curtains.getFloat());
}
Also used : Style(limelight.styles.Style) RichStyle(limelight.styles.RichStyle) Test(org.junit.Test)

Aggregations

Style (limelight.styles.Style)14 RichStyle (limelight.styles.RichStyle)4 Test (org.junit.Test)4 Box (limelight.util.Box)3 AutoDimensionValue (limelight.styles.values.AutoDimensionValue)2 IOException (java.io.IOException)1 LimelightException (limelight.LimelightException)1 StringValue (limelight.styles.abstrstyling.StringValue)1 GreedyDimensionValue (limelight.styles.values.GreedyDimensionValue)1 Pen (limelight.ui.Pen)1 ImageCache (limelight.ui.model.ImageCache)1 Scene (limelight.ui.model.Scene)1 TypedLayout (limelight.ui.text.TypedLayout)1