修改登录框
This commit is contained in:
@@ -5,74 +5,139 @@
|
||||
* @date: 2020/9/11 10:53
|
||||
*/
|
||||
|
||||
import com.epri.fx.client.AppStartup;
|
||||
import com.epri.fx.client.store.ApplicatonStore;
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.svg.SVGGlyph;
|
||||
import com.jfoenix.svg.SVGGlyphLoader;
|
||||
import javafx.animation.Interpolator;
|
||||
import javafx.animation.RotateTransition;
|
||||
import javafx.animation.SequentialTransition;
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.KeyValue;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.application.Application;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.property.DoubleProperty;
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
import javafx.event.Event;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.geometry.Point3D;
|
||||
import javafx.scene.DepthTest;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.effect.PerspectiveTransform;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestFx extends Application {
|
||||
|
||||
|
||||
//正面视图
|
||||
public StackPane frontNode;
|
||||
//反面视图
|
||||
public StackPane backNode;
|
||||
//是否翻转
|
||||
boolean flipped = false;
|
||||
//翻转角度
|
||||
DoubleProperty time = new SimpleDoubleProperty(Math.PI / 2);
|
||||
//正面翻转特效
|
||||
PerspectiveTransform frontEffect = new PerspectiveTransform();
|
||||
//反面翻转特效
|
||||
PerspectiveTransform backEffect = new PerspectiveTransform();
|
||||
Timeline anim = new Timeline();
|
||||
Timeline anim1 = new Timeline();
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
SVGGlyphLoader.loadGlyphsFont(AppStartup.class.getResourceAsStream("/fonts/icon_font/iconfont.svg"),
|
||||
ApplicatonStore.ICON_FONT_KEY);
|
||||
// SVGGlyphLoader.loadGlyphsFont(AppStartup.class.getResourceAsStream("/fonts/icon_font/icon-font-solid.svg"),
|
||||
// "IconFontSolid.svg");
|
||||
} catch (IOException ioExc) {
|
||||
ioExc.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
|
||||
JFXButton button = new JFXButton("");
|
||||
button.setPrefHeight(100);
|
||||
button.setPrefWidth(200);
|
||||
button.setRipplerFill(Color.RED);
|
||||
SVGGlyph materialIconView = SVGGlyphLoader.getIcoMoonGlyph(ApplicatonStore.ICON_FONT_KEY + ".home-outline");
|
||||
// materialIconView.setDepthTest(DepthTest.DISABLE);
|
||||
materialIconView.setRotationAxis(new Point3D(0, 1, 0));
|
||||
materialIconView.setSize(80);
|
||||
button.setGraphic(materialIconView);
|
||||
StackPane stackPane = new StackPane();
|
||||
stackPane.getChildren().add(button);
|
||||
StackPane rootPane = new StackPane();
|
||||
|
||||
RotateTransition transition1 = new RotateTransition(Duration.millis(500), materialIconView);
|
||||
transition1.setByAngle(180);
|
||||
transition1.setInterpolator(Interpolator.EASE_BOTH);
|
||||
transition1.setOnFinished(event -> {
|
||||
});
|
||||
|
||||
|
||||
button.setOnMouseEntered(event -> {
|
||||
transition1.play();
|
||||
});
|
||||
button.setOnMouseExited(event -> {
|
||||
transition1.play();
|
||||
});
|
||||
|
||||
Scene scene = new Scene(stackPane, 1000, 700);
|
||||
rootPane.getChildren().addAll(create());
|
||||
Scene scene = new Scene(rootPane, 1000, 700);
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.setTitle("JavaFX Welcome");
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
private StackPane create() {
|
||||
|
||||
Button a= new Button("正面视图");
|
||||
Button b= new Button("反面视图");
|
||||
a.setOnAction(event -> {
|
||||
|
||||
frontNode.setEffect(frontEffect);
|
||||
backNode.setEffect(backEffect);
|
||||
anim.play();
|
||||
});
|
||||
b.setOnAction(event -> {
|
||||
|
||||
frontNode.setEffect(frontEffect);
|
||||
backNode.setEffect(backEffect);
|
||||
anim1.play();
|
||||
});
|
||||
frontNode = new StackPane();
|
||||
frontNode.getChildren().add(a);
|
||||
frontNode.setStyle("-fx-background-color: #11aa55");
|
||||
backNode = new StackPane();
|
||||
backNode.getChildren().add(b);
|
||||
|
||||
backNode.setStyle("-fx-background-color: #88bb55");
|
||||
KeyFrame frame1 = new KeyFrame(Duration.ZERO, new KeyValue(time,
|
||||
Math.PI / 2, Interpolator.LINEAR));
|
||||
KeyFrame frame2 = new KeyFrame(Duration.seconds(1),
|
||||
new EventHandler() {
|
||||
@Override
|
||||
public void handle(Event event) {
|
||||
frontNode.setEffect(null);
|
||||
backNode.setEffect(null);
|
||||
}
|
||||
|
||||
}, new KeyValue(time, -Math.PI / 2, Interpolator.LINEAR));
|
||||
|
||||
KeyFrame frame3 = new KeyFrame(Duration.seconds(1), new EventHandler() {
|
||||
@Override
|
||||
public void handle(Event event) {
|
||||
frontNode.setEffect(null);
|
||||
backNode.setEffect(null);
|
||||
}
|
||||
|
||||
}, new KeyValue(time,
|
||||
Math.PI / 2, Interpolator.LINEAR));
|
||||
KeyFrame frame4 = new KeyFrame(Duration.ZERO, new KeyValue(time, -Math.PI / 2, Interpolator.LINEAR));
|
||||
|
||||
time.addListener((observable, oldValue, newValue) -> {
|
||||
setPT(frontEffect, time.get());
|
||||
setPT(backEffect, time.get() - Math.PI);
|
||||
});
|
||||
anim.getKeyFrames().addAll(frame1, frame2);
|
||||
|
||||
anim1.getKeyFrames().addAll(frame4, frame3);
|
||||
|
||||
|
||||
backNode.visibleProperty().bind(
|
||||
Bindings.when(time.lessThan(0)).then(true).otherwise(false));
|
||||
frontNode.visibleProperty().bind(backNode.visibleProperty().not());
|
||||
|
||||
|
||||
StackPane stackPane = new StackPane();
|
||||
stackPane.setPrefSize(460, 450);
|
||||
stackPane.setMaxSize(460, 450);
|
||||
stackPane.getChildren().addAll(backNode, frontNode);
|
||||
return stackPane;
|
||||
}
|
||||
|
||||
private void setPT(PerspectiveTransform pt, double t) {
|
||||
double width = 450;
|
||||
double height = 450;
|
||||
double radius = width / 2;
|
||||
double back = height / 10;
|
||||
pt.setUlx(radius - Math.sin(t) * radius);
|
||||
pt.setUly(0 - Math.cos(t) * back);
|
||||
pt.setUrx(radius + Math.sin(t) * radius);
|
||||
pt.setUry(0 + Math.cos(t) * back);
|
||||
pt.setLrx(radius + Math.sin(t) * radius);
|
||||
pt.setLry(height - Math.cos(t) * back);
|
||||
pt.setLlx(radius - Math.sin(t) * radius);
|
||||
pt.setLly(height + Math.cos(t) * back);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
94
client/src/test/java/TimelineEvents.java
Normal file
94
client/src/test/java/TimelineEvents.java
Normal file
@@ -0,0 +1,94 @@
|
||||
import javafx.application.Application;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.KeyValue;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.effect.Lighting;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Circle;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class TimelineEvents extends Application {
|
||||
|
||||
//主时间轴
|
||||
private Timeline timeline;
|
||||
private AnimationTimer timer;
|
||||
|
||||
//用于指定实际帧的变量
|
||||
private Integer i=0;
|
||||
|
||||
@Override public void start(Stage stage) {
|
||||
Group p = new Group();
|
||||
Scene scene = new Scene(p);
|
||||
stage.setScene(scene);
|
||||
stage.setWidth(500);
|
||||
stage.setHeight(500);
|
||||
p.setTranslateX(80);
|
||||
p.setTranslateY(80);
|
||||
|
||||
//创建一个带有特效的圆
|
||||
final Circle circle = new Circle(20, Color.rgb(156,216,255));
|
||||
circle.setEffect(new Lighting());
|
||||
//在圆内部创建一个文本
|
||||
final Text text = new Text (i.toString());
|
||||
text.setStroke(Color.BLACK);
|
||||
//为带有文本的圆创建一个布局
|
||||
final StackPane stack = new StackPane();
|
||||
stack.getChildren().addAll(circle, text);
|
||||
stack.setLayoutX(30);
|
||||
stack.setLayoutY(30);
|
||||
|
||||
p.getChildren().add(stack);
|
||||
stage.show();
|
||||
|
||||
//为了移动圆创建一个时间轴
|
||||
timeline = new Timeline();
|
||||
timeline.setCycleCount(1);
|
||||
timeline.setAutoReverse(true);
|
||||
|
||||
//在每个帧开始时你可以添加一个特定的动作
|
||||
timer = new AnimationTimer() {
|
||||
@Override
|
||||
public void handle(long l) {
|
||||
text.setText(i.toString());
|
||||
i++;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//创建一个带有缩放因子的keyValue:将圆缩放2倍
|
||||
KeyValue keyValueX = new KeyValue(stack.scaleXProperty(), 2);
|
||||
KeyValue keyValueY = new KeyValue(stack.scaleYProperty(), 2);
|
||||
|
||||
//创建一个KeyFrame, keyValue会在2秒钟时抵达
|
||||
Duration duration = Duration.millis(2000);
|
||||
//当抵达关键帧时可以指定一个特定的动作
|
||||
EventHandler onFinished = new EventHandler<ActionEvent>() {
|
||||
public void handle(ActionEvent t) {
|
||||
stack.setTranslateX(java.lang.Math.random()*200-100);
|
||||
//复位计数器
|
||||
i = 0;
|
||||
}
|
||||
};
|
||||
|
||||
KeyFrame keyFrame = new KeyFrame(duration, onFinished , keyValueX, keyValueY);
|
||||
|
||||
//将关键帧添加到时间轴中
|
||||
timeline.getKeyFrames().add(keyFrame);
|
||||
|
||||
timeline.play();
|
||||
timer.start();
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
Application.launch(args);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user