类javafx.scene.effect.Lighting源码实例Demo

下面列出了怎么用javafx.scene.effect.Lighting的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: marathonv5   文件: InterpolatorSample.java
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;
}
 
源代码2 项目: marathonv5   文件: InterpolatorSample.java
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;
}
 
源代码3 项目: netbeans   文件: TimelineInterpolator.java
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;
}
 
源代码4 项目: gef   文件: GeometryNodeSnippet.java
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;
}
 
源代码5 项目: gef   文件: MvcLogoExample.java
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;
}
 
源代码6 项目: marathonv5   文件: TimelineSample.java
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
}
 
源代码7 项目: marathonv5   文件: StopWatchSample.java
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);
}
 
源代码8 项目: marathonv5   文件: StopWatchSample.java
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;
}
 
源代码9 项目: marathonv5   文件: StageSample.java
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);
}
 
源代码10 项目: marathonv5   文件: TimelineSample.java
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
}
 
源代码11 项目: marathonv5   文件: StopWatchSample.java
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);
}
 
源代码12 项目: marathonv5   文件: StopWatchSample.java
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;
}
 
源代码13 项目: marathonv5   文件: StageSample.java
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);
}
 
源代码14 项目: netbeans   文件: StopWatch.java
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);
}
 
源代码15 项目: netbeans   文件: StopWatch.java
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;
}
 
源代码16 项目: FXTutorials   文件: Connect4App.java
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;
}
 
源代码17 项目: marathonv5   文件: TimelineEventsSample.java
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);
}
 
源代码18 项目: marathonv5   文件: AudioClipSample.java
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;
}
 
源代码19 项目: marathonv5   文件: TimelineEventsSample.java
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);
}
 
源代码20 项目: marathonv5   文件: AudioClipSample.java
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;
}
 
源代码21 项目: netbeans   文件: TimelineEvents.java
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);
}
 
 类所在包
 类方法
 同包方法