From a541fbdc8812337de120aad3792a2033a5dd7afe Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期四, 25 十二月 2025 12:23:01 +0800
Subject: [PATCH] 优化了首页

---
 src/lujing/MowingPathGenerationPage.java |  121 ++++++++++++++++++++++++++++-----------
 1 files changed, 86 insertions(+), 35 deletions(-)

diff --git a/src/lujing/MowingPathGenerationPage.java b/src/lujing/MowingPathGenerationPage.java
index de7c608..bbbe001 100644
--- a/src/lujing/MowingPathGenerationPage.java
+++ b/src/lujing/MowingPathGenerationPage.java
@@ -125,32 +125,65 @@
         
         // 鍦板潡杈圭晫
         boundaryArea = createInfoTextArea(boundaryValue != null ? boundaryValue : "", true, 6);
-        contentPanel.add(createTextAreaSection("鍦板潡杈圭晫", boundaryArea));
+        String boundaryTitle = "鍦板潡杈圭晫";
+        if (boundaryValue != null && !boundaryValue.trim().isEmpty() && !"-1".equals(boundaryValue.trim())) {
+            int boundaryCount = boundaryValue.split(";").length;
+            boundaryTitle = "鍦板潡杈圭晫 (" + boundaryCount + "鐐�)";
+        }
+        contentPanel.add(createTextAreaSection(boundaryTitle, boundaryArea));
         
         // 闅滅鐗╁潗鏍�
         obstacleArea = createInfoTextArea(obstacleValue != null ? obstacleValue : "", true, 6);
-        contentPanel.add(createTextAreaSection("闅滅鐗╁潗鏍�", obstacleArea));
+        String obstacleTitle = "闅滅鐗╁潗鏍�";
+        if (obstacleValue != null && !obstacleValue.trim().isEmpty() && !"-1".equals(obstacleValue.trim())) {
+            // 闅滅鐗╁潗鏍囨牸寮忓彲鑳芥槸绌烘牸鍒嗛殧鐨勫涓殰纰嶇墿锛屾瘡涓殰纰嶇墿鐢ㄥ垎鍙峰垎闅斿潗鏍囩偣
+            // 璁$畻鎵�鏈夐殰纰嶇墿鐨勬�诲潗鏍囩偣鏁�
+            String[] obstacles = obstacleValue.trim().split("\\s+");
+            int totalObstaclePoints = 0;
+            for (String obstacle : obstacles) {
+                if (obstacle != null && !obstacle.trim().isEmpty()) {
+                    totalObstaclePoints += obstacle.split(";").length;
+                }
+            }
+            if (totalObstaclePoints > 0) {
+                obstacleTitle = "闅滅鐗╁潗鏍� (" + totalObstaclePoints + "鐐�)";
+            }
+        }
+        contentPanel.add(createTextAreaSection(obstacleTitle, obstacleArea));
         
         // 鍓茶崏瀹藉害
         widthField = createInfoTextField(widthValue != null ? widthValue : "", true);
-        contentPanel.add(createTextFieldSection("鍓茶崏瀹藉害 (鍘樼背)", widthField));
+        contentPanel.add(createTextFieldSection("鍓茶崏瀹藉害 (cm)", widthField));
         
         // 鍓茶崏瀹夊叏璺濈锛堝彧璇绘樉绀猴級
+        // 浼樺厛浠嶥ikuai瀵硅薄鑾峰彇锛屽鏋淒ikuai涓病鏈夛紝鍐嶄粠Device鑾峰彇
         String displaySafetyDistance = "鏈缃�";
-        Device device = Device.getActiveDevice();
-        if (device != null) {
-            String safetyDistanceValue = device.getMowingSafetyDistance();
-            if (safetyDistanceValue != null && !"-1".equals(safetyDistanceValue) && !safetyDistanceValue.trim().isEmpty()) {
-                try {
-                    double distanceMeters = Double.parseDouble(safetyDistanceValue.trim());
-                    // 濡傛灉鍊煎ぇ浜�100锛岃涓烘槸鍘樼背锛岄渶瑕佽浆鎹负绫�
-                    if (distanceMeters > 100) {
-                        distanceMeters = distanceMeters / 100.0;
-                    }
-                    displaySafetyDistance = String.format("%.2f绫�", distanceMeters);
-                } catch (NumberFormatException e) {
-                    displaySafetyDistance = "鏈缃�";
+        String safetyDistanceValue = null;
+        
+        // 棣栧厛灏濊瘯浠嶥ikuai瀵硅薄鑾峰彇
+        if (dikuai != null) {
+            safetyDistanceValue = dikuai.getMowingSafetyDistance();
+        }
+        
+        // 濡傛灉Dikuai涓病鏈夛紝浠嶥evice鑾峰彇
+        if ((safetyDistanceValue == null || "-1".equals(safetyDistanceValue) || safetyDistanceValue.trim().isEmpty())) {
+            Device device = Device.getActiveDevice();
+            if (device != null) {
+                safetyDistanceValue = device.getMowingSafetyDistance();
+            }
+        }
+        
+        // 鏍煎紡鍖栨樉绀哄��
+        if (safetyDistanceValue != null && !"-1".equals(safetyDistanceValue) && !safetyDistanceValue.trim().isEmpty()) {
+            try {
+                double distanceMeters = Double.parseDouble(safetyDistanceValue.trim());
+                // 濡傛灉鍊煎ぇ浜�100锛岃涓烘槸鍘樼背锛岄渶瑕佽浆鎹负绫�
+                if (distanceMeters > 100) {
+                    distanceMeters = distanceMeters / 100.0;
                 }
+                displaySafetyDistance = String.format(Locale.US, "%.2fm", distanceMeters);
+            } catch (NumberFormatException e) {
+                displaySafetyDistance = "鏈缃�";
             }
         }
         contentPanel.add(createInfoValueSection("鍓茶崏瀹夊叏璺濈", displaySafetyDistance));
@@ -162,7 +195,12 @@
         String existingPath = prepareCoordinateForEditor(dikuai.getPlannedPath());
         String pathSeed = initialGeneratedPath != null ? initialGeneratedPath : existingPath;
         pathArea = createInfoTextArea(pathSeed != null ? pathSeed : "", true, 10);
-        contentPanel.add(createTextAreaSection("鍓茶崏璺緞鍧愭爣", pathArea));
+        String pathTitle = "鍓茶崏璺緞鍧愭爣";
+        if (pathSeed != null && !pathSeed.trim().isEmpty() && !"-1".equals(pathSeed.trim())) {
+            int pathCount = pathSeed.split(";").length;
+            pathTitle = "鍓茶崏璺緞鍧愭爣 (" + pathCount + "鐐�)";
+        }
+        contentPanel.add(createTextAreaSection(pathTitle, pathArea));
         
         JScrollPane dialogScrollPane = new JScrollPane(contentPanel);
         dialogScrollPane.setBorder(BorderFactory.createEmptyBorder());
@@ -372,7 +410,7 @@
         String rawWidthInput = widthField.getText() != null ? widthField.getText().trim() : "";
         String widthSanitized = sanitizeWidthString(widthField.getText());
         if (widthSanitized == null) {
-            String message = rawWidthInput.isEmpty() ? "璇峰厛璁剧疆鍓茶崏瀹藉害(鍘樼背)" : "鍓茶崏瀹藉害鏍煎紡涓嶆纭�";
+                String message = rawWidthInput.isEmpty() ? "璇峰厛璁剧疆鍓茶崏瀹藉害(cm)" : "鍓茶崏瀹藉害鏍煎紡涓嶆纭�";
             JOptionPane.showMessageDialog(this, message, "鎻愮ず", JOptionPane.WARNING_MESSAGE);
             return;
         }
@@ -459,7 +497,7 @@
         String widthStr = sanitizeWidthString(widthCmInput);
         if (widthStr == null) {
             if (showMessages) {
-                String message = rawWidth.isEmpty() ? "璇峰厛璁剧疆鍓茶崏瀹藉害(鍘樼背)" : "鍓茶崏瀹藉害鏍煎紡涓嶆纭�";
+                String message = rawWidth.isEmpty() ? "璇峰厛璁剧疆鍓茶崏瀹藉害(cm)" : "鍓茶崏瀹藉害鏍煎紡涓嶆纭�";
                 JOptionPane.showMessageDialog(parentComponent, message, "鎻愮ず", JOptionPane.WARNING_MESSAGE);
             }
             return null;
@@ -664,25 +702,38 @@
     
     /**
      * 鑾峰彇瀹夊叏璺濈瀛楃涓诧紙绫筹級
+     * 浼樺厛浠嶥ikuai瀵硅薄鑾峰彇锛屽鏋淒ikuai涓病鏈夛紝鍐嶄粠Device鑾峰彇
      */
     private String getSafetyDistanceString() {
-        Device device = Device.getActiveDevice();
-        if (device != null) {
-            String safetyDistanceValue = device.getMowingSafetyDistance();
-            if (safetyDistanceValue != null && !"-1".equals(safetyDistanceValue) && !safetyDistanceValue.trim().isEmpty()) {
-                try {
-                    double distanceMeters = Double.parseDouble(safetyDistanceValue.trim());
-                    // 濡傛灉鍊煎ぇ浜�100锛岃涓烘槸鍘樼背锛岄渶瑕佽浆鎹负绫�
-                    if (distanceMeters > 100) {
-                        distanceMeters = distanceMeters / 100.0;
-                    }
-                    return BigDecimal.valueOf(distanceMeters)
-                        .setScale(3, RoundingMode.HALF_UP)
-                        .stripTrailingZeros()
-                        .toPlainString();
-                } catch (NumberFormatException e) {
-                    // 瑙f瀽澶辫触锛岃繑鍥瀗ull锛屼娇鐢ㄩ粯璁ゅ��
+        String safetyDistanceValue = null;
+        
+        // 棣栧厛灏濊瘯浠嶥ikuai瀵硅薄鑾峰彇
+        if (dikuai != null) {
+            safetyDistanceValue = dikuai.getMowingSafetyDistance();
+        }
+        
+        // 濡傛灉Dikuai涓病鏈夛紝浠嶥evice鑾峰彇
+        if ((safetyDistanceValue == null || "-1".equals(safetyDistanceValue) || safetyDistanceValue.trim().isEmpty())) {
+            Device device = Device.getActiveDevice();
+            if (device != null) {
+                safetyDistanceValue = device.getMowingSafetyDistance();
+            }
+        }
+        
+        // 鏍煎紡鍖栧苟杩斿洖
+        if (safetyDistanceValue != null && !"-1".equals(safetyDistanceValue) && !safetyDistanceValue.trim().isEmpty()) {
+            try {
+                double distanceMeters = Double.parseDouble(safetyDistanceValue.trim());
+                // 濡傛灉鍊煎ぇ浜�100锛岃涓烘槸鍘樼背锛岄渶瑕佽浆鎹负绫�
+                if (distanceMeters > 100) {
+                    distanceMeters = distanceMeters / 100.0;
                 }
+                return BigDecimal.valueOf(distanceMeters)
+                    .setScale(3, RoundingMode.HALF_UP)
+                    .stripTrailingZeros()
+                    .toPlainString();
+            } catch (NumberFormatException e) {
+                // 瑙f瀽澶辫触锛岃繑鍥瀗ull锛屼娇鐢ㄩ粯璁ゅ��
             }
         }
         return null;

--
Gitblit v1.10.0