Search in sources :

Example 1 with TranslateTransition

use of javafx.animation.TranslateTransition in project Board-Instrumentation-Framework by intel.

the class IconSwitchSkin method initGraphics.

private void initGraphics() {
    // "OpenSans"
    Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/opensans-semibold.ttf"), (0.5 * PREFERRED_HEIGHT));
    font = Font.font("Open Sans", 0.5 * PREFERRED_HEIGHT);
    background = new Region();
    background.getStyleClass().setAll("background");
    background.setStyle("-switch-color: " + Util.colorToCss((Color) getSkinnable().getSwitchColor()) + ";");
    symbol = getSkinnable().getSymbol();
    symbol.setMouseTransparent(true);
    text = new Label(getSkinnable().getText());
    text.setTextAlignment(TextAlignment.CENTER);
    text.setAlignment(Pos.CENTER);
    text.setTextFill(getSkinnable().getSymbolColor());
    text.setFont(font);
    thumb = new Region();
    thumb.getStyleClass().setAll("thumb");
    thumb.setStyle("-thumb-color: " + Util.colorToCss((Color) getSkinnable().getThumbColor()) + ";");
    thumb.setMouseTransparent(true);
    pane = new Pane(background, symbol, text, thumb);
    pane.getStyleClass().setAll("icon-switch");
    moveToDeselected = new TranslateTransition(Duration.millis(180), thumb);
    moveToSelected = new TranslateTransition(Duration.millis(180), thumb);
    // Add all nodes
    getChildren().setAll(pane);
}
Also used : TranslateTransition(javafx.animation.TranslateTransition) Color(javafx.scene.paint.Color) Label(javafx.scene.control.Label) Region(javafx.scene.layout.Region) Pane(javafx.scene.layout.Pane)

Example 2 with TranslateTransition

use of javafx.animation.TranslateTransition in project Board-Instrumentation-Framework by intel.

the class OnOffSwitchSkin method initGraphics.

private void initGraphics() {
    // "OpenSans"
    Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/opensans-semibold.ttf"), (0.5 * PREFERRED_HEIGHT));
    font = Font.font("Open Sans", 0.5 * PREFERRED_HEIGHT);
    background = new Region();
    background.getStyleClass().setAll("background");
    background.setStyle("-switch-color: " + Util.colorToCss((Color) getSkinnable().getSwitchColor()) + ";");
    selectedText = new Text("1");
    selectedText.setFont(font);
    selectedText.getStyleClass().setAll("selected-text");
    selectedText.setStyle("-text-color-on: " + Util.colorToCss((Color) getSkinnable().getTextColorOn()) + ";");
    deselectedText = new Text("0");
    deselectedText.setFont(font);
    deselectedText.getStyleClass().setAll("deselected-text");
    deselectedText.setStyle("-text-color-off: " + Util.colorToCss((Color) getSkinnable().getTextColorOff()) + ";");
    thumb = new Region();
    thumb.getStyleClass().setAll("thumb");
    thumb.setMouseTransparent(true);
    thumb.setStyle("-thumb-color: " + Util.colorToCss((Color) getSkinnable().getThumbColor()) + ";");
    pane = new Pane(background, selectedText, deselectedText, thumb);
    pane.getStyleClass().setAll("on-off-switch");
    moveToDeselected = new TranslateTransition(Duration.millis(180), thumb);
    moveToSelected = new TranslateTransition(Duration.millis(180), thumb);
    // Add all nodes
    getChildren().setAll(pane);
}
Also used : TranslateTransition(javafx.animation.TranslateTransition) Color(javafx.scene.paint.Color) Region(javafx.scene.layout.Region) Text(javafx.scene.text.Text) Pane(javafx.scene.layout.Pane)

Aggregations

TranslateTransition (javafx.animation.TranslateTransition)2 Pane (javafx.scene.layout.Pane)2 Region (javafx.scene.layout.Region)2 Color (javafx.scene.paint.Color)2 Label (javafx.scene.control.Label)1 Text (javafx.scene.text.Text)1