Search in sources :

Example 1 with DropShadow

use of javafx.scene.effect.DropShadow in project PayFile by mikehearn.

the class ClickableBitcoinAddress method showQRCode.

@FXML
protected void showQRCode(MouseEvent event) {
    // Serialize to PNG and back into an image. Pretty lame but it's the shortest code to write and I'm feeling
    // lazy tonight.
    final byte[] imageBytes = QRCode.from(uri()).withSize(320, 240).to(ImageType.PNG).stream().toByteArray();
    Image qrImage = new Image(new ByteArrayInputStream(imageBytes));
    ImageView view = new ImageView(qrImage);
    view.setEffect(new DropShadow());
    // Embed the image in a pane to ensure the drop-shadow interacts with the fade nicely, otherwise it looks weird.
    // Then fix the width/height to stop it expanding to fill the parent, which would result in the image being
    // non-centered on the screen. Finally fade/blur it in.
    Pane pane = new Pane(view);
    pane.setMaxSize(qrImage.getWidth(), qrImage.getHeight());
    final Main.OverlayUI<ClickableBitcoinAddress> overlay = Main.instance.overlayUI(pane, this);
    view.setOnMouseClicked(new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent event) {
            overlay.done();
        }
    });
}
Also used : MouseEvent(javafx.scene.input.MouseEvent) ByteArrayInputStream(java.io.ByteArrayInputStream) ImageView(javafx.scene.image.ImageView) Image(javafx.scene.image.Image) Pane(javafx.scene.layout.Pane) AnchorPane(javafx.scene.layout.AnchorPane) Main(net.plan99.payfile.gui.Main) DropShadow(javafx.scene.effect.DropShadow) FXML(javafx.fxml.FXML)

Example 2 with DropShadow

use of javafx.scene.effect.DropShadow in project Malai by arnobl.

the class Pencil method configureBindings.

@Override
protected void configureBindings() {
    // A DnD interaction with the left button of the mouse will produce an AddShape command while interacting on the canvas.
    // A temporary view of the created shape is created and displayed by the canvas.
    // This view is removed at the end of the interaction.
    nodeBinder(AddShape.class, new DnD()).on(canvas).map(i -> new AddShape(drawing, new MyRect(i.getSrcLocalPoint().getX(), i.getSrcLocalPoint().getY()))).first((c, i) -> canvas.setTmpShape(ViewFactory.INSTANCE.createViewShape(c.getShape()))).then((c, i) -> {
        final MyRect sh = (MyRect) c.getShape();
        sh.setWidth(i.getEndLocalPt().getX() - sh.getX());
        sh.setHeight(i.getEndLocalPt().getY() - sh.getY());
    }).when(i -> i.getButton() == MouseButton.PRIMARY).end((c, i) -> canvas.setTmpShape(null)).log(LogLevel.INTERACTION).strictStart().help(new AddRectHelpAnimation(learningPane, canvas)).bind();
    // A DnD interaction with the right button of the mouse moves the targeted shape.
    // To incrementally moves the shape, the DnD interaction has its parameter 'updateSrcOnUpdate' set to true:
    // At each interaction updates, the source point and object take the latest target point and object.
    // The DnD interaction can be stopped (aborted) by pressing the key 'ESC'. This cancels the ongoing command (that thus needs to be undoable).
    nodeBinder(MoveShape.class, new DnD(true, true)).on(canvas.getShapesPane().getChildren()).map(i -> {
        final MyShape sh = i.getSrcObject().map(o -> (MyShape) o.getUserData()).get();
        return new MoveShape(sh, Bindings.createDoubleBinding(() -> sh.getX() + (i.getEndScenePt().getX() - i.getSrcScenePoint().getX()), i.endScenePtProperty(), i.srcScenePointProperty()), Bindings.createDoubleBinding(() -> sh.getY() + (i.getEndScenePt().getY() - i.getSrcScenePoint().getY()), i.endScenePtProperty(), i.srcScenePointProperty()));
    }).when(i -> i.getButton() == MouseButton.SECONDARY).exec().first((c, i) -> {
        // Required to grab the focus to get key events
        Platform.runLater(() -> i.getSrcObject().get().requestFocus());
        i.getSrcObject().get().setEffect(new DropShadow(20d, Color.BLACK));
    }).endOrCancel((c, i) -> i.getSrcObject().get().setEffect(null)).strictStart().help(new MoveRectHelpAnimation(learningPane, canvas)).bind();
    // nodeBinder(MoveShape.class, new CancellableDnD(true)).
    // // The binding dynamically registers elements of the given observable list.
    // // When nodes are added to this list, these nodes register the binding.
    // // When nodes are removed from this list, their binding is cancelled.
    // // This permits to interact on nodes (here, shapes) that are dynamically added to/removed from the canvas.
    // on(canvas.getShapesPane().getChildren()).
    // map(i -> new MoveShape(i.getSrcObject().map(o ->(MyShape) o.getUserData()).orElse(null))).
    // then((a, i) -> a.setCoord(a.getShape().getX() + (i.getEndScenePt().getX() - i.getSrcScenePoint().getX()),
    // a.getShape().getY() + (i.getEndScenePt().getY() - i.getSrcScenePoint().getY()))).
    // when(i -> i.getButton() == MouseButton.SECONDARY).
    // // exec(true): this allows to execute the command each time the interaction updates (and 'when' is true).
    // exec(true).
    // first((a, i) -> {
    // // Required to grab the focus to get key events
    // Platform.runLater(() -> i.getSrcObject().get().requestFocus());
    // i.getSrcObject().get().setEffect(new DropShadow(20d, Color.BLACK));
    // }).
    // end((a, i) -> i.getSrcObject().get().setEffect(null)).
    // strictStart().
    // bind();
    /*
		 * A DnD on the colour picker produces ChangeCol commands when the target of the DnD is a shape
		 * (the shape we want to change the colour). The interim feedback changes the cursor during the DnD to show the dragged colour.
		 * Note that the feedback callback is not optimised here as the colour does not change during the DnD. The cursor
		 * should be changed in 'first'
		 */
    nodeBinder(ChangeColour.class, new DnD()).on(lineCol).map(i -> new ChangeColour(lineCol.getValue(), null)).then((a, i) -> i.getEndObjet().map(view -> (MyShape) view.getUserData()).ifPresent(sh -> a.setShape(sh))).when(i -> i.getEndObjet().orElse(null) instanceof Shape).feedback(() -> lineCol.getScene().setCursor(new ColorCursor(lineCol.getValue()))).endOrCancel((a, i) -> lineCol.getScene().setCursor(Cursor.DEFAULT)).bind();
    /*
		 * A mouse pressure creates an anonymous command that simply shows a message in the console.
		 */
    anonCmdBinder(() -> System.out.println("An example of the anonymous command."), new Press()).on(canvas).bind();
    /*
		 * A widget binding that execute a command asynchronously.
		 * Widgets and properties are provided to the binding to:
		 * show/hide the cancel button, provide widgets with information regarding the progress of the command execution.
		 */
    buttonBinder(Save.class).on(save).async(cancel, progressbar.progressProperty(), textProgress.textProperty()).bind();
}
Also used : Button(javafx.scene.control.Button) AddShape(org.malai.ex.draw.command.AddShape) Initializable(javafx.fxml.Initializable) MouseButton(javafx.scene.input.MouseButton) MyCanvas(org.malai.ex.draw.view.MyCanvas) MyDrawing(org.malai.ex.draw.model.MyDrawing) URL(java.net.URL) Bindings(javafx.beans.binding.Bindings) AddRectHelpAnimation(org.malai.ex.draw.learning.AddRectHelpAnimation) ProgressBar(javafx.scene.control.ProgressBar) MyRect(org.malai.ex.draw.model.MyRect) ResourceBundle(java.util.ResourceBundle) ListChangeListener(javafx.collections.ListChangeListener) MyShape(org.malai.ex.draw.model.MyShape) DnD(org.malai.javafx.interaction.library.DnD) Pane(javafx.scene.layout.Pane) Save(org.malai.ex.draw.command.Save) MoveRectHelpAnimation(org.malai.ex.draw.learning.MoveRectHelpAnimation) ColorPicker(javafx.scene.control.ColorPicker) LogLevel(org.malai.logging.LogLevel) Color(javafx.scene.paint.Color) Label(javafx.scene.control.Label) MoveShape(org.malai.ex.draw.command.MoveShape) ViewFactory(org.malai.ex.draw.view.ViewFactory) ChangeColour(org.malai.ex.draw.command.ChangeColour) JfxInstrument(org.malai.javafx.instrument.JfxInstrument) Group(javafx.scene.Group) Collectors(java.util.stream.Collectors) DropShadow(javafx.scene.effect.DropShadow) Objects(java.util.Objects) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) Cursor(javafx.scene.Cursor) Press(org.malai.javafx.interaction.library.Press) ColorCursor(org.malai.ex.util.ColorCursor) Shape(javafx.scene.shape.Shape) AddShape(org.malai.ex.draw.command.AddShape) MoveShape(org.malai.ex.draw.command.MoveShape) AddShape(org.malai.ex.draw.command.AddShape) MyShape(org.malai.ex.draw.model.MyShape) MoveShape(org.malai.ex.draw.command.MoveShape) Shape(javafx.scene.shape.Shape) MyRect(org.malai.ex.draw.model.MyRect) AddRectHelpAnimation(org.malai.ex.draw.learning.AddRectHelpAnimation) ChangeColour(org.malai.ex.draw.command.ChangeColour) MyShape(org.malai.ex.draw.model.MyShape) ColorCursor(org.malai.ex.util.ColorCursor) DropShadow(javafx.scene.effect.DropShadow) MoveRectHelpAnimation(org.malai.ex.draw.learning.MoveRectHelpAnimation) Save(org.malai.ex.draw.command.Save) DnD(org.malai.javafx.interaction.library.DnD) Press(org.malai.javafx.interaction.library.Press)

Example 3 with DropShadow

use of javafx.scene.effect.DropShadow in project jphp by jphp-compiler.

the class UXDropShadowEffect method __construct.

@Signature
public void __construct(double radius) {
    __wrappedObject = new DropShadow();
    getWrappedObject().setRadius(radius);
}
Also used : DropShadow(javafx.scene.effect.DropShadow)

Example 4 with DropShadow

use of javafx.scene.effect.DropShadow in project bitsquare by bitsquare.

the class MainView method setupDisputesIcon.

private void setupDisputesIcon(Pane buttonHolder) {
    Label label = new Label();
    label.textProperty().bind(model.numOpenDisputesAsString);
    label.relocate(5, 1);
    label.setId("nav-alert-label");
    ImageView icon = new ImageView();
    icon.setLayoutX(0.5);
    icon.setId("image-alert-round");
    Pane notification = new Pane();
    notification.relocate(30, 9);
    notification.setMouseTransparent(true);
    notification.setEffect(new DropShadow(4, 1, 2, Color.GREY));
    notification.getChildren().addAll(icon, label);
    notification.visibleProperty().bind(model.showOpenDisputesNotification);
    buttonHolder.getChildren().add(notification);
}
Also used : ImageView(javafx.scene.image.ImageView) AnchorPane(javafx.scene.layout.AnchorPane) DropShadow(javafx.scene.effect.DropShadow)

Example 5 with DropShadow

use of javafx.scene.effect.DropShadow in project FXGL by AlmasB.

the class HighlightSample method initUI.

@Override
protected void initUI() {
    Text text = getUIFactory().newText("Level 1", Color.WHITESMOKE, 46.0);
    DropShadow ds = new DropShadow(25, 0, 0, Color.BLACK);
    text.setEffect(ds);
    getUIFactory().centerText(text);
    getGameScene().addUINode(text);
}
Also used : Text(javafx.scene.text.Text) DropShadow(javafx.scene.effect.DropShadow)

Aggregations

DropShadow (javafx.scene.effect.DropShadow)38 Pane (javafx.scene.layout.Pane)18 InnerShadow (javafx.scene.effect.InnerShadow)17 Region (javafx.scene.layout.Region)13 Text (javafx.scene.text.Text)13 Canvas (javafx.scene.canvas.Canvas)9 Group (javafx.scene.Group)8 Label (javafx.scene.control.Label)8 ImageView (javafx.scene.image.ImageView)8 Rotate (javafx.scene.transform.Rotate)6 AnchorPane (javafx.scene.layout.AnchorPane)5 Color (javafx.scene.paint.Color)5 Stop (javafx.scene.paint.Stop)5 Image (javafx.scene.image.Image)4 RadialGradient (javafx.scene.paint.RadialGradient)4 FXML (javafx.fxml.FXML)3 ProgressBar (javafx.scene.control.ProgressBar)3 StackPane (javafx.scene.layout.StackPane)3 VBox (javafx.scene.layout.VBox)3 LinearGradient (javafx.scene.paint.LinearGradient)3