Search in sources :

Example 1 with RadialGradient

use of javafx.scene.paint.RadialGradient in project fxexperience2 by EricCanull.

the class ColorPickerControl method initialize.

/**
     * Private
     */
private void initialize() {
    final FXMLLoader loader = new FXMLLoader();
    //NOI18N
    loader.setLocation(ColorPickerControl.class.getResource("/fxml/FXMLColorPicker.fxml"));
    loader.setController(this);
    loader.setRoot(this);
    try {
        loader.load();
    } catch (IOException ex) {
        Logger.getLogger(ColorPickerControl.class.getName()).log(Level.SEVERE, null, ex);
    }
    assert hue_slider != null;
    assert picker_region != null;
    assert hue_textfield != null;
    assert saturation_textfield != null;
    assert brightness_textfield != null;
    assert alpha_textfield != null;
    assert red_textfield != null;
    assert green_textfield != null;
    assert blue_textfield != null;
    assert alpha_slider != null;
    // Make the grad for hue slider
    hue_slider.setStyle(makeHueSliderCSS());
    // Investigate why height + width listeners do not work
    // Indeed, the picker_handle_stackpane bounds may still be null at this point
    // UPDATE BELOW TO BE CALLED ONCE ONLY AT DISPLAY TIME
    picker_region.boundsInParentProperty().addListener((ov, oldb, newb) -> {
        picker_scrollpane.setHvalue(0.5);
        picker_scrollpane.setVvalue(0.5);
        // Init time only
        final Paint paint = paintPickerController.getPaintProperty();
        if (paint instanceof Color) {
            updateUI((Color) paint);
        } else if (paint instanceof LinearGradient || paint instanceof RadialGradient) {
            final GradientPicker gradientPicker = paintPickerController.getGradientPicker();
            final GradientPickerStop gradientPickerStop = gradientPicker.getSelectedStop();
            // Update the color preview with the color of the selected stop
            if (gradientPickerStop != null) {
                updateUI(gradientPickerStop.getColor());
            }
        }
    });
    final ChangeListener<Boolean> onHSBFocusedChange = (ov, oldValue, newValue) -> {
        if (newValue == false) {
            // Update UI
            final Color color = updateUI_OnHSBChange();
            // Update model
            setPaintProperty(color);
        }
    };
    final ChangeListener<Boolean> onRGBFocusedChange = (ov, oldValue, newValue) -> {
        if (newValue == false) {
            // Update UI
            final Color color = updateUI_OnRGBChange();
            // Update model
            setPaintProperty(color);
        }
    };
    final ChangeListener<Boolean> onHexaFocusedChange = (ov, oldValue, newValue) -> {
        if (newValue == false) {
            try {
                // Update UI
                final Color color = updateUI_OnHexaChange();
                // Update model
                setPaintProperty(color);
            } catch (IllegalArgumentException iae) {
                handleHexaException();
            }
        }
    };
    // TextField ON FOCUS LOST event handler
    hue_textfield.focusedProperty().addListener(onHSBFocusedChange);
    saturation_textfield.focusedProperty().addListener(onHSBFocusedChange);
    brightness_textfield.focusedProperty().addListener(onHSBFocusedChange);
    alpha_textfield.focusedProperty().addListener(onHSBFocusedChange);
    red_textfield.focusedProperty().addListener(onRGBFocusedChange);
    green_textfield.focusedProperty().addListener(onRGBFocusedChange);
    blue_textfield.focusedProperty().addListener(onRGBFocusedChange);
    hexa_textfield.focusedProperty().addListener(onHexaFocusedChange);
    // Slider ON VALUE CHANGE event handler
    hue_slider.valueProperty().addListener((ov, oldValue, newValue) -> {
        if (updating == true) {
            return;
        }
        double hue = newValue.doubleValue();
        // retrieve HSB TextFields values
        double saturation = Double.valueOf(saturation_textfield.getText()) / 100.0;
        double brightness = Double.valueOf(brightness_textfield.getText()) / 100.0;
        double alpha = Double.valueOf(alpha_textfield.getText());
        // Update UI
        final Color color = updateUI(hue, saturation, brightness, alpha);
        // Update model
        setPaintProperty(color);
    });
    alpha_slider.valueProperty().addListener((ov, oldValue, newValue) -> {
        if (updating == true) {
            return;
        }
        double alpha = newValue.doubleValue();
        // retrieve HSB TextFields values
        double hue = Double.valueOf(hue_textfield.getText());
        double saturation = Double.valueOf(saturation_textfield.getText()) / 100.0;
        double brightness = Double.valueOf(brightness_textfield.getText()) / 100.0;
        // Update UI
        final Color color = updateUI(hue, saturation, brightness, alpha);
        // Update model
        setPaintProperty(color);
    });
    final ChangeListener<Boolean> liveUpdateListener = (ov, oldValue, newValue) -> paintPickerController.setLiveUpdate(newValue);
    picker_region.pressedProperty().addListener(liveUpdateListener);
    hue_slider.pressedProperty().addListener(liveUpdateListener);
    alpha_slider.pressedProperty().addListener(liveUpdateListener);
}
Also used : Color(javafx.scene.paint.Color) TextField(javafx.scene.control.TextField) Mode(com.fxexperience.javafx.scene.control.paintpicker.PaintPicker.Mode) MouseEvent(javafx.scene.input.MouseEvent) IOException(java.io.IOException) StackPane(javafx.scene.layout.StackPane) LinearGradient(javafx.scene.paint.LinearGradient) GradientPickerStop(com.fxexperience.javafx.scene.control.gradientpicker.GradientPickerStop) Logger(java.util.logging.Logger) VBox(javafx.scene.layout.VBox) Level(java.util.logging.Level) FXML(javafx.fxml.FXML) PaintPickerController(com.fxexperience.javafx.scene.control.paintpicker.PaintPickerController) ActionEvent(javafx.event.ActionEvent) ScrollPane(javafx.scene.control.ScrollPane) Slider(javafx.scene.control.Slider) Region(javafx.scene.layout.Region) Paint(javafx.scene.paint.Paint) FXMLLoader(javafx.fxml.FXMLLoader) RadialGradient(javafx.scene.paint.RadialGradient) GradientPicker(com.fxexperience.javafx.scene.control.gradientpicker.GradientPicker) ChangeListener(javafx.beans.value.ChangeListener) Circle(javafx.scene.shape.Circle) Bounds(javafx.geometry.Bounds) Color(javafx.scene.paint.Color) RadialGradient(javafx.scene.paint.RadialGradient) IOException(java.io.IOException) Paint(javafx.scene.paint.Paint) FXMLLoader(javafx.fxml.FXMLLoader) GradientPickerStop(com.fxexperience.javafx.scene.control.gradientpicker.GradientPickerStop) GradientPicker(com.fxexperience.javafx.scene.control.gradientpicker.GradientPicker) LinearGradient(javafx.scene.paint.LinearGradient)

Example 2 with RadialGradient

use of javafx.scene.paint.RadialGradient in project Board-Instrumentation-Framework by intel.

the class Led method draw.

// ******************** Resize/Redraw *************************************
private void draw() {
    double size = getWidth() < getHeight() ? getWidth() : getHeight();
    canvas.setWidth(size);
    canvas.setHeight(size);
    ctx.clearRect(0, 0, size, size);
    if (isFrameVisible()) {
        // frame
        Paint frame = new LinearGradient(0.14 * size, 0.14 * size, 0.84 * size, 0.84 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(20, 20, 20, 0.65)), new Stop(0.15, Color.rgb(20, 20, 20, 0.65)), new Stop(0.26, Color.rgb(41, 41, 41, 0.65)), new Stop(0.26, Color.rgb(41, 41, 41, 0.64)), new Stop(0.85, Color.rgb(200, 200, 200, 0.41)), new Stop(1.0, Color.rgb(200, 200, 200, 0.35)));
        ctx.setFill(frame);
        ctx.fillOval(0, 0, size, size);
    }
    InnerShadow innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 0.07 * size, 0, 0, 0);
    if (isOn()) {
        // on
        ctx.save();
        Paint on = new LinearGradient(0.25 * size, 0.25 * size, 0.74 * size, 0.74 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, ((Color) ledColor.get()).deriveColor(0d, 1d, 0.77, 1d)), new Stop(0.49, ((Color) ledColor.get()).deriveColor(0d, 1d, 0.5, 1d)), new Stop(1.0, ((Color) ledColor.get())));
        innerShadow.setInput(new DropShadow(BlurType.TWO_PASS_BOX, (Color) ledColor.get(), 0.36 * size, 0, 0, 0));
        ctx.setEffect(innerShadow);
        ctx.setFill(on);
        ctx.fillOval(0.14 * size, 0.14 * size, 0.72 * size, 0.72 * size);
        ctx.restore();
    } else {
        // off
        ctx.save();
        Paint off = new LinearGradient(0.25 * size, 0.25 * size, 0.74 * size, 0.74 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, ((Color) ledColor.get()).deriveColor(0d, 1d, 0.20, 1d)), new Stop(0.49, ((Color) ledColor.get()).deriveColor(0d, 1d, 0.13, 1d)), new Stop(1.0, ((Color) ledColor.get()).deriveColor(0d, 1d, 0.2, 1d)));
        ctx.setEffect(innerShadow);
        ctx.setFill(off);
        ctx.fillOval(0.14 * size, 0.14 * size, 0.72 * size, 0.72 * size);
        ctx.restore();
    }
    // highlight
    Paint highlight = new RadialGradient(0, 0, 0.3 * size, 0.3 * size, 0.29 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.WHITE), new Stop(1.0, Color.TRANSPARENT));
    ctx.setFill(highlight);
    ctx.fillOval(0.21 * size, 0.21 * size, 0.58 * size, 0.58 * size);
}
Also used : LinearGradient(javafx.scene.paint.LinearGradient) Stop(javafx.scene.paint.Stop) InnerShadow(javafx.scene.effect.InnerShadow) Color(javafx.scene.paint.Color) RadialGradient(javafx.scene.paint.RadialGradient) Paint(javafx.scene.paint.Paint) DropShadow(javafx.scene.effect.DropShadow)

Example 3 with RadialGradient

use of javafx.scene.paint.RadialGradient in project Board-Instrumentation-Framework by intel.

the class LedOne method recalc.

// ******************** Resize/Redraw *************************************
private void recalc() {
    width = getWidth();
    height = getHeight();
    if (width <= 0 || height <= 0)
        return;
    size = width < height ? width : height;
    offsetX = 0;
    offsetY = 0;
    if (width > height) {
        offsetX = 0.5 * (width - size);
    } else if (height > width) {
        offsetY = 0.5 * (height - size);
    }
    ledOffShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 0.07 * size, 0, 0, 0);
    ledOnShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 0.07 * size, 0, 0, 0);
    ledOnShadow.setInput(new DropShadow(BlurType.TWO_PASS_BOX, ledColor.get(), 0.36 * size, 0, 0, 0));
    frameGradient = new LinearGradient(offsetX + 0.14 * size, offsetY + 0.14 * size, offsetX + 0.84 * size, offsetY + 0.84 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(20, 20, 20, 0.65)), new Stop(0.15, Color.rgb(20, 20, 20, 0.65)), new Stop(0.26, Color.rgb(41, 41, 41, 0.65)), new Stop(0.26, Color.rgb(41, 41, 41, 0.64)), new Stop(0.85, Color.rgb(200, 200, 200, 0.41)), new Stop(1.0, Color.rgb(200, 200, 200, 0.35)));
    ledOnGradient = new LinearGradient(offsetX + 0.25 * size, offsetY + 0.25 * size, offsetX + 0.74 * size, offsetY + 0.74 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, ledColor.get().deriveColor(0d, 1d, 0.77, 1d)), new Stop(0.49, ledColor.get().deriveColor(0d, 1d, 0.5, 1d)), new Stop(1.0, ledColor.get()));
    ledOffGradient = new LinearGradient(offsetX + 0.25 * size, offsetY + 0.25 * size, offsetX + 0.74 * size, offsetY + 0.74 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, ledColor.get().deriveColor(0d, 1d, 0.20, 1d)), new Stop(0.49, ledColor.get().deriveColor(0d, 1d, 0.13, 1d)), new Stop(1.0, ledColor.get().deriveColor(0d, 1d, 0.2, 1d)));
    highlightGradient = new RadialGradient(0, 0, offsetX + 0.3 * size, offsetY + 0.3 * size, 0.29 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.WHITE), new Stop(1.0, Color.TRANSPARENT));
    draw();
}
Also used : LinearGradient(javafx.scene.paint.LinearGradient) InnerShadow(javafx.scene.effect.InnerShadow) Stop(javafx.scene.paint.Stop) RadialGradient(javafx.scene.paint.RadialGradient) DropShadow(javafx.scene.effect.DropShadow)

Example 4 with RadialGradient

use of javafx.scene.paint.RadialGradient in project Board-Instrumentation-Framework by intel.

the class Led method recalc.

// ******************** Resize/Redraw *************************************
private void recalc() {
    double size = getWidth() < getHeight() ? getWidth() : getHeight();
    ledOffShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 0.07 * size, 0, 0, 0);
    ledOnShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 0.07 * size, 0, 0, 0);
    ledOnShadow.setInput(new DropShadow(BlurType.TWO_PASS_BOX, ledColor.get(), 0.36 * size, 0, 0, 0));
    frameGradient = new LinearGradient(0.14 * size, 0.14 * size, 0.84 * size, 0.84 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(20, 20, 20, 0.65)), new Stop(0.15, Color.rgb(20, 20, 20, 0.65)), new Stop(0.26, Color.rgb(41, 41, 41, 0.65)), new Stop(0.26, Color.rgb(41, 41, 41, 0.64)), new Stop(0.85, Color.rgb(200, 200, 200, 0.41)), new Stop(1.0, Color.rgb(200, 200, 200, 0.35)));
    ledOnGradient = new LinearGradient(0.25 * size, 0.25 * size, 0.74 * size, 0.74 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, ledColor.get().deriveColor(0d, 1d, 0.77, 1d)), new Stop(0.49, ledColor.get().deriveColor(0d, 1d, 0.5, 1d)), new Stop(1.0, ledColor.get()));
    ledOffGradient = new LinearGradient(0.25 * size, 0.25 * size, 0.74 * size, 0.74 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, ledColor.get().deriveColor(0d, 1d, 0.20, 1d)), new Stop(0.49, ledColor.get().deriveColor(0d, 1d, 0.13, 1d)), new Stop(1.0, ledColor.get().deriveColor(0d, 1d, 0.2, 1d)));
    highlightGradient = new RadialGradient(0, 0, 0.3 * size, 0.3 * size, 0.29 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.WHITE), new Stop(1.0, Color.TRANSPARENT));
    draw();
}
Also used : LinearGradient(javafx.scene.paint.LinearGradient) InnerShadow(javafx.scene.effect.InnerShadow) Stop(javafx.scene.paint.Stop) RadialGradient(javafx.scene.paint.RadialGradient) DropShadow(javafx.scene.effect.DropShadow)

Example 5 with RadialGradient

use of javafx.scene.paint.RadialGradient in project POL-POM-5 by PhoenicisOrg.

the class AbstractStepRepresentation method drawLeftImage.

protected void drawLeftImage() {
    AnchorPane pane = new AnchorPane();
    pane.setPrefWidth(187);
    Stop[] stops = new Stop[] { new Stop(0, Color.web("#3c79b2")), new Stop(1, Color.web("#2d5d8b")) };
    RadialGradient gradient = new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, stops);
    Background background = new Background(new BackgroundFill(gradient, null, null));
    pane.setBackground(background);
    Text text = new Text(this.parent.getLeftImageText());
    text.setFill(Color.WHITE);
    text.setFont(Font.font("Maven Pro", 50));
    text.setRotate(-90);
    pane.setPadding(new Insets(-50));
    pane.getChildren().add(text);
    AnchorPane.setBottomAnchor(text, 160.0);
    AnchorPane.setRightAnchor(text, -40.0);
    getParent().getRoot().setLeft(pane);
}
Also used : Insets(javafx.geometry.Insets) Stop(javafx.scene.paint.Stop) RadialGradient(javafx.scene.paint.RadialGradient) Text(javafx.scene.text.Text)

Aggregations

RadialGradient (javafx.scene.paint.RadialGradient)16 Stop (javafx.scene.paint.Stop)12 LinearGradient (javafx.scene.paint.LinearGradient)6 Paint (javafx.scene.paint.Paint)5 DropShadow (javafx.scene.effect.DropShadow)4 InnerShadow (javafx.scene.effect.InnerShadow)4 Color (javafx.scene.paint.Color)4 Text (javafx.scene.text.Text)4 Insets (javafx.geometry.Insets)3 GradientPicker (com.fxexperience.javafx.scene.control.gradientpicker.GradientPicker)2 GradientPickerStop (com.fxexperience.javafx.scene.control.gradientpicker.GradientPickerStop)2 Mode (com.fxexperience.javafx.scene.control.paintpicker.PaintPicker.Mode)2 PaintPickerController (com.fxexperience.javafx.scene.control.paintpicker.PaintPickerController)2 IOException (java.io.IOException)2 Level (java.util.logging.Level)2 Logger (java.util.logging.Logger)2 ChangeListener (javafx.beans.value.ChangeListener)2 FXML (javafx.fxml.FXML)2 FXMLLoader (javafx.fxml.FXMLLoader)2 CacheHint (javafx.scene.CacheHint)2