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);
}
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);
}