-
-
Notifications
You must be signed in to change notification settings - Fork 8
#08.3 Layer
Valkryst edited this page Nov 6, 2017
·
10 revisions
import com.valkryst.VTerminal.Panel;
import com.valkryst.VTerminal.builder.PanelBuilder;
import com.valkryst.VTerminal.builder.component.LayerBuilder;
import com.valkryst.VTerminal.component.Layer;
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, InterruptedException {
final Font font = FontLoader.loadFontFromJar("Fonts/DejaVu Sans Mono/20pt/bitmap.png",
"Fonts/DejaVu Sans Mono/20pt/data.fnt",
1);
final PanelBuilder builder = new PanelBuilder();
builder.setFont(font);
final Panel panel = builder.build();
final LayerBuilder layerBuilder = new LayerBuilder();
layerBuilder.setPosition(10, 10);
layerBuilder.setWidth(5);
layerBuilder.setHeight(5);
layerBuilder.setBackgroundColor(Color.BLACK);
panel.addComponents(layerBuilder.build());
Thread.sleep(50);
panel.draw();
}
}
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.