From 87d7cf316e983b0398b270de03a8092412af8487 Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期五, 19 十二月 2025 16:56:30 +0800
Subject: [PATCH] 新增了收到绘制边界模式

---
 src/zhuye/bianjiedrwa.java |   38 ++++++++++++++++++++++++++++----------
 1 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/src/zhuye/bianjiedrwa.java b/src/zhuye/bianjiedrwa.java
index 1e3bb46..b40ee71 100644
--- a/src/zhuye/bianjiedrwa.java
+++ b/src/zhuye/bianjiedrwa.java
@@ -23,24 +23,42 @@
             return; // 鏃犳暟鎹繑鍥�
         } // if缁撴潫
 
-        Path2D path = new Path2D.Double(); // 鍒涘缓璺緞
+        float strokeWidth = (float) (3 / Math.max(0.5, scale)); // 璁$畻杈圭嚎瀹藉害
+        
+        // 濉厖鍖哄煙
+        Path2D fillPath = new Path2D.Double(); // 鍒涘缓濉厖璺緞
         boolean first = true; // 棣栫偣鏍囪
         for (Point2D.Double point : boundary) { // 閬嶅巻鐐�
             if (first) { // 棣栦釜鐐�
-                path.moveTo(point.x, point.y); // 绉诲姩鍒板紑濮嬬偣
+                fillPath.moveTo(point.x, point.y); // 绉诲姩鍒板紑濮嬬偣
                 first = false; // 鏇存柊鏍囪
             } else { // 鍏朵粬鐐�
-                path.lineTo(point.x, point.y); // 杩炵嚎鍒颁笅涓偣
+                fillPath.lineTo(point.x, point.y); // 杩炵嚎鍒颁笅涓偣
             } // if缁撴潫
         } // for缁撴潫
-        path.closePath(); // 闂悎璺緞
-
-        float strokeWidth = (float) (3 / Math.max(0.5, scale)); // 璁$畻杈圭嚎瀹藉害
-        g2d.setStroke(new BasicStroke(strokeWidth)); // 璁剧疆鎻忚竟
+        fillPath.closePath(); // 闂悎璺緞
+        
         g2d.setColor(fillColor); // 璁剧疆濉厖鑹�
-        g2d.fill(path); // 濉厖鍖哄煙
+        g2d.fill(fillPath); // 濉厖鍖哄煙
 
-        g2d.setColor(borderColor); // 璁剧疆杈圭嚎棰滆壊
-        g2d.draw(path); // 缁樺埗杈圭晫
+        // 缁樺埗杈圭晫绾匡紙鍖呮嫭璧风偣鍒扮粓鐐圭殑杩炴帴锛�- 瀹炵嚎
+        if (boundary.size() >= 2) {
+            Path2D.Double borderPath = new Path2D.Double(); // 鍒涘缓杈圭晫璺緞
+            Point2D.Double firstPoint = boundary.get(0);
+            borderPath.moveTo(firstPoint.x, firstPoint.y); // 绉诲姩鍒拌捣鐐�
+            for (int i = 1; i < boundary.size(); i++) { // 浠庣浜屼釜鐐瑰埌鏈�鍚庝竴涓偣
+                Point2D.Double point = boundary.get(i);
+                borderPath.lineTo(point.x, point.y); // 杩炵嚎
+            }
+            // 濡傛灉鏈�鍚庝竴涓偣涓嶆槸绗竴涓偣锛屽垯杩炴帴鍒拌捣鐐瑰舰鎴愰棴鍚�
+            Point2D.Double lastPoint = boundary.get(boundary.size() - 1);
+            if (!lastPoint.equals(firstPoint)) {
+                borderPath.lineTo(firstPoint.x, firstPoint.y); // 杩炴帴鍒拌捣鐐瑰舰鎴愰棴鍚�
+            }
+            
+            g2d.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); // 璁剧疆瀹炵嚎鎻忚竟
+            g2d.setColor(borderColor); // 璁剧疆杈圭嚎棰滆壊
+            g2d.draw(borderPath); // 缁樺埗瀹屾暣杈圭晫锛堝寘鎷捣鐐瑰埌缁堢偣鐨勮繛鎺ワ級
+        }
     } // 鏂规硶缁撴潫
 } // 绫荤粨鏉�

--
Gitblit v1.10.0