本文整理汇总了Java中javafx.scene.shape.Circle.setEffect方法的典型用法代码示例。如果您正苦于以下问题:Java Circle.setEffect方法的具体用法?Java Circle.setEffect怎么用?Java Circle.setEffect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.shape.Circle
的用法示例。
在下文中一共展示了Circle.setEffect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMovingCircle
import javafx.scene.shape.Circle; //导入方法依赖的package包/类
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;
}
示例2: createMovingCircle
import javafx.scene.shape.Circle; //导入方法依赖的package包/类
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: TimelineSample
import javafx.scene.shape.Circle; //导入方法依赖的package包/类
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
}
示例4: init
import javafx.scene.shape.Circle; //导入方法依赖的package包/类
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);
}
示例5: TimelineEventsSample
import javafx.scene.shape.Circle; //导入方法依赖的package包/类
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);
}
示例6: createIconContent
import javafx.scene.shape.Circle; //导入方法依赖的package包/类
public static Node createIconContent() {
Circle circle = new Circle(57,57,40);
circle.setStroke(Color.web("#b9c0c5"));
circle.setStrokeWidth(5);
circle.getStrokeDashArray().addAll(15d,15d);
circle.setFill(null);
javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow();
effect.setOffsetX(1);
effect.setOffsetY(1);
effect.setRadius(3);
effect.setColor(Color.rgb(0,0,0,0.6));
circle.setEffect(effect);
return circle;
}
示例7: createIOButton
import javafx.scene.shape.Circle; //导入方法依赖的package包/类
/**
* Sets the appearance of an IO button.
* @return Returns an I/O button.
*/
public Circle createIOButton(){
Circle channel = new Circle(5.0f);
channel.setFill(Paint.valueOf(BACKGROUND_COLOR));
channel.setStroke(Paint.valueOf(FOREGROUND_COLOR));
channel.setStrokeWidth(2.0f);
channel.setLayoutY(getMinHeight()/2);
channel.setEffect( new DropShadow() );
return channel;
}