From f0d6cefec73492c29d8323e66fb92ee6bbb60cd2 Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期五, 26 十二月 2025 18:58:23 +0800
Subject: [PATCH] 优化了预览时候视图居中的逻辑

---
 src/zhuye/MapRenderer.java |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/src/zhuye/MapRenderer.java b/src/zhuye/MapRenderer.java
index 9d63270..2d77ce3 100644
--- a/src/zhuye/MapRenderer.java
+++ b/src/zhuye/MapRenderer.java
@@ -1403,7 +1403,8 @@
             
             // 灏嗕笘鐣屽潗鏍囪浆鎹负灞忓箷鍧愭爣锛堢敤浜庢枃瀛楁樉绀猴級
             Point2D.Double worldMid = new Point2D.Double(midX, midY);
-            Point2D.Double screenMid = worldToScreen(worldMid);
+            Point2D.Double screenMid = new Point2D.Double();
+            originalTransform.transform(worldMid, screenMid);
             
             // 鎭㈠鍘熷鍙樻崲浠ョ粯鍒舵枃瀛楋紙鍥哄畾澶у皬锛屼笉闅忕缉鏀惧彉鍖栵級
             g2d.setTransform(new AffineTransform());
@@ -1958,6 +1959,7 @@
                    .append(',')
                    .append(formatCoordinate(point.y));
             if (i < boundary.size() - 1) {
+               
                 builder.append(';');
             }
         }
@@ -3516,4 +3518,17 @@
         this.boundaryPreviewUpdateCallback = callback;
     }
 
+    /**
+     * 灏嗚鍥句腑蹇冨鍑嗗綋鍓嶈竟鐣岀殑鍑犱綍涓績
+     */
+    public void centerViewOnBoundary() {
+        if (currentBoundary == null || currentBoundary.isEmpty()) {
+            return;
+        }
+        
+        Rectangle2D.Double bounds = computeBounds(currentBoundary);
+        if (bounds != null) {
+            fitBoundsToView(bounds);
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.10.0