「优化」部分界面

main
lensfrex 3 years ago
parent 7ae4dcb92b
commit 8140e063ea
Signed by: lensfrex
GPG Key ID: 947ADABD8533C476
  1. 13
      Dogename/src/main/java/me/lensferno/dogename/Main.java
  2. 5
      Dogename/src/main/java/me/lensferno/dogename/controllers/OcrPaneController.java
  3. 8
      Dogename/src/main/java/me/lensferno/dogename/controllers/ProgramInfoPaneController.java
  4. 8
      Dogename/src/main/java/me/lensferno/dogename/sayings/Gushici.java
  5. 8
      Dogename/src/main/java/me/lensferno/dogename/sayings/Hitokoto.java
  6. 6
      Dogename/src/main/java/me/lensferno/dogename/utils/ocr/ScreenCapture.java
  7. 2
      Dogename/src/main/resources/me/lensferno/dogename/FXMLs/MainInterface.fxml

@ -77,15 +77,14 @@ public class Main extends Application {
configLoader.writeAllConfigToFile(configLoader.getMainConfigLocation(), configLoader.getVoiceConfigLocation()); configLoader.writeAllConfigToFile(configLoader.getMainConfigLocation(), configLoader.getVoiceConfigLocation());
System.exit(0); System.exit(0);
}); });
if (mainInterfaceController.getMainConfig().isShowSaying()) { if (new Random().nextBoolean()){
if (new Random().nextBoolean()){ new Gushici().showGushici(mainInterfaceController.getRootPane(),mainInterfaceController.getTopBar(), mainInterfaceController.getMainConfig().isShowSaying());
new Gushici().showGushici(mainInterfaceController.getRootPane(),mainInterfaceController.getTopBar()); } else {
}else { new Hitokoto().showHitokoto(mainInterfaceController.getRootPane(),mainInterfaceController.getTopBar(), mainInterfaceController.getMainConfig().isShowSaying());
new Hitokoto().showHitokoto(mainInterfaceController.getRootPane(),mainInterfaceController.getTopBar());
}
} }
} }
} }

@ -22,6 +22,8 @@ public class OcrPaneController {
this.mainStage = mainStage; this.mainStage = mainStage;
} }
@FXML @FXML
void addNew() { void addNew() {
@ -39,7 +41,7 @@ public class OcrPaneController {
ScreenCapture screenCapture = new ScreenCapture(); ScreenCapture screenCapture = new ScreenCapture();
ocrText.textProperty().bindBidirectional(screenCapture.resultProperty()); ocrText.textProperty().bindBidirectional(screenCapture.resultProperty());
loadingSpinner.visibleProperty().bind(screenCapture.endProperty().not()); loadingSpinner.visibleProperty().set(true);
screenCapture.startCapture(); screenCapture.startCapture();
@ -47,6 +49,7 @@ public class OcrPaneController {
if (end) { if (end) {
mainStage.show(); mainStage.show();
thisStage.show(); thisStage.show();
loadingSpinner.visibleProperty().set(false);
} }
}); });
} }

@ -48,7 +48,7 @@ public class ProgramInfoPaneController extends VBox {
} }
@FXML @FXML
void showLicense(ActionEvent event) { void showLicense() {
TextArea textArea=new TextArea(IOUtil.inputStreamToString(getClass().getResourceAsStream("/gpl-3.0.txt"), StandardCharsets.UTF_8)); TextArea textArea=new TextArea(IOUtil.inputStreamToString(getClass().getResourceAsStream("/gpl-3.0.txt"), StandardCharsets.UTF_8));
textArea.setFont(Font.font("Microsoft YaHei",14)); textArea.setFont(Font.font("Microsoft YaHei",14));
textArea.setMinWidth(600); textArea.setMinWidth(600);
@ -58,7 +58,7 @@ public class ProgramInfoPaneController extends VBox {
} }
@FXML @FXML
void showLibLicense(ActionEvent event) { void showLibLicense() {
TextArea textArea=new TextArea(IOUtil.inputStreamToString(getClass().getResourceAsStream("/LibLicense.txt"), StandardCharsets.UTF_8)); TextArea textArea=new TextArea(IOUtil.inputStreamToString(getClass().getResourceAsStream("/LibLicense.txt"), StandardCharsets.UTF_8));
textArea.setFont(Font.font("Microsoft YaHei",14)); textArea.setFont(Font.font("Microsoft YaHei",14));
textArea.setMinWidth(600); textArea.setMinWidth(600);
@ -68,7 +68,7 @@ public class ProgramInfoPaneController extends VBox {
} }
@FXML @FXML
void showHelp(ActionEvent event) { void showHelp() {
JFXButton YesButton = new JFXButton("好的~去吧去吧"); JFXButton YesButton = new JFXButton("好的~去吧去吧");
YesButton.setFont(Font.font("Microsoft YaHei", FontWeight.BOLD,14)); YesButton.setFont(Font.font("Microsoft YaHei", FontWeight.BOLD,14));
@ -97,7 +97,7 @@ public class ProgramInfoPaneController extends VBox {
} }
@FXML @FXML
void viewCode(ActionEvent event) { void viewCode() {
JFXButton githubButton = new JFXButton("前往Github查看"); 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.setPrefWidth(150);

@ -19,7 +19,7 @@ public class Gushici {
return NetworkUtil.getHtml(GUSHICI_API); return NetworkUtil.getHtml(GUSHICI_API);
} }
public void showGushici(Pane rootPane, Label topBar){ public void showGushici(Pane rootPane, Label topBar, boolean showOnDialog){
new Thread(()->{ new Thread(()->{
@ -35,8 +35,10 @@ public class Gushici {
type=gushiciData.getType(); type=gushiciData.getType();
Platform.runLater(()->{ Platform.runLater(()->{
topBar.setText(content+" ——"+author+"《"+title+"》"); topBar.setText(content+" ——"+author+"《"+title+"》");
GushiciPaneController gushiciPaneController=new GushiciPaneController(content, title, author, type); if (showOnDialog) {
new DialogMaker(rootPane).createDialogWithOneBtn("每日古诗词",gushiciPaneController); GushiciPaneController gushiciPaneController=new GushiciPaneController(content, title, author, type);
new DialogMaker(rootPane).createDialogWithOneBtn("每日古诗词",gushiciPaneController);
}
}); });
} }
}).start(); }).start();

@ -20,7 +20,7 @@ public class Hitokoto {
return NetworkUtil.getHtml(HITOKOTO_API); return NetworkUtil.getHtml(HITOKOTO_API);
} }
public void showHitokoto(Pane rootPane, Label topBar) { public void showHitokoto(Pane rootPane, Label topBar, boolean showOnDialog) {
new Thread(() -> { new Thread(() -> {
@ -39,8 +39,10 @@ public class Hitokoto {
Platform.runLater(() -> { Platform.runLater(() -> {
topBar.setText(String.format("《%s》:%s (%s)", from, hitokoto, author)); topBar.setText(String.format("《%s》:%s (%s)", from, hitokoto, author));
HitokotoPaneController hitokotoPaneController = new HitokotoPaneController(hitokoto, from, author, creator, type); if (showOnDialog) {
new DialogMaker(rootPane).createDialogWithOneBtn("每日一句话", hitokotoPaneController); HitokotoPaneController hitokotoPaneController = new HitokotoPaneController(hitokoto, from, author, creator, type);
new DialogMaker(rootPane).createDialogWithOneBtn("每日一言", hitokotoPaneController);
}
}); });
} }
}).start(); }).start();

@ -22,7 +22,7 @@ public class ScreenCapture {
private OcrTool ocrTool; private OcrTool ocrTool;
private final String cacheImageFileLocation = "caches/image/ocrImageCache.jpg"; private final String cacheImageFileLocation = "caches/image/ocrImageCache.png";
private final Runnable finalEvent = new Runnable() { private final Runnable finalEvent = new Runnable() {
@Override @Override
@ -30,9 +30,9 @@ public class ScreenCapture {
if (ocrTool == null) { if (ocrTool == null) {
ocrTool = new OcrTool(); ocrTool = new OcrTool();
} }
end.set(true);
ocrTool.requestOcrAPI(cacheImageFileLocation); ocrTool.requestOcrAPI(cacheImageFileLocation);
result.set(ocrTool.getResult()); result.set(ocrTool.getResult());
end.set(true);
} }
}; };
@ -152,6 +152,8 @@ public class ScreenCapture {
} }
private void createNewSelectedAreaRectangle() { private void createNewSelectedAreaRectangle() {
rootPane.getChildren().removeAll(Width_Follow, Height_Follow, Width_Fixed, Height_Fixed);
Width_Follow = new Line(); Width_Follow = new Line();
Height_Follow = new Line(); Height_Follow = new Line();
Width_Fixed = new Line(); Width_Fixed = new Line();

@ -21,7 +21,7 @@
<font> <font>
<Font name="Microsoft YaHei" size="14.0" /> <Font name="Microsoft YaHei" size="14.0" />
</font></JFXButton> </font></JFXButton>
<Label fx:id="downLabel" alignment="CENTER" layoutX="194.0" layoutY="177.0" prefHeight="117.0" prefWidth="650.0" text="✋( ˙0˙)" textAlignment="CENTER" wrapText="true"> <Label fx:id="downLabel" alignment="CENTER" layoutX="194.0" layoutY="177.0" prefHeight="117.0" prefWidth="650.0" text="(¯﹃¯)" textAlignment="CENTER" wrapText="true">
<font> <font>
<Font name="Microsoft YaHei" size="86.0" /> <Font name="Microsoft YaHei" size="86.0" />
</font> </font>

Loading…
Cancel
Save