119 lines
4.8 KiB
Java
119 lines
4.8 KiB
Java
package fi.lpam.gui;
|
|
|
|
import fi.lpam.Main;
|
|
import fi.lpam.gui.elementit.TabPohja;
|
|
import javafx.collections.FXCollections;
|
|
import javafx.collections.ObservableList;
|
|
import javafx.geometry.Pos;
|
|
import javafx.scene.control.Button;
|
|
import javafx.scene.control.ComboBox;
|
|
import javafx.scene.control.Label;
|
|
import javafx.scene.control.Spinner;
|
|
import javafx.scene.layout.BorderPane;
|
|
import javafx.scene.layout.GridPane;
|
|
import javafx.scene.layout.HBox;
|
|
import javafx.scene.text.Font;
|
|
|
|
import java.util.Properties;
|
|
|
|
|
|
public class Asetukset extends TabPohja {
|
|
private static final Properties prop = Main.properties;
|
|
private static final ObservableList<String> järjestelmäFontit = FXCollections.observableArrayList(Font.getFamilies());
|
|
|
|
|
|
public Asetukset() {
|
|
BorderPane root = new BorderPane();
|
|
root.setPadding(oletusInsets);
|
|
|
|
HBox yläpalkki = new HBox();
|
|
yläpalkki.setSpacing(5);
|
|
yläpalkki.setAlignment(Pos.CENTER_RIGHT);
|
|
Button btnNollaa = new Button("Palauta oletukset");
|
|
btnNollaa.setFont(buttonFont);
|
|
btnNollaa.setOnAction(_ -> palautaOletukset());
|
|
yläpalkki.getChildren().add(btnNollaa);
|
|
root.setTop(yläpalkki);
|
|
|
|
root.setLeft(getFonttiAsetukset());
|
|
|
|
Label asetukset = new Label("Asetukset");
|
|
asetukset.setFont(tekstiFont);
|
|
root.setRight(asetukset);
|
|
|
|
this.getChildren().add(root);
|
|
}
|
|
|
|
private Spinner<Integer> tekstiFonttiKoko, buttonFonttiKoko, tulostusFonttiKoko, insets;
|
|
private ComboBox<String> tekstiFontti, buttonFontti;
|
|
private int minFonttiKoko = 8;
|
|
private int maxFonttiKoko = 30;
|
|
private int stepFontti = 1;
|
|
|
|
/**
|
|
* Luo paneelin fonttien asetusten säätämiseen
|
|
* @return paneeli
|
|
*/
|
|
private GridPane getFonttiAsetukset() {
|
|
GridPane root = new GridPane();
|
|
root.setAlignment(Pos.CENTER);
|
|
root.setHgap(10);
|
|
root.setVgap(10);
|
|
root.setBorder(oletusBorder);
|
|
root.setPadding(oletusInsets);
|
|
int row = 0;
|
|
|
|
Label otsikko = new Label("Fonttien asetukset");
|
|
otsikko.setFont(tekstiFont);
|
|
root.addRow(row++, otsikko);
|
|
|
|
tekstiFonttiKoko = new Spinner<>(minFonttiKoko, maxFonttiKoko, Double.parseDouble(prop.getProperty("tekstiFonttiKoko")), stepFontti);
|
|
tekstiFonttiKoko.setEditable(true);
|
|
tekstiFonttiKoko.valueProperty().addListener((_) -> prop.setProperty("tekstiFonttiKoko", String.valueOf(tekstiFonttiKoko.getValue())));
|
|
Label tekstinKoko = new Label("Tekstin koko");
|
|
tekstinKoko.setFont(tekstiFont);
|
|
root.addRow(row++, tekstinKoko, tekstiFonttiKoko);
|
|
|
|
tekstiFontti = new ComboBox<>();
|
|
tekstiFontti.setItems(järjestelmäFontit);
|
|
tekstiFontti.getSelectionModel().select(prop.getProperty("tekstiFontti"));
|
|
tekstiFontti.valueProperty().addListener((_) -> prop.setProperty("tekstiFontti", tekstiFontti.getValue()));
|
|
Label tekstinFontti = new Label("Tekstin fontti");
|
|
tekstinFontti.setFont(tekstiFont);
|
|
root.addRow(row++, tekstinFontti, tekstiFontti);
|
|
|
|
buttonFonttiKoko = new Spinner<>(minFonttiKoko, maxFonttiKoko, Double.parseDouble(prop.getProperty("buttonFonttiKoko")), stepFontti);
|
|
buttonFonttiKoko.valueProperty().addListener((_) -> prop.setProperty("buttonFonttiKoko", String.valueOf(buttonFonttiKoko.getValue())));
|
|
Label nappiTekstinKoko = new Label("Painikkeiden koko");
|
|
nappiTekstinKoko.setFont(tekstiFont);
|
|
root.addRow(row++, nappiTekstinKoko, buttonFonttiKoko);
|
|
|
|
buttonFontti = new ComboBox<>();
|
|
buttonFontti.setItems(järjestelmäFontit);
|
|
buttonFontti.getSelectionModel().select(prop.getProperty("buttonFontti"));
|
|
buttonFontti.valueProperty().addListener((_) -> prop.setProperty("buttonFontti", buttonFontti.getValue()));
|
|
Label napinFontti = new Label("Painikkeiden fontti");
|
|
napinFontti.setFont(tekstiFont);
|
|
root.addRow(row++, napinFontti, buttonFontti);
|
|
|
|
tulostusFonttiKoko = new Spinner<>(minFonttiKoko, maxFonttiKoko, Double.parseDouble(prop.getProperty("tulostusFonttiKoko")), stepFontti);
|
|
tulostusFonttiKoko.valueProperty().addListener((_) -> prop.setProperty("tulostusFonttiKoko", String.valueOf(tulostusFonttiKoko.getValue())));
|
|
Label tulostusFontinKoko = new Label("Tulostusfontin koko");
|
|
tulostusFontinKoko.setFont(tekstiFont);
|
|
root.addRow(row++, tulostusFontinKoko, tulostusFonttiKoko);
|
|
|
|
insets = new Spinner<>(0, 10, Double.parseDouble(prop.getProperty("insets")), 1);
|
|
insets.valueProperty().addListener((_) -> prop.setProperty("insets", String.valueOf(insets.getValue())));
|
|
Label insetsi = new Label("Yleinen fyllinki");
|
|
insetsi.setFont(tekstiFont);
|
|
root.addRow(row++, insetsi, insets);
|
|
|
|
return root;
|
|
}
|
|
|
|
private void palautaOletukset() {
|
|
|
|
|
|
}
|
|
}
|