Search in sources :

Example 1 with JFXRadioButton

use of com.jfoenix.controls.JFXRadioButton in project JFoenix by jfoenixadmin.

the class JFXRadioButtonSkin method updateAnimation.

private void updateAnimation() {
    Color unSelectedColor = ((JFXRadioButton) getSkinnable()).getUnSelectedColor();
    Color selectedColor = ((JFXRadioButton) getSkinnable()).getSelectedColor();
    timeline = new Timeline(new KeyFrame(Duration.ZERO, new KeyValue(dot.scaleXProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(dot.scaleYProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(radio.strokeProperty(), unSelectedColor, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(200), new KeyValue(dot.scaleXProperty(), 0.6, Interpolator.EASE_BOTH), new KeyValue(dot.scaleYProperty(), 0.6, Interpolator.EASE_BOTH), new KeyValue(radio.strokeProperty(), selectedColor, Interpolator.EASE_BOTH)));
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) JFXRadioButton(com.jfoenix.controls.JFXRadioButton) Color(javafx.scene.paint.Color) KeyFrame(javafx.animation.KeyFrame)

Example 2 with JFXRadioButton

use of com.jfoenix.controls.JFXRadioButton in project JFoenix by jfoenixadmin.

the class JFXRadioButtonSkin method initializeComponents.

private void initializeComponents(final double x, final double y, final double w, final double h) {
    Color unSelectedColor = ((JFXRadioButton) getSkinnable()).getUnSelectedColor();
    Color selectedColor = ((JFXRadioButton) getSkinnable()).getSelectedColor();
    radio.setStroke(unSelectedColor);
    rippler.setRipplerFill(getSkinnable().isSelected() ? selectedColor : unSelectedColor);
    updateAnimation();
    playAnimation();
}
Also used : JFXRadioButton(com.jfoenix.controls.JFXRadioButton) Color(javafx.scene.paint.Color)

Example 3 with JFXRadioButton

use of com.jfoenix.controls.JFXRadioButton in project JFoenix by jfoenixadmin.

the class RadioButtonDemo method start.

@Override
public void start(Stage primaryStage) {
    final ToggleGroup group = new ToggleGroup();
    JFXRadioButton javaRadio = new JFXRadioButton("JavaFX");
    javaRadio.setPadding(new Insets(10));
    javaRadio.setToggleGroup(group);
    JFXRadioButton jfxRadio = new JFXRadioButton("JFoenix");
    jfxRadio.setPadding(new Insets(10));
    jfxRadio.setToggleGroup(group);
    VBox vbox = new VBox();
    vbox.getChildren().add(javaRadio);
    vbox.getChildren().add(jfxRadio);
    vbox.setSpacing(10);
    HBox hbox = new HBox();
    hbox.getChildren().add(vbox);
    hbox.setSpacing(50);
    hbox.setPadding(new Insets(40, 10, 10, 120));
    Scene scene = new Scene(hbox);
    primaryStage.setScene(scene);
    primaryStage.setWidth(500);
    primaryStage.setHeight(400);
    primaryStage.setTitle("JFX RadioButton Demo ");
    scene.getStylesheets().add(RadioButtonDemo.class.getResource("/css/jfoenix-components.css").toExternalForm());
    primaryStage.show();
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) JFXRadioButton(com.jfoenix.controls.JFXRadioButton) ToggleGroup(javafx.scene.control.ToggleGroup) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox)

Example 4 with JFXRadioButton

use of com.jfoenix.controls.JFXRadioButton in project JFoenix by jfoenixadmin.

the class JFXRadioButtonSkin method updateColors.

private void updateColors() {
    boolean isSelected = getSkinnable().isSelected();
    Color unSelectedColor = ((JFXRadioButton) getSkinnable()).getUnSelectedColor();
    Color selectedColor = ((JFXRadioButton) getSkinnable()).getSelectedColor();
    rippler.setRipplerFill(isSelected ? selectedColor : unSelectedColor);
    radio.setStroke(isSelected ? selectedColor : unSelectedColor);
}
Also used : JFXRadioButton(com.jfoenix.controls.JFXRadioButton) Color(javafx.scene.paint.Color)

Example 5 with JFXRadioButton

use of com.jfoenix.controls.JFXRadioButton in project JFoenix by jfoenixadmin.

the class JFXRadioButtonSkin method handleControlPropertyChanged.

@Override
protected void handleControlPropertyChanged(String p) {
    super.handleControlPropertyChanged(p);
    if ("SELECTED_COLOR".equals(p)) {
        // update current colors
        updateColors();
    } else if ("UNSELECTED_COLOR".equals(p)) {
        // update current colors
        updateColors();
    } else if ("SELECTED".equals(p)) {
        // update ripple color
        boolean isSelected = getSkinnable().isSelected();
        Color unSelectedColor = ((JFXRadioButton) getSkinnable()).getUnSelectedColor();
        Color selectedColor = ((JFXRadioButton) getSkinnable()).getSelectedColor();
        rippler.setRipplerFill(isSelected ? selectedColor : unSelectedColor);
        if (((JFXRadioButton) getSkinnable()).isDisableAnimation()) {
            // apply end values
            timer.applyEndValues();
        } else {
            // play selection animation
            timer.reverseAndContinue();
        }
    }
}
Also used : JFXRadioButton(com.jfoenix.controls.JFXRadioButton) Color(javafx.scene.paint.Color)

Aggregations

JFXRadioButton (com.jfoenix.controls.JFXRadioButton)5 Color (javafx.scene.paint.Color)4 KeyFrame (javafx.animation.KeyFrame)1 KeyValue (javafx.animation.KeyValue)1 Timeline (javafx.animation.Timeline)1 Insets (javafx.geometry.Insets)1 Scene (javafx.scene.Scene)1 ToggleGroup (javafx.scene.control.ToggleGroup)1 HBox (javafx.scene.layout.HBox)1 VBox (javafx.scene.layout.VBox)1