javafx.scene.effect.MotionBlur Java Examples
The following examples show how to use
javafx.scene.effect.MotionBlur.
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: OrganView.java From narjillos with MIT License | 6 votes |
private void addMotionBlurEffect(Shape organShape, double zoomLevel, boolean effectsOn) { organShape.setEffect(null); if (!effectsOn) return; if (zoomLevel < MOTION_BLUR_DISTANCE) return; Vector movement = calculateMovement(); if (movement.equals(Vector.ZERO)) return; double velocity = movement.getLength(); if (velocity < MOTION_BLUR_THRESHOLD) return; try { organShape.setEffect(new MotionBlur(movement.getAngle(), velocity / MOTION_BLUR_THRESHOLD * MOTION_BLUR_INTENSITY)); } catch (ZeroVectorAngleException e) { } }
Example #2
Source File: Dialog.java From LogFX with GNU General Public License v3.0 | 4 votes |
public static void showMessage( String text, MessageLevel level ) { Platform.runLater( () -> { Text messageText = new Text( text ); messageText.setWrappingWidth( Math.max( 100, primaryStage.getWidth() - 20 ) ); Dialog dialog = new Dialog( messageText ); dialog.setStyle( StageStyle.TRANSPARENT ); dialog.getBox().setSpacing( 0 ); dialog.getBox().getStyleClass().addAll( "message", level.name().toLowerCase() ); MotionBlur blurText = new MotionBlur(); blurText.setAngle( 0 ); blurText.setRadius( 0 ); messageText.setEffect( blurText ); Animation blurAnimation = new Timeline( new KeyFrame( Duration.millis( 450 ), new KeyValue( blurText.angleProperty(), 45.0 ), new KeyValue( blurText.radiusProperty(), 20.0 ) ) ); blurAnimation.setDelay( Duration.millis( 500 ) ); FadeTransition hideAnimation = new FadeTransition( Duration.seconds( 1 ), dialog.getBox() ); hideAnimation.setFromValue( 1.0 ); hideAnimation.setToValue( 0.1 ); hideAnimation.setInterpolator( Interpolator.EASE_IN ); ParallelTransition allAnimations = new ParallelTransition( hideAnimation, blurAnimation ); allAnimations.setDelay( Duration.seconds( level.getDelay() ) ); allAnimations.setOnFinished( event -> { dialog.hide(); currentMessageStages.remove( dialog.dialogStage ); } ); dialog.getBox().setOnMouseClicked( event -> { allAnimations.setDelay( Duration.seconds( 0 ) ); allAnimations.stop(); allAnimations.play(); } ); dialog.show( DialogPosition.TOP_CENTER ); allAnimations.play(); double yShift = 20 + currentMessageStages.stream() .mapToDouble( stage -> stage.getHeight() + 5.0 ) .sum(); StageTranslateTransition shiftDown = new StageTranslateTransition( dialog.dialogStage ); shiftDown.setToY( yShift ); shiftDown.setDuration( Duration.millis( 250.0 ) ); shiftDown.setInterpolator( Interpolator.EASE_BOTH ); shiftDown.play(); currentMessageStages.add( dialog.dialogStage ); } ); }