From 13d032241e1a2938a8be4f64c9171e1240e9ea1e Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期一, 22 十二月 2025 18:50:42 +0800
Subject: [PATCH] 新增了边界管理页面和首页边界虚线功能
---
src/zhuye/bianjiedrwa.java | 55 +++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 45 insertions(+), 10 deletions(-)
diff --git a/src/zhuye/bianjiedrwa.java b/src/zhuye/bianjiedrwa.java
index 1e3bb46..485d16d 100644
--- a/src/zhuye/bianjiedrwa.java
+++ b/src/zhuye/bianjiedrwa.java
@@ -23,24 +23,59 @@
return; // 鏃犳暟鎹繑鍥�
} // if缁撴潫
- Path2D path = new Path2D.Double(); // 鍒涘缓璺緞
+ float strokeWidth = (float) (6 / Math.max(0.5, scale)); // 璁$畻杈圭嚎瀹藉害锛堝鍔犱竴鍊嶏紝浠�3鏀逛负6锛�
+
+ // 濉厖鍖哄煙
+ 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); // 缁樺埗瀹屾暣杈圭晫锛堝寘鎷捣鐐瑰埌缁堢偣鐨勮繛鎺ワ級
+
+ // 鍦ㄨ竟鐣岀嚎涓棿缁樺埗娣辩伆鑹插皬鍦嗙偣铏氱嚎
+ float dashedLineWidth = strokeWidth / 3.0f; // 铏氱嚎瀹藉害涓哄疄绾跨殑涓夊垎涔嬩竴
+ float[] dashPattern = {2.0f, 2.0f}; // 绛夐棿闅斿皬鍦嗙偣铏氱嚎妯″紡锛�2鍍忕礌瀹炵嚎锛堝舰鎴愬渾鐐癸級锛�2鍍忕礌绌虹櫧锛堝潎鍖�闂撮殧锛�
+ BasicStroke dashedStroke = new BasicStroke(
+ dashedLineWidth,
+ BasicStroke.CAP_ROUND, // 浣跨敤鍦嗗舰绔偣锛屽舰鎴愬渾鐐规晥鏋�
+ BasicStroke.JOIN_ROUND,
+ 0.0f,
+ dashPattern,
+ 0.0f
+ );
+ g2d.setStroke(dashedStroke); // 璁剧疆铏氱嚎鎻忚竟
+ Color darkGrayColor = new Color(64, 64, 64); // 娣辩伆鑹�
+ g2d.setColor(darkGrayColor); // 璁剧疆铏氱嚎棰滆壊
+ g2d.draw(borderPath); // 鍦ㄤ腑闂寸粯鍒跺皬鍦嗙偣铏氱嚎
+ }
} // 鏂规硶缁撴潫
} // 绫荤粨鏉�
--
Gitblit v1.10.0