Search in sources :

Example 1 with IComponent

use of de.mossgrabers.framework.graphics.canvas.component.IComponent in project DrivenByMoss by git-moss.

the class AbstractGraphicDisplay method renderImage.

private void renderImage() {
    this.image.render(this.configuration.isAntialiasEnabled(), gc -> {
        final int width = this.dimensions.getWidth();
        final int height = this.dimensions.getHeight();
        final double separatorSize = this.dimensions.getSeparatorSize();
        // Clear display
        final ColorEx colorBorder = this.configuration.getColorBorder();
        gc.fillRectangle(0, 0, width, height, colorBorder);
        final List<IComponent> elements = this.info.getComponents();
        final int size = elements.size();
        if (size == 0)
            return;
        final int gridWidth = width / size;
        final double paintWidth = gridWidth - separatorSize;
        final double offsetX = separatorSize / 2.0;
        final IGraphicsInfo graphicsInfo = new DefaultGraphicsInfo(gc, this.configuration, this.dimensions);
        for (int i = 0; i < size; i++) {
            final IComponent component = elements.get(i);
            if (component != null)
                component.draw(graphicsInfo.withBounds(i * gridWidth + offsetX, 0, paintWidth, height));
        }
        final String notification = this.info.getNotification();
        if (notification == null)
            return;
        final ColorEx colorText = this.configuration.getColorText();
        gc.drawTextInBounds(notification, 0, 0, width, height, Align.CENTER, colorText, colorBorder, height / 4.0);
    });
}
Also used : DefaultGraphicsInfo(de.mossgrabers.framework.graphics.DefaultGraphicsInfo) IComponent(de.mossgrabers.framework.graphics.canvas.component.IComponent) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) IGraphicsInfo(de.mossgrabers.framework.graphics.IGraphicsInfo)

Aggregations

ColorEx (de.mossgrabers.framework.controller.color.ColorEx)1 DefaultGraphicsInfo (de.mossgrabers.framework.graphics.DefaultGraphicsInfo)1 IGraphicsInfo (de.mossgrabers.framework.graphics.IGraphicsInfo)1 IComponent (de.mossgrabers.framework.graphics.canvas.component.IComponent)1