From 8ce07ce9a4034fdc959d280dd38ecb3e05cbe6e1 Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期三, 17 十二月 2025 16:40:11 +0800
Subject: [PATCH] 重新设计了障碍物的绘制逻辑

---
 src/zhangaiwu/AddDikuai.java |   53 ++++++++++++++++++++++++++++-------------------------
 1 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/src/zhangaiwu/AddDikuai.java b/src/zhangaiwu/AddDikuai.java
index 263b539..02ac96d 100644
--- a/src/zhangaiwu/AddDikuai.java
+++ b/src/zhangaiwu/AddDikuai.java
@@ -27,10 +27,12 @@
 import dikuai.Dikuaiguanli;
 import bianjie.bianjieguihua2;
 import lujing.Lunjingguihua;
+import set.Setsys;
 import ui.UIConfig;
 import zhuye.MowerLocationData;
 import zhuye.Shouye;
 import zhuye.Coordinate;
+import zhuye.buttonset;
 
 /**
  * 鏂板鍦板潡瀵硅瘽妗� - 澶氭楠よ〃鍗曡璁�
@@ -290,10 +292,6 @@
         formGroup.add(areaNameField);
         formGroup.add(Box.createRigidArea(new Dimension(0, 8)));
         formGroup.add(hintLabel);
-
-    formGroup.add(Box.createRigidArea(new Dimension(0, 20)));
-    JPanel obstacleSection = createObstacleSummarySection();
-    formGroup.add(obstacleSection);
         
         stepPanel.add(formGroup);
         stepPanel.add(Box.createVerticalGlue());
@@ -741,8 +739,9 @@
                 if (!optionPanel.isEnabled()) {
                     return;
                 }
-                selectDrawingOption(optionPanel, type);
-                startEndDrawingBtn.setEnabled(true); // 閫夋嫨鍚庡惎鐢ㄦ寜閽�
+                if (selectDrawingOption(optionPanel, type, true)) {
+                    startEndDrawingBtn.setEnabled(true); // 閫夋嫨鍚庡惎鐢ㄦ寜閽�
+                }
             }
             
             @Override
@@ -764,7 +763,15 @@
         return optionPanel;
     }
     
-    private void selectDrawingOption(JPanel optionPanel, String type) {
+    private boolean selectDrawingOption(JPanel optionPanel, String type, boolean userTriggered) {
+        if (optionPanel == null) {
+            return false;
+        }
+        if (userTriggered && "handheld".equalsIgnoreCase(type) && !hasConfiguredHandheldMarker()) {
+            JOptionPane.showMessageDialog(this, "璇峰厛娣诲姞渚挎惡鎵撶偣鍣ㄧ紪鍙�", "鎻愮ず", JOptionPane.WARNING_MESSAGE);
+            return false;
+        }
+
         // 閲嶇疆涔嬪墠閫変腑鐨勯�夐」
         if (selectedOptionPanel != null) {
             selectedOptionPanel.setBorder(BorderFactory.createLineBorder(BORDER_COLOR, 2));
@@ -774,7 +781,7 @@
                 ((JLabel) oldTitle).setForeground(TEXT_COLOR);
             }
         }
-        
+
         // 璁剧疆鏂扮殑閫変腑鐘舵��
         optionPanel.setBorder(BorderFactory.createLineBorder(PRIMARY_COLOR, 3));
         optionPanel.setBackground(PRIMARY_LIGHT);
@@ -783,9 +790,15 @@
             ((JLabel) titleObj).setForeground(PRIMARY_COLOR);
         }
         selectedOptionPanel = optionPanel;
-        
+
         // 淇濆瓨閫夋嫨
         dikuaiData.put("drawingMethod", type);
+        return true;
+    }
+
+    private boolean hasConfiguredHandheldMarker() {
+        String handheldId = Setsys.getPropertyValue("handheldMarkerId");
+        return handheldId != null && !handheldId.trim().isEmpty();
     }
     
     private void toggleDrawing() {
@@ -1260,18 +1273,14 @@
     }
     
     private JButton createPrimaryButton(String text, int fontSize) {
-        JButton button = new JButton(text);
+        JButton button = buttonset.createStyledButton(text, PRIMARY_COLOR);
         button.setFont(new Font("寰蒋闆呴粦", Font.BOLD, fontSize));
-        button.setBackground(PRIMARY_COLOR);
-        button.setForeground(WHITE);
         button.setBorder(BorderFactory.createCompoundBorder(
             BorderFactory.createLineBorder(PRIMARY_DARK, 2),
             BorderFactory.createEmptyBorder(12, 25, 12, 25)
         ));
-        button.setFocusPainted(false);
         button.setCursor(new Cursor(Cursor.HAND_CURSOR));
-        
-        // 鎸夐挳鎮仠鏁堟灉
+
         button.addMouseListener(new MouseAdapter() {
             @Override
             public void mouseEntered(MouseEvent e) {
@@ -1279,7 +1288,7 @@
                     button.setBackground(PRIMARY_DARK);
                 }
             }
-            
+
             @Override
             public void mouseExited(MouseEvent e) {
                 if (button.isEnabled()) {
@@ -1287,7 +1296,7 @@
                 }
             }
         });
-        
+
         return button;
     }
 
@@ -1335,15 +1344,13 @@
         buttonPanel.setBackground(WHITE);
         buttonPanel.setBorder(BorderFactory.createEmptyBorder(20, 0, 0, 0));
 
-        prevButton = new JButton("涓婁竴姝�");
+        prevButton = buttonset.createStyledButton("涓婁竴姝�", MEDIUM_GRAY);
         prevButton.setFont(new Font("寰蒋闆呴粦", Font.BOLD, 16));
-        prevButton.setBackground(MEDIUM_GRAY);
         prevButton.setForeground(TEXT_COLOR);
         prevButton.setBorder(BorderFactory.createCompoundBorder(
             BorderFactory.createLineBorder(BORDER_COLOR, 2),
             BorderFactory.createEmptyBorder(10, 25, 10, 25)
         ));
-        prevButton.setFocusPainted(false);
         prevButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
 
         nextButton = createPrimaryButton("涓嬩竴姝�", 16);
@@ -1647,10 +1654,6 @@
     private void showStep(int step) {
         currentStep = step;
         cardLayout.show(stepsPanel, "step" + step);
-        
-        if (step == 1) {
-            updateObstacleSummary();
-        }
 
         // 鏇存柊鎸夐挳鐘舵��
         updateButtonState(step);
@@ -1951,7 +1954,7 @@
         if (method != null) {
             JPanel panel = drawingOptionPanels.get(method);
             if (panel != null) {
-                selectDrawingOption(panel, method);
+                selectDrawingOption(panel, method, false);
             }
         }
 

--
Gitblit v1.10.0