From 5d6d890cfd10466d5d14ff5177adcc888baaa0e4 Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期三, 17 十二月 2025 17:46:13 +0800
Subject: [PATCH] 新增了边界距离显示优化了设置页面布局
---
src/zhuye/MapRenderer.java | 42 +++++++++++++++++++++++++++++++++---------
1 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/src/zhuye/MapRenderer.java b/src/zhuye/MapRenderer.java
index b83f3c8..78bbf86 100644
--- a/src/zhuye/MapRenderer.java
+++ b/src/zhuye/MapRenderer.java
@@ -74,6 +74,7 @@
private String boundaryName;
private boolean boundaryPointsVisible;
private boolean obstaclePointsVisible;
+ private boolean boundaryLengthVisible = false; // 鏄惁鏄剧ず杈圭晫璺濈锛岄粯璁ゅ叧闂�
private double boundaryPointSizeScale = 1.0d;
private boolean previewSizingEnabled;
private String currentBoundaryLandNumber;
@@ -381,7 +382,8 @@
Obstacledraw.drawObstacles(g2d, currentObstacles, scale, selectedObstacleName);
}
- if (boundaryPointsVisible && hasBoundary) {
+ // 鏄剧ず杈圭晫鐐癸紙濡傛灉杈圭晫鐐瑰彲瑙侊紝鎴栬�呰竟鐣岃窛绂诲彲瑙侊級
+ if ((boundaryPointsVisible || boundaryLengthVisible) && hasBoundary) {
// 棰勮妯″紡涓嬫樉绀哄簭鍙�
if (previewSizingEnabled) {
drawBoundaryPointsWithNumbers(g2d, currentBoundary, scale);
@@ -397,7 +399,7 @@
);
}
}
-
+
// 缁樺埗闅滅鐗╁潗鏍囩偣锛堝甫搴忓彿锛�
if (obstaclePointsVisible && hasObstacles) {
drawObstaclePointsWithNumbers(g2d, currentObstacles, scale);
@@ -413,9 +415,18 @@
drawMower(g2d);
+ // 淇濆瓨褰撳墠鍙樻崲锛堝寘鍚鍥惧彉鎹級鐢ㄤ簬鍧愭爣杞崲
+ AffineTransform currentTransformForLength = g2d.getTransform();
+
// 鎭㈠鍘熷鍙樻崲
g2d.setTransform(originalTransform);
+ // 缁樺埗杈圭晫闀垮害锛堝鏋滃惎鐢級- 鍦ㄦ仮澶嶅師濮嬪彉鎹㈠悗缁樺埗
+ if (boundaryLengthVisible && hasBoundary) {
+ bianjie.BoundaryLengthDrawer.drawBoundaryLengths(g2d, currentBoundary, scale,
+ visualizationPanel.getWidth(), visualizationPanel.getHeight(), translateX, translateY);
+ }
+
// 缁樺埗瑙嗗浘淇℃伅
drawViewInfo(g2d);
}
@@ -1690,14 +1701,10 @@
return;
}
- // 璁剧疆鐐圭殑澶у皬锛堥殢缂╂斁鍙樺寲锛�
+ // 璁剧疆鐐圭殑澶у皬锛堜笌杈圭晫绾垮搴︿竴鑷达級
+ // 杈圭晫绾垮搴︼細3 / Math.max(0.5, scale)
double scaleFactor = Math.max(0.5, scale);
- double clampedScale = boundaryPointSizeScale * (previewSizingEnabled ? PREVIEW_BOUNDARY_MARKER_SCALE : 1.0d);
- if (!Double.isFinite(clampedScale) || clampedScale <= 0.0d) {
- clampedScale = 1.0d;
- }
- double minimumDiameter = clampedScale < 1.0 ? 0.5 : 1.0;
- double markerDiameter = Math.max(minimumDiameter, (10.0 / scaleFactor) * 0.2 * clampedScale);
+ double markerDiameter = 3.0 / scaleFactor; // 涓庤竟鐣岀嚎瀹藉害涓�鑷�
double markerRadius = markerDiameter / 2.0;
// 璁剧疆瀛椾綋锛堜笌闅滅鐗╁簭鍙蜂竴鑷达紝涓嶉殢缂╂斁鍙樺寲锛�
@@ -2370,6 +2377,23 @@
this.obstaclePointsVisible = visible;
visualizationPanel.repaint();
}
+
+ /**
+ * 璁剧疆鏄惁鏄剧ず杈圭晫璺濈
+ */
+ public void setBoundaryLengthVisible(boolean visible) {
+ boundaryLengthVisible = visible;
+ if (visualizationPanel != null) {
+ visualizationPanel.repaint();
+ }
+ }
+
+ /**
+ * 鑾峰彇鏄惁鏄剧ず杈圭晫璺濈
+ */
+ public boolean isBoundaryLengthVisible() {
+ return boundaryLengthVisible;
+ }
public void setBoundaryPointSizeScale(double sizeScale) {
double normalized = (Double.isFinite(sizeScale) && sizeScale > 0.0d) ? sizeScale : 1.0d;
--
Gitblit v1.10.0