Search in sources :

Example 11 with ColorPicker

use of javafx.scene.control.ColorPicker in project FXGL by AlmasB.

the class ParticleSystemSample method initUI.

@Override
protected void initUI() {
    Spinner<Integer> spinnerNumParticles = new Spinner<>(0, 100, 15, 1);
    emitter.numParticlesProperty().bind(spinnerNumParticles.valueProperty());
    Spinner<Double> spinnerRate = new Spinner<>(0.0, 1.0, 1.0, 0.05);
    emitter.emissionRateProperty().bind(spinnerRate.valueProperty());
    Spinner<Double> spinnerMinSize = new Spinner<>(1.0, 100.0, 9.0, 1);
    emitter.minSizeProperty().bind(spinnerMinSize.valueProperty());
    Spinner<Double> spinnerMaxSize = new Spinner<>(1.0, 100.0, 12.0, 1);
    emitter.maxSizeProperty().bind(spinnerMaxSize.valueProperty());
    Spinner<Double> spinnerVelX = new Spinner<>(-500.0, 500.0, 0.0, 10);
    Spinner<Double> spinnerVelY = new Spinner<>(-500.0, 500.0, -30.0, 10);
    spinnerVelX.setPrefWidth(65);
    spinnerVelY.setPrefWidth(65);
    spinnerVelX.valueProperty().addListener((observable, oldValue, newValue) -> {
        emitter.setVelocityFunction((i, x, y) -> new Point2D(newValue, spinnerVelY.getValue()));
    });
    spinnerVelY.valueProperty().addListener((observable, oldValue, newValue) -> {
        emitter.setVelocityFunction((i, x, y) -> new Point2D(spinnerVelX.getValue(), newValue));
    });
    Spinner<Double> spinnerAccelX = new Spinner<>(-150.0, 150.0, 0.0, 10);
    Spinner<Double> spinnerAccelY = new Spinner<>(-150.0, 150.0, 0.0, 10);
    spinnerAccelX.setPrefWidth(65);
    spinnerAccelY.setPrefWidth(65);
    spinnerAccelX.valueProperty().addListener((observable, oldValue, newValue) -> {
        emitter.setAccelerationFunction(() -> new Point2D(newValue, spinnerAccelY.getValue()));
    });
    spinnerAccelY.valueProperty().addListener((observable, oldValue, newValue) -> {
        emitter.setAccelerationFunction(() -> new Point2D(spinnerAccelX.getValue(), newValue));
    });
    ChoiceBox<BlendMode> choiceBlend = getUIFactory().newChoiceBox(FXCollections.observableArrayList(BlendMode.values()));
    emitter.blendModeProperty().bind(choiceBlend.valueProperty());
    choiceBlend.setValue(BlendMode.ADD);
    ChoiceBox<EasingInterpolator> choiceInterpolator = getUIFactory().newChoiceBox(FXCollections.observableArrayList(Interpolators.values()));
    choiceInterpolator.setValue(Interpolators.LINEAR);
    choiceInterpolator.valueProperty().addListener((observable, oldValue, newValue) -> {
        emitter.setInterpolator(newValue.EASE_OUT());
    });
    ColorPicker startColor = new ColorPicker((Color) emitter.getStartColor());
    ColorPicker endColor = new ColorPicker((Color) emitter.getEndColor());
    emitter.startColorProperty().bind(startColor.valueProperty());
    emitter.endColorProperty().bind(endColor.valueProperty());
    VBox vbox = new VBox(10);
    vbox.setTranslateX(700);
    vbox.getChildren().addAll(new HBox(10, new Text("Vel X and Y"), spinnerVelX, spinnerVelY), new HBox(10, new Text("Acc X and Y"), spinnerAccelX, spinnerAccelY), new Text("Number of Particles:"), spinnerNumParticles, new Text("Min Size:"), spinnerMinSize, new Text("Max Size:"), spinnerMaxSize, new Text("Emission Rate:"), spinnerRate, new Text("Start Color:"), startColor, new Text("End Color:"), endColor, choiceBlend, choiceInterpolator);
    getGameScene().addUINode(vbox);
}
Also used : HBox(javafx.scene.layout.HBox) EasingInterpolator(com.almasb.fxgl.animation.EasingInterpolator) ColorPicker(javafx.scene.control.ColorPicker) Spinner(javafx.scene.control.Spinner) BlendMode(javafx.scene.effect.BlendMode) Text(javafx.scene.text.Text) Point2D(javafx.geometry.Point2D) VBox(javafx.scene.layout.VBox)

Example 12 with ColorPicker

use of javafx.scene.control.ColorPicker in project Malai by arnobl.

the class TestScroll method testScrollingNoActionWhenNullRegistered.

@Test
void testScrollingNoActionWhenNullRegistered() throws CancelFSMException {
    ColorPicker dummyWidget = new ColorPicker();
    interaction.registerToNodes(null);
    dummyWidget.fireEvent(createScrollEvent(1, 2, 5, 0));
    Mockito.verify(handler, Mockito.never()).fsmStops();
    Mockito.verify(handler, Mockito.never()).fsmStarts();
}
Also used : ColorPicker(javafx.scene.control.ColorPicker) Test(org.junit.jupiter.api.Test)

Example 13 with ColorPicker

use of javafx.scene.control.ColorPicker in project Malai by arnobl.

the class TestScroll method testScrollingNoActionWhenContainsNullRegistered.

@Test
void testScrollingNoActionWhenContainsNullRegistered() throws CancelFSMException {
    ColorPicker dummyWidget = new ColorPicker();
    interaction.registerToNodes(Collections.singletonList(null));
    dummyWidget.fireEvent(createScrollEvent(1, 2, 5, 0));
    Mockito.verify(handler, Mockito.never()).fsmStops();
    Mockito.verify(handler, Mockito.never()).fsmStarts();
}
Also used : ColorPicker(javafx.scene.control.ColorPicker) Test(org.junit.jupiter.api.Test)

Example 14 with ColorPicker

use of javafx.scene.control.ColorPicker in project Malai by arnobl.

the class TestScroll method testNoActionWhenNotScrollingRegistered.

@Test
void testNoActionWhenNotScrollingRegistered() throws CancelFSMException {
    ColorPicker dummyWidgetNotRegistered = new ColorPicker();
    interaction.registerToNodes(Collections.singletonList(new CheckBox()));
    dummyWidgetNotRegistered.fireEvent(createScrollEvent(1, 2, 5, 0));
    Mockito.verify(handler, Mockito.never()).fsmStops();
    Mockito.verify(handler, Mockito.never()).fsmStarts();
}
Also used : ColorPicker(javafx.scene.control.ColorPicker) CheckBox(javafx.scene.control.CheckBox) Test(org.junit.jupiter.api.Test)

Aggregations

ColorPicker (javafx.scene.control.ColorPicker)14 Test (org.junit.jupiter.api.Test)5 Label (javafx.scene.control.Label)3 VBox (javafx.scene.layout.VBox)3 Insets (javafx.geometry.Insets)2 Scene (javafx.scene.Scene)2 Button (javafx.scene.control.Button)2 CheckBox (javafx.scene.control.CheckBox)2 Separator (javafx.scene.control.Separator)2 Spinner (javafx.scene.control.Spinner)2 HBox (javafx.scene.layout.HBox)2 Region (javafx.scene.layout.Region)2 Color (javafx.scene.paint.Color)2 EasingInterpolator (com.almasb.fxgl.animation.EasingInterpolator)1 JFXColorPickerSkin (com.jfoenix.skins.JFXColorPickerSkin)1 DataInputStream (java.io.DataInputStream)1 DataOutputStream (java.io.DataOutputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1