Skip to content

#08.3 Layer

Valkryst edited this page Feb 9, 2018 · 10 revisions

Create a Layer

import com.valkryst.VTerminal.Panel;
import com.valkryst.VTerminal.builder.PanelBuilder;
import com.valkryst.VTerminal.builder.component.LayerBuilder;
import com.valkryst.VTerminal.font.Font;
import com.valkryst.VTerminal.font.FontLoader;

import java.awt.Color;
import java.io.IOException;
import java.net.URISyntaxException;

public class Driver {
    public static void main(final String[] args) throws IOException, URISyntaxException {
        final Panel panel = new PanelBuilder().build();

        final LayerBuilder layerBuilder = new LayerBuilder();
        layerBuilder.setPosition(10, 10);
        layerBuilder.setWidth(5);
        layerBuilder.setHeight(5);
        layerBuilder.setBackgroundColor(Color.BLACK);

        panel.addComponents(layerBuilder.build());

        panel.draw();
    }
}

Code Explanation

final LayerBuilder layerBuilder = new LayerBuilder();

Constructs a new LayerBuilder. You can view the documentation here.

You can reuse the builder, so you won't need to create a new LayerBuilder every time you want to create a new check box.


layerBuilder.setPosition(10, 10);

This tells the builder to place the check box at position (10x, 10y).


layerBuilder.setWidth(5);
layerBuilder.setHeight(5);

This tells the builder that the layer should be 5 cells wide and 5 cells tall.


layerBuilder.setBackgroundColor(Color.BLACK);

This sets the background color of the layer to black.


panel.addComponents(layerBuilder.build());

This builds the layer and adds it to the panel.

Result

Clone this wiki locally