javafx.scene.effect.Lighting Java Examples
The following examples show how to use
javafx.scene.effect.Lighting.
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: StopWatchSample.java From marathonv5 with Apache License 2.0 | 7 votes |
private Rectangle createBackground(Color stroke, Color fill) { Rectangle background = new Rectangle(14, 17, fill); background.setStroke(stroke); background.setStrokeWidth(2); background.setEffect(new Lighting()); background.setCache(true); return background; }
Example #2
Source File: MvcLogoExample.java From gef with Eclipse Public License 2.0 | 6 votes |
private static Effect createShadowEffect() { DropShadow outerShadow = new DropShadow(); outerShadow.setRadius(3); outerShadow.setSpread(0.2); outerShadow.setOffsetX(3); outerShadow.setOffsetY(3); outerShadow.setColor(new Color(0.3, 0.3, 0.3, 1)); Distant light = new Distant(); light.setAzimuth(-135.0f); Lighting l = new Lighting(); l.setLight(light); l.setSurfaceScale(3.0f); Blend effects = new Blend(BlendMode.MULTIPLY); effects.setTopInput(l); effects.setBottomInput(outerShadow); return effects; }
Example #3
Source File: GeometryNodeSnippet.java From gef with Eclipse Public License 2.0 | 6 votes |
protected static Effect createShadowEffect() { final DropShadow outerShadow = new DropShadow(); outerShadow.setRadius(3); outerShadow.setSpread(0.2); outerShadow.setOffsetX(3); outerShadow.setOffsetY(3); outerShadow.setColor(new Color(0.3, 0.3, 0.3, 1)); final Distant light = new Distant(); light.setAzimuth(-135.0f); final Lighting l = new Lighting(); l.setLight(light); l.setSurfaceScale(3.0f); final Blend effects = new Blend(BlendMode.MULTIPLY); effects.setTopInput(l); effects.setBottomInput(outerShadow); return effects; }
Example #4
Source File: TimelineInterpolator.java From netbeans with Apache License 2.0 | 6 votes |
private Circle createMovingCircle(Interpolator interpolator) { //create a transparent circle Circle circle = new Circle(45,45, 40, Color.web("1c89f4")); circle.setOpacity(0); //add effect circle.setEffect(new Lighting()); //create a timeline for moving the circle timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(true); //create a keyValue for horizontal translation of circle to the position 155px with given interpolator KeyValue keyValue = new KeyValue(circle.translateXProperty(), 155, interpolator); //create a keyFrame with duration 4s KeyFrame keyFrame = new KeyFrame(Duration.seconds(4), keyValue); //add the keyframe to the timeline timeline.getKeyFrames().add(keyFrame); return circle; }
Example #5
Source File: InterpolatorSample.java From marathonv5 with Apache License 2.0 | 6 votes |
private Circle createMovingCircle(Interpolator interpolator, Color color){ Circle circle = new Circle(25,25,35,color); circle.setOpacity(0.0); //add effect circle.setEffect(new Lighting()); //create a timeline for moving the circle timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(true); //create a keyValue for horizontal translation of circle to the position 155px with given interpolator KeyValue keyValue = new KeyValue(circle.translateXProperty(), 155, interpolator); //create a keyFrame with duration 4s KeyFrame keyFrame = new KeyFrame(Duration.seconds(4), keyValue); //add the keyframe to the timeline timeline.getKeyFrames().add(keyFrame); return circle; }
Example #6
Source File: InterpolatorSample.java From marathonv5 with Apache License 2.0 | 6 votes |
private Circle createMovingCircle(Interpolator interpolator, Color color){ Circle circle = new Circle(25,25,35,color); circle.setOpacity(0.0); //add effect circle.setEffect(new Lighting()); //create a timeline for moving the circle timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(true); //create a keyValue for horizontal translation of circle to the position 155px with given interpolator KeyValue keyValue = new KeyValue(circle.translateXProperty(), 155, interpolator); //create a keyFrame with duration 4s KeyFrame keyFrame = new KeyFrame(Duration.seconds(4), keyValue); //add the keyframe to the timeline timeline.getKeyFrames().add(keyFrame); return circle; }
Example #7
Source File: StopWatchSample.java From marathonv5 with Apache License 2.0 | 5 votes |
private void configureEffect() { handEffect.setOffsetX(radius / 40); handEffect.setOffsetY(radius / 40); handEffect.setRadius(6); handEffect.setColor(Color.web("#000000")); Lighting lighting = new Lighting(); Light.Distant light = new Light.Distant(); light.setAzimuth(225); lighting.setLight(light); handEffect.setInput(lighting); handEffectGroup.setEffect(handEffect); }
Example #8
Source File: Connect4App.java From FXTutorials with MIT License | 5 votes |
private Shape makeGrid() { Shape shape = new Rectangle((COLUMNS + 1) * TILE_SIZE, (ROWS + 1) * TILE_SIZE); for (int y = 0; y < ROWS; y++) { for (int x = 0; x < COLUMNS; x++) { Circle circle = new Circle(TILE_SIZE / 2); circle.setCenterX(TILE_SIZE / 2); circle.setCenterY(TILE_SIZE / 2); circle.setTranslateX(x * (TILE_SIZE + 5) + TILE_SIZE / 4); circle.setTranslateY(y * (TILE_SIZE + 5) + TILE_SIZE / 4); shape = Shape.subtract(shape, circle); } } Light.Distant light = new Light.Distant(); light.setAzimuth(45.0); light.setElevation(30.0); Lighting lighting = new Lighting(); lighting.setLight(light); lighting.setSurfaceScale(5.0); shape.setFill(Color.BLUE); shape.setEffect(lighting); return shape; }
Example #9
Source File: StopWatch.java From netbeans with Apache License 2.0 | 5 votes |
private Rectangle createBackground(Color stroke, Color fill) { Rectangle background = new Rectangle(14, 17, fill); background.setStroke(stroke); background.setStrokeWidth(2); background.setEffect(new Lighting()); background.setCache(true); return background; }
Example #10
Source File: StopWatch.java From netbeans with Apache License 2.0 | 5 votes |
private void configureEffect() { handEffect.setOffsetX(radius / 40); handEffect.setOffsetY(radius / 40); handEffect.setRadius(6); handEffect.setColor(Color.web("#000000")); Lighting lighting = new Lighting(); Light.Distant light = new Light.Distant(); light.setAzimuth(225); lighting.setLight(light); handEffect.setInput(lighting); handEffectGroup.setEffect(handEffect); }
Example #11
Source File: StageSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public StageSample() { //create a button for initializing our new stage Button button = new Button("Create a Stage"); button.setStyle("-fx-font-size: 24;"); button.setDefaultButton(true); button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { final Stage stage = new Stage(); //create root node of scene, i.e. group Group rootGroup = new Group(); //create scene with set width, height and color Scene scene = new Scene(rootGroup, 200, 200, Color.WHITESMOKE); //set scene to stage stage.setScene(scene); //center stage on screen stage.centerOnScreen(); //show the stage stage.show(); //add some node to scene Text text = new Text(20, 110, "JavaFX"); text.setFill(Color.DODGERBLUE); text.setEffect(new Lighting()); text.setFont(Font.font(Font.getDefault().getFamily(), 50)); //add text to the main root group rootGroup.getChildren().add(text); } }); getChildren().add(button); }
Example #12
Source File: StopWatchSample.java From marathonv5 with Apache License 2.0 | 5 votes |
private Rectangle createBackground(Color stroke, Color fill) { Rectangle background = new Rectangle(14, 17, fill); background.setStroke(stroke); background.setStrokeWidth(2); background.setEffect(new Lighting()); background.setCache(true); return background; }
Example #13
Source File: TimelineSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public TimelineSample() { super(280,120); //create a circle final Circle circle = new Circle(25,25, 20, Color.web("1c89f4")); circle.setEffect(new Lighting()); //create a timeline for moving the circle timeline = new Timeline(); timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(true); //one can start/pause/stop/play animation by //timeline.play(); //timeline.pause(); //timeline.stop(); //timeline.playFromStart(); //add the following keyframes to the timeline timeline.getKeyFrames().addAll (new KeyFrame(Duration.ZERO, new KeyValue(circle.translateXProperty(), 0)), new KeyFrame(new Duration(4000), new KeyValue(circle.translateXProperty(), 205))); getChildren().add(createNavigation()); getChildren().add(circle); // REMOVE ME setControls( new SimplePropertySheet.PropDesc("Timeline rate", timeline.rateProperty(), -4d, 4d) //TODO it is possible to do it for integer? ); // END REMOVE ME }
Example #14
Source File: StageSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public StageSample() { //create a button for initializing our new stage Button button = new Button("Create a Stage"); button.setStyle("-fx-font-size: 24;"); button.setDefaultButton(true); button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { final Stage stage = new Stage(); //create root node of scene, i.e. group Group rootGroup = new Group(); //create scene with set width, height and color Scene scene = new Scene(rootGroup, 200, 200, Color.WHITESMOKE); //set scene to stage stage.setScene(scene); //center stage on screen stage.centerOnScreen(); //show the stage stage.show(); //add some node to scene Text text = new Text(20, 110, "JavaFX"); text.setFill(Color.DODGERBLUE); text.setEffect(new Lighting()); text.setFont(Font.font(Font.getDefault().getFamily(), 50)); //add text to the main root group rootGroup.getChildren().add(text); } }); getChildren().add(button); }
Example #15
Source File: StopWatchSample.java From marathonv5 with Apache License 2.0 | 5 votes |
private void configureEffect() { handEffect.setOffsetX(radius / 40); handEffect.setOffsetY(radius / 40); handEffect.setRadius(6); handEffect.setColor(Color.web("#000000")); Lighting lighting = new Lighting(); Light.Distant light = new Light.Distant(); light.setAzimuth(225); lighting.setLight(light); handEffect.setInput(lighting); handEffectGroup.setEffect(handEffect); }
Example #16
Source File: TimelineSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public TimelineSample() { super(280,120); //create a circle final Circle circle = new Circle(25,25, 20, Color.web("1c89f4")); circle.setEffect(new Lighting()); //create a timeline for moving the circle timeline = new Timeline(); timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(true); //one can start/pause/stop/play animation by //timeline.play(); //timeline.pause(); //timeline.stop(); //timeline.playFromStart(); //add the following keyframes to the timeline timeline.getKeyFrames().addAll (new KeyFrame(Duration.ZERO, new KeyValue(circle.translateXProperty(), 0)), new KeyFrame(new Duration(4000), new KeyValue(circle.translateXProperty(), 205))); getChildren().add(createNavigation()); getChildren().add(circle); // REMOVE ME setControls( new SimplePropertySheet.PropDesc("Timeline rate", timeline.rateProperty(), -4d, 4d) //TODO it is possible to do it for integer? ); // END REMOVE ME }
Example #17
Source File: TimelineEventsSample.java From marathonv5 with Apache License 2.0 | 4 votes |
public TimelineEventsSample() { super(70,70); //create a circle with effect final Circle circle = new Circle(20, Color.rgb(156,216,255)); circle.setEffect(new Lighting()); //create a text inside a circle final Text text = new Text (i.toString()); text.setStroke(Color.BLACK); //create a layout for circle with text inside final StackPane stack = new StackPane(); stack.getChildren().addAll(circle, text); stack.setLayoutX(30); stack.setLayoutY(30); //create a timeline for moving the circle timeline = new Timeline(); timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(true); //one can add a specific action when each frame is started. There are one or more frames during // executing one KeyFrame depending on set Interpolator. timer = new AnimationTimer() { @Override public void handle(long l) { text.setText(i.toString()); i++; } }; //create a keyValue with factory: scaling the circle 2times KeyValue keyValueX = new KeyValue(stack.scaleXProperty(), 2); KeyValue keyValueY = new KeyValue(stack.scaleYProperty(), 2); //create a keyFrame, the keyValue is reached at time 2s Duration duration = Duration.seconds(2); //one can add a specific action when the keyframe is reached EventHandler<ActionEvent> onFinished = new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { stack.setTranslateX(java.lang.Math.random()*200-100); //reset counter i = 0; } }; KeyFrame keyFrame = new KeyFrame(duration, onFinished , keyValueX, keyValueY); //add the keyframe to the timeline timeline.getKeyFrames().add(keyFrame); getChildren().add(stack); }
Example #18
Source File: AudioClipSample.java From marathonv5 with Apache License 2.0 | 4 votes |
public static Node createIconContent() { Group rectangleGroup = new Group(); double xStart = 5.0; double xOffset = 30.0; double yPos = 230.0; double barWidth = 22.0; double barDepth = 7.0; Group base1Group = createRectangle(new Color(0.2, 0.12, 0.1, 1.0), xStart + 135, yPos + 20.0, barWidth*11.5, 10.0); Group base2Group = createRectangle(new Color(0.2, 0.12, 0.1, 1.0), xStart + 135, yPos - 20.0, barWidth*11.5, 10.0); Group bar1Group = createRectangle(Color.PURPLE, xStart + 1*xOffset, yPos, barWidth, 100.0); Group bar2Group = createRectangle(Color.BLUEVIOLET, xStart + 2*xOffset, yPos, barWidth, 95.0); Group bar3Group = createRectangle(Color.BLUE, xStart + 3*xOffset, yPos, barWidth, 90.0); Group bar4Group = createRectangle(Color.GREEN, xStart + 4*xOffset, yPos, barWidth, 85.0); Group bar5Group = createRectangle(Color.GREENYELLOW, xStart + 5*xOffset, yPos, barWidth, 80.0); Group bar6Group = createRectangle(Color.YELLOW, xStart + 6*xOffset, yPos, barWidth, 75.0); Group bar7Group = createRectangle(Color.ORANGE, xStart + 7*xOffset, yPos, barWidth, 70.0); Group bar8Group = createRectangle(Color.RED, xStart + 8*xOffset, yPos, barWidth, 65.0); Light.Point light = new Light.Point(); light.setX(-20); light.setY(-20); light.setZ(100); Lighting l = new Lighting(); l.setLight(light); l.setSurfaceScale(1.0f); bar1Group.setEffect(l); bar2Group.setEffect(l); bar3Group.setEffect(l); bar4Group.setEffect(l); bar5Group.setEffect(l); bar6Group.setEffect(l); bar7Group.setEffect(l); bar8Group.setEffect(l); rectangleGroup.getChildren().add(base1Group); rectangleGroup.getChildren().add(base2Group); rectangleGroup.getChildren().add(bar1Group); rectangleGroup.getChildren().add(bar2Group); rectangleGroup.getChildren().add(bar3Group); rectangleGroup.getChildren().add(bar4Group); rectangleGroup.getChildren().add(bar5Group); rectangleGroup.getChildren().add(bar6Group); rectangleGroup.getChildren().add(bar7Group); rectangleGroup.getChildren().add(bar8Group); rectangleGroup.setScaleX(0.4); rectangleGroup.setScaleY(0.4); return rectangleGroup; }
Example #19
Source File: TimelineEvents.java From netbeans with Apache License 2.0 | 4 votes |
private void init(Stage primaryStage) { Group root = new Group(); primaryStage.setResizable(false); primaryStage.setScene(new Scene(root, 260,100)); //create a circle with effect final Circle circle = new Circle(20, Color.rgb(156,216,255)); circle.setEffect(new Lighting()); //create a text inside a circle final Text text = new Text (i.toString()); text.setStroke(Color.BLACK); //create a layout for circle with text inside final StackPane stack = new StackPane(); stack.getChildren().addAll(circle, text); stack.setLayoutX(30); stack.setLayoutY(30); //create a timeline for moving the circle timeline = new Timeline(); timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(true); //one can add a specific action when each frame is started. There are one or more frames during // executing one KeyFrame depending on set Interpolator. timer = new AnimationTimer() { @Override public void handle(long l) { text.setText(i.toString()); i++; } }; //create a keyValue with factory: scaling the circle 2times KeyValue keyValueX = new KeyValue(stack.scaleXProperty(), 2); KeyValue keyValueY = new KeyValue(stack.scaleYProperty(), 2); //create a keyFrame, the keyValue is reached at time 2s Duration duration = Duration.seconds(2); //one can add a specific action when the keyframe is reached EventHandler<ActionEvent> onFinished = new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { stack.setTranslateX(java.lang.Math.random()*200); //reset counter i = 0; } }; KeyFrame keyFrame = new KeyFrame(duration, onFinished , keyValueX, keyValueY); //add the keyframe to the timeline timeline.getKeyFrames().add(keyFrame); root.getChildren().add(stack); }
Example #20
Source File: AudioClipSample.java From marathonv5 with Apache License 2.0 | 4 votes |
public static Node createIconContent() { Group rectangleGroup = new Group(); double xStart = 5.0; double xOffset = 30.0; double yPos = 230.0; double barWidth = 22.0; double barDepth = 7.0; Group base1Group = createRectangle(new Color(0.2, 0.12, 0.1, 1.0), xStart + 135, yPos + 20.0, barWidth*11.5, 10.0); Group base2Group = createRectangle(new Color(0.2, 0.12, 0.1, 1.0), xStart + 135, yPos - 20.0, barWidth*11.5, 10.0); Group bar1Group = createRectangle(Color.PURPLE, xStart + 1*xOffset, yPos, barWidth, 100.0); Group bar2Group = createRectangle(Color.BLUEVIOLET, xStart + 2*xOffset, yPos, barWidth, 95.0); Group bar3Group = createRectangle(Color.BLUE, xStart + 3*xOffset, yPos, barWidth, 90.0); Group bar4Group = createRectangle(Color.GREEN, xStart + 4*xOffset, yPos, barWidth, 85.0); Group bar5Group = createRectangle(Color.GREENYELLOW, xStart + 5*xOffset, yPos, barWidth, 80.0); Group bar6Group = createRectangle(Color.YELLOW, xStart + 6*xOffset, yPos, barWidth, 75.0); Group bar7Group = createRectangle(Color.ORANGE, xStart + 7*xOffset, yPos, barWidth, 70.0); Group bar8Group = createRectangle(Color.RED, xStart + 8*xOffset, yPos, barWidth, 65.0); Light.Point light = new Light.Point(); light.setX(-20); light.setY(-20); light.setZ(100); Lighting l = new Lighting(); l.setLight(light); l.setSurfaceScale(1.0f); bar1Group.setEffect(l); bar2Group.setEffect(l); bar3Group.setEffect(l); bar4Group.setEffect(l); bar5Group.setEffect(l); bar6Group.setEffect(l); bar7Group.setEffect(l); bar8Group.setEffect(l); rectangleGroup.getChildren().add(base1Group); rectangleGroup.getChildren().add(base2Group); rectangleGroup.getChildren().add(bar1Group); rectangleGroup.getChildren().add(bar2Group); rectangleGroup.getChildren().add(bar3Group); rectangleGroup.getChildren().add(bar4Group); rectangleGroup.getChildren().add(bar5Group); rectangleGroup.getChildren().add(bar6Group); rectangleGroup.getChildren().add(bar7Group); rectangleGroup.getChildren().add(bar8Group); rectangleGroup.setScaleX(0.4); rectangleGroup.setScaleY(0.4); return rectangleGroup; }
Example #21
Source File: TimelineEventsSample.java From marathonv5 with Apache License 2.0 | 4 votes |
public TimelineEventsSample() { super(70,70); //create a circle with effect final Circle circle = new Circle(20, Color.rgb(156,216,255)); circle.setEffect(new Lighting()); //create a text inside a circle final Text text = new Text (i.toString()); text.setStroke(Color.BLACK); //create a layout for circle with text inside final StackPane stack = new StackPane(); stack.getChildren().addAll(circle, text); stack.setLayoutX(30); stack.setLayoutY(30); //create a timeline for moving the circle timeline = new Timeline(); timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(true); //one can add a specific action when each frame is started. There are one or more frames during // executing one KeyFrame depending on set Interpolator. timer = new AnimationTimer() { @Override public void handle(long l) { text.setText(i.toString()); i++; } }; //create a keyValue with factory: scaling the circle 2times KeyValue keyValueX = new KeyValue(stack.scaleXProperty(), 2); KeyValue keyValueY = new KeyValue(stack.scaleYProperty(), 2); //create a keyFrame, the keyValue is reached at time 2s Duration duration = Duration.seconds(2); //one can add a specific action when the keyframe is reached EventHandler<ActionEvent> onFinished = new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { stack.setTranslateX(java.lang.Math.random()*200-100); //reset counter i = 0; } }; KeyFrame keyFrame = new KeyFrame(duration, onFinished , keyValueX, keyValueY); //add the keyframe to the timeline timeline.getKeyFrames().add(keyFrame); getChildren().add(stack); }