From 58870870ae5cf5f0c6af4108f99cc703444d7097 Mon Sep 17 00:00:00 2001 From: xxrjun Date: Tue, 16 Apr 2024 23:07:13 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=8Arefactor:=20remove=20unused=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UMLObjectFactory.java} | 8 ++++---- .../com/xxrjun/modes/CreateBasicUMLObject.java | 3 ++- .../com/xxrjun/modes/CreateUMLConnectionLine.java | 5 +++-- .../com/xxrjun/modes/UMLFactoryInterface.java | 15 --------------- 4 files changed, 9 insertions(+), 22 deletions(-) rename src/main/java/com/xxrjun/{modes/UMLFactory.java => factories/UMLObjectFactory.java} (95%) delete mode 100644 src/main/java/com/xxrjun/modes/UMLFactoryInterface.java diff --git a/src/main/java/com/xxrjun/modes/UMLFactory.java b/src/main/java/com/xxrjun/factories/UMLObjectFactory.java similarity index 95% rename from src/main/java/com/xxrjun/modes/UMLFactory.java rename to src/main/java/com/xxrjun/factories/UMLObjectFactory.java index 10832a7..c465aa8 100644 --- a/src/main/java/com/xxrjun/modes/UMLFactory.java +++ b/src/main/java/com/xxrjun/factories/UMLObjectFactory.java @@ -1,4 +1,4 @@ -package com.xxrjun.modes; +package com.xxrjun.factories; import com.xxrjun.components.uml.basics.UMLBasicObject; import com.xxrjun.components.uml.basics.ClassBasicObject; @@ -18,11 +18,11 @@ */ // TODO: Could be improved, but now I don't have time QQ // ref: https://java-design-patterns.com/patterns/abstract-factory/#applicability -public abstract class UMLFactory { +public abstract class UMLObjectFactory { - private static final Logger logger = LoggerFactory.getLogger(UMLFactory.class); + private static final Logger logger = LoggerFactory.getLogger(UMLObjectFactory.class); - private UMLFactory() { + private UMLObjectFactory() { throw new IllegalStateException("Utility class"); } diff --git a/src/main/java/com/xxrjun/modes/CreateBasicUMLObject.java b/src/main/java/com/xxrjun/modes/CreateBasicUMLObject.java index 8f2c8a6..bc9f4a2 100644 --- a/src/main/java/com/xxrjun/modes/CreateBasicUMLObject.java +++ b/src/main/java/com/xxrjun/modes/CreateBasicUMLObject.java @@ -2,6 +2,7 @@ import com.xxrjun.components.uml.basics.UMLBasicObject; import com.xxrjun.enums.UMLObjectTypes; +import com.xxrjun.factories.UMLObjectFactory; import java.awt.event.MouseEvent; @@ -23,7 +24,7 @@ public CreateBasicUMLObject(UMLObjectTypes objectType) { @Override public void mousePressed(MouseEvent e) { - UMLBasicObject newUMLBasicObject = UMLFactory.createUMLBasicObject(objectType, e.getPoint()); + UMLBasicObject newUMLBasicObject = UMLObjectFactory.createUMLBasicObject(objectType, e.getPoint()); canvas.addUMLObject(newUMLBasicObject); canvas.repaint(); } diff --git a/src/main/java/com/xxrjun/modes/CreateUMLConnectionLine.java b/src/main/java/com/xxrjun/modes/CreateUMLConnectionLine.java index e90b501..05f9baf 100644 --- a/src/main/java/com/xxrjun/modes/CreateUMLConnectionLine.java +++ b/src/main/java/com/xxrjun/modes/CreateUMLConnectionLine.java @@ -5,6 +5,7 @@ import com.xxrjun.components.uml.basics.UMLBasicObject; import com.xxrjun.components.uml.connectionlines.UMLConnectionLine; import com.xxrjun.enums.UMLObjectTypes; +import com.xxrjun.factories.UMLObjectFactory; import java.awt.*; import java.awt.event.MouseEvent; @@ -62,7 +63,7 @@ public void mouseReleased(MouseEvent e) { if (endPoint != null && startPoint != null) { // Create the connection line - UMLConnectionLine newConnectionLine = UMLFactory.createUMLConnectionLine(lineType, startPoint, endPoint); + UMLConnectionLine newConnectionLine = UMLObjectFactory.createUMLConnectionLine(lineType, startPoint, endPoint); canvas.addUMLObject(newConnectionLine); // Set port for line @@ -87,7 +88,7 @@ public void mouseReleased(MouseEvent e) { public void mouseDragged(MouseEvent e) { // Display temporary dragged line if (startPoint != null) { - UMLConnectionLine tmpConnectionLine = UMLFactory.createUMLConnectionLine(lineType, startPoint, e.getPoint()); + UMLConnectionLine tmpConnectionLine = UMLObjectFactory.createUMLConnectionLine(lineType, startPoint, e.getPoint()); canvas.setTmpConnectionLine(tmpConnectionLine); canvas.repaint(); } diff --git a/src/main/java/com/xxrjun/modes/UMLFactoryInterface.java b/src/main/java/com/xxrjun/modes/UMLFactoryInterface.java deleted file mode 100644 index 80e370a..0000000 --- a/src/main/java/com/xxrjun/modes/UMLFactoryInterface.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.xxrjun.modes; - -import com.xxrjun.components.uml.basics.UMLBasicObject; - -/** - * The interface Uml factory interface. - */ -public interface UMLFactoryInterface { - /** - * Create uml object uml basic object. - * - * @return the uml basic object - */ - UMLBasicObject createUMLObject(); -}