Java Code Examples for javafx.scene.Node#setEffect()

The following examples show how to use javafx.scene.Node#setEffect() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Transitions.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void removeEffect(Node node, int duration) {
    if (node != null) {
        node.setMouseTransparent(false);
        removeEffectTimeLine = new Timeline();
        GaussianBlur blur = (GaussianBlur) node.getEffect();
        if (blur != null) {
            KeyValue kv1 = new KeyValue(blur.radiusProperty(), 0.0);
            KeyFrame kf1 = new KeyFrame(Duration.millis(getDuration(duration)), kv1);
            removeEffectTimeLine.getKeyFrames().add(kf1);

            ColorAdjust darken = (ColorAdjust) blur.getInput();
            KeyValue kv2 = new KeyValue(darken.brightnessProperty(), 0.0);
            KeyFrame kf2 = new KeyFrame(Duration.millis(getDuration(duration)), kv2);
            removeEffectTimeLine.getKeyFrames().add(kf2);
            removeEffectTimeLine.setOnFinished(actionEvent -> {
                node.setEffect(null);
                removeEffectTimeLine = null;
            });
            removeEffectTimeLine.play();
        } else {
            node.setEffect(null);
            removeEffectTimeLine = null;
        }
    }
}
 
Example 2
Source File: MouseDragSnippet.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
protected void onMousePress(MouseEvent event) {
	pressed = (Node) event.getTarget();
	System.out.println("press " + pressed);
	startMousePosition = new Point2D(event.getSceneX(), event.getSceneY());
	startLayoutPosition = new Point2D(pressed.getLayoutX(),
			pressed.getLayoutY());

	// add effect
	pressed.setEffect(new Bloom(0));
	IAnchor ifxAnchor = anchors.get(pressed);
	if (ifxAnchor != null) {
		Set<AnchorKey> keys = ifxAnchor.positionsUnmodifiableProperty()
				.keySet();
		for (AnchorKey key : keys) {
			key.getAnchored().setEffect(null);
		}
	}
}
 
Example 3
Source File: AlertMaker.java    From Library-Assistant with Apache License 2.0 6 votes vote down vote up
public static void showMaterialDialog(StackPane root, Node nodeToBeBlurred, List<JFXButton> controls, String header, String body) {
    BoxBlur blur = new BoxBlur(3, 3, 3);
    if (controls.isEmpty()) {
        controls.add(new JFXButton("Okay"));
    }
    JFXDialogLayout dialogLayout = new JFXDialogLayout();
    JFXDialog dialog = new JFXDialog(root, dialogLayout, JFXDialog.DialogTransition.TOP);

    controls.forEach(controlButton -> {
        controlButton.getStyleClass().add("dialog-button");
        controlButton.addEventHandler(MouseEvent.MOUSE_CLICKED, (MouseEvent mouseEvent) -> {
            dialog.close();
        });
    });

    dialogLayout.setHeading(new Label(header));
    dialogLayout.setBody(new Label(body));
    dialogLayout.setActions(controls);
    dialog.show();
    dialog.setOnDialogClosed((JFXDialogEvent event1) -> {
        nodeToBeBlurred.setEffect(null);
    });
    nodeToBeBlurred.setEffect(blur);
}
 
Example 4
Source File: BlendEffect.java    From Learn-Java-12-Programming with MIT License 5 votes vote down vote up
static Node[] setEffectOnCircle(BlendMode bm1, BlendMode bm2){
    Node txt1 = new Text(bm1.name());
    Node txt2 = new Text(bm2.name());

    Blend blnd1 = new Blend();
    blnd1.setMode(bm1);

    Node c1 = createCircle();
    Node s1 = createSquare();
    c1.setEffect(blnd1);

    Node c2 = createCircle();
    Node s2 = createSquare();
    c2.setEffect(blnd1);

    Blend blnd2 = new Blend();
    blnd2.setMode(bm2);

    Node c3 = createCircle();
    Node s3 = createSquare();
    c3.setEffect(blnd2);

    Node c4 = createCircle();
    Node s4 = createSquare();
    c4.setEffect(blnd2);

    Node[] arr = {txt1, new Group(s1, c1), new Group(c2, s2), txt2, new Group(s3, c3), new Group(c4, s4) };
    return arr;
}
 
Example 5
Source File: GuiUtils.java    From thundernetwork with GNU Affero General Public License v3.0 5 votes vote down vote up
public static void blurOut(Node node) {
    GaussianBlur blur = new GaussianBlur(0.0);
    node.setEffect(blur);
    Timeline timeline = new Timeline();
    KeyValue kv = new KeyValue(blur.radiusProperty(), 10.0);
    KeyFrame kf = new KeyFrame(Duration.millis(UI_ANIMATION_TIME_MSEC), kv);
    timeline.getKeyFrames().add(kf);
    timeline.play();
}
 
Example 6
Source File: GuiUtils.java    From devcoretalk with GNU General Public License v2.0 5 votes vote down vote up
public static void blurOut(Node node) {
    GaussianBlur blur = new GaussianBlur(0.0);
    node.setEffect(blur);
    Timeline timeline = new Timeline();
    KeyValue kv = new KeyValue(blur.radiusProperty(), 10.0);
    KeyFrame kf = new KeyFrame(Duration.millis(UI_ANIMATION_TIME_MSEC), kv);
    timeline.getKeyFrames().add(kf);
    timeline.play();
}
 
Example 7
Source File: JFXTooltip.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Skin<?> createDefaultSkin() {
    return new TooltipSkin(this) {
        {
            Node node = getNode();
            node.setEffect(null);
        }
    };
}
 
Example 8
Source File: JFXDepthManager.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
/**
 * this method is used to add shadow effect to the node,
 * however the shadow is not real ( gets affected with node transformations)
 * <p>
 * use {@link #createMaterialNode(Node, int)} instead to generate a real shadow
 */
public static void setDepth(Node control, int level) {
    level = level < 0 ? 0 : level;
    level = level > 5 ? 5 : level;
    control.setEffect(new DropShadow(BlurType.GAUSSIAN,
        depth[level].getColor(),
        depth[level].getRadius(),
        depth[level].getSpread(),
        depth[level].getOffsetX(),
        depth[level].getOffsetY()));
}
 
Example 9
Source File: MainScene.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public void setGlow(Node node) {
	int depth = 70; //Setting the uniform variable for the glow width and height	 
	borderGlow = new DropShadow();
	borderGlow.setOffsetY(0f);
	borderGlow.setOffsetX(0f);
	if (theme == 7)
		borderGlow.setColor(Color.ORANGE);
	else
		borderGlow.setColor(Color.BLUE);		
	borderGlow.setWidth(depth);
	borderGlow.setHeight(depth); 
	node.setEffect(borderGlow);
}
 
Example 10
Source File: GuiUtils.java    From GreenBits with GNU General Public License v3.0 5 votes vote down vote up
public static void blurOut(Node node) {
    GaussianBlur blur = new GaussianBlur(0.0);
    node.setEffect(blur);
    Timeline timeline = new Timeline();
    KeyValue kv = new KeyValue(blur.radiusProperty(), 10.0);
    KeyFrame kf = new KeyFrame(Duration.millis(UI_ANIMATION_TIME_MSEC), kv);
    timeline.getKeyFrames().add(kf);
    timeline.play();
}
 
Example 11
Source File: FxIconBuilder.java    From FxDock with Apache License 2.0 5 votes vote down vote up
protected void applyNodeProperties(Node n)
{
	n.setOpacity(opacity);
	n.setScaleX(scale);
	n.setScaleY(scale);
	n.setTranslateX(xtranslate);
	n.setTranslateY(ytranslate);
	n.setEffect(effect);
	n.setRotate(rotate);
}
 
Example 12
Source File: GuiUtils.java    From thunder with GNU Affero General Public License v3.0 5 votes vote down vote up
public static void blurOut (Node node) {
    GaussianBlur blur = new GaussianBlur(0.0);
    node.setEffect(blur);
    Timeline timeline = new Timeline();
    KeyValue kv = new KeyValue(blur.radiusProperty(), 10.0);
    KeyFrame kf = new KeyFrame(Duration.millis(UI_ANIMATION_TIME_MSEC), kv);
    timeline.getKeyFrames().add(kf);
    timeline.play();
}
 
Example 13
Source File: GuiUtils.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
public static void blurOut(Node node) {
    GaussianBlur blur = new GaussianBlur(0.0);
    node.setEffect(blur);
    Timeline timeline = new Timeline();
    KeyValue kv = new KeyValue(blur.radiusProperty(), 10.0);
    KeyFrame kf = new KeyFrame(Duration.millis(UI_ANIMATION_TIME_MSEC), kv);
    timeline.getKeyFrames().add(kf);
    timeline.play();
}
 
Example 14
Source File: BlendEffect.java    From Learn-Java-12-Programming with MIT License 5 votes vote down vote up
static Node[] setEffectOnSquare(BlendMode bm1, BlendMode bm2){

        Node txt1 = new Text(bm1.name());
        Node txt2 = new Text(bm2.name());

        Blend blnd1 = new Blend();
        blnd1.setMode(bm1);

        Node c1 = createCircle();
        Node s1 = createSquare();
        s1.setEffect(blnd1);

        Node c2 = createCircle();
        Node s2 = createSquare();
        s2.setEffect(blnd1);

        Blend blnd2 = new Blend();
        blnd2.setMode(bm2);

        Node c3 = createCircle();
        Node s3 = createSquare();
        s3.setEffect(blnd2);

        Node c4 = createCircle();
        Node s4 = createSquare();
        s4.setEffect(blnd2);

        Node[] arr = {txt1, new Group(s1, c1), new Group(c2, s2), txt2, new Group(s3, c3), new Group(c4, s4) };
        return arr;
    }
 
Example 15
Source File: BlendEffect.java    From Learn-Java-12-Programming with MIT License 5 votes vote down vote up
static Node[] setEffectOnGroup(BlendMode bm1, BlendMode bm2){
    Node txt1 = new Text(bm1.name());
    Node txt2 = new Text(bm2.name());

    Blend blnd1 = new Blend();
    blnd1.setMode(bm1);

    Node c1 = createCircle();
    Node s1 = createSquare();
    Node g1 = new Group(s1, c1);
    g1.setEffect(blnd1);

    Node c2 = createCircle();
    Node s2 = createSquare();
    Node g2 = new Group(c2, s2);
    g2.setEffect(blnd1);

    Blend blnd2 = new Blend();
    blnd2.setMode(bm2);

    Node c3 = createCircle();
    Node s3 = createSquare();
    Node g3 = new Group(s3, c3);
    g3.setEffect(blnd2);

    Node c4 = createCircle();
    Node s4 = createSquare();
    Node g4 = new Group(c4, s4);
    g4.setEffect(blnd2);

    Node[] arr = {txt1, g1, g2, txt2, g3, g4 };
    return arr;
}
 
Example 16
Source File: MosaicPane.java    From Mosaic with Apache License 2.0 4 votes vote down vote up
public SurfaceListener<T> getSurfaceObserver() {
	SurfaceListener<T> l = new SurfaceListener<T>() {
		public void changed(ChangeType changeType, Node n, String id, Rectangle2D r1, Rectangle2D r2) {
			switch(changeType) {
		    	case REMOVE_DISCARD: {
		    		content.getChildren().remove(n);
		    		requestLayout();
		    		break;
		    	}
		    	case RESIZE_RELOCATE: {
		    		n.resizeRelocate(r2.getX(), r2.getY(), r2.getWidth(), r2.getHeight());
					requestLayout();
			        
			        break;
		    	}
		    	case ADD_COMMIT: {
		    		content.getChildren().add(n);
		    		n.resizeRelocate(r2.getX(), r2.getY(), r2.getWidth(), r2.getHeight());
					requestLayout();
			        break;
		    	}
		    	case MOVE_BEGIN: {
		    		DropShadow shadow = new DropShadow();
		    		shadow.setOffsetX(10);
		    		shadow.setOffsetY(10);
		    		shadow.setRadius(5);
		    		shadow.setColor(Color.GRAY);
		    		n.setEffect(shadow);
		    		n.toFront();
		    		n.setOpacity(.5);
		    		break;
		    	}
		    	case RELOCATE_DRAG_TARGET: {
		    		n.resizeRelocate(r2.getX(), r2.getY(), r2.getWidth(), r2.getHeight());
					requestLayout();
		    		break;
		    	}
		    	case RESIZE_DRAG_TARGET: {
		    		n.resizeRelocate(r2.getX(), r2.getY(), r2.getWidth(), r2.getHeight());
					requestLayout();
			        break;
		    	}
		    	case MOVE_END: {
		    		n.setOpacity(1);
		    		n.setEffect(null);
		    		break;
		    	}
		    	case ANIMATE_RESIZE_RELOCATE: {
		    		n.resizeRelocate(r2.getX(), r2.getY(), r2.getWidth(), r2.getHeight());
					requestLayout();
			        break;
		    	}
		    	default: break;
	    	}
		}
	};
	return l;
}
 
Example 17
Source File: JFXDepthManager.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
public static void pop(Node control) {
    control.setEffect(new DropShadow(BlurType.GAUSSIAN, Color.rgb(0, 0, 0, 0.26), 5, 0.05, 0, 1));
}
 
Example 18
Source File: EnvironmentView.java    From narjillos with MIT License 4 votes vote down vote up
private void darkenWithDistance(Node node, double zoomLevel) {
	double brightnessAdjust = -zoomLevel / 5;
	node.setEffect(new ColorAdjust(0, 0, brightnessAdjust, 0));
}