From b315a6943e6c0d6bdf0d5f7565c570d719154d6c Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期三, 17 十二月 2025 14:56:58 +0800
Subject: [PATCH] 新增了障碍物管理页面
---
src/zhuye/Shouye.java | 42 ++++++++++++++++++++++++++++--------------
1 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/src/zhuye/Shouye.java b/src/zhuye/Shouye.java
index 7c20720..e76f5c7 100644
--- a/src/zhuye/Shouye.java
+++ b/src/zhuye/Shouye.java
@@ -11,6 +11,8 @@
import java.awt.event.*;
import chuankou.dellmessage;
+import chuankou.sendmessage;
+import chuankou.SerialPortService;
import dikuai.Dikuai;
import dikuai.Dikuaiguanli;
import dikuai.addzhangaiwu;
@@ -287,6 +289,8 @@
// 杈圭晫妫�鏌ュ畾鏃跺櫒锛氭瘡500ms妫�鏌ヤ竴娆″壊鑽夋満鏄惁鍦ㄨ竟鐣屽唴
boundaryWarningTimer = new Timer(500, e -> {
checkMowerBoundaryStatus();
+ // 鍚屾椂鏇存柊钃濈墮鍥炬爣鐘舵��
+ updateBluetoothButtonIcon();
});
boundaryWarningTimer.setInitialDelay(0);
boundaryWarningTimer.start();
@@ -316,7 +320,7 @@
}
// 鍏抽棴妯″紡鏃朵笉闇�瑕佸仛浠讳綍鎿嶄綔锛岀敤鎴峰凡缁忓彲浠ヨ嚜鐢辩Щ鍔ㄥ湴鍥�
- // 鏇存柊宸ュ叿鎻愮ず
+ // 鏇存柊鍥炬爣鏄剧ず锛堥噸缁樹互鍒囨崲鍥炬爣锛�
if (visualizationPanel != null) {
visualizationPanel.repaint();
}
@@ -560,14 +564,16 @@
// 鍙鍖栧尯鍩� - 浣跨敤MapRenderer杩涜缁樺埗
visualizationPanel = new JPanel() {
- private ImageIcon gecaojiIcon = null;
+ private ImageIcon gecaojiIcon1 = null; // 榛樿鍥炬爣
+ private ImageIcon gecaojiIcon2 = null; // 浠ュ壊鑽夋満涓轰腑蹇冩ā寮忓浘鏍�
private static final int GECAOJI_ICON_X = 37;
private static final int GECAOJI_ICON_Y = 10;
private static final int GECAOJI_ICON_SIZE = 20;
{
// 鍔犺浇鍓茶崏鏈哄浘鏍囷紝澶у皬20x20鍍忕礌
- gecaojiIcon = loadScaledIcon("image/gecaoji.png", GECAOJI_ICON_SIZE, GECAOJI_ICON_SIZE);
+ gecaojiIcon1 = loadScaledIcon("image/gecaojishijiao1.png", GECAOJI_ICON_SIZE, GECAOJI_ICON_SIZE);
+ gecaojiIcon2 = loadScaledIcon("image/gecaojishijiao2.png", GECAOJI_ICON_SIZE, GECAOJI_ICON_SIZE);
}
/**
@@ -603,11 +609,15 @@
if (isMowerOutsideBoundary && warningIconVisible) {
// 缁樺埗绾㈣壊涓夎褰㈣鍛婂浘鏍囷紙甯﹀徆鍙凤級
drawWarningIcon(g, GECAOJI_ICON_X, GECAOJI_ICON_Y, GECAOJI_ICON_SIZE);
- } else if (gecaojiIcon != null) {
- // 缁樺埗姝e父鐨勫壊鑽夋満鍥炬爣
- // 姘村钩鏂瑰悜涓庨�熷害鎸囩ず鍣ㄥ榻愶紙x=37锛�
- // 鍨傜洿鏂瑰悜涓庡崼鏄熺姸鎬佸浘鏍囧榻愶紙y=10锛岄�熷害鎸囩ず鍣ㄩ潰鏉块《閮ㄨ竟璺�10鍍忕礌锛屼娇鍥炬爣涓績瀵归綈锛�
- g.drawImage(gecaojiIcon.getImage(), GECAOJI_ICON_X, GECAOJI_ICON_Y, null);
+ } else {
+ // 鏍规嵁妯″紡閫夋嫨涓嶅悓鐨勫浘鏍�
+ ImageIcon iconToDraw = centerOnMowerMode ? gecaojiIcon2 : gecaojiIcon1;
+ if (iconToDraw != null) {
+ // 缁樺埗鍓茶崏鏈哄浘鏍�
+ // 姘村钩鏂瑰悜涓庨�熷害鎸囩ず鍣ㄥ榻愶紙x=37锛�
+ // 鍨傜洿鏂瑰悜涓庡崼鏄熺姸鎬佸浘鏍囧榻愶紙y=10锛岄�熷害鎸囩ず鍣ㄩ潰鏉块《閮ㄨ竟璺�10鍍忕礌锛屼娇鍥炬爣涓績瀵归綈锛�
+ g.drawImage(iconToDraw.getImage(), GECAOJI_ICON_X, GECAOJI_ICON_Y, null);
+ }
}
}
@@ -957,12 +967,14 @@
}
});
ensureBluetoothIconsLoaded();
- bluetoothConnected = Bluelink.isConnected();
- ImageIcon initialIcon = bluetoothConnected ? bluetoothLinkedIcon : bluetoothIcon;
+ // 鏍规嵁涓插彛杩炴帴鐘舵�佹樉绀哄浘鏍�
+ SerialPortService service = sendmessage.getActiveService();
+ boolean serialConnected = (service != null && service.isOpen());
+ ImageIcon initialIcon = serialConnected ? bluetoothLinkedIcon : bluetoothIcon;
if (initialIcon != null) {
button.setIcon(initialIcon);
} else {
- button.setText(bluetoothConnected ? "宸茶繛" : "钃濈墮");
+ button.setText(serialConnected ? "宸茶繛" : "钃濈墮");
}
return button;
}
@@ -1862,13 +1874,15 @@
return;
}
ensureBluetoothIconsLoaded();
- bluetoothConnected = Bluelink.isConnected();
- ImageIcon icon = bluetoothConnected ? bluetoothLinkedIcon : bluetoothIcon;
+ // 鏍规嵁涓插彛杩炴帴鐘舵�佹樉绀哄浘鏍�
+ SerialPortService service = sendmessage.getActiveService();
+ boolean serialConnected = (service != null && service.isOpen());
+ ImageIcon icon = serialConnected ? bluetoothLinkedIcon : bluetoothIcon;
if (icon != null) {
bluetoothBtn.setIcon(icon);
bluetoothBtn.setText(null);
} else {
- bluetoothBtn.setText(bluetoothConnected ? "宸茶繛" : "钃濈墮");
+ bluetoothBtn.setText(serialConnected ? "宸茶繛" : "钃濈墮");
}
}
--
Gitblit v1.10.0