From dc9dce0555beb85d1262893fd5d56747d6a83855 Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期五, 19 十二月 2025 11:48:37 +0800
Subject: [PATCH] 新增了导航预览功能
---
src/zhuye/Shouye.java | 123 +++++++++++++++++++++++++++++++++++++++--
1 files changed, 117 insertions(+), 6 deletions(-)
diff --git a/src/zhuye/Shouye.java b/src/zhuye/Shouye.java
index 56c4e39..b588d83 100644
--- a/src/zhuye/Shouye.java
+++ b/src/zhuye/Shouye.java
@@ -80,6 +80,8 @@
private JLabel statusLabel;
private JLabel speedLabel; // 閫熷害鏄剧ず鏍囩
private JLabel areaNameLabel;
+ private JLabel drawingBoundaryLabel; // 姝e湪缁樺埗杈圭晫鐘舵�佹爣绛�
+ private JLabel navigationPreviewLabel; // 瀵艰埅棰勮妯″紡鏍囩
// 杈圭晫璀﹀憡鐩稿叧
private Timer boundaryWarningTimer; // 杈圭晫璀﹀憡妫�鏌ュ畾鏃跺櫒
@@ -453,10 +455,18 @@
}
mapRenderer.setIdleTrailDurationSeconds(durationSeconds);
- // 搴旂敤杈圭晫璺濈鏄剧ず璁剧疆
+ // 搴旂敤杈圭晫璺濈鏄剧ず璁剧疆鍜屾祴閲忔ā寮忚缃�
Setsys setsys = new Setsys();
setsys.initializeFromProperties();
mapRenderer.setBoundaryLengthVisible(setsys.isBoundaryLengthVisible());
+ // 鍒濆鍖栨祴閲忔ā寮�
+ boolean measurementEnabled = setsys.isMeasurementModeEnabled();
+ mapRenderer.setMeasurementMode(measurementEnabled);
+ if (measurementEnabled) {
+ celiangmoshi.start();
+ } else {
+ celiangmoshi.stop();
+ }
}
private void createHeaderPanel() {
@@ -503,14 +513,28 @@
// 娣诲姞閫熷害鏄剧ず鏍囩
speedLabel = new JLabel("");
- speedLabel.setFont(new Font("寰蒋闆呴粦", Font.PLAIN, 12));
- speedLabel.setForeground(Color.GRAY);
- speedLabel.setVisible(false); // 榛樿闅愯棌
+ speedLabel.setFont(new Font("寰蒋闆呴粦", Font.PLAIN, 12));
+ speedLabel.setForeground(Color.GRAY);
+ speedLabel.setVisible(false); // 榛樿闅愯棌
+
+ // 姝e湪缁樺埗杈圭晫鐘舵�佹爣绛�
+ drawingBoundaryLabel = new JLabel("姝e湪缁樺埗杈圭晫");
+ drawingBoundaryLabel.setFont(new Font("寰蒋闆呴粦", Font.PLAIN, 14));
+ drawingBoundaryLabel.setForeground(new Color(46, 139, 87));
+ drawingBoundaryLabel.setVisible(false); // 榛樿闅愯棌
+
+ // 瀵艰埅棰勮妯″紡鏍囩
+ navigationPreviewLabel = new JLabel("褰撳墠瀵艰埅棰勮妯″紡");
+ navigationPreviewLabel.setFont(new Font("寰蒋闆呴粦", Font.PLAIN, 14));
+ navigationPreviewLabel.setForeground(new Color(46, 139, 87));
+ navigationPreviewLabel.setVisible(false); // 榛樿闅愯棌
// 灏嗙姸鎬佷笌閫熷害鏀惧湪鍚屼竴琛岋紝鏄剧ず鍦ㄥ湴鍧楀悕绉颁笅闈竴琛�
JPanel statusRow = new JPanel(new FlowLayout(FlowLayout.LEFT, 8, 0));
statusRow.setOpaque(false);
statusRow.add(statusLabel);
+ statusRow.add(drawingBoundaryLabel);
+ statusRow.add(navigationPreviewLabel);
statusRow.add(speedLabel);
// 宸﹀榻愭爣绛句笌鐘舵�佽锛岀‘淇濆畠浠湪 BoxLayout 涓潬宸︽樉绀�
@@ -1146,7 +1170,7 @@
if (parentWindow != null) {
// 浣跨敤 yaokong 鍖呬腑鐨� RemoteControlDialog 瀹炵幇
remoteDialog = new yaokong.RemoteControlDialog(this, THEME_COLOR, speedLabel);
- } else {
+ } else {/* */
remoteDialog = new yaokong.RemoteControlDialog((JFrame) null, THEME_COLOR, speedLabel);
}
}
@@ -2785,6 +2809,11 @@
circleDialogMode = false;
hideCircleGuidancePanel();
enterDrawingControlMode();
+
+ // 鏄剧ず"姝e湪缁樺埗杈圭晫"鎻愮ず
+ if (drawingBoundaryLabel != null) {
+ drawingBoundaryLabel.setVisible(true);
+ }
boolean enableCircleGuidance = drawingShape != null
&& "circle".equalsIgnoreCase(drawingShape.trim());
@@ -3260,7 +3289,34 @@
if (latest == null) {
return false;
}
- return lastCapturedCoordinate == null || latest != lastCapturedCoordinate;
+
+ // 妫�鏌ユ槸鍚︽湁鏂扮殑鍧愭爣锛堜笌涓婃閲囬泦鐨勪笉鍚岋級
+ if (lastCapturedCoordinate != null && latest == lastCapturedCoordinate) {
+ return false;
+ }
+
+ // 妫�鏌ュ畾浣嶇姸鎬佹槸鍚︿负4锛堝浐瀹氳В锛�
+ // 褰撻�夋嫨鍓茶崏鏈虹粯鍒跺渾褰㈤殰纰嶇墿鏃讹紝闇�瑕佹鏌ヨ澶囩紪鍙峰拰瀹氫綅鐘舵��
+ Device device = Device.getGecaoji();
+ if (device == null) {
+ return false;
+ }
+
+ String positioningStatus = device.getPositioningStatus();
+ if (positioningStatus == null || !"4".equals(positioningStatus.trim())) {
+ return false;
+ }
+
+ // 妫�鏌ヨ澶囩紪鍙锋槸鍚﹀尮閰嶅壊鑽夋満缂栧彿
+ String mowerId = Setsys.getPropertyValue("mowerId");
+ String deviceId = device.getMowerNumber();
+ if (mowerId != null && !mowerId.trim().isEmpty()) {
+ if (deviceId == null || !mowerId.trim().equals(deviceId.trim())) {
+ return false;
+ }
+ }
+
+ return true;
}
private void applyCirclePrimaryButtonState(boolean enabled) {
@@ -3462,6 +3518,12 @@
activeBoundaryMode = BoundaryCaptureMode.NONE;
}
endDrawingCallback = null;
+
+ // 闅愯棌"姝e湪缁樺埗杈圭晫"鎻愮ず
+ if (drawingBoundaryLabel != null) {
+ drawingBoundaryLabel.setVisible(false);
+ }
+
visualizationPanel.revalidate();
visualizationPanel.repaint();
setHandheldMowerIconActive(false);
@@ -3607,6 +3669,55 @@
return mapRenderer;
}
+ /**
+ * 鑾峰彇鎺у埗闈㈡澘锛堢敤浜庡鑸瑙堟椂鏇挎崲鎸夐挳锛�
+ * @return 鎺у埗闈㈡澘
+ */
+ public JPanel getControlPanel() {
+ return controlPanel;
+ }
+
+ /**
+ * 鑾峰彇寮�濮嬫寜閽紙鐢ㄤ簬瀵艰埅棰勮鏃堕殣钘忥級
+ * @return 寮�濮嬫寜閽�
+ */
+ public JButton getStartButton() {
+ return startBtn;
+ }
+
+ /**
+ * 鑾峰彇缁撴潫鎸夐挳锛堢敤浜庡鑸瑙堟椂闅愯棌锛�
+ * @return 缁撴潫鎸夐挳
+ */
+ public JButton getStopButton() {
+ return stopBtn;
+ }
+
+ /**
+ * 璁剧疆瀵艰埅棰勮妯″紡鏍囩鐨勬樉绀虹姸鎬�
+ * @param visible 鏄惁鏄剧ず
+ */
+ public void setNavigationPreviewLabelVisible(boolean visible) {
+ if (navigationPreviewLabel != null) {
+ navigationPreviewLabel.setVisible(visible);
+ }
+ }
+
+ /**
+ * 鑾峰彇鍙鍖栭潰鏉垮疄渚�
+ */
+ public JPanel getVisualizationPanel() {
+ return visualizationPanel;
+ }
+
+ /**
+ * 鑾峰彇涓诲唴瀹归潰鏉垮疄渚嬶紙鐢ㄤ簬娣诲姞娴姩鎸夐挳锛�
+ */
+ public JPanel getMainContentPanel() {
+ return mainContentPanel;
+ }
+
+
public void updateCurrentAreaName(String areaName) {
if (areaNameLabel == null) {
return;
--
Gitblit v1.10.0