package leigh.elements.javafx.type1;

import eu.hansolo.tilesfx.Tile;
import eu.hansolo.tilesfx.TileBuilder;
import javafx.scene.Node;
import javafx.scene.paint.Color;
import leigh.elements.ElementBase;
import leigh.elements.sdk.type1.TextTileElement;
import leigh.eo.EO;

public class TextTileElementJFX extends ElementBase implements ElementJFX {
    private final Tile tile;

    protected TextTileElementJFX(EO cfg) {
        super(cfg);

        String title = cfg.getValueString(TextTileElement.KEY_TITLE);
        String text = cfg.getValueString(TextTileElement.KEY_TEXT);

        TileBuilder tb = TileBuilder.create()
                .skinType(Tile.SkinType.TEXT)
                .prefSize(150, 150)
                .textVisible(true)
                .backgroundColor(Color.web("#808080"));

        if (title != null) {
            tb.title(title);
        }

        if (text != null) {
            tb.description(text);
        }

        tile = tb.build();
    }

    @Override
    public Node getJavaFXNode() {
        return tile;
    }
}
