优化代码
This commit is contained in:
parent
bd3dc18fce
commit
56913b9acc
Binary file not shown.
|
@ -20,6 +20,7 @@ public class RoomItSlider extends Slider {
|
|||
}
|
||||
|
||||
private void initEvents() {
|
||||
// 使滑动块按步数走
|
||||
this.setOnMouseReleased(e -> this.setValue(Math.round(this.getValue())));
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ public class Toast extends Label {
|
|||
/**
|
||||
* 定时线程池
|
||||
*/
|
||||
private static final ScheduledExecutorService scheduledExecutorService = new ScheduledThreadPoolExecutor(1, new ToastThreadFactory());
|
||||
private final ScheduledExecutorService scheduledExecutorService = new ScheduledThreadPoolExecutor(1, new ToastThreadFactory());
|
||||
|
||||
/**
|
||||
* 每次透明度减少的间隔毫秒数
|
||||
|
|
|
@ -119,6 +119,11 @@ public class MainWindowController extends BaseController implements Initializabl
|
|||
initDrawingBoard();
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发用户定义的快捷键
|
||||
*
|
||||
* @param keyBoardText 经过转换后的快捷键
|
||||
*/
|
||||
public void triggerKeyboard(String keyBoardText) {
|
||||
switch (keyBoardConfiguration.getType(keyBoardText)) {
|
||||
// 切换为画笔
|
||||
|
@ -353,6 +358,7 @@ public class MainWindowController extends BaseController implements Initializabl
|
|||
private void clear() {
|
||||
canvasGroup.clear();
|
||||
shapePane.clear();
|
||||
container.requestFocus();
|
||||
}
|
||||
|
||||
}
|
|
@ -28,8 +28,14 @@ public class RoomItCursor extends SVGPath {
|
|||
*/
|
||||
private int sizeLevel = 0;
|
||||
|
||||
/**
|
||||
* 跟随鼠标的logo
|
||||
*/
|
||||
private MouseSymbol mouseSymbol;
|
||||
|
||||
/**
|
||||
* 记录鼠标全局的xy轴位置
|
||||
*/
|
||||
private double x, y;
|
||||
|
||||
public RoomItCursor() {
|
||||
|
@ -121,30 +127,10 @@ public class RoomItCursor extends SVGPath {
|
|||
}
|
||||
}
|
||||
|
||||
private static class Size {
|
||||
private final double scale, rotate, extraX, extraY;
|
||||
private final LogoPosition logoPosition;
|
||||
|
||||
public Size(double scale, double rotate, double extraX, double extraY, LogoPosition logoPosition) {
|
||||
this.scale = scale;
|
||||
this.rotate = rotate;
|
||||
this.extraX = extraX;
|
||||
this.extraY = extraY;
|
||||
this.logoPosition = logoPosition;
|
||||
}
|
||||
private record Size(double scale, double rotate, double extraX, double extraY,
|
||||
LogoPosition logoPosition) {
|
||||
}
|
||||
|
||||
private static class LogoPosition {
|
||||
|
||||
private final double bx, by, rx, ry, ex, ey;
|
||||
|
||||
public LogoPosition(double bx, double by, double rx, double ry, double ex, double ey) {
|
||||
this.bx = bx;
|
||||
this.by = by;
|
||||
this.rx = rx;
|
||||
this.ry = ry;
|
||||
this.ex = ex;
|
||||
this.ey = ey;
|
||||
}
|
||||
private record LogoPosition(double bx, double by, double rx, double ry, double ex, double ey) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
package org.rococy.roomit.event;
|
||||
|
||||
import javafx.event.Event;
|
||||
import javafx.event.EventType;
|
||||
|
||||
/**
|
||||
* 容器操作事件(子元素的增删改查)
|
||||
*
|
||||
* @author Rococy
|
||||
* @date 2022/9/24
|
||||
*/
|
||||
public class ContainerManipulationEvent extends Event {
|
||||
|
||||
public static final EventType<ContainerManipulationEvent> ADDED = new EventType<>(Event.ANY, "ADDED");
|
||||
public static final EventType<ContainerManipulationEvent> REMOVED = new EventType<>(Event.ANY, "REMOVED");
|
||||
|
||||
public ContainerManipulationEvent(EventType<? extends Event> eventType) {
|
||||
super(eventType);
|
||||
}
|
||||
}
|
|
@ -9,6 +9,9 @@ package org.rococy.roomit.function;
|
|||
@FunctionalInterface
|
||||
public interface Handler {
|
||||
|
||||
/**
|
||||
* 使用
|
||||
*/
|
||||
void apply();
|
||||
|
||||
}
|
||||
|
|
|
@ -101,22 +101,6 @@ public class WindowGlobalKeyBoardListener {
|
|||
private boolean isAltDown;
|
||||
private KeyCode keyCode;
|
||||
|
||||
public boolean isShiftDown() {
|
||||
return isShiftDown;
|
||||
}
|
||||
|
||||
public boolean isCtrlDown() {
|
||||
return isCtrlDown;
|
||||
}
|
||||
|
||||
public boolean isAltDown() {
|
||||
return isAltDown;
|
||||
}
|
||||
|
||||
public KeyCode getKeyCode() {
|
||||
return keyCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GlobalKeyEvent{" +
|
||||
|
|
|
@ -12,13 +12,6 @@ import java.util.StringJoiner;
|
|||
*/
|
||||
public class AutoStartFile {
|
||||
|
||||
private static final String START_UP_FILE_PATH = "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\RoomIt.bat";
|
||||
|
||||
private static final String COPY_AUTO_START_FILE_PATH = ResourceUtils.getResourceByProject("config/copy_auto_start_file.bat");
|
||||
private static final String CANCEL_AUTO_START_FILE_PATH = ResourceUtils.getResourceByProject("config/cancel_auto_start.bat");
|
||||
private static final String BAT_FILE_PATH = ResourceUtils.getResourceByProject("config/RoomIt.bat");
|
||||
private static final String AUTO_START_EXEC_FILE_PATH = ResourceUtils.getResourceByProject("");
|
||||
|
||||
private static final BasicConfiguration BASIC_CONFIGURATION = ConfigurationManager.getBasicConfiguration();
|
||||
|
||||
public static void toggleExists() {
|
||||
|
@ -30,14 +23,18 @@ public class AutoStartFile {
|
|||
}
|
||||
|
||||
private static void generate() {
|
||||
try {
|
||||
final String startUpFilePath = "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\RoomIt.bat";
|
||||
final String copyAutoStartFilePath = ResourceUtils.getResourceByProject("config/copy_auto_start_file.bat");
|
||||
final String batFilePath = ResourceUtils.getResourceByProject("config/RoomIt.bat");
|
||||
final String autoStartExecFilePath = ResourceUtils.getResourceByProject("");
|
||||
|
||||
try {
|
||||
StringJoiner fileContentJoiner = new StringJoiner("\n");
|
||||
String driveLetter = AUTO_START_EXEC_FILE_PATH.substring(0, 2);
|
||||
String driveLetter = autoStartExecFilePath.substring(0, 2);
|
||||
fileContentJoiner.add("@echo off");
|
||||
fileContentJoiner.add("if exist \"" + AUTO_START_EXEC_FILE_PATH + "RoomIt.exe\" (");
|
||||
fileContentJoiner.add("if exist \"" + autoStartExecFilePath + "RoomIt.exe\" (");
|
||||
fileContentJoiner.add(driveLetter);
|
||||
fileContentJoiner.add("cd " + AUTO_START_EXEC_FILE_PATH);
|
||||
fileContentJoiner.add("cd " + autoStartExecFilePath);
|
||||
fileContentJoiner.add("start /b RoomIt");
|
||||
fileContentJoiner.add(") else (");
|
||||
fileContentJoiner.add("exit");
|
||||
|
@ -45,7 +42,7 @@ public class AutoStartFile {
|
|||
|
||||
String fileContent = fileContentJoiner.toString();
|
||||
|
||||
File startUpFile = new File(START_UP_FILE_PATH);
|
||||
File startUpFile = new File(startUpFilePath);
|
||||
|
||||
if (startUpFile.exists()) {
|
||||
FileInputStream is = new FileInputStream(startUpFile);
|
||||
|
@ -59,7 +56,7 @@ public class AutoStartFile {
|
|||
}
|
||||
|
||||
// 复制自启动bat文件到windows的startup目录下
|
||||
File file = new File(BAT_FILE_PATH);
|
||||
File file = new File(batFilePath);
|
||||
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
|
@ -71,14 +68,14 @@ public class AutoStartFile {
|
|||
fos.flush();
|
||||
fos.close();
|
||||
|
||||
executeBatFile(COPY_AUTO_START_FILE_PATH);
|
||||
executeBatFile(copyAutoStartFilePath);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void delete() {
|
||||
executeBatFile(CANCEL_AUTO_START_FILE_PATH);
|
||||
executeBatFile(ResourceUtils.getResourceByProject("config/cancel_auto_start.bat"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue