diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index c8aa7af..cea6b82 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -6,46 +6,109 @@
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
+
+
+
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -74,20 +137,11 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -95,62 +149,49 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
+
-
-
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
-
+
+
@@ -159,10 +200,24 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -170,6 +225,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -199,6 +272,7 @@
System
Property
Simple
+ builder
config.FXMLoaer
@@ -207,6 +281,7 @@
FXMLLoaderPlus(
Wrapper
ReadOnly
+ Pane
@@ -217,8 +292,6 @@
@@ -315,6 +390,8 @@
+
+
@@ -340,6 +417,195 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/cn/edu/scau/biubiusuisui/annotation/FXWindow.java b/src/main/java/cn/edu/scau/biubiusuisui/annotation/FXWindow.java
index 1cef591..5fc30e2 100644
--- a/src/main/java/cn/edu/scau/biubiusuisui/annotation/FXWindow.java
+++ b/src/main/java/cn/edu/scau/biubiusuisui/annotation/FXWindow.java
@@ -16,8 +16,8 @@ public @interface FXWindow {
double preHeight()default 0.0;
double minWidth() default 0.0;
double minHeight() default 0.0;
- boolean fix() default false;
- boolean dragable() default false;
+ boolean resizable() default false;
+ boolean draggable() default false;
StageStyle style() default StageStyle.DECORATED;
String title () ;
diff --git a/src/main/java/cn/edu/scau/biubiusuisui/entity/FXFieldPropertyMapping.java b/src/main/java/cn/edu/scau/biubiusuisui/entity/FXFieldPropertyMapping.java
new file mode 100644
index 0000000..db638b3
--- /dev/null
+++ b/src/main/java/cn/edu/scau/biubiusuisui/entity/FXFieldPropertyMapping.java
@@ -0,0 +1,33 @@
+package cn.edu.scau.biubiusuisui.entity;
+
+import javafx.beans.property.Property;
+import javafx.beans.value.ObservableValue;
+
+import java.lang.reflect.Method;
+
+/**
+ * @Author jack
+ * @Date:2019/6/28 10:03
+ */
+public class FXFieldPropertyMapping {
+
+ private boolean readOnly;
+ private Class type;
+
+
+ public boolean isReadOnly() {
+ return readOnly;
+ }
+
+ public void setReadOnly(boolean readOnly) {
+ this.readOnly = readOnly;
+ }
+
+ public Class getType() {
+ return type;
+ }
+
+ public void setType(Class type) {
+ this.type = type;
+ }
+}
diff --git a/src/main/java/cn/edu/scau/biubiusuisui/example/MainController.java b/src/main/java/cn/edu/scau/biubiusuisui/example/MainController.java
index 47e18ad..65d0ae2 100644
--- a/src/main/java/cn/edu/scau/biubiusuisui/example/MainController.java
+++ b/src/main/java/cn/edu/scau/biubiusuisui/example/MainController.java
@@ -20,7 +20,7 @@ import java.util.ResourceBundle;
* @Date:2019/6/25 1:47
*/
@FXController(path = "Main.fxml")
-@FXWindow(title = "demo1",dragable = true,fix = true,style = StageStyle.UNDECORATED)
+@FXWindow(title = "demo1", draggable = true, resizable = true,style = StageStyle.UNDECORATED)
public class MainController extends FXBaseController{
@FXML
diff --git a/src/main/java/cn/edu/scau/biubiusuisui/factory/FXFactory.java b/src/main/java/cn/edu/scau/biubiusuisui/factory/FXFactory.java
index 2b684b6..97bd4ac 100644
--- a/src/main/java/cn/edu/scau/biubiusuisui/factory/FXFactory.java
+++ b/src/main/java/cn/edu/scau/biubiusuisui/factory/FXFactory.java
@@ -5,14 +5,12 @@ import cn.edu.scau.biubiusuisui.annotation.FXWindow;
import cn.edu.scau.biubiusuisui.config.FXMLLoaderPlus;
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
import cn.edu.scau.biubiusuisui.entity.FXPlusContext;
-import cn.edu.scau.biubiusuisui.function.DragWindowHandlerImpl;
-import cn.edu.scau.biubiusuisui.parser.WindowAnnotationParser;
-import javafx.event.EventHandler;
+import cn.edu.scau.biubiusuisui.function.FXWindowParser;
+import cn.edu.scau.biubiusuisui.messageQueue.MessageQueue;
+import cn.edu.scau.biubiusuisui.proxy.classProxy.FXControllerProxy;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
-import cn.edu.scau.biubiusuisui.messageQueue.MessageQueue;
-import cn.edu.scau.biubiusuisui.proxy.classProxy.FXControllerProxy;
import java.io.IOException;
import java.lang.annotation.Annotation;
@@ -24,10 +22,9 @@ import java.net.URL;
*/
public class FXFactory {
- private static WindowAnnotationParser windowAnnotationParser = new WindowAnnotationParser();;
- private FXFactory() {
+ private static FXWindowParser windowAnnotationParser = new FXWindowParser();
- }
+ private FXFactory() { }
public static void loadFXController(Class clazz) {
getFXController(clazz, "");
@@ -38,6 +35,7 @@ public class FXFactory {
return fxBaseController;
}
+
public static FXBaseController getFXController(Class clazz, String controllerName) {
FXBaseController fxBaseController = getFxBaseController(clazz, controllerName);
return fxBaseController;
diff --git a/src/main/java/cn/edu/scau/biubiusuisui/function/DragWindowHandlerImpl.java b/src/main/java/cn/edu/scau/biubiusuisui/function/DragWindowHandlerImpl.java
new file mode 100644
index 0000000..2253ab1
--- /dev/null
+++ b/src/main/java/cn/edu/scau/biubiusuisui/function/DragWindowHandlerImpl.java
@@ -0,0 +1,119 @@
+package cn.edu.scau.biubiusuisui.function;
+
+import javafx.event.EventHandler;
+import javafx.scene.Cursor;
+import javafx.scene.input.MouseEvent;
+import javafx.scene.layout.AnchorPane;
+import javafx.scene.layout.Pane;
+import javafx.stage.Stage;
+
+/**
+ * @Author jack
+ * @Date:2019/6/30 10:11
+ */
+public class DragWindowHandlerImpl implements EventHandler {
+ //参考
+ private Stage stage; //primaryStage为start方法头中的Stage
+ private double oldStageX;
+ private double oldStageY;
+ private double oldScreenX;
+ private double oldScreenY;
+ final int RESIZE_WIDTH = 5;// 判定是否为调整窗口状态的范围与边界距离
+ private double MIN_WIDTH = 300;// 窗口最小宽度
+ private double MIN_HEIGHT = 250;// 窗口最小高度
+ boolean isRight;// 是否处于右边界调整窗口状态
+ boolean isBottomRight;// 是否处于右下角调整窗口状态
+ boolean isBottom;// 是否处于下边界调整窗口状态
+ private Pane pane;
+ private boolean fix = false;
+
+ public DragWindowHandlerImpl(Stage primaryStage, Pane pane,boolean fix) { //构造器
+ this.stage = primaryStage;
+ this.pane = pane;
+ this.fix = fix;
+ }
+
+ public DragWindowHandlerImpl(Stage stage, double MIN_WIDTH, double MIN_HEIGHT, Pane pane, boolean fix) {
+ this.stage = stage;
+ this.MIN_WIDTH = MIN_WIDTH;
+ this.MIN_HEIGHT = MIN_HEIGHT;
+ this.pane = pane;
+ this.fix = fix;
+ }
+
+ @Override
+ public void handle(MouseEvent e) {
+
+ if (e.getEventType() == MouseEvent.MOUSE_PRESSED) { //鼠标按下的事件
+ this.oldStageX = this.stage.getX();
+ this.oldStageY = this.stage.getY();
+ this.oldScreenX = e.getScreenX();
+ this.oldScreenY = e.getScreenY();
+
+ } else if (e.getEventType() == MouseEvent.MOUSE_DRAGGED) { //鼠标拖动的事件
+ //
+ double nextX = stage.getX();
+ double nextY = stage.getY();
+ double nextWidth = stage.getWidth();
+ double nextHeight = stage.getHeight();
+ if(!fix) {
+ double x = e.getSceneX();
+ double y = e.getSceneY();
+ // 保存窗口改变后的x、y坐标和宽度、高度,用于预判是否会小于最小宽度、最小高度
+
+
+ if (isRight || isBottomRight) {// 所有右边调整窗口状态
+ nextWidth = x;
+ }
+ if (isBottomRight || isBottom) {// 所有下边调整窗口状态
+ nextHeight = y;
+ }
+ if (nextWidth <= MIN_WIDTH) {// 如果窗口改变后的宽度小于最小宽度,则宽度调整到最小宽度
+ nextWidth = MIN_WIDTH;
+ }
+ if (nextHeight <= MIN_HEIGHT) {// 如果窗口改变后的高度小于最小高度,则高度调整到最小高度
+ nextHeight = MIN_HEIGHT;
+ }
+ }
+
+ // 最后统一改变窗口的x、y坐标和宽度、高度,可以防止刷新频繁出现的屏闪情况
+ if(isBottom ||isBottomRight ||isRight) {
+ stage.setX(nextX);
+ stage.setY(nextY);
+ stage.setWidth(nextWidth);
+ stage.setHeight(nextHeight);
+ }else {
+ this.stage.setX(e.getScreenX() - this.oldScreenX + this.oldStageX);
+ this.stage.setY(e.getScreenY() - this.oldScreenY + this.oldStageY);
+ }
+ } else if (e.getEventType() == MouseEvent.MOUSE_MOVED) {
+ if(!fix) {
+ e.consume();
+ double x = e.getSceneX();
+ double y = e.getSceneY();
+ double width = stage.getWidth();
+ double height = stage.getHeight();
+ Cursor cursorType = Cursor.DEFAULT;// 鼠标光标初始为默认类型,若未进入调整窗口状态,保持默认类型
+ // 先将所有调整窗口状态重置
+ isRight = isBottomRight = isBottom = false;
+ if (y >= height - RESIZE_WIDTH) {
+ if (x <= RESIZE_WIDTH) {// 左下角调整窗口状态
+
+ } else if (x >= width - RESIZE_WIDTH) {// 右下角调整窗口状态
+ isBottomRight = true;
+ cursorType = Cursor.SE_RESIZE;
+ } else {// 下边界调整窗口状态
+ isBottom = true;
+ cursorType = Cursor.S_RESIZE;
+ }
+ } else if (x >= width - RESIZE_WIDTH) {// 右边界调整窗口状态
+ isRight = true;
+ cursorType = Cursor.E_RESIZE;
+ }
+ // 最后改变鼠标光标
+
+ pane.setCursor(cursorType);
+ }
+ }
+ }
+}
diff --git a/src/main/java/cn/edu/scau/biubiusuisui/function/FXWindowParser.java b/src/main/java/cn/edu/scau/biubiusuisui/function/FXWindowParser.java
new file mode 100644
index 0000000..3be482f
--- /dev/null
+++ b/src/main/java/cn/edu/scau/biubiusuisui/function/FXWindowParser.java
@@ -0,0 +1,32 @@
+package cn.edu.scau.biubiusuisui.function;
+
+import cn.edu.scau.biubiusuisui.annotation.FXWindow;
+import cn.edu.scau.biubiusuisui.function.DragWindowHandlerImpl;
+import javafx.event.EventHandler;
+import javafx.scene.layout.Pane;
+import javafx.stage.Stage;
+
+/**
+ * @Author jack
+ * @Date:2019/6/30 10:40
+ */
+public class FXWindowParser {
+
+ public void parse(Stage stage, Pane fxControllerProxy, FXWindow fxWindow){
+
+ stage.setTitle(fxWindow.title());
+
+ if(fxWindow.resizable()){
+ stage.setResizable(false);
+ }
+
+ if(fxWindow.draggable()) {
+ final int RESIZE_WIDTH = 5;// 判定是否为调整窗口状态的范围与边界距离
+ EventHandler dragWindowHandler= new DragWindowHandlerImpl(stage,fxWindow.minWidth(),fxWindow.minHeight(),fxControllerProxy,fxWindow.resizable());
+ fxControllerProxy.setOnMousePressed(dragWindowHandler);
+ fxControllerProxy.setOnMouseDragged(dragWindowHandler);
+ fxControllerProxy.setOnMouseMoved(dragWindowHandler);
+ }
+ stage.initStyle(fxWindow.style());
+ }
+}
diff --git a/target/classes/cn/edu/scau/biubiusuisui/annotation/FXWindow.class b/target/classes/cn/edu/scau/biubiusuisui/annotation/FXWindow.class
index 9a7b31f..52a822d 100644
Binary files a/target/classes/cn/edu/scau/biubiusuisui/annotation/FXWindow.class and b/target/classes/cn/edu/scau/biubiusuisui/annotation/FXWindow.class differ
diff --git a/target/classes/cn/edu/scau/biubiusuisui/entity/FXFieldPropertyMapping.class b/target/classes/cn/edu/scau/biubiusuisui/entity/FXFieldPropertyMapping.class
new file mode 100644
index 0000000..33b2ec1
Binary files /dev/null and b/target/classes/cn/edu/scau/biubiusuisui/entity/FXFieldPropertyMapping.class differ
diff --git a/target/classes/cn/edu/scau/biubiusuisui/example/MainController.class b/target/classes/cn/edu/scau/biubiusuisui/example/MainController.class
index 5c518be..669901c 100644
Binary files a/target/classes/cn/edu/scau/biubiusuisui/example/MainController.class and b/target/classes/cn/edu/scau/biubiusuisui/example/MainController.class differ
diff --git a/target/classes/cn/edu/scau/biubiusuisui/factory/FXFactory.class b/target/classes/cn/edu/scau/biubiusuisui/factory/FXFactory.class
index 8413b9d..4f70fcd 100644
Binary files a/target/classes/cn/edu/scau/biubiusuisui/factory/FXFactory.class and b/target/classes/cn/edu/scau/biubiusuisui/factory/FXFactory.class differ
diff --git a/target/classes/cn/edu/scau/biubiusuisui/function/DragWindowHandlerImpl.class b/target/classes/cn/edu/scau/biubiusuisui/function/DragWindowHandlerImpl.class
new file mode 100644
index 0000000..cb9b750
Binary files /dev/null and b/target/classes/cn/edu/scau/biubiusuisui/function/DragWindowHandlerImpl.class differ
diff --git a/target/classes/cn/edu/scau/biubiusuisui/function/FXWindowParser.class b/target/classes/cn/edu/scau/biubiusuisui/function/FXWindowParser.class
new file mode 100644
index 0000000..007473b
Binary files /dev/null and b/target/classes/cn/edu/scau/biubiusuisui/function/FXWindowParser.class differ