diff --git a/Dogename/dogename.iml b/Dogename/dogename.iml
index e46daca..59f0a82 100644
--- a/Dogename/dogename.iml
+++ b/Dogename/dogename.iml
@@ -13,14 +13,7 @@
-
-
-
-
-
-
-
diff --git a/Dogename/pom.xml b/Dogename/pom.xml
index 57d5c33..9944067 100644
--- a/Dogename/pom.xml
+++ b/Dogename/pom.xml
@@ -52,13 +52,6 @@
8.0.9
-
-
- org.apache.logging.log4j
- log4j-core
- 2.13.2
-
-
commons-io
diff --git a/Dogename/src/main/java/log4j2.xml b/Dogename/src/main/java/log4j2.xml
deleted file mode 100644
index 92d39c3..0000000
--- a/Dogename/src/main/java/log4j2.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Dogename/src/main/java/me/lensferno/dogename/Main.java b/Dogename/src/main/java/me/lensferno/dogename/Main.java
index f2766b3..addc1ef 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/Main.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/Main.java
@@ -9,8 +9,6 @@ import me.lensferno.dogename.configs.ConfigLoader;
import me.lensferno.dogename.controllers.MainInterfaceController;
import me.lensferno.dogename.sayings.Gushici;
import me.lensferno.dogename.sayings.Hitokoto;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
import java.io.File;
import java.lang.management.ManagementFactory;
@@ -18,9 +16,9 @@ import java.util.Random;
public class Main extends Application {
- Logger log = LogManager.getLogger();
-
- public static void main(String[] args){ launch(args);}
+ public static void main(String[] args) {
+ launch(args);
+ }
@Override
public void start(Stage primaryStage) {
@@ -34,30 +32,30 @@ public class Main extends Application {
tempFile.createNewFile();
tempFile.deleteOnExit();
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
}
FXMLLoader fxmlLoader;
Parent parent;
- try{
- fxmlLoader=new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/MainInterface.fxml"));
- parent=fxmlLoader.load();
- }catch (Exception e){
- log.error("Error to load main interface FXML :"+e.toString());
+ try {
+ fxmlLoader = new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/MainInterface.fxml"));
+ parent = fxmlLoader.load();
+ } catch (Exception e) {
+ System.out.println("Error to load main interface FXML :" + e);
return;
}
- Scene scene=new Scene(parent,990,700);
+ Scene scene = new Scene(parent, 990, 700);
primaryStage.setTitle("DogeName 叁号姬");
primaryStage.setScene(scene);
primaryStage.show();
- ConfigLoader configLoader=new ConfigLoader();
+ ConfigLoader configLoader = new ConfigLoader();
- MainInterfaceController mainInterfaceController=fxmlLoader.getController();
+ MainInterfaceController mainInterfaceController = fxmlLoader.getController();
mainInterfaceController.setToggleGroup();
@@ -78,10 +76,10 @@ public class Main extends Application {
System.exit(0);
});
- if (new Random().nextBoolean()){
- new Gushici().showGushici(mainInterfaceController.getRootPane(),mainInterfaceController.getTopBar(), mainInterfaceController.getMainConfig().isShowSaying());
+ if (new Random().nextBoolean()) {
+ new Gushici().showGushici(mainInterfaceController.getRootPane(), mainInterfaceController.getTopBar(), mainInterfaceController.getMainConfig().isShowSaying());
} else {
- new Hitokoto().showHitokoto(mainInterfaceController.getRootPane(),mainInterfaceController.getTopBar(), mainInterfaceController.getMainConfig().isShowSaying());
+ new Hitokoto().showHitokoto(mainInterfaceController.getRootPane(), mainInterfaceController.getTopBar(), mainInterfaceController.getMainConfig().isShowSaying());
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/configs/ConfigLoader.java b/Dogename/src/main/java/me/lensferno/dogename/configs/ConfigLoader.java
index ce759d2..2499ccd 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/configs/ConfigLoader.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/configs/ConfigLoader.java
@@ -2,28 +2,27 @@ package me.lensferno.dogename.configs;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import javafx.beans.property.*;
+import javafx.beans.property.SimpleBooleanProperty;
+import javafx.beans.property.SimpleDoubleProperty;
+import javafx.beans.property.SimpleIntegerProperty;
+import javafx.beans.property.SimpleStringProperty;
import me.lensferno.dogename.configs.adapters.BooleanPropertyAdapter;
import me.lensferno.dogename.configs.adapters.DoublePropertyAdapter;
import me.lensferno.dogename.configs.adapters.IntegerPropertyAdapter;
import me.lensferno.dogename.configs.adapters.StringPropertyAdapter;
import org.apache.commons.io.IOUtils;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
import java.io.*;
import java.nio.charset.StandardCharsets;
public class ConfigLoader {
- Logger log = LogManager.getLogger();
+ private final String mainConfigLocation = "files" + File.separator + "Config.json";
+ private final String voiceConfigLocation = "files" + File.separator + "VoiceConfig.json";
//ConfigValuesBean config;
private MainConfig mainConfig;
private VoiceConfig voiceConfig;
-
- private final String mainConfigLocation = "files"+ File.separator+"Config.json";
- private final String voiceConfigLocation = "files"+ File.separator+"VoiceConfig.json";
public String getMainConfigLocation() {
return mainConfigLocation;
@@ -37,43 +36,43 @@ public class ConfigLoader {
return mainConfig;
}
- public MainConfig readConfigFromFile(String fileLocation){
+ public MainConfig readConfigFromFile(String fileLocation) {
//property属性应该要自定义一个json适配器才能解析出来
- Gson gson=new GsonBuilder()
- .registerTypeAdapter(SimpleBooleanProperty.class,new BooleanPropertyAdapter())
- .registerTypeAdapter(SimpleIntegerProperty.class,new IntegerPropertyAdapter())
- .registerTypeAdapter(SimpleStringProperty.class,new StringPropertyAdapter())
- .registerTypeAdapter(SimpleDoubleProperty.class,new DoublePropertyAdapter())
+ Gson gson = new GsonBuilder()
+ .registerTypeAdapter(SimpleBooleanProperty.class, new BooleanPropertyAdapter())
+ .registerTypeAdapter(SimpleIntegerProperty.class, new IntegerPropertyAdapter())
+ .registerTypeAdapter(SimpleStringProperty.class, new StringPropertyAdapter())
+ .registerTypeAdapter(SimpleDoubleProperty.class, new DoublePropertyAdapter())
.setPrettyPrinting()
.create();
String ConfigJSON;
- try{
- File configFile=new File(fileLocation);
- if(!configFile.exists()){
+ try {
+ File configFile = new File(fileLocation);
+ if (!configFile.exists()) {
configFile.getParentFile().mkdirs();
configFile.createNewFile();
- mainConfig=new MainConfig();
+ mainConfig = new MainConfig();
writeMainConfigToFile(mainConfigLocation);
return mainConfig;
}
- InputStream inputStream=new FileInputStream(configFile);
- ConfigJSON=IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ InputStream inputStream = new FileInputStream(configFile);
+ ConfigJSON = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
- mainConfig=gson.fromJson(ConfigJSON,MainConfig.class);
+ mainConfig = gson.fromJson(ConfigJSON, MainConfig.class);
if (mainConfig == null) {
- mainConfig=new MainConfig();
+ mainConfig = new MainConfig();
writeMainConfigToFile(mainConfigLocation);
return mainConfig;
}
- }catch (Exception e){
- log.error("Error to load config file:"+e+"\nUse Default config.");
+ } catch (Exception e) {
+ System.out.println("Error to load config file:" + e + "\nUse Default config.");
- mainConfig=new MainConfig();
+ mainConfig = new MainConfig();
writeMainConfigToFile(mainConfigLocation);
return mainConfig;
}
@@ -81,44 +80,44 @@ public class ConfigLoader {
return this.mainConfig;
}
- public VoiceConfig readVoiceConfigFromFile(String fileLocation){
+ public VoiceConfig readVoiceConfigFromFile(String fileLocation) {
//property属性应该要自定义一个json适配器才能解析出来
- Gson gson=new GsonBuilder()
- .registerTypeAdapter(SimpleBooleanProperty.class,new BooleanPropertyAdapter())
- .registerTypeAdapter(SimpleIntegerProperty.class,new IntegerPropertyAdapter())
- .registerTypeAdapter(SimpleStringProperty.class,new StringPropertyAdapter())
- .registerTypeAdapter(SimpleDoubleProperty.class,new DoublePropertyAdapter())
+ Gson gson = new GsonBuilder()
+ .registerTypeAdapter(SimpleBooleanProperty.class, new BooleanPropertyAdapter())
+ .registerTypeAdapter(SimpleIntegerProperty.class, new IntegerPropertyAdapter())
+ .registerTypeAdapter(SimpleStringProperty.class, new StringPropertyAdapter())
+ .registerTypeAdapter(SimpleDoubleProperty.class, new DoublePropertyAdapter())
.setPrettyPrinting()
.create();
String ConfigJSON;
- try{
- File configFile=new File(fileLocation);
- if(!configFile.exists()){
+ try {
+ File configFile = new File(fileLocation);
+ if (!configFile.exists()) {
configFile.getParentFile().mkdirs();
configFile.createNewFile();
- voiceConfig=new VoiceConfig();
+ voiceConfig = new VoiceConfig();
writeVoiceConfigToFile(voiceConfigLocation);
return voiceConfig;
}
- InputStream inputStream=new FileInputStream(configFile);
- ConfigJSON=IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ InputStream inputStream = new FileInputStream(configFile);
+ ConfigJSON = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
writeVoiceConfigToFile(voiceConfigLocation);
- voiceConfig=gson.fromJson(ConfigJSON,VoiceConfig.class);
+ voiceConfig = gson.fromJson(ConfigJSON, VoiceConfig.class);
if (voiceConfig == null) {
- voiceConfig=new VoiceConfig();
+ voiceConfig = new VoiceConfig();
writeVoiceConfigToFile(voiceConfigLocation);
return voiceConfig;
}
- }catch (Exception e){
- log.error("Error to load voice config file:"+e+"\nUse Default voice config.");
+ } catch (Exception e) {
+ System.out.println("Error to load voice config file:" + e + "\nUse Default voice config.");
- voiceConfig=new VoiceConfig();
+ voiceConfig = new VoiceConfig();
writeVoiceConfigToFile(voiceConfigLocation);
return voiceConfig;
}
@@ -127,85 +126,85 @@ public class ConfigLoader {
}
//
- public MainConfig setValuesToProperty(){
+ public MainConfig setValuesToProperty() {
//mainconfig.set..(config.get..)
//...so on
//
return this.mainConfig;
}
- private String toJSON(MainConfig config){
+ private String toJSON(MainConfig config) {
- Gson gson=new GsonBuilder()
- .registerTypeAdapter(SimpleBooleanProperty.class,new BooleanPropertyAdapter())
- .registerTypeAdapter(SimpleIntegerProperty.class,new IntegerPropertyAdapter())
- .registerTypeAdapter(SimpleStringProperty.class,new StringPropertyAdapter())
- .setPrettyPrinting()
- .create();
+ Gson gson = new GsonBuilder()
+ .registerTypeAdapter(SimpleBooleanProperty.class, new BooleanPropertyAdapter())
+ .registerTypeAdapter(SimpleIntegerProperty.class, new IntegerPropertyAdapter())
+ .registerTypeAdapter(SimpleStringProperty.class, new StringPropertyAdapter())
+ .setPrettyPrinting()
+ .create();
return gson.toJson(config);
}
- private String VoiceConfigtoJSON(VoiceConfig config){
+ private String VoiceConfigtoJSON(VoiceConfig config) {
- Gson gson=new GsonBuilder()
- .registerTypeAdapter(SimpleDoubleProperty.class,new DoublePropertyAdapter())
+ Gson gson = new GsonBuilder()
+ .registerTypeAdapter(SimpleDoubleProperty.class, new DoublePropertyAdapter())
.setPrettyPrinting()
.create();
return gson.toJson(config);
}
- public void writeAllConfigToFile(String outputLocation, String voiceConfigFile){
+ public void writeAllConfigToFile(String outputLocation, String voiceConfigFile) {
File outputFile = new File(outputLocation);
- try{
- if(! outputFile.exists()){
+ try {
+ if (!outputFile.exists()) {
outputFile.getParentFile().mkdirs();
outputFile.createNewFile();
}
- OutputStream stream=new FileOutputStream(outputFile);
- IOUtils.write(toJSON(this.mainConfig).getBytes(StandardCharsets.UTF_8),stream);
+ OutputStream stream = new FileOutputStream(outputFile);
+ IOUtils.write(toJSON(this.mainConfig).getBytes(StandardCharsets.UTF_8), stream);
- OutputStream voiceConfigFileStream=new FileOutputStream(voiceConfigFile);
- IOUtils.write(VoiceConfigtoJSON(this.voiceConfig).getBytes(StandardCharsets.UTF_8),voiceConfigFileStream);
+ OutputStream voiceConfigFileStream = new FileOutputStream(voiceConfigFile);
+ IOUtils.write(VoiceConfigtoJSON(this.voiceConfig).getBytes(StandardCharsets.UTF_8), voiceConfigFileStream);
- }catch (Exception e){
- log.error("Error in writing all config:"+e);
+ } catch (Exception e) {
+ System.out.println("Error in writing all config:" + e);
}
}
- public void writeMainConfigToFile(String outputLocation){
+ public void writeMainConfigToFile(String outputLocation) {
File outputFile = new File(outputLocation);
- try{
- if(! outputFile.exists()){
+ try {
+ if (!outputFile.exists()) {
outputFile.getParentFile().mkdirs();
outputFile.createNewFile();
}
- OutputStream stream=new FileOutputStream(outputFile);
- IOUtils.write(toJSON(this.mainConfig).getBytes(StandardCharsets.UTF_8),stream);
+ OutputStream stream = new FileOutputStream(outputFile);
+ IOUtils.write(toJSON(this.mainConfig).getBytes(StandardCharsets.UTF_8), stream);
- }catch (Exception e){
- log.error("Error in writing main config:"+e);
+ } catch (Exception e) {
+ System.out.println("Error in writing main config:" + e);
}
}
- public void writeVoiceConfigToFile(String voiceConfigFile){
+ public void writeVoiceConfigToFile(String voiceConfigFile) {
File outputFile = new File(voiceConfigFile);
- try{
+ try {
- if(! outputFile.exists()) {
+ if (!outputFile.exists()) {
outputFile.getParentFile().mkdirs();
outputFile.createNewFile();
}
- OutputStream voiceConfigFileStream=new FileOutputStream(voiceConfigFile);
- IOUtils.write(VoiceConfigtoJSON(this.voiceConfig).getBytes(StandardCharsets.UTF_8),voiceConfigFileStream);
+ OutputStream voiceConfigFileStream = new FileOutputStream(voiceConfigFile);
+ IOUtils.write(VoiceConfigtoJSON(this.voiceConfig).getBytes(StandardCharsets.UTF_8), voiceConfigFileStream);
- }catch (Exception e){
- log.error("Error in writing voice config:"+e);
+ } catch (Exception e) {
+ System.out.println("Error in writing voice config:" + e);
}
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/configs/MainConfig.java b/Dogename/src/main/java/me/lensferno/dogename/configs/MainConfig.java
index baec855..acaf510 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/configs/MainConfig.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/configs/MainConfig.java
@@ -1,55 +1,48 @@
package me.lensferno.dogename.configs;
import com.google.gson.annotations.Expose;
-import javafx.beans.property.*;
+import javafx.beans.property.SimpleBooleanProperty;
+import javafx.beans.property.SimpleIntegerProperty;
+import javafx.beans.property.SimpleStringProperty;
public class MainConfig {
// ---------------------- Default values ---------------------------------------------------------
- private final int currentVersion = 3;
-
@Expose
public static final boolean DEFAULT_NAME_CHOOSE = true;
-
public static final int METHOD_NAME = 0; // 名字挑选法
public static final int METHOD_NUMBER = 1; // 数字挑选法
-
public static final int DEFAULT_MAX_TOTAL_COUNT = 120; // 默认轮回次数:120
public static final int DEFAULT_SPEED = 80; // 默认速度:20ms,对应滑动条80的位置
-
public static final boolean DEFAULT_RANDOM_TIMES = true; // 默认挑选轮回次数是否随机:ture
-
public static final boolean DEFAULT_IGNORE_PAST = true; // 默认忽略已经点过的名字:ture
-
public static final boolean DEFAULT_EQUAL_MODE = true; // 默认开启"机会均等"
-
public static final boolean DEFAULT_NEW_ALGO = true; // 默认使用新算法"Java sec random"
public static final boolean DEFAULT_VOICE_PLAY = true; // 默认使用语音播报
-
public static final boolean DEFAULT_SHOW_SAYING = true;
+ private final int currentVersion = 3;
// ----------------------Properties----------------------------------------------------------------
+ private final SimpleBooleanProperty nameChoose;
- private SimpleBooleanProperty nameChoose;
-
- private SimpleBooleanProperty randomCount; // 挑选次数是否随机
- private SimpleBooleanProperty passSelectedResult; // 是否忽略已经被点过的名字/数字
+ private final SimpleBooleanProperty randomCount; // 挑选次数是否随机
+ private final SimpleBooleanProperty passSelectedResult; // 是否忽略已经被点过的名字/数字
- private SimpleIntegerProperty chooseMethod; // 挑选方式: 0->名字挑选法 1->数字挑选法
- private SimpleIntegerProperty maxTotalCount; // 挑选轮回次数
+ private final SimpleIntegerProperty chooseMethod; // 挑选方式: 0->名字挑选法 1->数字挑选法
+ private final SimpleIntegerProperty maxTotalCount; // 挑选轮回次数
- private SimpleIntegerProperty speed; // 速度
+ private final SimpleIntegerProperty speed; // 速度
- private SimpleStringProperty minNumber; // 最小值
- private SimpleStringProperty maxNumber; // 最大值
+ private final SimpleStringProperty minNumber; // 最小值
+ private final SimpleStringProperty maxNumber; // 最大值
- private SimpleBooleanProperty equalMode; // 是否开启"机会均等"
+ private final SimpleBooleanProperty equalMode; // 是否开启"机会均等"
- private SimpleBooleanProperty secureRandom; // 是否使用secure random
- private SimpleBooleanProperty voicePlay; // 是否使用语音播报
+ private final SimpleBooleanProperty secureRandom; // 是否使用secure random
+ private final SimpleBooleanProperty voicePlay; // 是否使用语音播报
- private SimpleBooleanProperty showSaying;
+ private final SimpleBooleanProperty showSaying;
// -------------------------- 初始化 --------------------------------------------------------------
public MainConfig() {
@@ -80,146 +73,146 @@ public class MainConfig {
return nameChoose.get();
}
- public SimpleBooleanProperty nameChooseProperty() {
- return nameChoose;
- }
-
public void setNameChoose(boolean nameChoose) {
this.nameChoose.set(nameChoose);
}
- public boolean getRandomCount() {
- return randomCount.get();
+ public SimpleBooleanProperty nameChooseProperty() {
+ return nameChoose;
}
- public SimpleBooleanProperty randomCountProperty() {
- return randomCount;
+ public boolean getRandomCount() {
+ return randomCount.get();
}
public void setRandomCount(boolean randomCount) {
this.randomCount.set(randomCount);
}
- public boolean getPassSelectedResult() {
- return passSelectedResult.get();
+ public SimpleBooleanProperty randomCountProperty() {
+ return randomCount;
}
- public SimpleBooleanProperty passSelectedResultProperty() {
- return passSelectedResult;
+ public boolean getPassSelectedResult() {
+ return passSelectedResult.get();
}
public void setPassSelectedResult(boolean passSelectedResult) {
this.passSelectedResult.set(passSelectedResult);
}
- public int getChooseMethod() {
- return chooseMethod.get();
+ public SimpleBooleanProperty passSelectedResultProperty() {
+ return passSelectedResult;
}
- public SimpleIntegerProperty chooseMethodProperty() {
- return chooseMethod;
+ public int getChooseMethod() {
+ return chooseMethod.get();
}
public void setChooseMethod(int chooseMethod) {
this.chooseMethod.set(chooseMethod);
}
- public int getMaxTotalCount() {
- return maxTotalCount.get();
+ public SimpleIntegerProperty chooseMethodProperty() {
+ return chooseMethod;
}
- public SimpleIntegerProperty maxTotalCountProperty() {
- return maxTotalCount;
+ public int getMaxTotalCount() {
+ return maxTotalCount.get();
}
public void setMaxTotalCount(int maxTotalCount) {
this.maxTotalCount.set(maxTotalCount);
}
- public int getSpeed() {
- return speed.get();
+ public SimpleIntegerProperty maxTotalCountProperty() {
+ return maxTotalCount;
}
- public SimpleIntegerProperty speedProperty() {
- return speed;
+ public int getSpeed() {
+ return speed.get();
}
public void setSpeed(int speed) {
this.speed.set(speed);
}
- public String getMinNumber() {
- return minNumber.get();
+ public SimpleIntegerProperty speedProperty() {
+ return speed;
}
- public SimpleStringProperty minNumberProperty() {
- return minNumber;
+ public String getMinNumber() {
+ return minNumber.get();
}
public void setMinNumber(String minNumber) {
this.minNumber.set(minNumber);
}
- public String getMaxNumber() {
- return maxNumber.get();
+ public SimpleStringProperty minNumberProperty() {
+ return minNumber;
}
- public SimpleStringProperty maxNumberProperty() {
- return maxNumber;
+ public String getMaxNumber() {
+ return maxNumber.get();
}
public void setMaxNumber(String maxNumber) {
this.maxNumber.set(maxNumber);
}
- public boolean getEqualMode() {
- return equalMode.get();
+ public SimpleStringProperty maxNumberProperty() {
+ return maxNumber;
}
- public SimpleBooleanProperty equalModeProperty() {
- return equalMode;
+ public boolean getEqualMode() {
+ return equalMode.get();
}
public void setEqualMode(boolean equalMode) {
this.equalMode.set(equalMode);
}
- public boolean getSecureRandom() {
- return secureRandom.get();
+ public SimpleBooleanProperty equalModeProperty() {
+ return equalMode;
}
- public SimpleBooleanProperty secureRandomProperty() {
- return secureRandom;
+ public boolean getSecureRandom() {
+ return secureRandom.get();
}
public void setSecureRandom(boolean secureRandom) {
this.secureRandom.set(secureRandom);
}
- public boolean getVoicePlay() {
- return voicePlay.get();
+ public SimpleBooleanProperty secureRandomProperty() {
+ return secureRandom;
}
- public SimpleBooleanProperty voicePlayProperty() {
- return voicePlay;
+ public boolean getVoicePlay() {
+ return voicePlay.get();
}
public void setVoicePlay(boolean voicePlay) {
this.voicePlay.set(voicePlay);
}
- public boolean isShowSaying() {
- return showSaying.get();
+ public SimpleBooleanProperty voicePlayProperty() {
+ return voicePlay;
}
- public SimpleBooleanProperty showSayingProperty() {
- return showSaying;
+ public boolean isShowSaying() {
+ return showSaying.get();
}
public void setShowSaying(boolean showSaying) {
this.showSaying.set(showSaying);
}
+ public SimpleBooleanProperty showSayingProperty() {
+ return showSaying;
+ }
+
public int getCurrentConfigVersion() {
return currentVersion;
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/configs/VoiceConfig.java b/Dogename/src/main/java/me/lensferno/dogename/configs/VoiceConfig.java
index aa4be98..e39c408 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/configs/VoiceConfig.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/configs/VoiceConfig.java
@@ -5,16 +5,24 @@ import javafx.event.ActionEvent;
import javafx.fxml.FXML;
public class VoiceConfig {
-
- private String speaker;
- private int selectedSpeaker;
+
+ public final int DEFAULT_SPEED = 5;
+ public final int DEFAULT_INTONATION = 5;
//度小宇=1,度小美=0,度逍遥=3,度丫丫=4
//度博文=106,度小童=110,度小萌=111,度米朵=103,度小娇=5
-
- private SimpleDoubleProperty speed;
- private SimpleDoubleProperty intonation;
+ private String speaker;
+ private int selectedSpeaker;
+ private final SimpleDoubleProperty speed;
+ private final SimpleDoubleProperty intonation;
+
+ public VoiceConfig() {
+ selectedSpeaker = 0;
+ speaker = "1";
+ speed = new SimpleDoubleProperty(DEFAULT_SPEED);
+ intonation = new SimpleDoubleProperty(DEFAULT_INTONATION);
+ }
public String getSpeaker() {
return speaker;
@@ -24,16 +32,6 @@ public class VoiceConfig {
this.speaker = speaker;
}
- public final int DEFAULT_SPEED=5;
- public final int DEFAULT_INTONATION=5;
-
- public VoiceConfig(){
- selectedSpeaker=0;
- speaker="1";
- speed=new SimpleDoubleProperty(DEFAULT_SPEED);
- intonation=new SimpleDoubleProperty(DEFAULT_INTONATION);
- }
-
public int getSelectedSpeaker() {
return selectedSpeaker;
}
@@ -41,35 +39,35 @@ public class VoiceConfig {
public void setSelectedSpeaker(int selectedSpeaker) {
this.selectedSpeaker = selectedSpeaker;
}
+
public double getSpeed() {
return speed.get();
}
- public SimpleDoubleProperty speedProperty() {
- return speed;
- }
-
public void setSpeed(double speed) {
this.speed.set(speed);
}
- public double getIntonation() {
- return intonation.get();
+ public SimpleDoubleProperty speedProperty() {
+ return speed;
}
- public SimpleDoubleProperty intonationProperty() {
- return intonation;
+ public double getIntonation() {
+ return intonation.get();
}
public void setIntonation(double intonation) {
this.intonation.set(intonation);
}
+ public SimpleDoubleProperty intonationProperty() {
+ return intonation;
+ }
+
@FXML
void showAdvancedVoiceSettings(ActionEvent event) {
}
-
-
+
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/configs/adapters/BooleanPropertyAdapter.java b/Dogename/src/main/java/me/lensferno/dogename/configs/adapters/BooleanPropertyAdapter.java
index 6c87d4a..e5d1dd8 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/configs/adapters/BooleanPropertyAdapter.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/configs/adapters/BooleanPropertyAdapter.java
@@ -9,18 +9,18 @@ public class BooleanPropertyAdapter implements JsonSerializer, JsonDeserializer {
@Override
public SimpleIntegerProperty deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
- if(jsonElement==null) {
+ if (jsonElement == null) {
throw new JsonParseException("Json is wrong.");
- }else {
+ } else {
return new SimpleIntegerProperty(jsonElement.getAsInt());
}
}
@Override
public JsonElement serialize(SimpleIntegerProperty simpleIntegerProperty, Type type, JsonSerializationContext jsonSerializationContext) {
- if(simpleIntegerProperty==null){
+ if (simpleIntegerProperty == null) {
throw new JsonParseException("Json is wrong.");
- }else {
+ } else {
return new JsonPrimitive(simpleIntegerProperty.get());
}
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/configs/adapters/StringPropertyAdapter.java b/Dogename/src/main/java/me/lensferno/dogename/configs/adapters/StringPropertyAdapter.java
index 0bbf7d5..e872c9c 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/configs/adapters/StringPropertyAdapter.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/configs/adapters/StringPropertyAdapter.java
@@ -8,18 +8,18 @@ import java.lang.reflect.Type;
public class StringPropertyAdapter implements JsonSerializer, JsonDeserializer {
@Override
public SimpleStringProperty deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
- if(jsonElement==null) {
+ if (jsonElement == null) {
throw new JsonParseException("Json is wrong.");
- }else {
+ } else {
return new SimpleStringProperty(jsonElement.getAsString());
}
}
@Override
public JsonElement serialize(SimpleStringProperty simpleStringProperty, Type type, JsonSerializationContext jsonSerializationContext) {
- if(simpleStringProperty==null) {
+ if (simpleStringProperty == null) {
throw new JsonParseException("Json is wrong.");
- }else {
+ } else {
return new JsonPrimitive(simpleStringProperty.get());
}
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/controllers/GushiciPaneController.java b/Dogename/src/main/java/me/lensferno/dogename/controllers/GushiciPaneController.java
index de2e948..deab22b 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/controllers/GushiciPaneController.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/controllers/GushiciPaneController.java
@@ -4,13 +4,10 @@ import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
public class GushiciPaneController extends VBox {
- Logger log= LogManager.getLogger();
@FXML
public Text contentText;
@@ -20,20 +17,18 @@ public class GushiciPaneController extends VBox {
@FXML
public Text contentInfo;
- public GushiciPaneController (String content,String title,String author,String type){
+ public GushiciPaneController(String content, String title, String author, String type) {
- FXMLLoader loader=new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/GushiciPane.fxml"));
+ FXMLLoader loader = new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/GushiciPane.fxml"));
loader.setRoot(this);
loader.setController(this);
try {
loader.load();
- }catch(Exception e){
- log.error("Error to load Gushici pane FXML: "+e.toString());
-
- //e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
}
- contentText.setText("“"+content+"”");
- contentInfo.setText("《"+title+"》"+"——"+author);
+ contentText.setText("“" + content + "”");
+ contentInfo.setText("《" + title + "》" + "——" + author);
contentType.setText(type);
}
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/controllers/HistoryPaneController.java b/Dogename/src/main/java/me/lensferno/dogename/controllers/HistoryPaneController.java
index d1a0328..63a0471 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/controllers/HistoryPaneController.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/controllers/HistoryPaneController.java
@@ -1,6 +1,8 @@
package me.lensferno.dogename.controllers;
-import com.jfoenix.controls.*;
+import com.jfoenix.controls.JFXButton;
+import com.jfoenix.controls.JFXListView;
+import com.jfoenix.controls.JFXTextField;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
@@ -8,25 +10,33 @@ import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
-import me.lensferno.dogename.utils.DialogMaker;
import me.lensferno.dogename.data.History;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
+import me.lensferno.dogename.utils.DialogMaker;
public class HistoryPaneController extends VBox {
- Logger log= LogManager.getLogger(HitokotoPaneController.class);
+ public static final ObservableList shownHistoryList = FXCollections.observableArrayList();
History history;
Pane rootPane;
+ int pointer = 0;
+ @FXML
+ private JFXListView historyList;
- public static final ObservableList shownHistoryList = FXCollections.observableArrayList();
+ @FXML
+ private JFXTextField searchBar;
+
+ @FXML
+ private JFXButton previousBtn;
+
+ @FXML
+ private JFXButton nextBtn;
- public HistoryPaneController(History history, Pane rootPane){
- FXMLLoader loader=new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/HistoryPane.fxml"));
+ public HistoryPaneController(History history, Pane rootPane) {
+ FXMLLoader loader = new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/HistoryPane.fxml"));
loader.setRoot(this);
loader.setController(this);
- this.history=history;
- this.rootPane=rootPane;
+ this.history = history;
+ this.rootPane = rootPane;
try {
loader.load();
@@ -34,54 +44,40 @@ public class HistoryPaneController extends VBox {
historyList.setItems(shownHistoryList);
searchBar.textProperty().addListener((observable, oldValue, newValue) -> pointer = 0);
- }catch(Exception e){
- log.error("Error in loading history Fxml:"+e.toString());
+ } catch (Exception e) {
+ e.printStackTrace();
}
}
- @FXML
- private JFXListView historyList;
-
- @FXML
- private JFXTextField searchBar;
-
- @FXML
- private JFXButton previousBtn;
-
- @FXML
- private JFXButton nextBtn;
-
- private void pointOutSearchResult(int pointer){
+ private void pointOutSearchResult(int pointer) {
historyList.getSelectionModel().select(pointer);
}
- int pointer=0;
-
@FXML
void upSearch(ActionEvent event) {
- String searchText=searchBar.getText();
- String[] historyArrayList =history.getHistoryList().toArray(new String[0]);
+ String searchText = searchBar.getText();
+ String[] historyArrayList = history.getHistoryList().toArray(new String[0]);
- if (historyArrayList.length==0){
+ if (historyArrayList.length == 0) {
return;
}
- if (pointer>historyArrayList.length-1||pointer<0){
- pointer=historyArrayList.length-1;
+ if (pointer > historyArrayList.length - 1 || pointer < 0) {
+ pointer = historyArrayList.length - 1;
}
- while (!historyArrayList[pointer].contains(searchText)){
+ while (!historyArrayList[pointer].contains(searchText)) {
pointer--;
- if (pointer<0){
- pointer=historyArrayList.length-1;
+ if (pointer < 0) {
+ pointer = historyArrayList.length - 1;
return;
}
}
pointOutSearchResult(pointer);
pointer--;
- if (pointer<0){
- pointer=historyArrayList.length-1;
+ if (pointer < 0) {
+ pointer = historyArrayList.length - 1;
}
}
@@ -89,37 +85,37 @@ public class HistoryPaneController extends VBox {
@FXML
void downSearch(ActionEvent event) {
- String searchText=searchBar.getText();
- String[] historyArrayList =history.getHistoryList().toArray(new String[0]);
+ String searchText = searchBar.getText();
+ String[] historyArrayList = history.getHistoryList().toArray(new String[0]);
- if (historyArrayList.length==0){
+ if (historyArrayList.length == 0) {
return;
}
- if (pointer>historyArrayList.length-1||pointer<0){
- pointer=0;
+ if (pointer > historyArrayList.length - 1 || pointer < 0) {
+ pointer = 0;
}
- while (!historyArrayList[pointer].contains(searchText)){
+ while (!historyArrayList[pointer].contains(searchText)) {
pointer++;
- if (pointer {
+ void clearHistory() {
+ new DialogMaker(rootPane).createDialogWithOKAndCancel("且慢!", "真的要清除全部历史记录吗?", (e) -> {
this.history.clearHistory();
- pointer=0;
+ pointer = 0;
});
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/controllers/HitokotoPaneController.java b/Dogename/src/main/java/me/lensferno/dogename/controllers/HitokotoPaneController.java
index 7f97b2b..74fc39d 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/controllers/HitokotoPaneController.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/controllers/HitokotoPaneController.java
@@ -5,12 +5,9 @@ import javafx.fxml.FXMLLoader;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
-import java.util.logging.Logger;
public class HitokotoPaneController extends VBox {
- Logger log=Logger.getLogger("HitokotoPaneLogger");
-
@FXML
private Text hitokotoContent;
@@ -20,19 +17,18 @@ public class HitokotoPaneController extends VBox {
@FXML
private Text contentInfo;
- public HitokotoPaneController(String hitokoto, String from,String author,String creator,String type){
+ public HitokotoPaneController(String hitokoto, String from, String author, String creator, String type) {
- FXMLLoader loader=new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/HitokotoPane.fxml"));
+ FXMLLoader loader = new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/HitokotoPane.fxml"));
loader.setRoot(this);
loader.setController(this);
try {
loader.load();
- }catch(Exception e){
- log.warning("Error to load Gushici pane FXML: "+e.toString());
- //e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
}
- hitokotoContent.setText("『 "+hitokoto+" 』");
- contentInfo.setText("出自:"+from+" | 作者:"+author+" | 上传者:"+creator);
+ hitokotoContent.setText("『 " + hitokoto + " 』");
+ contentInfo.setText("出自:" + from + " | 作者:" + author + " | 上传者:" + creator);
contentType.setText(type);
}
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/controllers/MainInterfaceController.java b/Dogename/src/main/java/me/lensferno/dogename/controllers/MainInterfaceController.java
index 23b361c..6ef5271 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/controllers/MainInterfaceController.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/controllers/MainInterfaceController.java
@@ -1,27 +1,28 @@
package me.lensferno.dogename.controllers;
-import com.jfoenix.controls.*;
+import com.jfoenix.controls.JFXButton;
+import com.jfoenix.controls.JFXRadioButton;
+import com.jfoenix.controls.JFXTextArea;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
-import javafx.scene.control.*;
+import javafx.scene.control.Label;
+import javafx.scene.control.ToggleGroup;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
-import me.lensferno.dogename.select.Selector;
-import me.lensferno.dogename.utils.DialogMaker;
import me.lensferno.dogename.configs.ConfigLoader;
import me.lensferno.dogename.configs.MainConfig;
import me.lensferno.dogename.configs.VoiceConfig;
-import me.lensferno.dogename.data.History;
import me.lensferno.dogename.data.Data;
+import me.lensferno.dogename.data.History;
+import me.lensferno.dogename.select.Selector;
+import me.lensferno.dogename.utils.DialogMaker;
import me.lensferno.dogename.utils.ocr.OcrTool;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
import java.io.File;
import java.io.IOException;
@@ -32,54 +33,44 @@ public final class MainInterfaceController {
public JFXTextArea message;
- OcrTool ocrTool=null;
-
- History history=new History();
+ OcrTool ocrTool = null;
+ History history = new History();
+ MainConfig mainConfig;
+ VoiceConfig voiceConfig;
+ Random random = new Random();
+ Data data = new Data();
+ Selector selector = new Selector();
@FXML
private Pane rootPane;
-
@FXML
private JFXRadioButton nameChoose;
-
@FXML
private JFXButton showHistoryBtn;
-
@FXML
private JFXRadioButton numbChoose;
-
@FXML
private JFXButton anPaiBtn;
-
@FXML
private Pane mainPane;
-
@FXML
private Label topBar;
-
@FXML
private JFXButton showNameMangerButton;
-
@FXML
private Label upperLabel;
-
@FXML
private ImageView mainView;
-
@FXML
private JFXButton miniModeBtn;
-
@FXML
private Label downLabel;
- public MainInterfaceController(){
+ public MainInterfaceController() {
history.loadHistory();
}
- MainConfig mainConfig;
- VoiceConfig voiceConfig;
-
- public void bindProperties(){
+ public void bindProperties() {
nameChoose.selectedProperty().bindBidirectional(mainConfig.nameChooseProperty());
numbChoose.selectedProperty().bind(mainConfig.nameChooseProperty().not());
@@ -90,67 +81,64 @@ public final class MainInterfaceController {
});
}
- public void setImg(InputStream stream){
+ public void setImg(InputStream stream) {
mainView.setImage(new Image(stream));
}
- public void setUpConfig(ConfigLoader configLoader){
- mainConfig=configLoader.readConfigFromFile("files"+ File.separator +"Config.json");
- voiceConfig=configLoader.readVoiceConfigFromFile("files"+ File.separator +"VoiceConfig.json");
+ public void setUpConfig(ConfigLoader configLoader) {
+ mainConfig = configLoader.readConfigFromFile("files" + File.separator + "Config.json");
+ voiceConfig = configLoader.readVoiceConfigFromFile("files" + File.separator + "VoiceConfig.json");
}
@FXML
void showProgramInfo(ActionEvent event) {
- new DialogMaker(rootPane).createDialogWithOneBtn("程序信息",new ProgramInfoPaneController(rootPane));
+ new DialogMaker(rootPane).createDialogWithOneBtn("程序信息", new ProgramInfoPaneController(rootPane));
}
-
@FXML
void showNameManger(ActionEvent event) {
- if (selector.isWorkerRunning()){
- new DialogMaker(rootPane).createMessageDialog("(・。・)","安排中......\n为保证运行的稳定,此时还不能进行该操作哦。");
+ if (selector.isWorkerRunning()) {
+ new DialogMaker(rootPane).createMessageDialog("(・。・)", "安排中......\n为保证运行的稳定,此时还不能进行该操作哦。");
return;
}
- NameManagerPaneController nameManagerPaneController =new NameManagerPaneController(data,rootPane,ocrTool);
- new DialogMaker(rootPane).createDialogWithOneBtn("名单管理",nameManagerPaneController);
+ NameManagerPaneController nameManagerPaneController = new NameManagerPaneController(data, rootPane, ocrTool);
+ new DialogMaker(rootPane).createDialogWithOneBtn("名单管理", nameManagerPaneController);
}
@FXML
void showNunberSetting(ActionEvent event) {
- if (selector.isWorkerRunning()){
- new DialogMaker(rootPane).createMessageDialog("(・。・)","安排中......\n为保证运行的稳定,此时还不能进行该操作哦。");
+ if (selector.isWorkerRunning()) {
+ new DialogMaker(rootPane).createMessageDialog("(・。・)", "安排中......\n为保证运行的稳定,此时还不能进行该操作哦。");
return;
}
- NumberSettingsPaneController numberSettingsPaneController =new NumberSettingsPaneController(data);
+ NumberSettingsPaneController numberSettingsPaneController = new NumberSettingsPaneController(data);
numberSettingsPaneController.bindProperties(mainConfig);
- new DialogMaker(rootPane).createDialogWithOneBtn("调整数字",numberSettingsPaneController);
+ new DialogMaker(rootPane).createDialogWithOneBtn("调整数字", numberSettingsPaneController);
}
- Logger log= LogManager.getLogger();
-
@FXML
void miniMode(ActionEvent event) {
- FXMLLoader loader=new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/MiniPane.fxml"));
+ FXMLLoader loader = new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/MiniPane.fxml"));
Parent parent;
try {
- parent=loader.load();
+ parent = loader.load();
} catch (IOException e) {
- log.error("Error in loading MiniPane Fxml:"+e);
+ e.printStackTrace();
return;
}
- Scene miniScene=new Scene(parent,300,134);
- Stage miniStage=new Stage();
+ Scene miniScene = new Scene(parent, 300, 134);
+ Stage miniStage = new Stage();
miniStage.setScene(miniScene);
miniStage.initStyle(StageStyle.UNDECORATED);
- MiniPaneController miniPaneController=loader.getController();
+ MiniPaneController miniPaneController = loader.getController();
miniPaneController.setBase(data, mainConfig, selector);
- Stage currentStage=(Stage)anPaiBtn.getScene().getWindow();
+ Stage currentStage = (Stage) anPaiBtn.getScene().getWindow();
miniPaneController.setOldStage(currentStage);
miniPaneController.setCurrentStage(miniStage);
@@ -165,7 +153,7 @@ public final class MainInterfaceController {
@FXML
void showSettings(ActionEvent event) {
- SettingsPaneController settingsPaneController =new SettingsPaneController();
+ SettingsPaneController settingsPaneController = new SettingsPaneController();
settingsPaneController.setToggleGroup();
settingsPaneController.bindProperties(mainConfig);
@@ -176,27 +164,21 @@ public final class MainInterfaceController {
settingsPaneController.setData(data);
- new DialogMaker(rootPane).createDialogWithOneBtn("更多设置",settingsPaneController);
+ new DialogMaker(rootPane).createDialogWithOneBtn("更多设置", settingsPaneController);
}
@FXML
void showHistory(ActionEvent event) {
- HistoryPaneController historyPaneController =new HistoryPaneController(history,rootPane);
+ HistoryPaneController historyPaneController = new HistoryPaneController(history, rootPane);
- new DialogMaker(rootPane).createDialogWithOneBtn("历史记录",historyPaneController);
+ new DialogMaker(rootPane).createDialogWithOneBtn("历史记录", historyPaneController);
}
- Random random=new Random();
-
- Data data =new Data();
-
- Selector selector =new Selector();
-
- public void init(){
+ public void init() {
selector.initialVariable(mainConfig, data, history, upperLabel.textProperty(), downLabel.textProperty());
- selector.addStoppedEventListener((observableValue, oldValue, stop)->{
+ selector.addStoppedEventListener((observableValue, oldValue, stop) -> {
if (stop) {
anPaiBtn.setText("安排一下");
nameChoose.setDisable(false);
@@ -208,46 +190,46 @@ public final class MainInterfaceController {
}
});
}
-
+
@FXML
void anPai() {
- if(selector.isWorkerRunning()){
+ if (selector.isWorkerRunning()) {
selector.forceStop();
anPaiBtn.setText("安排一下");
return;
}
-
- if(mainConfig.getRandomCount()) {
- mainConfig.setMaxTotalCount(100+random.nextInt(151));
+
+ if (mainConfig.getRandomCount()) {
+ mainConfig.setMaxTotalCount(100 + random.nextInt(151));
}
- if(mainConfig.getNameChoose()){
+ if (mainConfig.getNameChoose()) {
runNameMode();
- }else {
+ } else {
runNumberMode();
}
}
- public void setToggleGroup(){
- ToggleGroup toggleGroup =new ToggleGroup();
+ public void setToggleGroup() {
+ ToggleGroup toggleGroup = new ToggleGroup();
nameChoose.setToggleGroup(toggleGroup);
numbChoose.setToggleGroup(toggleGroup);
}
- private void runNameMode(){
+ private void runNameMode() {
- if(data.isEmpty()){
- new DialogMaker(rootPane).createMessageDialog("哦霍~","现在名单还是空的捏~请前往名单管理添加名字 或 使用数字挑选法。");
+ if (data.isEmpty()) {
+ new DialogMaker(rootPane).createMessageDialog("哦霍~", "现在名单还是空的捏~请前往名单管理添加名字 或 使用数字挑选法。");
return;
}
- if(data.compareNameIgnoreList() && mainConfig.getPassSelectedResult()){
+ if (data.compareNameIgnoreList() && mainConfig.getPassSelectedResult()) {
- if(mainConfig.getEqualMode()) {
+ if (mainConfig.getEqualMode()) {
new DialogMaker(rootPane).createDialogWithOKAndCancel("啊?", "全部名字都被点完啦!\n要把名字的忽略列表重置吗?", e -> data.clearNameIgnoreList());
- }else {
+ } else {
new DialogMaker(rootPane).createMessageDialog("啊?", "全部名字都被点完啦!\n请多添加几个名字 或 点击“机会均等”的“重置”按钮。");
}
return;
@@ -258,29 +240,29 @@ public final class MainInterfaceController {
selector.run();
}
- private void runNumberMode(){
+ private void runNumberMode() {
- try{
+ try {
- int minNumber=Integer.parseInt(mainConfig.getMinNumber());
- int maxNumber=Integer.parseInt(mainConfig.getMaxNumber());
+ int minNumber = Integer.parseInt(mainConfig.getMinNumber());
+ int maxNumber = Integer.parseInt(mainConfig.getMaxNumber());
- if(maxNumber-minNumber <= 0){
- new DialogMaker(rootPane).createMessageDialog("嗯哼?","数字要前小后大啊~");
+ if (maxNumber - minNumber <= 0) {
+ new DialogMaker(rootPane).createMessageDialog("嗯哼?", "数字要前小后大啊~");
return;
}
- if(data.getNumberIgnoreListSize() >= (maxNumber-minNumber+1) && mainConfig.getPassSelectedResult()){
- if(mainConfig.getEqualMode()) {
+ if (data.getNumberIgnoreListSize() >= (maxNumber - minNumber + 1) && mainConfig.getPassSelectedResult()) {
+ if (mainConfig.getEqualMode()) {
new DialogMaker(rootPane).createDialogWithOKAndCancel("啊?", "全部数字都被点完啦!\n要把数字的忽略列表重置吗?", e -> data.clearNumberIgnoreList());
- }else {
+ } else {
new DialogMaker(rootPane).createMessageDialog("啊?", "全部数字都被点完啦!\n请扩大数字范围 或 点击“机会均等”的“重置”按钮。");
}
return;
}
- }catch (Exception e){
- new DialogMaker(rootPane).createMessageDialog("嗯哼?","输入个有效的数字啊~");
+ } catch (Exception e) {
+ new DialogMaker(rootPane).createMessageDialog("嗯哼?", "输入个有效的数字啊~");
return;
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/controllers/MiniPaneController.java b/Dogename/src/main/java/me/lensferno/dogename/controllers/MiniPaneController.java
index 28703df..a0bde71 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/controllers/MiniPaneController.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/controllers/MiniPaneController.java
@@ -10,26 +10,30 @@ import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.TouchEvent;
import javafx.stage.Stage;
-import me.lensferno.dogename.select.Selector;
import me.lensferno.dogename.configs.MainConfig;
import me.lensferno.dogename.controllers.WindowListeners.MoveWindowByMouse;
import me.lensferno.dogename.controllers.WindowListeners.MoveWindowByTouch;
import me.lensferno.dogename.data.Data;
+import me.lensferno.dogename.select.Selector;
import java.util.Random;
public class MiniPaneController {
+ Stage oldStage;
+ Stage currentStage;
+ Scene currentScene;
+ StringProperty[] oldTextProperties = null;
@FXML
private Label chosenNameLabel;
-
@FXML
private JFXButton anPaiBtn;
-
@FXML
private JFXButton miniModeBtn;
-
- Stage oldStage;
+ private final Random random = new Random();
+ private Data data;
+ private MainConfig mainConfig;
+ private Selector selector = new Selector();
public Stage getOldStage() {
return oldStage;
@@ -39,12 +43,6 @@ public class MiniPaneController {
this.oldStage = oldStage;
}
- private Random random = new Random();
- private Data data;
-
- Stage currentStage;
- Scene currentScene;
-
public void setCurrentScene(Scene currentScene) {
this.currentScene = currentScene;
}
@@ -53,8 +51,6 @@ public class MiniPaneController {
this.currentStage = currentStage;
}
- StringProperty[] oldTextProperties = null;
-
public void setBase(Data data, MainConfig mainConfig, Selector selector) {
this.data = data;
this.mainConfig = mainConfig;
@@ -95,9 +91,6 @@ public class MiniPaneController {
miniModeBtn.setOnTouchMoved(touchHandler);
}
- private MainConfig mainConfig;
- private Selector selector = new Selector();
-
@FXML
void anPai() {
diff --git a/Dogename/src/main/java/me/lensferno/dogename/controllers/NameManagerPaneController.java b/Dogename/src/main/java/me/lensferno/dogename/controllers/NameManagerPaneController.java
index a18797f..71c228b 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/controllers/NameManagerPaneController.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/controllers/NameManagerPaneController.java
@@ -1,6 +1,8 @@
package me.lensferno.dogename.controllers;
-import com.jfoenix.controls.*;
+import com.jfoenix.controls.JFXButton;
+import com.jfoenix.controls.JFXListView;
+import com.jfoenix.controls.JFXTextArea;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
@@ -12,58 +14,50 @@ import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
-import me.lensferno.dogename.utils.DialogMaker;
import me.lensferno.dogename.data.Data;
-import me.lensferno.dogename.utils.ocr.OcrTool;
import me.lensferno.dogename.utils.Clipboard;
+import me.lensferno.dogename.utils.DialogMaker;
+import me.lensferno.dogename.utils.ocr.OcrTool;
import java.io.File;
import java.util.logging.Logger;
-public class NameManagerPaneController extends VBox {
+public class NameManagerPaneController extends VBox {
+ public static final ObservableList shownNameList = FXCollections.observableArrayList();
Data data;
Pane rootPane;
OcrTool ocrTool;
-
Logger log = Logger.getLogger("NameManagerPaneLOgger");
+ @FXML
+ private JFXListView nameList;
+ @FXML
+ private JFXButton deleteAll;
+ @FXML
+ private JFXButton addName;
+ @FXML
+ private JFXButton deleteName;
+ @FXML
+ private JFXTextArea inputName;
- public static final ObservableList shownNameList = FXCollections.observableArrayList();
-
- public NameManagerPaneController(Data data, Pane rootPane, OcrTool ocrTool){
- FXMLLoader loader=new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/NameManagerPane.fxml"));
+ public NameManagerPaneController(Data data, Pane rootPane, OcrTool ocrTool) {
+ FXMLLoader loader = new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/NameManagerPane.fxml"));
loader.setRoot(this);
loader.setController(this);
try {
loader.load();
- }catch(Exception e){
+ } catch (Exception e) {
e.printStackTrace();
}
- this.data=data;
- this.rootPane=rootPane;
+ this.data = data;
+ this.rootPane = rootPane;
shownNameList.setAll(data.getNameList());
this.nameList.setItems(shownNameList);
- this.ocrTool=ocrTool;
+ this.ocrTool = ocrTool;
}
- @FXML
- private JFXListView nameList;
-
- @FXML
- private JFXButton deleteAll;
-
- @FXML
- private JFXButton addName;
-
- @FXML
- private JFXButton deleteName;
-
- @FXML
- private JFXTextArea inputName;
-
-
@FXML
void deleteName(ActionEvent event) {
@@ -72,7 +66,7 @@ public class NameManagerPaneController extends VBox {
"真的要这个名字吗?该操作无法撤销,除非您已经备份了名单。",
e -> {
String deletedName = nameList.getSelectionModel().getSelectedItems().get(0);
-
+
data.delete(deletedName);
shownNameList.remove(deletedName);
@@ -134,15 +128,15 @@ public class NameManagerPaneController extends VBox {
data.saveToFile();
System.gc();
- });
+ });
}
@FXML
void addName(ActionEvent event) {
- if(inputName.getText().equals("")){
- new DialogMaker(rootPane).createMessageDialog("诶诶诶~","输入框怎么是空的呢?");
+ if (inputName.getText().equals("")) {
+ new DialogMaker(rootPane).createMessageDialog("诶诶诶~", "输入框怎么是空的呢?");
return;
}
@@ -161,30 +155,30 @@ public class NameManagerPaneController extends VBox {
FXMLLoader fxmlLoader;
Parent parent;
- Stage stage=new Stage();
+ Stage stage = new Stage();
- try{
- fxmlLoader=new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/OcrPane.fxml"));
- parent=fxmlLoader.load();
- }catch (Exception e){
- log.warning("Error to load main interface FXML :"+e.toString());
+ try {
+ fxmlLoader = new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/OcrPane.fxml"));
+ parent = fxmlLoader.load();
+ } catch (Exception e) {
+ log.warning("Error to load main interface FXML :" + e);
return;
}
- Scene scene=new Scene(parent,515,604);
+ Scene scene = new Scene(parent, 515, 604);
stage.setTitle("Ocr模块");
stage.setScene(scene);
log.fine("窗口加载完成");
- OcrPaneController ocrPaneController= fxmlLoader.getController();
- ocrPaneController.setMainStage((Stage)inputName.getScene().getWindow());
+ OcrPaneController ocrPaneController = fxmlLoader.getController();
+ ocrPaneController.setMainStage((Stage) inputName.getScene().getWindow());
stage.show();
}
@FXML
void copyTo(ActionEvent event) {
- inputName.setText(inputName.getText()+ Clipboard.getClipboardString());
+ inputName.setText(inputName.getText() + Clipboard.getClipboardString());
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/controllers/NumberSettingsPaneController.java b/Dogename/src/main/java/me/lensferno/dogename/controllers/NumberSettingsPaneController.java
index 47fc9ae..af4acc8 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/controllers/NumberSettingsPaneController.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/controllers/NumberSettingsPaneController.java
@@ -9,31 +9,30 @@ import me.lensferno.dogename.data.Data;
public class NumberSettingsPaneController extends VBox {
Data data;
- public NumberSettingsPaneController(Data data){
- FXMLLoader loader=new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/NumberSettingPane.fxml"));
+ @FXML
+ private JFXTextField minValueField;
+ @FXML
+ private JFXTextField maxValueField;
+
+ public NumberSettingsPaneController(Data data) {
+ FXMLLoader loader = new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/NumberSettingPane.fxml"));
loader.setRoot(this);
loader.setController(this);
try {
loader.load();
- }catch(Exception e){
+ } catch (Exception e) {
e.printStackTrace();
}
- this.data=data;
+ this.data = data;
}
- @FXML
- private JFXTextField minValueField;
-
- @FXML
- private JFXTextField maxValueField;
-
- public void bindProperties(MainConfig mainConfig){
+ public void bindProperties(MainConfig mainConfig) {
minValueField.textProperty().bindBidirectional(mainConfig.minNumberProperty());
- minValueField.textProperty().addListener((observable, oldValue, newValue) -> data.clearNumberIgnoreList() );
+ minValueField.textProperty().addListener((observable, oldValue, newValue) -> data.clearNumberIgnoreList());
maxValueField.textProperty().bindBidirectional(mainConfig.maxNumberProperty());
- maxValueField.textProperty().addListener((observable, oldValue, newValue) -> data.clearNumberIgnoreList() );
+ maxValueField.textProperty().addListener((observable, oldValue, newValue) -> data.clearNumberIgnoreList());
}
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/controllers/OcrPaneController.java b/Dogename/src/main/java/me/lensferno/dogename/controllers/OcrPaneController.java
index 5e69be6..a52ff72 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/controllers/OcrPaneController.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/controllers/OcrPaneController.java
@@ -3,31 +3,26 @@ package me.lensferno.dogename.controllers;
import com.jfoenix.controls.JFXSpinner;
import javafx.fxml.FXML;
import javafx.scene.control.TextArea;
-import javafx.scene.text.Text;
import javafx.stage.Stage;
-import me.lensferno.dogename.utils.ocr.ScreenCapture;
import me.lensferno.dogename.utils.Clipboard;
+import me.lensferno.dogename.utils.ocr.ScreenCapture;
public class OcrPaneController {
+ Stage mainStage;
@FXML
private TextArea ocrText;
-
@FXML
private JFXSpinner loadingSpinner;
- Stage mainStage;
-
public void setMainStage(Stage mainStage) {
this.mainStage = mainStage;
}
-
-
@FXML
void addNew() {
- Stage thisStage=(Stage)ocrText.getScene().getWindow();
+ Stage thisStage = (Stage) ocrText.getScene().getWindow();
thisStage.hide();
mainStage.hide();
diff --git a/Dogename/src/main/java/me/lensferno/dogename/controllers/ProgramInfoPaneController.java b/Dogename/src/main/java/me/lensferno/dogename/controllers/ProgramInfoPaneController.java
index 69284ac..796135b 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/controllers/ProgramInfoPaneController.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/controllers/ProgramInfoPaneController.java
@@ -28,13 +28,13 @@ public class ProgramInfoPaneController extends VBox {
Pane rootPane;
- public ProgramInfoPaneController(Pane rootPane){
- FXMLLoader loader=new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/ProgramInfoPane.fxml"));
+ public ProgramInfoPaneController(Pane rootPane) {
+ FXMLLoader loader = new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/ProgramInfoPane.fxml"));
loader.setRoot(this);
loader.setController(this);
try {
loader.load();
- }catch(Exception e){
+ } catch (Exception e) {
e.printStackTrace();
}
@@ -44,51 +44,51 @@ public class ProgramInfoPaneController extends VBox {
e.printStackTrace();
}
- this.rootPane=rootPane;
+ this.rootPane = rootPane;
}
@FXML
void showLicense() {
- TextArea textArea=new TextArea(IOUtil.inputStreamToString(getClass().getResourceAsStream("/gpl-3.0.txt"), StandardCharsets.UTF_8));
- textArea.setFont(Font.font("Microsoft YaHei",14));
+ TextArea textArea = new TextArea(IOUtil.inputStreamToString(getClass().getResourceAsStream("/gpl-3.0.txt"), StandardCharsets.UTF_8));
+ textArea.setFont(Font.font("Microsoft YaHei", 14));
textArea.setMinWidth(600);
textArea.setPrefHeight(400);
textArea.setEditable(false);
- new DialogMaker(rootPane).createDialogWithOneBtn("开源协议(GPL v3)",textArea);
+ new DialogMaker(rootPane).createDialogWithOneBtn("开源协议(GPL v3)", textArea);
}
@FXML
void showLibLicense() {
- TextArea textArea=new TextArea(IOUtil.inputStreamToString(getClass().getResourceAsStream("/LibLicense.txt"), StandardCharsets.UTF_8));
- textArea.setFont(Font.font("Microsoft YaHei",14));
+ TextArea textArea = new TextArea(IOUtil.inputStreamToString(getClass().getResourceAsStream("/LibLicense.txt"), StandardCharsets.UTF_8));
+ textArea.setFont(Font.font("Microsoft YaHei", 14));
textArea.setMinWidth(600);
textArea.setPrefHeight(400);
textArea.setEditable(false);
- new DialogMaker(rootPane).createDialogWithOneBtn("其他开源许可",textArea);
+ new DialogMaker(rootPane).createDialogWithOneBtn("其他开源许可", textArea);
}
@FXML
void showHelp() {
JFXButton YesButton = new JFXButton("好的~去吧去吧");
- YesButton.setFont(Font.font("Microsoft YaHei", FontWeight.BOLD,14));
+ YesButton.setFont(Font.font("Microsoft YaHei", FontWeight.BOLD, 14));
YesButton.setPrefWidth(160);
YesButton.setPrefHeight(40);
- YesButton.addEventHandler(ActionEvent.ACTION,e -> jumpToHelp());
+ YesButton.addEventHandler(ActionEvent.ACTION, e -> jumpToHelp());
JFXButton cancelButton = new JFXButton("算了算了");
- cancelButton.setFont(Font.font("Microsoft YaHei", FontWeight.BOLD,14));
+ cancelButton.setFont(Font.font("Microsoft YaHei", FontWeight.BOLD, 14));
cancelButton.setPrefWidth(100);
cancelButton.setPrefHeight(40);
- Text messageText=new Text("即将跳转到本程序Github页面上的使用帮助,是否继续?");
- messageText.setFont(Font.font("Microsoft YaHei",14));
+ Text messageText = new Text("即将跳转到本程序Github页面上的使用帮助,是否继续?");
+ messageText.setFont(Font.font("Microsoft YaHei", 14));
- new DialogMaker(rootPane).createDialog("查看帮助",messageText,cancelButton,YesButton);
+ new DialogMaker(rootPane).createDialog("查看帮助", messageText, cancelButton, YesButton);
}
- private void jumpToHelp(){
+ private void jumpToHelp() {
try {
Desktop.getDesktop().browse(new URI("https://github.com/lensferno/dogename/blob/main/res/usage.md"));
} catch (IOException | URISyntaxException e) {
@@ -99,30 +99,30 @@ public class ProgramInfoPaneController extends VBox {
@FXML
void viewCode() {
JFXButton githubButton = new JFXButton("前往Github查看");
- githubButton.setFont(Font.font("Microsoft YaHei", FontWeight.BOLD,14));
+ githubButton.setFont(Font.font("Microsoft YaHei", FontWeight.BOLD, 14));
githubButton.setPrefWidth(150);
githubButton.setPrefHeight(40);
- githubButton.addEventHandler(ActionEvent.ACTION,e -> jumpToGithub());
+ githubButton.addEventHandler(ActionEvent.ACTION, e -> jumpToGithub());
JFXButton giteeButton = new JFXButton("前往Gitee查看");
- giteeButton.setFont(Font.font("Microsoft YaHei", FontWeight.BOLD,14));
+ giteeButton.setFont(Font.font("Microsoft YaHei", FontWeight.BOLD, 14));
giteeButton.setPrefWidth(150);
giteeButton.setPrefHeight(40);
- giteeButton.addEventHandler(ActionEvent.ACTION,e -> jumpToGitee());
+ giteeButton.addEventHandler(ActionEvent.ACTION, e -> jumpToGitee());
JFXButton cancelButton = new JFXButton("哪都不去");
- cancelButton.setFont(Font.font("Microsoft YaHei", FontWeight.BOLD,14));
+ cancelButton.setFont(Font.font("Microsoft YaHei", FontWeight.BOLD, 14));
cancelButton.setPrefWidth(100);
cancelButton.setPrefHeight(40);
- Text messageText=new Text("Dogename在Github和码云(Gitee)都发布有代码和介绍。\n您想去哪里?\nGithub:将跳转到https://github.com/lensferno/dogename\nGitee:将跳转到https://gitee.com/lensferno/dogename");
- messageText.setFont(Font.font("Microsoft YaHei",14));
+ Text messageText = new Text("Dogename在Github和码云(Gitee)都发布有代码和介绍。\n您想去哪里?\nGithub:将跳转到https://github.com/lensferno/dogename\nGitee:将跳转到https://gitee.com/lensferno/dogename");
+ messageText.setFont(Font.font("Microsoft YaHei", 14));
- new DialogMaker(rootPane).createDialog("查看源代码",messageText,cancelButton,githubButton,giteeButton);
+ new DialogMaker(rootPane).createDialog("查看源代码", messageText, cancelButton, githubButton, giteeButton);
}
- private void jumpToGithub(){
+ private void jumpToGithub() {
try {
Desktop.getDesktop().browse(new URI("https://github.com/lensferno/dogename"));
} catch (IOException | URISyntaxException e) {
@@ -130,7 +130,7 @@ public class ProgramInfoPaneController extends VBox {
}
}
- private void jumpToGitee(){
+ private void jumpToGitee() {
try {
Desktop.getDesktop().browse(new URI("https://gitee.com/lensferno/dogename"));
} catch (IOException | URISyntaxException e) {
diff --git a/Dogename/src/main/java/me/lensferno/dogename/controllers/SettingsPaneController.java b/Dogename/src/main/java/me/lensferno/dogename/controllers/SettingsPaneController.java
index a12dd9c..c3972b1 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/controllers/SettingsPaneController.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/controllers/SettingsPaneController.java
@@ -9,63 +9,48 @@ import javafx.fxml.FXMLLoader;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
-import me.lensferno.dogename.utils.DialogMaker;
import me.lensferno.dogename.configs.MainConfig;
import me.lensferno.dogename.configs.VoiceConfig;
import me.lensferno.dogename.data.Data;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
+import me.lensferno.dogename.utils.DialogMaker;
public class SettingsPaneController extends VBox {
+ MainConfig mainConfig;
+ VoiceConfig voiceConfig;
+ Pane rootPane;
+ Data data;
@FXML
private JFXCheckBox showSayingBtn;
-
@FXML
private JFXCheckBox newAlgoBtn;
-
@FXML
private JFXSlider cycleTimesBar;
-
@FXML
private JFXCheckBox voicePlayBtn;
-
@FXML
private JFXSlider speedBar;
-
@FXML
private JFXCheckBox equalModeBtn;
-
@FXML
private JFXRadioButton ignoreOnce;
-
@FXML
private JFXRadioButton chooseOnce;
-
@FXML
private JFXRadioButton randomTimes;
-
@FXML
private JFXRadioButton fixedTimes;
- MainConfig mainConfig;
- VoiceConfig voiceConfig;
-
- Pane rootPane;
-
- Data data;
-
- Logger log = LogManager.getLogger("SettingsPaneControllerLogger");
- public SettingsPaneController(){
- FXMLLoader loader=new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/SettingsPane.fxml"));
+ public SettingsPaneController() {
+ FXMLLoader loader = new FXMLLoader(getClass().getResource("/me/lensferno/dogename/FXMLs/SettingsPane.fxml"));
loader.setRoot(this);
loader.setController(this);
try {
loader.load();
- }catch(Exception e){
- log.warn("Error to load settings pane FXML: "+e.toString());
+ } catch (Exception e) {
+ e.printStackTrace();
}
}
@@ -77,11 +62,11 @@ public class SettingsPaneController extends VBox {
this.voiceConfig = voiceConfig;
}
- public void setRootPane(Pane rootPane){
- this.rootPane=rootPane;
+ public void setRootPane(Pane rootPane) {
+ this.rootPane = rootPane;
}
- public void bindProperties(MainConfig mainConfig){
+ public void bindProperties(MainConfig mainConfig) {
setMainConfig(mainConfig);
ignoreOnce.selectedProperty().bindBidirectional(mainConfig.passSelectedResultProperty());
@@ -103,29 +88,28 @@ public class SettingsPaneController extends VBox {
showSayingBtn.selectedProperty().bindBidirectional(mainConfig.showSayingProperty());
mainConfig.passSelectedResultProperty().addListener((observable, oldValue, isIgnorePast) -> {
- if(!isIgnorePast)
- {
+ if (!isIgnorePast) {
//如果 忽略被点过的名字 被取消后就把机会均等模式的按钮给取消掉
equalModeBtn.setSelected(false);
}
});
}
- public void setToggleGroup(){
- ToggleGroup pastGroup=new ToggleGroup();
+ public void setToggleGroup() {
+ ToggleGroup pastGroup = new ToggleGroup();
chooseOnce.setToggleGroup(pastGroup);
ignoreOnce.setToggleGroup(pastGroup);
- ToggleGroup fixedTimesGroup=new ToggleGroup();
+ ToggleGroup fixedTimesGroup = new ToggleGroup();
randomTimes.setToggleGroup(fixedTimesGroup);
fixedTimes.setToggleGroup(fixedTimesGroup);
}
@FXML
void showVoiceSettingsPane(ActionEvent event) {
- VoiceSettingsPaneController voiceSettingsPaneController=new VoiceSettingsPaneController();
+ VoiceSettingsPaneController voiceSettingsPaneController = new VoiceSettingsPaneController();
voiceSettingsPaneController.bindPropertied(voiceConfig);
- new DialogMaker(rootPane).createDialogWithOneBtn("语音设置",voiceSettingsPaneController);
+ new DialogMaker(rootPane).createDialogWithOneBtn("语音设置", voiceSettingsPaneController);
}
@FXML
@@ -137,7 +121,7 @@ public class SettingsPaneController extends VBox {
@FXML
void clearIgnoreList(ActionEvent event) {
- new DialogMaker(rootPane).createDialogWithOKAndCancel("真的吗?","真的要重置吗?",(e)->{
+ new DialogMaker(rootPane).createDialogWithOKAndCancel("真的吗?", "真的要重置吗?", (e) -> {
data.clearNumberIgnoreList();
data.clearNameIgnoreList();
});
@@ -145,9 +129,9 @@ public class SettingsPaneController extends VBox {
@FXML
void equalBtnAction(ActionEvent event) {
- if(!mainConfig.getPassSelectedResult()){
+ if (!mainConfig.getPassSelectedResult()) {
equalModeBtn.setSelected(false);
- new DialogMaker(rootPane).createMessageDialog("且慢","无法在“概率均分”的模式下使用,如需使用请在“人人有份”模式下启用。");
+ new DialogMaker(rootPane).createMessageDialog("且慢", "无法在“概率均分”的模式下使用,如需使用请在“人人有份”模式下启用。");
}
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/controllers/VoiceSettingsPaneController.java b/Dogename/src/main/java/me/lensferno/dogename/controllers/VoiceSettingsPaneController.java
index 4ac0631..2688530 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/controllers/VoiceSettingsPaneController.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/controllers/VoiceSettingsPaneController.java
@@ -13,25 +13,18 @@ import me.lensferno.dogename.configs.VoiceConfig;
import java.util.logging.Logger;
public class VoiceSettingsPaneController extends VBox {
+ public static final ObservableList shownSpeakerList = FXCollections.observableArrayList();
+ private final String[] speakers = {
+ "1", "0", "3", "4",
+ "106", "110", "111", "103", "5"};
Logger log = Logger.getLogger("VoiceSettingsPaneControllerLogger");
-
- VoiceConfig voiceConfig=new VoiceConfig();
-
-
+ VoiceConfig voiceConfig = new VoiceConfig();
@FXML
private JFXSlider intonationBar;
-
@FXML
private JFXComboBox speakerSelectBar;
-
@FXML
private JFXSlider voiceSpeedBar;
-
- public static final ObservableList shownSpeakerList = FXCollections.observableArrayList();
-
- private final String[] speakers={
- "1","0","3","4",
- "106","110","111","103","5"};
//度小宇=1,度小美=0,度逍遥=3,度丫丫=4
//度博文=106,度小童=110,度小萌=111,度米朵=103,度小娇=5
@@ -42,9 +35,9 @@ public class VoiceSettingsPaneController extends VBox {
try {
loader.load();
} catch (Exception e) {
- log.warning("Error to load settings pane FXML: " + e.toString());
+ log.warning("Error to load settings pane FXML: " + e);
}
- if(shownSpeakerList.isEmpty()) {
+ if (shownSpeakerList.isEmpty()) {
shownSpeakerList.addAll(
"度小宇=1", "度小美=0", "度逍遥=3", "度丫丫=4",
"度博文=106", "度小童=110", "度小萌=111", "度米朵=103", "度小娇=5");
@@ -53,14 +46,14 @@ public class VoiceSettingsPaneController extends VBox {
speakerSelectBar.setItems(shownSpeakerList);
}
- public void bindPropertied(VoiceConfig voiceConfig){
+ public void bindPropertied(VoiceConfig voiceConfig) {
- this.voiceConfig=voiceConfig;
+ this.voiceConfig = voiceConfig;
//speakerSelectBar.
speakerSelectBar.selectionModelProperty().addListener((observable, oldValue, newValue) -> {
- System.out.println("what?"+newValue.getSelectedIndex());
+ System.out.println("what?" + newValue.getSelectedIndex());
this.voiceConfig.setSpeaker(speakers[newValue.getSelectedIndex()]);
this.voiceConfig.setSelectedSpeaker(newValue.getSelectedIndex());
});
@@ -79,7 +72,6 @@ public class VoiceSettingsPaneController extends VBox {
}
-
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/controllers/WindowListeners/MoveWindowByMouse.java b/Dogename/src/main/java/me/lensferno/dogename/controllers/WindowListeners/MoveWindowByMouse.java
index 6e839c7..69d472b 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/controllers/WindowListeners/MoveWindowByMouse.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/controllers/WindowListeners/MoveWindowByMouse.java
@@ -6,7 +6,7 @@ import javafx.stage.Stage;
public class MoveWindowByMouse implements EventHandler {
- private Stage primaryStage;
+ private final Stage primaryStage;
private double oldStageX;
private double oldStageY;
private double oldScreenX;
diff --git a/Dogename/src/main/java/me/lensferno/dogename/controllers/WindowListeners/MoveWindowByTouch.java b/Dogename/src/main/java/me/lensferno/dogename/controllers/WindowListeners/MoveWindowByTouch.java
index 130dbb7..6fad2e6 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/controllers/WindowListeners/MoveWindowByTouch.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/controllers/WindowListeners/MoveWindowByTouch.java
@@ -6,7 +6,7 @@ import javafx.stage.Stage;
public class MoveWindowByTouch implements EventHandler {
- private Stage primaryStage;
+ private final Stage primaryStage;
private double oldStageX;
private double oldStageY;
private double oldScreenX;
diff --git a/Dogename/src/main/java/me/lensferno/dogename/data/Data.java b/Dogename/src/main/java/me/lensferno/dogename/data/Data.java
index c038cd3..b2cc47b 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/data/Data.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/data/Data.java
@@ -1,8 +1,6 @@
package me.lensferno.dogename.data;
import com.google.gson.Gson;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
import java.io.*;
import java.nio.charset.StandardCharsets;
@@ -11,19 +9,47 @@ import java.util.*;
public class Data {
- Logger log = LogManager.getLogger("dataLogger");
-
public static final int IGNORELIST_NAME_ONLY = 0;
public static final int IGNORELIST_NUMBER_ONLY = 1;
public static final int IGNORELIST_ALL = 2;
+ File dataFile;
+ SecureRandom secRandom = new SecureRandom();
+ Random random = new Random();
+ private List nameList;
+ private final IgnoreList ignoreList = new IgnoreList();
+ public Data() {
- private List nameList;
- private IgnoreList ignoreList = new IgnoreList();
+ dataFile = new File("files" + File.separator + "Namelist.data");
- File dataFile;
+ try {
- SecureRandom secRandom = new SecureRandom();
+ if (!dataFile.exists()) {
+ dataFile.getParentFile().mkdirs();
+ dataFile.createNewFile();
+ nameList = new ArrayList<>();
+ saveToFile();
+ return;
+ }
+
+ ObjectInputStream ois = new ObjectInputStream(new FileInputStream(dataFile));
+ this.nameList = (ArrayList) ois.readObject();
+
+ System.out.println(nameList.size() + " names loaded.");
+
+ } catch (EOFException EOFe) {
+ nameList = new ArrayList<>();
+ System.out.println("Data file is empty.");
+ saveToFile();
+ } catch (Exception e) {
+ nameList = new ArrayList<>();
+ saveToFile();
+ System.out.println("Failed to load data file.");
+ e.printStackTrace();
+ }
+
+ ignoreList.readIgnoreList();
+ }
public List getNameList() {
return nameList;
@@ -35,9 +61,9 @@ public class Data {
FileOutputStream oos = new FileOutputStream(path);
oos.write(new Gson().toJson(nameList).getBytes(StandardCharsets.UTF_8));
oos.close();
- log.info("Exported list to:" + path.getPath());
+ System.out.println("Exported list to:" + path.getPath());
} catch (Exception e) {
- log.warn("error in export namelist: " + e.toString());
+ System.out.println("error in export namelist: " + e);
e.printStackTrace();
}
}
@@ -58,9 +84,9 @@ public class Data {
}
nameList = new Gson().fromJson(sb.toString(), List.class);
- log.info("Imported list from:" + path.getPath());
+ System.out.println("Imported list from:" + path.getPath());
} catch (Exception e) {
- log.warn("error in import namelist:" + e.toString());
+ System.out.println("error in import namelist:" + e);
e.printStackTrace();
}
@@ -86,56 +112,6 @@ public class Data {
}
- public Data() {
-
-
- if (System.getProperty("os.name").toLowerCase().contains("window"))
- dataFile = new File("files\\Namelist.data");
- else
- dataFile = new File("files/Namelist.data");
-
- File oldDataFile = new File("D:\\dogename\\files\\data");
-
- try {
-
- if (oldDataFile.exists()) {
- ObjectInputStream ois = new ObjectInputStream(new FileInputStream(oldDataFile));
- this.nameList = (ArrayList) ois.readObject();
-
- ois.close();
- oldDataFile.delete();
- saveToFile();
- return;
- }
-
- if (!dataFile.exists()) {
- dataFile.getParentFile().mkdirs();
- dataFile.createNewFile();
- nameList = new ArrayList<>();
- saveToFile();
- return;
- }
-
- ObjectInputStream ois = new ObjectInputStream(new FileInputStream(dataFile));
- this.nameList = (ArrayList) ois.readObject();
-
- log.info(nameList.size() + " names loaded.");
-
- } catch (EOFException EOFe) {
- nameList = new ArrayList<>();
- log.warn("Data file is empty.");
- saveToFile();
- } catch (Exception e) {
- nameList = new ArrayList<>();
- saveToFile();
- log.warn("Failed to load data file.");
- e.printStackTrace();
- }
-
- ignoreList.readIgnoreList();
- }
-
-
public void add(String text) {
String[] splitedText;
@@ -158,7 +134,6 @@ public class Data {
System.gc();
}
-
public boolean compareNameIgnoreList() {
return ignoreList.getNameIgnoreListSize() >= nameList.size();
}
@@ -177,8 +152,6 @@ public class Data {
return nameList.isEmpty();
}
- Random random = new Random();
-
public String randomGet(boolean secureRandom) {
if (secureRandom)
return nameList.get(secRandom.nextInt(nameList.size()));
@@ -237,12 +210,10 @@ public class Data {
class IgnoreList {
- private HashSet ignoreNameList = new HashSet<>();
-
- private HashSet ignoreNumberList = new HashSet<>();
-
private final File nameIgnoreFile = new File("files" + File.separator + "IgnoredNameList.data");
private final File numbIgnoreFile = new File("files" + File.separator + "IgnoredNumberList.data");
+ private HashSet ignoreNameList = new HashSet<>();
+ private HashSet ignoreNumberList = new HashSet<>();
public void writeIgnoreList(int switchy) {
switch (switchy) {
@@ -279,7 +250,7 @@ public class Data {
public void readIgnoreList() {
readNameIgnoreList();
readNumberIgnoreList();
- log.info("There are " + ignoreNameList.size() + " names and " + ignoreNumberList.size() + " numbers ignored.");
+ System.out.println("There are " + ignoreNameList.size() + " names and " + ignoreNumberList.size() + " numbers ignored.");
}
private void readNameIgnoreList() {
@@ -319,11 +290,11 @@ public class Data {
this.ignoreNumberList = (HashSet) ois.readObject();
} catch (EOFException e) {
ignoreNumberList = new HashSet<>();
- log.warn("Ignored number list is empty.");
+ System.out.println("Ignored number list is empty.");
writeIgnoreList(IGNORELIST_NUMBER_ONLY);
} catch (Exception e) {
ignoreNumberList = new HashSet<>();
- log.warn("Failed to load ignored number list");
+ System.out.println("Failed to load ignored number list");
writeIgnoreList(IGNORELIST_NUMBER_ONLY);
e.printStackTrace();
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/data/History.java b/Dogename/src/main/java/me/lensferno/dogename/data/History.java
index 8b96db9..ce78e95 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/data/History.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/data/History.java
@@ -1,24 +1,17 @@
package me.lensferno.dogename.data;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
import java.io.*;
import java.util.ArrayList;
public class History {
- Logger log = LogManager.getLogger();
-
-
- private String HISTORY_FILE;
- public static final String separator=File.separator;
-
+ public static final String separator = File.separator;
ArrayList history;
+ private String HISTORY_FILE;
- public void loadHistory(){
+ public void loadHistory() {
- HISTORY_FILE="files"+separator+"history.data";
+ HISTORY_FILE = "files" + separator + "history.data";
try {
File historyFile = new File(HISTORY_FILE);
@@ -34,57 +27,49 @@ public class History {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(historyFile));
history = (ArrayList) ois.readObject();
- } catch (EOFException e){
- history =new ArrayList<>();
- log.warn("History file is empty.");
+ } catch (EOFException e) {
+ history = new ArrayList<>();
+ System.out.println("History file is empty.");
writeHistory();
- }catch (Exception e) {
+ } catch (Exception e) {
history = new ArrayList<>();
- log.error("Failed to load history file:"+e.toString());
+ System.out.println("Failed to load history file:" + e);
e.printStackTrace();
}
}
- public ArrayList getHistoryList(){
+ public ArrayList getHistoryList() {
return history;
}
- public void addHistory(String name){
- if(history.size()>2000) {
+ public void addHistory(String name) {
+ if (history.size() > 2000) {
history.clear();
}
history.add(String.format("%d. %s", (history.size() + 1), name));
writeHistory();
}
- private void writeHistory(){
+ private void writeHistory() {
- HISTORY_FILE="files"+separator+"history.data";
- File historyFile=new File(HISTORY_FILE);
+ HISTORY_FILE = "files" + separator + "history.data";
+ File historyFile = new File(HISTORY_FILE);
- try{
+ try {
if (!historyFile.exists()) {
historyFile.createNewFile();
}
- ObjectOutputStream oos =new ObjectOutputStream(new FileOutputStream(historyFile));
+ ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(historyFile));
oos.writeObject(history);
oos.close();
- }catch (Exception e){
- log.error("Error in writing history file:"+e);
+ } catch (Exception e) {
+ System.out.println("Error in writing history file:" + e);
}
}
- public int downSearch(){
- return 1;
- }
-
- public int upSearch(){
- return 1;
- }
-
- public void clearHistory(){
+ public void clearHistory() {
this.history.clear();
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/sayings/Gushici.java b/Dogename/src/main/java/me/lensferno/dogename/sayings/Gushici.java
index 2b2c6a0..e89fd12 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/sayings/Gushici.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/sayings/Gushici.java
@@ -5,13 +5,13 @@ import com.google.gson.annotations.SerializedName;
import javafx.application.Platform;
import javafx.scene.control.Label;
import javafx.scene.layout.Pane;
-import me.lensferno.dogename.utils.DialogMaker;
import me.lensferno.dogename.controllers.GushiciPaneController;
+import me.lensferno.dogename.utils.DialogMaker;
import me.lensferno.dogename.utils.NetworkUtil;
public class Gushici {
- private final String GUSHICI_API="https://v1.jinrishici.com/all.json";
+ private final String GUSHICI_API = "https://v1.jinrishici.com/all.json";
String gushiciJSON = null;
@@ -19,25 +19,26 @@ public class Gushici {
return NetworkUtil.getHtml(GUSHICI_API);
}
- public void showGushici(Pane rootPane, Label topBar, boolean showOnDialog){
+ public void showGushici(Pane rootPane, Label topBar, boolean showOnDialog) {
- new Thread(()->{
+ new Thread(() -> {
//gushiciJSON=getGushici();
String content, title, author, type;
- if((gushiciJSON=getGushici())!=null){
- GushiciData gushiciData=new Gson().fromJson(gushiciJSON,GushiciData.class);
- content=gushiciData.getContent();
- title=gushiciData.getTitle();
- author=gushiciData.getAuthor();
- type=gushiciData.getType();
- Platform.runLater(()->{
- topBar.setText(content+" ——"+author+"《"+title+"》");
+ if ((gushiciJSON = getGushici()) != null) {
+ GushiciData gushiciData = new Gson().fromJson(gushiciJSON, GushiciData.class);
+ content = gushiciData.getContent();
+ title = gushiciData.getTitle();
+ author = gushiciData.getAuthor();
+ type = gushiciData.getType();
+ Platform.runLater(() -> {
+ topBar.setText(content + " ——" + author + "《" + title + "》");
+ topBar.setText(String.format("%s ——%s 《%s》", content, author, title));
if (showOnDialog) {
- GushiciPaneController gushiciPaneController=new GushiciPaneController(content, title, author, type);
- new DialogMaker(rootPane).createDialogWithOneBtn("每日古诗词",gushiciPaneController);
+ GushiciPaneController gushiciPaneController = new GushiciPaneController(content, title, author, type);
+ new DialogMaker(rootPane).createDialogWithOneBtn("每日古诗词", gushiciPaneController);
}
});
}
@@ -45,7 +46,7 @@ public class Gushici {
}
- static class GushiciData{
+ static class GushiciData {
private String content;//诗歌的内容
@@ -57,32 +58,36 @@ public class Gushici {
@SerializedName("category")
private String type;//诗歌类型
- public void setContent(String content) {
- this.content = content;
- }
public String getContent() {
return content;
}
- public void setTitle(String title) {
- this.title = title;
+ public void setContent(String content) {
+ this.content = content;
}
+
public String getTitle() {
return title;
}
- public void setAuthor(String author) {
- this.author = author;
+ public void setTitle(String title) {
+ this.title = title;
}
+
public String getAuthor() {
return author;
}
- public void setType(String type) {
- this.type = type;
+ public void setAuthor(String author) {
+ this.author = author;
}
+
public String getType() {
return type;
}
+
+ public void setType(String type) {
+ this.type = type;
+ }
}
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/sayings/Hitokoto.java b/Dogename/src/main/java/me/lensferno/dogename/sayings/Hitokoto.java
index 484ec3e..5e6ade3 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/sayings/Hitokoto.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/sayings/Hitokoto.java
@@ -5,8 +5,8 @@ import com.google.gson.annotations.SerializedName;
import javafx.application.Platform;
import javafx.scene.control.Label;
import javafx.scene.layout.Pane;
-import me.lensferno.dogename.utils.DialogMaker;
import me.lensferno.dogename.controllers.HitokotoPaneController;
+import me.lensferno.dogename.utils.DialogMaker;
import me.lensferno.dogename.utils.NetworkUtil;
public class Hitokoto {
@@ -60,24 +60,20 @@ public class Hitokoto {
private String creator;
- public void setId(int id) {
- this.id = id;
- }
-
public int getId() {
return id;
}
- public void setHitokoto(String hitokoto) {
- this.hitokoto = hitokoto;
+ public void setId(int id) {
+ this.id = id;
}
public String getHitokoto() {
return hitokoto;
}
- public void setType(String type) {
- this.type = type;
+ public void setHitokoto(String hitokoto) {
+ this.hitokoto = hitokoto;
}
/**
@@ -143,29 +139,33 @@ public class Hitokoto {
return type;
}
- public void setFrom(String from) {
- this.from = from;
+ public void setType(String type) {
+ this.type = type;
}
public String getFrom() {
return from;
}
- public void setAuthor(String author) {
- this.author = author;
+ public void setFrom(String from) {
+ this.from = from;
}
public String getAuthor() {
return author;
}
- public void setCreator(String creator) {
- this.creator = creator;
+ public void setAuthor(String author) {
+ this.author = author;
}
public String getCreator() {
return creator;
}
+ public void setCreator(String creator) {
+ this.creator = creator;
+ }
+
}
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/select/Selector.java b/Dogename/src/main/java/me/lensferno/dogename/select/Selector.java
index df46911..7a68e51 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/select/Selector.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/select/Selector.java
@@ -6,8 +6,8 @@ import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;
import me.lensferno.dogename.configs.MainConfig;
import me.lensferno.dogename.configs.VoiceConfig;
-import me.lensferno.dogename.data.History;
import me.lensferno.dogename.data.Data;
+import me.lensferno.dogename.data.History;
import me.lensferno.dogename.select.core.Worker;
import me.lensferno.dogename.voice.TokenManager;
import me.lensferno.dogename.voice.VoicePlayer;
@@ -62,9 +62,8 @@ public final class Selector {
// ---------------------------------------------------
static class Processor extends AnimationTimer {
- private Worker coreWorker;
-
MainConfig config = null;
+ private Worker coreWorker;
protected void initialVariable(MainConfig config, VoicePlayer voicePlayer, Data data, History history, StringProperty... labelTexts) {
coreWorker = new Worker(labelTexts, config, data, history, voicePlayer);
diff --git a/Dogename/src/main/java/me/lensferno/dogename/select/core/Worker.java b/Dogename/src/main/java/me/lensferno/dogename/select/core/Worker.java
index 427139a..fca5e22 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/select/core/Worker.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/select/core/Worker.java
@@ -3,55 +3,40 @@ package me.lensferno.dogename.select.core;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.StringProperty;
import me.lensferno.dogename.configs.MainConfig;
-import me.lensferno.dogename.data.History;
import me.lensferno.dogename.data.Data;
-
+import me.lensferno.dogename.data.History;
import me.lensferno.dogename.utils.Random;
import me.lensferno.dogename.voice.VoicePlayer;
public final class Worker {
private final Random randomNumber = new Random();
-
- private StringProperty[] labelTexts;
private final SimpleBooleanProperty stoppedIndicator = new SimpleBooleanProperty(true);
-
private final MainConfig config;
-
//挑选方法
private final int selectMethod = MainConfig.METHOD_NAME;
private final Data data;
-
private final History history;
-
private final VoicePlayer voicePlayer;
-
- private int speed = 0;
-
//数值范围最大最小值
private final int[] numberRange = new int[2];
private final int MIN_NUMBER = 0;
private final int MAX_NUMBER = 1;
-
+ private final Counter counter = new Counter();
+ private StringProperty[] labelTexts;
+ private int speed = 0;
//挑选次数和每一轮的挑选次数
private int maxTotalCount = MainConfig.DEFAULT_MAX_TOTAL_COUNT;
private int maxCycleCount = 0;
-
//已经挑选了多少次
private int totalCount = 0;
private int cycleCount = 0;
-
private boolean finalResult = true;
-
private boolean forceStop = false;
-
private String selectedResult;
private boolean continueSelecting = false;
-
private int resultLabelId = 0;
- private final Counter counter = new Counter();
-
public Worker(StringProperty[] labelTexts, MainConfig config, Data data, History history, VoicePlayer voicePlayer) {
this.labelTexts = labelTexts;
this.config = config;
@@ -150,6 +135,31 @@ public final class Worker {
}
}
+ public boolean getStoppedIndicator() {
+ return stoppedIndicator.get();
+ }
+
+ public SimpleBooleanProperty stoppedIndicatorProperty() {
+ return stoppedIndicator;
+ }
+
+ public void setNumberRange(int minNumber, int maxNumber) {
+ this.numberRange[MIN_NUMBER] = minNumber;
+ this.numberRange[MAX_NUMBER] = maxNumber;
+ }
+
+ public void setForceStop(boolean forceStop) {
+ this.forceStop = forceStop;
+ }
+
+ public void setMaxTotalCount(int maxTotalCount) {
+ this.maxTotalCount = maxTotalCount;
+ }
+
+ public void setSpeed(int speed) {
+ this.speed = speed;
+ }
+
// 这里有个内部类Counter计数菌
final class Counter {
@@ -183,29 +193,4 @@ public final class Worker {
return newResultLabelId;
}
}
-
- public boolean getStoppedIndicator() {
- return stoppedIndicator.get();
- }
-
- public SimpleBooleanProperty stoppedIndicatorProperty() {
- return stoppedIndicator;
- }
-
- public void setNumberRange(int minNumber, int maxNumber) {
- this.numberRange[MIN_NUMBER] = minNumber;
- this.numberRange[MAX_NUMBER] = maxNumber;
- }
-
- public void setForceStop(boolean forceStop) {
- this.forceStop = forceStop;
- }
-
- public void setMaxTotalCount(int maxTotalCount) {
- this.maxTotalCount = maxTotalCount;
- }
-
- public void setSpeed(int speed) {
- this.speed = speed;
- }
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/utils/DialogMaker.java b/Dogename/src/main/java/me/lensferno/dogename/utils/DialogMaker.java
index b8587f3..0682a41 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/utils/DialogMaker.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/utils/DialogMaker.java
@@ -19,84 +19,85 @@ import javafx.scene.text.Text;
public class DialogMaker {
Pane rootPane;
-
- public DialogMaker(@NamedArg("rootPane") Pane rootPane){
- this.rootPane=rootPane;
- }
+ JFXDialog dialog;
- JFXDialog dialog;
+ public DialogMaker(@NamedArg("rootPane") Pane rootPane) {
+ this.rootPane = rootPane;
+ }
- public void createMessageDialog(@NamedArg("title") String title, @NamedArg("message") String message){
+ public void createMessageDialog(@NamedArg("title") String title, @NamedArg("message") String message) {
JFXButton OKButton = new JFXButton("了解!");
- OKButton.setFont(Font.font("Microsoft YaHei",FontWeight.BOLD,12));
+ OKButton.setFont(Font.font("Microsoft YaHei", FontWeight.BOLD, 12));
OKButton.setPrefWidth(60);
OKButton.setPrefHeight(30);
- Text messageText=new Text(message);
- messageText.setFont(Font.font("Microsoft YaHei",14));
+ Text messageText = new Text(message);
+ messageText.setFont(Font.font("Microsoft YaHei", 14));
- createDialog(title,messageText,OKButton);
+ createDialog(title, messageText, OKButton);
}
//创建只有一个按钮的dialog
- public void createDialogWithOneBtn(@NamedArg("title") String title, @NamedArg("theBody") Node body){
- //dialog.setPrefHeight(rootPane.getPrefHeight());
+ public void createDialogWithOneBtn(@NamedArg("title") String title, @NamedArg("theBody") Node body) {
+ //dialog.setPrefHeight(rootPane.getPrefHeight());
//dialog.setPrefWidth(rootPane.getPrefWidth());
JFXButton OKButton = new JFXButton("好的!");
- OKButton.setFont(Font.font("Microsoft YaHei",FontWeight.BOLD,12));
+ OKButton.setFont(Font.font("Microsoft YaHei", FontWeight.BOLD, 12));
OKButton.setPrefWidth(60);
OKButton.setPrefHeight(30);
- createDialog(title,body,OKButton);
+ createDialog(title, body, OKButton);
dialog.show();
}
//创建有OK和cancel按钮的dialog
- public void createDialogWithOKAndCancel(@NamedArg("title") String title, @NamedArg("message") String message, @NamedArg("OKEvent") EventHandler OKEvent){
+ public void createDialogWithOKAndCancel(@NamedArg("title") String title, @NamedArg("message") String message, @NamedArg("OKEvent") EventHandler OKEvent) {
//dialog.setPrefHeight(rootPane.getPrefHeight());
//dialog.setPrefWidth(rootPane.getPrefWidth());
JFXButton CancelButton = new JFXButton("手滑了");
- CancelButton.setFont(Font.font("Microsoft YaHei",FontWeight.BOLD,12));
+ CancelButton.setFont(Font.font("Microsoft YaHei", FontWeight.BOLD, 12));
CancelButton.setPrefWidth(60);
CancelButton.setPrefHeight(30);
JFXButton OKButton = new JFXButton("是!");
- OKButton.setFont(Font.font("Microsoft YaHei",FontWeight.BOLD,12));
+ OKButton.setFont(Font.font("Microsoft YaHei", FontWeight.BOLD, 12));
OKButton.setPrefWidth(60);
OKButton.setPrefHeight(30);
OKButton.setTextFill(Paint.valueOf("red"));
- OKButton.addEventHandler(ActionEvent.ACTION,e -> {dialog.close();});
- OKButton.addEventHandler(ActionEvent.ACTION,OKEvent);
+ OKButton.addEventHandler(ActionEvent.ACTION, e -> {
+ dialog.close();
+ });
+ OKButton.addEventHandler(ActionEvent.ACTION, OKEvent);
- Text messageText=new Text(message);
- messageText.setFont(Font.font("Microsoft YaHei",14));
+ Text messageText = new Text(message);
+ messageText.setFont(Font.font("Microsoft YaHei", 14));
- createDialog(title,messageText,CancelButton,OKButton);
+ createDialog(title, messageText, CancelButton, OKButton);
dialog.show();
}
- public void createDialog(@NamedArg("title") String title, @NamedArg("theBody") Node body, @NamedArg("buttons") JFXButton...buttons){
+ public void createDialog(@NamedArg("title") String title, @NamedArg("theBody") Node body, @NamedArg("buttons") JFXButton... buttons) {
JFXDialogLayout content = new JFXDialogLayout();
- Label titleLabel=new Label(title);
- titleLabel.setFont(Font.font("Microsoft YaHei", FontWeight.BOLD,20));
+ Label titleLabel = new Label(title);
+ titleLabel.setFont(Font.font("Microsoft YaHei", FontWeight.BOLD, 20));
content.setHeading(titleLabel);
content.setBody(body);
content.setAlignment(Pos.CENTER);
- StackPane tempPane=new StackPane();
+ StackPane tempPane = new StackPane();
tempPane.setPrefHeight(rootPane.getPrefHeight());
tempPane.setPrefWidth(rootPane.getPrefWidth());
rootPane.getChildren().add(tempPane);
- dialog = new JFXDialog(tempPane,content,JFXDialog.DialogTransition.TOP);
+ dialog = new JFXDialog(tempPane, content, JFXDialog.DialogTransition.TOP);
dialog.setOnDialogClosed(event -> rootPane.getChildren().remove(tempPane));
diff --git a/Dogename/src/main/java/me/lensferno/dogename/utils/IOUtil.java b/Dogename/src/main/java/me/lensferno/dogename/utils/IOUtil.java
index f91c386..c912a91 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/utils/IOUtil.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/utils/IOUtil.java
@@ -1,6 +1,9 @@
package me.lensferno.dogename.utils;
-import java.io.*;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
import java.nio.charset.Charset;
public class IOUtil {
@@ -38,7 +41,7 @@ public class IOUtil {
}
}
- public static void writeFile(byte[] bytes, File file) throws Exception{
+ public static void writeFile(byte[] bytes, File file) throws Exception {
FileOutputStream fileOutputStream = new FileOutputStream(file);
fileOutputStream.write(bytes);
fileOutputStream.close();
diff --git a/Dogename/src/main/java/me/lensferno/dogename/utils/NetworkUtil.java b/Dogename/src/main/java/me/lensferno/dogename/utils/NetworkUtil.java
index 6f739e7..06c816f 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/utils/NetworkUtil.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/utils/NetworkUtil.java
@@ -1,10 +1,10 @@
package me.lensferno.dogename.utils;
import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.URL;
@@ -16,8 +16,6 @@ import java.util.zip.InflaterInputStream;
public class NetworkUtil {
- private static Logger log = LogManager.getLogger();
-
public static final String REQUEST_USERAGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.67";
public static String getHtml(String address) {
@@ -61,12 +59,12 @@ public class NetworkUtil {
is.close();
} catch (Exception e) {
- log.error("Error in getting HTML:" + e);
+ System.out.println("Error in getting HTML:" + e);
return null;
}
if (output)
- System.out.println("[INFO]Got:" + sb.toString());
+ System.out.println("[INFO]Got:" + sb);
return sb.toString();
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/utils/Random.java b/Dogename/src/main/java/me/lensferno/dogename/utils/Random.java
index 44bab69..43251e4 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/utils/Random.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/utils/Random.java
@@ -13,16 +13,16 @@ public final class Random {
this.useSecureRandom = useSecureRandom;
}
- public int getRandomNumber (int minNumber, int maxNumber) {
- if (useSecureRandom){
+ public int getRandomNumber(int minNumber, int maxNumber) {
+ if (useSecureRandom) {
return minNumber + secRandom.nextInt(maxNumber - minNumber + 1);
} else {
return minNumber + random.nextInt(maxNumber - minNumber + 1);
}
}
- public int getRandomNumber (int maxNumber) {
- if (useSecureRandom){
+ public int getRandomNumber(int maxNumber) {
+ if (useSecureRandom) {
return secRandom.nextInt(maxNumber + 1);
} else {
return random.nextInt(maxNumber + 1);
diff --git a/Dogename/src/main/java/me/lensferno/dogename/utils/ocr/OcrTool.java b/Dogename/src/main/java/me/lensferno/dogename/utils/ocr/OcrTool.java
index a2b76b8..5628b0a 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/utils/ocr/OcrTool.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/utils/ocr/OcrTool.java
@@ -15,37 +15,37 @@ public class OcrTool {
AipOcr client = new AipOcr(APP_ID, API_KEY, SECRET_KEY);
String result;
- int resultNum=0;
+ int resultNum = 0;
- public void requestOcrAPI(String imageFileLocation){
- JSONObject respondJSON=client.basicGeneral(imageFileLocation, new HashMap<>());
- if (respondJSON==null){
- result="错误:返回了空的数据。";
+ public void requestOcrAPI(String imageFileLocation) {
+ JSONObject respondJSON = client.basicGeneral(imageFileLocation, new HashMap<>());
+ if (respondJSON == null) {
+ result = "错误:返回了空的数据。";
return;
}
- if(!respondJSON.has("words_result")){
- String errorCode=respondJSON.get("error_code").toString();
- result=findErrorMsg(errorCode);
+ if (!respondJSON.has("words_result")) {
+ String errorCode = respondJSON.get("error_code").toString();
+ result = findErrorMsg(errorCode);
return;
}
- resultNum=respondJSON.getInt("words_result_num");
- System.out.println("total result:"+resultNum);
- JSONArray resultArray=respondJSON.getJSONArray("words_result");
+ resultNum = respondJSON.getInt("words_result_num");
+ System.out.println("total result:" + resultNum);
+ JSONArray resultArray = respondJSON.getJSONArray("words_result");
- StringBuffer stringBuffer=new StringBuffer();
+ StringBuffer stringBuffer = new StringBuffer();
- for(int i=0;i {
- if (e.getCode().equals(KeyCode.ESCAPE)){
+ if (e.getCode().equals(KeyCode.ESCAPE)) {
stage.close();
end.set(true);
}
@@ -85,20 +94,6 @@ public class ScreenCapture {
stage.show();
}
- private double dragStartX = 0;
- private double dragStartY = 0;
-
- private double dragEndX = 0;
- private double dragEndY = 0;
-
- private double selectedAreaWidth = 0;
- private double selectedAreaHeight = 0;
-
- private Line Width_Follow;
- private Line Height_Follow;
- private Line Width_Fixed;
- private Line Height_Fixed;
-
private void addEventListeners() {
rootPane.setOnMousePressed(e -> {
dragStartX = e.getX();
@@ -113,16 +108,16 @@ public class ScreenCapture {
rootPane.setOnMouseReleased(e -> {
dragEndX = e.getX();
dragEndY = e.getY();
- int clipPositionX = (int)dragStartX;
- int clipPositionY = (int)dragStartY;
+ int clipPositionX = (int) dragStartX;
+ int clipPositionY = (int) dragStartY;
if (selectedAreaWidth < 0) {
- clipPositionX = (int)dragEndX;
+ clipPositionX = (int) dragEndX;
}
if (selectedAreaHeight < 0) {
- clipPositionY = (int)dragEndY;
+ clipPositionY = (int) dragEndY;
}
try {
- this.saveImage(clipPositionX, clipPositionY, Math.abs((int)selectedAreaWidth), Math.abs((int)selectedAreaHeight));
+ this.saveImage(clipPositionX, clipPositionY, Math.abs((int) selectedAreaWidth), Math.abs((int) selectedAreaHeight));
this.runFinalEvent(finalEvent);
} catch (Exception exc) {
exc.printStackTrace();
@@ -136,7 +131,7 @@ public class ScreenCapture {
Platform.runLater(finalEvent);
}
- private void saveImage(int x, int y, int width, int height){
+ private void saveImage(int x, int y, int width, int height) {
try {
File outputFile = new File(cacheImageFileLocation);
File outputDir = outputFile.getParentFile();
@@ -181,9 +176,6 @@ public class ScreenCapture {
Height_Follow.layoutYProperty().set(dragStartY);
}
- private final Line MouseLine_X = new Line();
- private final Line MouseLine_Y = new Line();
-
private void addMouseLine() {
MouseLine_X.layoutXProperty().set(0);
MouseLine_X.endXProperty().set(screenWidth);
@@ -215,8 +207,17 @@ public class ScreenCapture {
Height_Follow.endYProperty().set(selectedAreaHeight);
}
+ public SimpleStringProperty resultProperty() {
+ return result;
+ }
+
+ public SimpleBooleanProperty endProperty() {
+ return end;
+ }
+
class ScreenshotTool {
BufferedImage fullscreenBufferedImage;
+
public Image getFullScreenshotImageData() {
try {
Robot robot = new Robot();
@@ -232,16 +233,8 @@ public class ScreenCapture {
}
}
- public void saveClippedImage(int x, int y, int width, int height, String formateName, File output) throws Exception{
- ImageIO.write(fullscreenBufferedImage.getSubimage(x, y, width, height), formateName, output);
+ public void saveClippedImage(int x, int y, int width, int height, String formateName, File output) throws Exception {
+ ImageIO.write(fullscreenBufferedImage.getSubimage(x, y, width, height), formateName, output);
}
}
-
- public SimpleStringProperty resultProperty() {
- return result;
- }
-
- public SimpleBooleanProperty endProperty() {
- return end;
- }
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/voice/Token.java b/Dogename/src/main/java/me/lensferno/dogename/voice/Token.java
index 443e4a1..416d36b 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/voice/Token.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/voice/Token.java
@@ -34,20 +34,20 @@ aue =6 ,返回为二进制wav文件,具体header信息 Content-Type: audio/w
return System.currentTimeMillis() > expTime;
}
- public void setAccessToken(String accessToken) {
- this.accessToken = accessToken;
- }
-
public String getAccessToken() {
return accessToken;
}
- public void setExpiresIn(long expiresIn) {
- this.expiresIn = expiresIn;
+ public void setAccessToken(String accessToken) {
+ this.accessToken = accessToken;
}
public long getExpiresIn() {
return expiresIn;
}
+ public void setExpiresIn(long expiresIn) {
+ this.expiresIn = expiresIn;
+ }
+
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/voice/TokenManager.java b/Dogename/src/main/java/me/lensferno/dogename/voice/TokenManager.java
index 797d11c..78c1f2a 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/voice/TokenManager.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/voice/TokenManager.java
@@ -2,8 +2,6 @@ package me.lensferno.dogename.voice;
import com.google.gson.Gson;
import me.lensferno.dogename.utils.NetworkUtil;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
import java.io.*;
import java.net.HttpURLConnection;
@@ -11,29 +9,20 @@ import java.net.URL;
public class TokenManager {
- Logger log= LogManager.getLogger();
-
- public static final String separator=File.separator;
-
- private final int TOKEN_NULL = -2;
- private final int TOKEN_EXPIRED = -1;
-
+ public static final String separator = File.separator;
public static final int TOKEN_OK = 0;
public static final int TOKEN_BAD = 1;
-
+ final String API_KEY = "dIHCtamVdD0ERO1yyFir2iI4";
+ final String SEC_KEY = "HmpBQY3gG4PyZ0cmudnCbMeoMcMejuuW";
+ final String TOKEN_API_URL = "https://openapi.baidu.com/oauth/2.0/token";
+ private final int TOKEN_NULL = -2;
+ private final int TOKEN_EXPIRED = -1;
+ File tokenFile = new File("API_voice.token");
private int tokenStatus = TOKEN_OK;
-
- final String API_KEY="dIHCtamVdD0ERO1yyFir2iI4";
- final String SEC_KEY="HmpBQY3gG4PyZ0cmudnCbMeoMcMejuuW";
-
- final String TOKEN_API_URL ="https://openapi.baidu.com/oauth/2.0/token";
-
- File tokenFile=new File("API_voice.token");
-
private Token token = null;
-
- private void updateTokenStatus(int statusCode){
- switch(statusCode){
+
+ private void updateTokenStatus(int statusCode) {
+ switch (statusCode) {
case TOKEN_OK:
tokenStatus = TOKEN_OK;
break;
@@ -41,42 +30,42 @@ public class TokenManager {
case TOKEN_EXPIRED:
case TOKEN_NULL:
- if(netAvailable()){
+ if (netAvailable()) {
refreshToken();
}
- if(checkTokenAvailable()!=0){
+ if (checkTokenAvailable() != 0) {
tokenStatus = TOKEN_BAD;
}
break;
- default :
- tokenStatus = TOKEN_BAD;
- break;
- }
+ default:
+ tokenStatus = TOKEN_BAD;
+ break;
+ }
}
-
- private void refreshToken(){
+
+ private void refreshToken() {
fetchToken();
writeToken();
}
- public void init(){
+ public void init() {
- if(tokenFile.exists()){
+ if (tokenFile.exists()) {
loadToken();
updateTokenStatus(checkTokenAvailable());
-
- }else{
-
- if(netAvailable()){
-
- refreshToken();
-
- updateTokenStatus(checkTokenAvailable());
- }else {
+ } else {
+
+ if (netAvailable()) {
+
+ refreshToken();
+
+ updateTokenStatus(checkTokenAvailable());
+
+ } else {
tokenStatus = TOKEN_BAD;
}
@@ -95,42 +84,42 @@ public class TokenManager {
//token是空的就返回-2
if (token == null || token.getAccessToken() == null) {
- log.info("Token was null");
+ System.out.println("Token was null");
return -2;
}
//token过期了就返回-1
if (token.isTokenTimeOut()) {
- log.info("Token expired.");
+ System.out.println("Token expired.");
return -1;
}
//正常的话就返回0
- log.info("Token OK.");
+ System.out.println("Token OK.");
return 0;
}
- void fetchToken(){
- try{
- token=new Gson().fromJson(
+ void fetchToken() {
+ try {
+ token = new Gson().fromJson(
NetworkUtil.getHtml(
TOKEN_API_URL
- + "?grant_type=client_credentials&client_id=" + API_KEY
- + "&client_secret=" + SEC_KEY,
- true)
- ,Token.class);
+ + "?grant_type=client_credentials&client_id=" + API_KEY
+ + "&client_secret=" + SEC_KEY,
+ true)
+ , Token.class);
token.setExpTime();
- }catch (Exception e){
- log.error("Error to get Token:"+e);
- token=null;
+ } catch (Exception e) {
+ System.out.println("Error to get Token:" + e);
+ token = null;
}
}
- private boolean netAvailable(){
+ private boolean netAvailable() {
try {
-
+
URL sourcesURL = new URL("http://www.baidu.com");
HttpURLConnection connection = (HttpURLConnection) sourcesURL.openConnection();
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36");
@@ -139,34 +128,34 @@ public class TokenManager {
InputStream stream = connection.getInputStream();
stream.read();
stream.close();
-
+
return true;
- }catch (Exception e){
- log.info("Network is not available.");
+ } catch (Exception e) {
+ System.out.println("Network is not available.");
return false;
}
}
- private void loadToken(){
+ private void loadToken() {
ObjectInputStream ois;
- try{
- ois =new ObjectInputStream(new FileInputStream(tokenFile));
- this.token =(Token) ois.readObject();
+ try {
+ ois = new ObjectInputStream(new FileInputStream(tokenFile));
+ this.token = (Token) ois.readObject();
ois.close();
- }catch (Exception e){
- log.error("Error in loading Token:"+e);
- this.token=null;
+ } catch (Exception e) {
+ System.out.println("Error in loading Token:" + e);
+ this.token = null;
}
}
- private void writeToken(){
+ private void writeToken() {
- try{
- ObjectOutputStream oos =new ObjectOutputStream(new FileOutputStream(tokenFile));
+ try {
+ ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(tokenFile));
oos.writeObject(token);
oos.close();
- }catch (Exception e){
- log.error("Error in writing Token:"+e);
+ } catch (Exception e) {
+ System.out.println("Error in writing Token:" + e);
}
}
diff --git a/Dogename/src/main/java/me/lensferno/dogename/voice/VoicePlayer.java b/Dogename/src/main/java/me/lensferno/dogename/voice/VoicePlayer.java
index ed9c523..0a3d270 100644
--- a/Dogename/src/main/java/me/lensferno/dogename/voice/VoicePlayer.java
+++ b/Dogename/src/main/java/me/lensferno/dogename/voice/VoicePlayer.java
@@ -14,11 +14,10 @@ public class VoicePlayer {
public static final String separator = File.separator;
private final String VOICE_API = "https://tsn.baidu.com/text2audio";
- private VoiceConfig voiceConfig = null;
-
String cachePath = "caches" + separator + "voice" + separator;
-
Token token;
+ StreamPlayer streamPlayer = new StreamPlayer();
+ private VoiceConfig voiceConfig = null;
public VoicePlayer(Token token, VoiceConfig voiceConfig) {
this.token = token;
@@ -90,8 +89,6 @@ public class VoicePlayer {
return success;
}
- StreamPlayer streamPlayer = new StreamPlayer();
-
private void playSound(File file) {
try {
streamPlayer.open(file);