Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support skip boot animation #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 41 additions & 36 deletions src/main/java/com/leewyatt/fxtools/ui/InitialLoadingPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.leewyatt.fxtools.event.AnimFinishedEvent;
import com.leewyatt.fxtools.event.EventBusUtil;
import com.leewyatt.fxtools.utils.ToolSettingsUtil;

import javafx.animation.*;
import javafx.scene.Node;
import javafx.scene.effect.DropShadow;
Expand Down Expand Up @@ -29,72 +31,75 @@ public InitialLoadingPane(String skinStyle) {
SVGPath icon = new SVGPath();
icon.setScaleX(2);
icon.setScaleY(2);
icon.setContent("M10.3,7.3L8.2,5.2l0,0L7.8,4.5L7,3.9L6.1,4.8l0.6,0.8L7.4,6l0,0l2.1,2.1L9.2,8.4l1.4,1.4 c0.3,0.3,0.7,0.3,1,0L12,9.5c0.3-0.3,0.3-0.7,0-1l-1.4-1.4C10.6,7,10.3,7.3,10.3,7.3zM11.8,6.3c0.5-0.5,0.5-1.2,0.3-1.7l-0.9,1L10.6,5l0.9-1C11,3.7,10.3,3.8,9.8,4.3C9.4,4.6,9.2,5.2,9.4,5.7 L6.2,8.8C6.1,9,6.1,9.3,6.2,9.5l0,0l0.4,0.3c0.2,0.2,0.5,0.2,0.7,0l3.2-3.1C10.9,6.8,11.4,6.7,11.8,6.3zM1.4,2.4h1.4v7.5H1.4V2.4z M1.9,2.4h4.4v1.3H1.9C1.9,3.8,1.9,2.4,1.9,2.4z M1.9,5.6h3.8v1.3H1.9V5.6zM10.3,13H2.7C1.2,13,0,11.8,0,10.3V2.7C0,1.2,1.2,0,2.7,0h7.6C11.8,0,13,1.2,13,2.7v7.6C13,11.8,11.8,13,10.3,13z M2.7,0.3 c-1.3,0-2.4,1.1-2.4,2.4v7.6c0,1.3,1.1,2.4,2.4,2.4h7.6c1.3,0,2.4-1.1,2.4-2.4V2.7c0-1.3-1.1-2.4-2.4-2.4C10.3,0.3,2.7,0.3,2.7,0.3z");
icon.setContent(
"M10.3,7.3L8.2,5.2l0,0L7.8,4.5L7,3.9L6.1,4.8l0.6,0.8L7.4,6l0,0l2.1,2.1L9.2,8.4l1.4,1.4 c0.3,0.3,0.7,0.3,1,0L12,9.5c0.3-0.3,0.3-0.7,0-1l-1.4-1.4C10.6,7,10.3,7.3,10.3,7.3zM11.8,6.3c0.5-0.5,0.5-1.2,0.3-1.7l-0.9,1L10.6,5l0.9-1C11,3.7,10.3,3.8,9.8,4.3C9.4,4.6,9.2,5.2,9.4,5.7 L6.2,8.8C6.1,9,6.1,9.3,6.2,9.5l0,0l0.4,0.3c0.2,0.2,0.5,0.2,0.7,0l3.2-3.1C10.9,6.8,11.4,6.7,11.8,6.3zM1.4,2.4h1.4v7.5H1.4V2.4z M1.9,2.4h4.4v1.3H1.9C1.9,3.8,1.9,2.4,1.9,2.4z M1.9,5.6h3.8v1.3H1.9V5.6zM10.3,13H2.7C1.2,13,0,11.8,0,10.3V2.7C0,1.2,1.2,0,2.7,0h7.6C11.8,0,13,1.2,13,2.7v7.6C13,11.8,11.8,13,10.3,13z M2.7,0.3 c-1.3,0-2.4,1.1-2.4,2.4v7.6c0,1.3,1.1,2.4,2.4,2.4h7.6c1.3,0,2.4-1.1,2.4-2.4V2.7c0-1.3-1.1-2.4-2.4-2.4C10.3,0.3,2.7,0.3,2.7,0.3z");
icon.setFill(new LinearGradient(
0.0, 0.0, 1.0, 0.0, true, CycleMethod.NO_CYCLE,
new Stop(0.0, new Color(0.11, 0.52, 0.93, 1.0)),
new Stop(1.0, new Color(0.68, 0.05, 0.93, 1.0))));

StackPane iconPane = new StackPane(icon);
iconPane.setPrefSize(radius, radius);
iconPane.setStyle("-fx-background-color: "+("light".equalsIgnoreCase(skinStyle)?"white":"#2b2b2b")+";-fx-background-radius: "+radius/2.0+"px");
iconPane.setStyle("-fx-background-color: " + ("light".equalsIgnoreCase(skinStyle) ? "white" : "#2b2b2b")
+ ";-fx-background-radius: " + radius / 2.0 + "px");
iconPane.setEffect(new DropShadow());
iconPane.setLayoutX((w-radius)/2.0);
iconPane.setLayoutY((h-radius)/2.0);
iconPane.setLayoutX((w - radius) / 2.0);
iconPane.setLayoutY((h - radius) / 2.0);
getChildren().add(iconPane);
iconPane.setOpacity(0.2);
//Color Animation 颜色动画, 暂时没有搭配得非常满意的颜色
//DoubleProperty dp = new SimpleDoubleProperty(0.001);
//Timeline colorAnim = new Timeline(new KeyFrame(Duration.seconds(1.2),new KeyValue(dp, 0.98)));
//Random random = new Random();
//int choose = random.nextInt(2);
//Color c1;
//Color c2;
//Color c3;
//if (choose == 0) {
// c1 = new Color(0.11, 0.52, 0.93, 1.0);
// c2= new Color(0.0549, 0.9294, 0.6353, 1.0);
// c3 = new Color(0.68, 0.05, 0.93, 1.0);
//}else {
// c1 = new Color(0.9735, 0.0, 0.99, 1.0);
// c2 = new Color(0.209, 0.5178, 0.95, 1.0);
// c3 = new Color(0.0174, 0.87, 0.87, 1.0);
//}
// Color Animation 颜色动画, 暂时没有搭配得非常满意的颜色
// DoubleProperty dp = new SimpleDoubleProperty(0.001);
// Timeline colorAnim = new Timeline(new KeyFrame(Duration.seconds(1.2),new
// KeyValue(dp, 0.98)));
// Random random = new Random();
// int choose = random.nextInt(2);
// Color c1;
// Color c2;
// Color c3;
// if (choose == 0) {
// c1 = new Color(0.11, 0.52, 0.93, 1.0);
// c2= new Color(0.0549, 0.9294, 0.6353, 1.0);
// c3 = new Color(0.68, 0.05, 0.93, 1.0);
// }else {
// c1 = new Color(0.9735, 0.0, 0.99, 1.0);
// c2 = new Color(0.209, 0.5178, 0.95, 1.0);
// c3 = new Color(0.0174, 0.87, 0.87, 1.0);
// }
//
//dp.addListener((observable, oldValue, newValue) -> {
// LinearGradient p = new LinearGradient(
// 0.0, 0.0, 1.0, 1.0, true, CycleMethod.NO_CYCLE,
// new Stop(0.0, c1),
// new Stop(newValue.doubleValue(), c2),
// new Stop(1.0, c3));
// icon.setFill(p);
//});
// dp.addListener((observable, oldValue, newValue) -> {
// LinearGradient p = new LinearGradient(
// 0.0, 0.0, 1.0, 1.0, true, CycleMethod.NO_CYCLE,
// new Stop(0.0, c1),
// new Stop(newValue.doubleValue(), c2),
// new Stop(1.0, c3));
// icon.setFill(p);
// });

Circle circle = new Circle(70);
FadeTransition fadeTransition = new FadeTransition(Duration.seconds(1.5), iconPane);
fadeTransition.setFromValue(0.2);
fadeTransition.setToValue(1.0);
PathTransition pathTransition = new PathTransition(Duration.seconds(2), circle,iconPane);
PathTransition pathTransition = new PathTransition(Duration.seconds(2), circle, iconPane);
ScaleTransition scaleTransition = scaleTransition(1.2, iconPane, 2, 2);
//ParallelTransition pt = new ParallelTransition(scaleTransition,colorAnim);
SequentialTransition animation = new SequentialTransition(fadeTransition,pathTransition,scaleTransition);
// ParallelTransition pt = new ParallelTransition(scaleTransition,colorAnim);
SequentialTransition animation = new SequentialTransition(fadeTransition, pathTransition, scaleTransition);
animation.setInterpolator(Interpolator.EASE_IN);
animation.setOnFinished(event -> {
EventBusUtil.getDefault().post(new AnimFinishedEvent());
});
// 加速跳过
if (ToolSettingsUtil.getInstance().getSKipBootAnimation()) {
animation.setRate(10);
}
animation.play();


}



public ScaleTransition scaleTransition(double duration, Node node, double byX, double byY) {
ScaleTransition scaleTransition = new ScaleTransition(Duration.seconds(duration), node);
scaleTransition.setByX(byX);
scaleTransition.setByY(byY);
return scaleTransition;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public class SettingsPageController {
@FXML
private CheckBox updateNotifyCheckBox;

@FXML
private CheckBox skipBootAnimationCheckbox;

public SettingsPageController() {
EventBusUtil.getDefault().register(this);
}
Expand Down Expand Up @@ -96,6 +99,7 @@ void initialize() {
threadField.setText(i+"");
}
});
skipBootAnimationCheckbox.selectedProperty().addListener((ob, ov, nv) -> util.saveSkipBootAnimation(nv));
}

private void showSettingsOnUI() {
Expand All @@ -110,6 +114,7 @@ private void showSettingsOnUI() {
showPreviewImageCheckbox.setSelected(util.getGeneratePreviewImg());
parseImageSizeCheckbox.setSelected(util.getParseImageSize());
threadField.setText(util.getThreadNum() + "");
skipBootAnimationCheckbox.setSelected(util.getSKipBootAnimation());
}

}
17 changes: 17 additions & 0 deletions src/main/java/com/leewyatt/fxtools/utils/ToolSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class ToolSettings {

public static final boolean DEFAULT_UPDATE_NOTIFY = true;

public static final boolean DEFAULT_SKIP_BOOT_ANIMATION = false;

/**
* 默认皮肤
*/
Expand Down Expand Up @@ -98,6 +100,13 @@ public class ToolSettings {

private boolean updateNotify;

/**
* 是否跳过启动动画
* true 跳过
* false 不跳过
*/
private boolean skipBootAnimation;

public ToolSettings() {

}
Expand Down Expand Up @@ -209,4 +218,12 @@ public boolean isUpdateNotify() {
public void setUpdateNotify(boolean updateNotify) {
this.updateNotify = updateNotify;
}

public boolean isSkipBootAnimation() {
return skipBootAnimation;
}

public void setSkipBootAnimation(boolean skipBootAnimation) {
this.skipBootAnimation = skipBootAnimation;
}
}
16 changes: 16 additions & 0 deletions src/main/java/com/leewyatt/fxtools/utils/ToolSettingsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ private ToolSettingsUtil() {
settings.setAutoSwitch(Boolean.parseBoolean(props.getProperty("autoSwitch", defaultSettings.isAutoSwitch() + "")));
settings.setAlwaysTop(Boolean.parseBoolean(props.getProperty("alwaysTop", defaultSettings.isAlwaysTop() + "")));
settings.setUpdateNotify(Boolean.parseBoolean(props.getProperty("updateNotify", defaultSettings.isUpdateNotify() + "")));
settings.setSkipBootAnimation(Boolean.parseBoolean(props.getProperty("skipBootAnimation", defaultSettings.isSkipBootAnimation() + "")));
reader.close();
}
} catch (IOException e) {
Expand All @@ -70,6 +71,7 @@ private void initDefaultSettings() {
defaultSettings.setAutoSwitch(ToolSettings.DEFAULT_AUTO_SWITCH);
defaultSettings.setAlwaysTop(ToolSettings.DEFAULT_ALWAYS_TOP);
defaultSettings.setUpdateNotify(ToolSettings.DEFAULT_UPDATE_NOTIFY);
defaultSettings.setSkipBootAnimation(ToolSettings.DEFAULT_SKIP_BOOT_ANIMATION);
}

public static ToolSettingsUtil getInstance() {
Expand All @@ -94,6 +96,7 @@ public void saveSettings(ToolSettings newSettings) {
settings.setAutoSwitch(newSettings.isAutoSwitch());
settings.setAlwaysTop(newSettings.isAlwaysTop());
settings.setUpdateNotify(newSettings.isUpdateNotify());
settings.setSkipBootAnimation(newSettings.isSkipBootAnimation());
saveSettings();
}

Expand All @@ -112,6 +115,7 @@ public void saveSettings() {
props.setProperty("autoSwitch", settings.isAutoSwitch() + "");
props.setProperty("alwaysTop", settings.isAlwaysTop() + "");
props.setProperty("updateNotify",settings.isUpdateNotify()+"");
props.setProperty("skipBootAnimation",settings.isSkipBootAnimation()+"");
try {
FileWriter writer = new FileWriter(propertiesFile);
props.store(writer, "Change settings");
Expand Down Expand Up @@ -313,5 +317,17 @@ public void saveUpdateNotify(boolean notify) {
settings.setUpdateNotify(notify);
saveSettings();
}
/*
* ***************
* 启动时是否跳过动画
* ***************
*/
public boolean getSKipBootAnimation() {
return settings.isSkipBootAnimation();
}

public void saveSkipBootAnimation(boolean skipBootAnimation) {
settings.setSkipBootAnimation(skipBootAnimation);;
saveSettings();
}
}
1 change: 1 addition & 0 deletions src/main/resources/fxml/settings-page.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
</styleClass>
</Button>
<CheckBox fx:id="updateNotifyCheckBox" mnemonicParsing="false" selected="true" text="%updateNotify" />
<CheckBox fx:id="skipBootAnimationCheckbox" mnemonicParsing="false" selected="true" text="%skipBootAnimation" />
</children>
<padding>
<Insets left="20.0" />
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/language/language.properties
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,5 @@ icon.allSize=All Size
icon.only512=Only 512x512
carousel=Carousel
carousel.autoSwitch=Auto Switch
colorPickerTips=Click to copy color
colorPickerTips=Click to copy color
skipBootAnimation=Skip boot animation
3 changes: 2 additions & 1 deletion src/main/resources/language/language_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,5 @@ icon.allSize=\u591A\u79CD\u5C3A\u5BF8(\u591A\u56FE)
icon.only512=512x512(\u4E00\u56FE)
carousel=\u8F6E\u64AD\u56FE
carousel.autoSwitch=\u81EA\u52A8\u5207\u6362
colorPickerTips=\u70B9\u51FB\u590D\u5236\u989C\u8272
colorPickerTips=\u70B9\u51FB\u590D\u5236\u989C\u8272
skipBootAnimation=\u8df3\u8fc7\u542f\u52a8\u52a8\u753b