Search in sources :

Example 1 with StringValue

use of limelight.styles.abstrstyling.StringValue 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)

Aggregations

IOException (java.io.IOException)1 Style (limelight.styles.Style)1 StringValue (limelight.styles.abstrstyling.StringValue)1 ImageCache (limelight.ui.model.ImageCache)1 Scene (limelight.ui.model.Scene)1 Box (limelight.util.Box)1