From 1cf1ecbc75c6d14b40efb3161e7db0b8b64f7de2 Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期三, 17 十二月 2025 12:05:27 +0800
Subject: [PATCH] 新增有障碍物的路径规划算法和优化没有障碍物的路径算法
---
src/zhangaiwu/AddDikuai.java | 45 ++++++++++++++++++++++++++++-----------------
1 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/src/zhangaiwu/AddDikuai.java b/src/zhangaiwu/AddDikuai.java
index 263b539..eff3e45 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;
/**
* 鏂板鍦板潡瀵硅瘽妗� - 澶氭楠よ〃鍗曡璁�
@@ -741,8 +743,9 @@
if (!optionPanel.isEnabled()) {
return;
}
- selectDrawingOption(optionPanel, type);
- startEndDrawingBtn.setEnabled(true); // 閫夋嫨鍚庡惎鐢ㄦ寜閽�
+ if (selectDrawingOption(optionPanel, type, true)) {
+ startEndDrawingBtn.setEnabled(true); // 閫夋嫨鍚庡惎鐢ㄦ寜閽�
+ }
}
@Override
@@ -764,7 +767,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 +785,7 @@
((JLabel) oldTitle).setForeground(TEXT_COLOR);
}
}
-
+
// 璁剧疆鏂扮殑閫変腑鐘舵��
optionPanel.setBorder(BorderFactory.createLineBorder(PRIMARY_COLOR, 3));
optionPanel.setBackground(PRIMARY_LIGHT);
@@ -783,9 +794,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 +1277,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 +1292,7 @@
button.setBackground(PRIMARY_DARK);
}
}
-
+
@Override
public void mouseExited(MouseEvent e) {
if (button.isEnabled()) {
@@ -1287,7 +1300,7 @@
}
}
});
-
+
return button;
}
@@ -1335,15 +1348,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);
@@ -1951,7 +1962,7 @@
if (method != null) {
JPanel panel = drawingOptionPanels.get(method);
if (panel != null) {
- selectDrawingOption(panel, method);
+ selectDrawingOption(panel, method, false);
}
}
--
Gitblit v1.10.0