From 13d032241e1a2938a8be4f64c9171e1240e9ea1e Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期一, 22 十二月 2025 18:50:42 +0800
Subject: [PATCH] 新增了边界管理页面和首页边界虚线功能

---
 src/dikuai/Dikuaiguanli.java |  576 +++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 436 insertions(+), 140 deletions(-)

diff --git a/src/dikuai/Dikuaiguanli.java b/src/dikuai/Dikuaiguanli.java
index 2c6f253..ce8aafb 100644
--- a/src/dikuai/Dikuaiguanli.java
+++ b/src/dikuai/Dikuaiguanli.java
@@ -11,8 +11,6 @@
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import ui.UIConfig;
-import ui.UIUtils;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Map;
@@ -25,6 +23,9 @@
 
 import lujing.Lunjingguihua;
 import lujing.MowingPathGenerationPage;
+import publicway.Fuzhibutton;
+import publicway.Lookbutton;
+import publicway.buttonset;
 import zhangaiwu.AddDikuai;
 import zhangaiwu.Obstacledge;
 import zhuye.MapRenderer;
@@ -72,7 +73,7 @@
 	private ImageIcon workUnselectedIcon;
 	private ImageIcon boundaryVisibleIcon;
 	private ImageIcon boundaryHiddenIcon;
-	private static final int BOUNDARY_TOGGLE_ICON_SIZE = 48;
+	private static final int BOUNDARY_TOGGLE_ICON_SIZE = 24;
 	private Map<String, ObstacleSummary> obstacleSummaryCache = Collections.emptyMap();
 
 	public Dikuaiguanli(String landNumber) {
@@ -166,7 +167,7 @@
 			for (Dikuai dikuai : allDikuai.values()) {
 				JPanel card = createDikuaiCard(dikuai);
 				cardsPanel.add(card);
-				cardsPanel.add(Box.createRigidArea(new Dimension(0, 15)));
+				cardsPanel.add(Box.createRigidArea(new Dimension(0, 10)));
 			}
 		}
 		
@@ -246,11 +247,11 @@
 		
 		// 鍦板潡缂栧彿
 		contentPanel.add(createCardInfoItem("鍦板潡缂栧彿:", getDisplayValue(dikuai.getLandNumber(), "鏈煡")));
-	contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
+	contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
 
 		// 娣诲姞鏃堕棿
 		contentPanel.add(createCardInfoItem("娣诲姞鏃堕棿:", getDisplayValue(dikuai.getCreateTime(), "鏈煡")));
-	contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
+	contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
 
 		// 鍦板潡闈㈢Н
 		String landArea = dikuai.getLandArea();
@@ -260,59 +261,7 @@
 			landArea = "鏈煡";
 		}
 		contentPanel.add(createCardInfoItem("鍦板潡闈㈢Н:", landArea));
-	contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
-
-		// 杩斿洖鐐瑰潗鏍囷紙甯︿慨鏀规寜閽級
-		contentPanel.add(createCardInfoItemWithButton("杩斿洖鐐瑰潗鏍�:",
-			getDisplayValue(dikuai.getReturnPointCoordinates(), "鏈缃�"),
-			"淇敼", e -> editReturnPoint(dikuai)));
-	contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
-
-		// 鍦板潡杈圭晫鍧愭爣锛堝甫鏄剧ず椤剁偣鎸夐挳锛�
-		JPanel boundaryPanel = createBoundaryInfoItem(dikuai);
-		configureInteractiveLabel(getInfoItemTitleLabel(boundaryPanel),
-			() -> editBoundaryCoordinates(dikuai),
-			"鐐瑰嚮鏌ョ湅/缂栬緫鍦板潡杈圭晫鍧愭爣");
-		contentPanel.add(boundaryPanel);
-	contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
-
-		ObstacleSummary obstacleSummary = getObstacleSummaryFromCache(dikuai.getLandNumber());
-		JPanel obstaclePanel = createCardInfoItemWithButton("闅滅鐗�:",
-			obstacleSummary.buildDisplayValue(),
-			"鏂板",
-			e -> addNewObstacle(dikuai));
-		setInfoItemTooltip(obstaclePanel, obstacleSummary.buildTooltip());
-		// 璁╅殰纰嶇墿鏍囬鍙偣鍑伙紝鎵撳紑闅滅鐗╃鐞嗛〉闈�
-		configureInteractiveLabel(getInfoItemTitleLabel(obstaclePanel),
-			() -> showObstacleManagementPage(dikuai),
-			"鐐瑰嚮鏌ョ湅/绠$悊闅滅鐗�");
-		contentPanel.add(obstaclePanel);
-	contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
-
-		// 璺緞鍧愭爣锛堝甫鏌ョ湅鎸夐挳锛�
-		JPanel pathPanel = createCardInfoItemWithButtonOnly("璺緞鍧愭爣:",
-			"鏌ョ湅", e -> editPlannedPath(dikuai));
-		configureInteractiveLabel(getInfoItemTitleLabel(pathPanel),
-			() -> editPlannedPath(dikuai),
-			"鐐瑰嚮鏌ョ湅/缂栬緫璺緞鍧愭爣");
-		contentPanel.add(pathPanel);
-	contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
-
-	JPanel baseStationPanel = createCardInfoItemWithButtonOnly("鍩虹珯鍧愭爣:",
-		"鏌ョ湅", e -> editBaseStationCoordinates(dikuai));
-	configureInteractiveLabel(getInfoItemTitleLabel(baseStationPanel),
-		() -> editBaseStationCoordinates(dikuai),
-		"鐐瑰嚮鏌ョ湅/缂栬緫鍩虹珯鍧愭爣");
-	contentPanel.add(baseStationPanel);
-	contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
-
-	JPanel boundaryOriginalPanel = createCardInfoItemWithButtonOnly("杈圭晫鍘熷鍧愭爣:",
-		"鏌ョ湅", e -> editBoundaryOriginalCoordinates(dikuai));
-	configureInteractiveLabel(getInfoItemTitleLabel(boundaryOriginalPanel),
-		() -> editBoundaryOriginalCoordinates(dikuai),
-		"鐐瑰嚮鏌ョ湅/缂栬緫杈圭晫鍘熷鍧愭爣");
-	contentPanel.add(boundaryOriginalPanel);
-		contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
+	contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
 
 		JPanel mowingPatternPanel = createCardInfoItem("鍓茶崏妯″紡:",
 			formatMowingPatternForDisplay(dikuai.getMowingPattern()));
@@ -320,7 +269,7 @@
 			() -> editMowingPattern(dikuai),
 			"鐐瑰嚮鏌ョ湅/缂栬緫鍓茶崏妯″紡");
 		contentPanel.add(mowingPatternPanel);
-		contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
+		contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
 
 		// 鍓茶崏鏈哄壊鍒�瀹藉害
 		String mowingBladeWidthValue = dikuai.getMowingBladeWidth();
@@ -336,7 +285,7 @@
 		}
 		JPanel mowingBladeWidthPanel = createCardInfoItem("鍓茶崏鏈哄壊鍒�瀹藉害:", displayBladeWidth);
 		contentPanel.add(mowingBladeWidthPanel);
-		contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
+		contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
 
 		String mowingWidthValue = dikuai.getMowingWidth();
 		String displayWidth = "鏈缃�";
@@ -345,33 +294,78 @@
 		}
 		JPanel mowingWidthPanel = createCardInfoItem("鍓茶崏瀹藉害:", displayWidth);
 		contentPanel.add(mowingWidthPanel);
-		contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
+		contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
 
 		// 鍓茶崏瀹夊叏璺濈
 		String displaySafetyDistance = "鏈缃�";
-		Device device = Device.getActiveDevice();
-		if (device != null) {
-			String safetyDistanceValue = device.getMowingSafetyDistance();
-			if (safetyDistanceValue != null && !"-1".equals(safetyDistanceValue) && !safetyDistanceValue.trim().isEmpty()) {
-				try {
-					double distanceMeters = Double.parseDouble(safetyDistanceValue.trim());
-					// 濡傛灉鍊煎ぇ浜�100锛岃涓烘槸鍘樼背锛岄渶瑕佽浆鎹负绫�
-					if (distanceMeters > 100) {
-						distanceMeters = distanceMeters / 100.0;
-					}
-					displaySafetyDistance = String.format("%.2f绫�", distanceMeters);
-				} catch (NumberFormatException e) {
-					displaySafetyDistance = "鏈缃�";
+		String safetyDistanceValue = dikuai.getMowingSafetyDistance();
+		if (safetyDistanceValue != null && !"-1".equals(safetyDistanceValue) && !safetyDistanceValue.trim().isEmpty()) {
+			try {
+				double distanceMeters = Double.parseDouble(safetyDistanceValue.trim());
+				// 濡傛灉鍊煎ぇ浜�100锛岃涓烘槸鍘樼背锛岄渶瑕佽浆鎹负绫�
+				if (distanceMeters > 100) {
+					distanceMeters = distanceMeters / 100.0;
 				}
+				displaySafetyDistance = String.format("%.2f绫�", distanceMeters);
+			} catch (NumberFormatException e) {
+				displaySafetyDistance = "鏈缃�";
 			}
 		}
 		JPanel mowingSafetyDistancePanel = createCardInfoItem("鍓茶崏瀹夊叏璺濈:", displaySafetyDistance);
 		contentPanel.add(mowingSafetyDistancePanel);
-		contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
+		contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
+
+		// 寰�杩旂偣璺緞锛堝甫鏌ョ湅鍥炬爣鎸夐挳锛�
+		JPanel returnPathPanel = createCardInfoItemWithIconButton("寰�杩旂偣璺緞:",
+			createViewButton(e -> editReturnPath(dikuai)));
+		configureInteractiveLabel(getInfoItemTitleLabel(returnPathPanel),
+			() -> editReturnPath(dikuai),
+			"鐐瑰嚮鏌ョ湅/缂栬緫寰�杩旂偣璺緞");
+		contentPanel.add(returnPathPanel);
+	contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
+
+		ObstacleSummary obstacleSummary = getObstacleSummaryFromCache(dikuai.getLandNumber());
+		JPanel obstaclePanel = createCardInfoItemWithButton("闅滅鐗�:",
+			obstacleSummary.buildDisplayValue(),
+			"鏂板",
+			e -> addNewObstacle(dikuai));
+		setInfoItemTooltip(obstaclePanel, obstacleSummary.buildTooltip());
+		// 璁╅殰纰嶇墿鏍囬鍙偣鍑伙紝鎵撳紑闅滅鐗╃鐞嗛〉闈�
+		configureInteractiveLabel(getInfoItemTitleLabel(obstaclePanel),
+			() -> showObstacleManagementPage(dikuai),
+			"鐐瑰嚮鏌ョ湅/绠$悊闅滅鐗�");
+		contentPanel.add(obstaclePanel);
+	contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
+
+		// 鍦板潡杈圭晫鍧愭爣锛堝甫鏌ョ湅鎸夐挳锛�
+		JPanel boundaryPanel = createCardInfoItemWithIconButton("鍦板潡杈圭晫:",
+			createViewButton(e -> editBoundaryCoordinates(dikuai)));
+		configureInteractiveLabel(getInfoItemTitleLabel(boundaryPanel),
+			() -> editBoundaryCoordinates(dikuai),
+			"鐐瑰嚮鏌ョ湅/缂栬緫鍦板潡杈圭晫鍧愭爣");
+		contentPanel.add(boundaryPanel);
+	contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
+
+		// 璺緞鍧愭爣锛堝甫鏌ョ湅鎸夐挳锛�
+		JPanel pathPanel = createCardInfoItemWithIconButton("璺緞鍧愭爣:",
+			createViewButton(e -> editPlannedPath(dikuai)));
+		configureInteractiveLabel(getInfoItemTitleLabel(pathPanel),
+			() -> editPlannedPath(dikuai),
+			"鐐瑰嚮鏌ョ湅/缂栬緫璺緞鍧愭爣");
+		contentPanel.add(pathPanel);
+	contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
+
+	JPanel baseStationPanel = createCardInfoItemWithIconButton("鍩虹珯鍧愭爣:",
+		createViewButton(e -> editBaseStationCoordinates(dikuai)));
+	configureInteractiveLabel(getInfoItemTitleLabel(baseStationPanel),
+		() -> editBaseStationCoordinates(dikuai),
+		"鐐瑰嚮鏌ョ湅/缂栬緫鍩虹珯鍧愭爣");
+	contentPanel.add(baseStationPanel);
+	contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
 
 		JPanel completedTrackPanel = createCardInfoItemWithButton("宸插畬鎴愬壊鑽夎矾寰�:",
 			getTruncatedValue(dikuai.getMowingTrack(), 12, "鏈褰�"),
-			"鏌ョ湅", e -> showCompletedMowingTrackDialog(dikuai));
+			createViewButton(e -> showCompletedMowingTrackDialog(dikuai)));
 		setInfoItemTooltip(completedTrackPanel, dikuai.getMowingTrack());
 		configureInteractiveLabel(getInfoItemTitleLabel(completedTrackPanel),
 			() -> showCompletedMowingTrackDialog(dikuai),
@@ -456,6 +450,38 @@
 		return itemPanel;
 	}
 
+	private JPanel createCardInfoItemWithButton(String label, String value, JButton button) {
+		JPanel itemPanel = new JPanel(new BorderLayout());
+		itemPanel.setBackground(CARD_BACKGROUND);
+		// 澧炲姞楂樺害浠ョ‘淇濇寜閽畬鏁存樉绀猴紙鎸夐挳楂樺害绾�24-28鍍忕礌锛屽姞涓婁笂涓嬭竟璺濓級
+		itemPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 35));
+		itemPanel.setPreferredSize(new Dimension(Integer.MAX_VALUE, 30));
+		itemPanel.setMinimumSize(new Dimension(0, 28));
+		
+		JLabel labelComp = new JLabel(label);
+		labelComp.setFont(new Font("寰蒋闆呴粦", Font.PLAIN, 14));
+		labelComp.setForeground(LIGHT_TEXT);
+		
+		JPanel rightPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0));
+		rightPanel.setBackground(CARD_BACKGROUND);
+		// 娣诲姞鍨傜洿鍐呰竟璺濅互纭繚鎸夐挳涓嶈瑁佸壀
+		rightPanel.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
+		
+		JLabel valueComp = new JLabel(value);
+		valueComp.setFont(new Font("寰蒋闆呴粦", Font.PLAIN, 14));
+		valueComp.setForeground(TEXT_COLOR);
+		
+		rightPanel.add(valueComp);
+		rightPanel.add(button);
+		
+		itemPanel.add(labelComp, BorderLayout.WEST);
+		itemPanel.add(rightPanel, BorderLayout.CENTER);
+		itemPanel.putClientProperty("valueLabel", valueComp);
+		itemPanel.putClientProperty("titleLabel", labelComp);
+		
+		return itemPanel;
+	}
+
 	private JPanel createCardInfoItemWithButtonOnly(String label, String buttonText, ActionListener listener) {
 		JPanel itemPanel = new JPanel(new BorderLayout());
 		itemPanel.setBackground(CARD_BACKGROUND);
@@ -484,15 +510,41 @@
 		return itemPanel;
 	}
 
+	private JPanel createCardInfoItemWithIconButton(String label, JButton button) {
+		JPanel itemPanel = new JPanel(new BorderLayout());
+		itemPanel.setBackground(CARD_BACKGROUND);
+		// 澧炲姞楂樺害浠ョ‘淇濇寜閽畬鏁存樉绀猴紙鎸夐挳楂樺害绾�24-28鍍忕礌锛屽姞涓婁笂涓嬭竟璺濓級
+		itemPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 35));
+		itemPanel.setPreferredSize(new Dimension(Integer.MAX_VALUE, 30));
+		itemPanel.setMinimumSize(new Dimension(0, 28));
+		
+		JLabel labelComp = new JLabel(label);
+		labelComp.setFont(new Font("寰蒋闆呴粦", Font.PLAIN, 14));
+		labelComp.setForeground(LIGHT_TEXT);
+		
+		JPanel rightPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0));
+		rightPanel.setBackground(CARD_BACKGROUND);
+		// 娣诲姞鍨傜洿鍐呰竟璺濅互纭繚鎸夐挳涓嶈瑁佸壀
+		rightPanel.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
+		
+		rightPanel.add(button);
+		
+		itemPanel.add(labelComp, BorderLayout.WEST);
+		itemPanel.add(rightPanel, BorderLayout.CENTER);
+		itemPanel.putClientProperty("titleLabel", labelComp);
+		
+		return itemPanel;
+	}
+
 		private JPanel createBoundaryInfoItem(Dikuai dikuai) {
 			JPanel itemPanel = new JPanel(new BorderLayout());
 			itemPanel.setBackground(CARD_BACKGROUND);
-			// 澧炲姞楂樺害浠ョ‘淇濇寜閽笅杈圭紭瀹屾暣鏄剧ず锛堟寜閽珮搴�56锛屽姞涓婁笂涓嬭竟璺濓級
-			int rowHeight = Math.max(60, BOUNDARY_TOGGLE_ICON_SIZE + 16);
+			// 澧炲姞楂樺害浠ョ‘淇濇寜閽笅杈圭紭瀹屾暣鏄剧ず锛堟寜閽珮搴�28锛屽姞涓婁笂涓嬭竟璺濓級
+			int rowHeight = Math.max(30, BOUNDARY_TOGGLE_ICON_SIZE + 8);
 			Dimension rowDimension = new Dimension(Integer.MAX_VALUE, rowHeight);
 			itemPanel.setMaximumSize(rowDimension);
 			itemPanel.setPreferredSize(rowDimension);
-			itemPanel.setMinimumSize(new Dimension(0, 56));
+			itemPanel.setMinimumSize(new Dimension(0, 28));
 
 			JLabel labelComp = new JLabel("鍦板潡杈圭晫:");
 			labelComp.setFont(new Font("寰蒋闆呴粦", Font.PLAIN, 14));
@@ -537,7 +589,7 @@
 			button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
 			button.setMargin(new Insets(0, 0, 0, 0));
 			button.setIconTextGap(0);
-			button.setPreferredSize(new Dimension(56, 56));
+			button.setPreferredSize(new Dimension(28, 28));
 
 			String landNumber = dikuai.getLandNumber();
 			boolean isVisible = boundaryPointVisibility.getOrDefault(landNumber, false);
@@ -695,6 +747,20 @@
 	}
 
 	private String promptCoordinateEditing(String title, String initialValue) {
+		return promptCoordinateEditing(title, initialValue, null);
+	}
+	
+	private String promptCoordinateEditing(String title, String initialValue, Dikuai dikuai) {
+		// 鍒ゆ柇鏄惁鏄線杩旂偣璺緞瀵硅瘽妗�
+		boolean isReturnPathDialog = title != null && title.contains("寰�杩旂偣璺緞");
+		
+		if (isReturnPathDialog) {
+			Window owner = SwingUtilities.getWindowAncestor(this);
+			Wangfanpathpage page = new Wangfanpathpage(owner, title, initialValue, dikuai);
+			page.setVisible(true);
+			return page.getResult();
+		}
+		
 		JTextArea textArea = new JTextArea(prepareCoordinateForEditor(initialValue));
 		textArea.setLineWrap(true);
 		textArea.setWrapStyleWord(true);
@@ -703,7 +769,8 @@
 		textArea.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
 
 		JScrollPane scrollPane = new JScrollPane(textArea);
-		scrollPane.setPreferredSize(new Dimension(360, 240));
+		// 濡傛灉鏄線杩旂偣璺緞瀵硅瘽妗嗭紝楂樺害璋冩暣涓洪�傚簲涓や釜鏂囨湰鍩�
+		scrollPane.setPreferredSize(new Dimension(360, isReturnPathDialog ? 100 : 240));
 
 		Window owner = SwingUtilities.getWindowAncestor(this);
 		JDialog dialog;
@@ -716,54 +783,224 @@
 		}
 		dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
 
-		JPanel contentPanel = new JPanel(new BorderLayout());
+		JPanel contentPanel = new JPanel();
 		contentPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
-		contentPanel.add(scrollPane, BorderLayout.CENTER);
+		
+		if (isReturnPathDialog) {
+			contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
+			// 鍑忓皬杈硅窛浠ュ鍔犳枃鏈煙瀹藉害 (98%宸﹀彸)
+			contentPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+			
+			// 1. 鍘熷寰�杩旇矾寰勫潗鏍囧尯鍩�
+			String rawCoords = dikuai != null ? prepareCoordinateForEditor(dikuai.getReturnPathRawCoordinates()) : "";
+			int rawCount = 0;
+			if (rawCoords != null && !rawCoords.isEmpty() && !"-1".equals(rawCoords)) {
+				rawCount = rawCoords.split(";").length;
+			}
+			
+			JPanel rawHeaderPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
+			rawHeaderPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
+			rawHeaderPanel.setBackground(BACKGROUND_COLOR);
+			rawHeaderPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 30));
+			
+			JLabel rawTitleLabel = new JLabel("鍘熷寰�杩旇矾寰勫潗鏍� (" + rawCount + "鐐�)  ");
+			rawTitleLabel.setFont(new Font("寰蒋闆呴粦", Font.BOLD, 14));
+			rawHeaderPanel.add(rawTitleLabel);
+			
+			// 鍘熷鍧愭爣澶嶅埗鎸夐挳
+			final String finalRawCoords = rawCoords;
+			JButton rawCopyBtn = Fuzhibutton.createCopyButton(
+				() -> {
+					if (finalRawCoords == null || finalRawCoords.isEmpty() || "-1".equals(finalRawCoords)) return null;
+					return finalRawCoords;
+				},
+				"澶嶅埗",
+				new Color(230, 250, 240)
+			);
+			rawCopyBtn.setFont(new Font("寰蒋闆呴粦", Font.PLAIN, 12));
+			rawCopyBtn.setPreferredSize(new Dimension(50, 24));
+			rawCopyBtn.setMargin(new Insets(0,0,0,0));
+			rawHeaderPanel.add(rawCopyBtn);
+			
+			contentPanel.add(rawHeaderPanel);
+			contentPanel.add(Box.createVerticalStrut(5));
+			
+			JTextArea rawTextArea = new JTextArea(rawCoords);
+			rawTextArea.setLineWrap(true);
+			rawTextArea.setWrapStyleWord(true);
+			rawTextArea.setFont(new Font("寰蒋闆呴粦", Font.PLAIN, 13));
+			rawTextArea.setEditable(false); // 鍘熷鍧愭爣閫氬父涓嶅彲缂栬緫
+			rawTextArea.setRows(4);
+			rawTextArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+			
+			JScrollPane rawScroll = new JScrollPane(rawTextArea);
+			rawScroll.setAlignmentX(Component.LEFT_ALIGNMENT);
+			// 璁剧疆鏈�澶у搴﹀厑璁告墿灞曪紝棣栭�夊搴﹂�備腑
+			rawScroll.setPreferredSize(new Dimension(300, 100));
+			rawScroll.setMaximumSize(new Dimension(Integer.MAX_VALUE, 100));
+			contentPanel.add(rawScroll);
+			
+			contentPanel.add(Box.createVerticalStrut(15));
+			
+			// 2. 浼樺寲鍚庡線杩旇矾寰勫潗鏍囧尯鍩�
+			String optCoords = prepareCoordinateForEditor(initialValue);
+			int optCount = 0;
+			if (optCoords != null && !optCoords.isEmpty() && !"-1".equals(optCoords)) {
+				optCount = optCoords.split(";").length;
+			}
+			
+			JPanel optHeaderPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
+			optHeaderPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
+			optHeaderPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 30));
+			
+			JLabel optTitleLabel = new JLabel("浼樺寲鍚庡線杩旇矾寰勫潗鏍� (" + optCount + "鐐�)  ");
+			optTitleLabel.setFont(new Font("寰蒋闆呴粦", Font.BOLD, 14));
+			optHeaderPanel.add(optTitleLabel);
+			
+			// 浼樺寲鍧愭爣澶嶅埗鎸夐挳 - 鍔ㄦ�佽幏鍙栨枃鏈煙鍐呭
+			JButton optCopyBtn = Fuzhibutton.createCopyButton(
+				() -> {
+					String text = textArea.getText();
+					if (text == null || text.trim().isEmpty() || "-1".equals(text.trim())) return null;
+					return text;
+				},
+				"澶嶅埗",
+				new Color(230, 250, 240)
+			);
+			optCopyBtn.setFont(new Font("寰蒋闆呴粦", Font.PLAIN, 12));
+			optCopyBtn.setPreferredSize(new Dimension(50, 24));
+			optCopyBtn.setMargin(new Insets(0,0,0,0));
+			optHeaderPanel.add(optCopyBtn);
+			
+			contentPanel.add(optHeaderPanel);
+			contentPanel.add(Box.createVerticalStrut(5));
+			
+			// 浣跨敤浼犲叆鐨� textArea (宸插垵濮嬪寲涓� initialValue)
+			textArea.setRows(4);
+			scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
+			scrollPane.setPreferredSize(new Dimension(300, 100));
+			scrollPane.setMaximumSize(new Dimension(Integer.MAX_VALUE, 100));
+			contentPanel.add(scrollPane);
+			
+		} else {
+			contentPanel.setLayout(new BorderLayout());
+			contentPanel.add(scrollPane, BorderLayout.CENTER);
+		}
 
 		JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
-		JButton okButton = new JButton("纭畾");
-		JButton cancelButton = new JButton("鍙栨秷");
-		JButton copyButton = new JButton("澶嶅埗");
+		
+		JButton okButton;
+		JButton cancelButton;
+		JButton copyButton = null; // 鍒濆鍖栦负null
+		
+		if (isReturnPathDialog) {
+			// 寰�杩旂偣璺緞瀵硅瘽妗嗭細浣跨敤 buttonset 椋庢牸鐨勭‘瀹氭寜閽紝鍥炬爣鎸夐挳
+			okButton = buttonset.createStyledButton("鍘荤粯鍒�", new Color(70, 130, 220));
+			
+			// 鍙栨秷鎸夐挳浣跨敤 closepage.png 鍥炬爣
+			cancelButton = new JButton();
+			ImageIcon closeIcon = loadIcon("image/closepage.png", 25, 25);
+			if (closeIcon != null) {
+				cancelButton.setIcon(closeIcon);
+			} else {
+				cancelButton.setText("鍏抽棴");
+			}
+			cancelButton.setFont(new Font("寰蒋闆呴粦", Font.PLAIN, 11));
+			cancelButton.setForeground(PRIMARY_COLOR);
+			cancelButton.setBorder(BorderFactory.createEmptyBorder());
+			cancelButton.setContentAreaFilled(false);
+			cancelButton.setFocusPainted(false);
+			cancelButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
+			cancelButton.addMouseListener(new MouseAdapter() {
+				public void mouseEntered(MouseEvent e) { cancelButton.setOpaque(true); cancelButton.setBackground(new Color(255, 240, 240)); }
+				public void mouseExited(MouseEvent e) { cancelButton.setOpaque(false); }
+			});
+			
+			// 浣跨敤 Fuzhibutton 鍒涘缓澶嶅埗鎸夐挳 (杩欓噷涓嶅啀闇�瑕佸簳閮ㄧ殑澶嶅埗鎸夐挳锛屽洜涓轰笂闈㈠凡缁忔湁浜�)
+			// copyButton = ... 
+			
+		} else {
+			// 鍏朵粬瀵硅瘽妗嗕繚鎸佸師鏈夋牱寮�
+			okButton = new JButton("纭畾");
+			cancelButton = new JButton("鍙栨秷");
+			copyButton = new JButton("澶嶅埗");
+			
+			// 鍏朵粬瀵硅瘽妗嗙殑澶嶅埗鎸夐挳閫昏緫
+			copyButton.addActionListener(e -> {
+				String text = textArea.getText();
+				if (text == null) {
+					text = "";
+				}
+				String trimmed = text.trim();
+				if (trimmed.isEmpty() || "-1".equals(trimmed)) {
+					JOptionPane.showMessageDialog(dialog, title + " 鏈缃�", "鎻愮ず", JOptionPane.INFORMATION_MESSAGE);
+					return;
+				}
+				try {
+					StringSelection selection = new StringSelection(text);
+					Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+					clipboard.setContents(selection, selection);
+					JOptionPane.showMessageDialog(dialog, title + " 宸插鍒跺埌鍓创鏉�", "鎻愮ず", JOptionPane.INFORMATION_MESSAGE);
+				} catch (Exception ex) {
+					JOptionPane.showMessageDialog(dialog, "澶嶅埗澶辫触: " + ex.getMessage(), "閿欒", JOptionPane.ERROR_MESSAGE);
+				}
+			});
+		}
 
 		final boolean[] confirmed = new boolean[] {false};
 		final String[] resultHolder = new String[1];
 
 		okButton.addActionListener(e -> {
-			resultHolder[0] = textArea.getText();
-			confirmed[0] = true;
-			dialog.dispose();
+			if (isReturnPathDialog) {
+				// 寰�杩旂偣璺緞瀵硅瘽妗嗭細鏍囪涓烘墦寮�缁樺埗椤甸潰
+				// 濡傛灉鏂囨湰鍩熶腑宸茬粡鏈夊潗鏍囷紝琛ㄧず瑕侀噸鏂扮粯鍒�
+				String currentText = textArea.getText();
+				if (currentText != null && !currentText.trim().isEmpty() && !"-1".equals(currentText.trim())) {
+					// 鏈夊潗鏍囷紝琛ㄧず閲嶆柊缁樺埗
+					resultHolder[0] = "__OPEN_DRAW_PAGE_REFRESH__";
+				} else {
+					// 娌℃湁鍧愭爣锛屾甯哥粯鍒�
+					resultHolder[0] = "__OPEN_DRAW_PAGE__";
+				}
+				confirmed[0] = true;
+				dialog.dispose();
+			} else {
+				resultHolder[0] = textArea.getText();
+				confirmed[0] = true;
+				dialog.dispose();
+			}
 		});
 
 		cancelButton.addActionListener(e -> dialog.dispose());
 
-		copyButton.addActionListener(e -> {
-			String text = textArea.getText();
-			if (text == null) {
-				text = "";
-			}
-			String trimmed = text.trim();
-			if (trimmed.isEmpty() || "-1".equals(trimmed)) {
-				JOptionPane.showMessageDialog(dialog, title + " 鏈缃�", "鎻愮ず", JOptionPane.INFORMATION_MESSAGE);
-				return;
-			}
-			try {
-				StringSelection selection = new StringSelection(text);
-				Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
-				clipboard.setContents(selection, selection);
-				JOptionPane.showMessageDialog(dialog, title + " 宸插鍒跺埌鍓创鏉�", "鎻愮ず", JOptionPane.INFORMATION_MESSAGE);
-			} catch (Exception ex) {
-				JOptionPane.showMessageDialog(dialog, "澶嶅埗澶辫触: " + ex.getMessage(), "閿欒", JOptionPane.ERROR_MESSAGE);
-			}
-		});
-
 		buttonPanel.add(okButton);
 		buttonPanel.add(cancelButton);
-		buttonPanel.add(copyButton);
+		if (copyButton != null) {
+			buttonPanel.add(copyButton);
+		}
 
-		contentPanel.add(buttonPanel, BorderLayout.SOUTH);
+		contentPanel.add(buttonPanel, isReturnPathDialog ? null : BorderLayout.SOUTH);
+		if (isReturnPathDialog) {
+			// 瀵逛簬 BoxLayout锛岀洿鎺ユ坊鍔犲埌搴曢儴
+			JPanel bottomWrapper = new JPanel(new BorderLayout());
+			bottomWrapper.add(buttonPanel, BorderLayout.EAST);
+			contentPanel.add(bottomWrapper);
+		}
 		dialog.setContentPane(contentPanel);
 		dialog.getRootPane().setDefaultButton(okButton);
 		dialog.pack();
+		
+		// 濡傛灉鏄線杩旂偣璺緞瀵硅瘽妗嗭紝璁剧疆瀹藉害涓洪椤电殑90%锛岄珮搴︿繚鎸佷笉鍙�
+		if (isReturnPathDialog) {
+			Shouye shouye = Shouye.getInstance();
+			if (shouye != null && shouye.getWidth() > 0) {
+				int homeWidth = shouye.getWidth();
+				int dialogWidth = (int)(homeWidth * 0.9);
+				Dimension currentSize = dialog.getSize();
+				dialog.setSize(dialogWidth, currentSize.height);
+			}
+		}
+		
 		dialog.setLocationRelativeTo(this);
 		dialog.setVisible(true);
 
@@ -791,17 +1028,35 @@
 		if (dikuai == null) {
 			return;
 		}
-		String edited = promptCoordinateEditing("鏌ョ湅 / 缂栬緫鍦板潡杈圭晫鍧愭爣", dikuai.getBoundaryCoordinates());
+		Window owner = SwingUtilities.getWindowAncestor(this);
+		
+		// 鑾峰彇鍦板潡绠$悊瀵硅瘽妗嗭紝鍑嗗鍦ㄦ墦寮�杈圭晫缂栬緫椤甸潰鏃跺叧闂�
+		Window managementWindow = null;
+		if (owner instanceof JDialog) {
+			managementWindow = owner;
+		}
+		
+		// 鎵撳紑杈圭晫缂栬緫椤甸潰
+		Dikuanbianjipage page = new Dikuanbianjipage(owner, "鍦板潡杈圭晫绠$悊椤甸潰", dikuai.getBoundaryCoordinates(), dikuai);
+		page.setVisible(true);
+		
+		// 鍏抽棴鍦板潡绠$悊椤甸潰
+		if (managementWindow != null) {
+			managementWindow.dispose();
+		}
+		
+		// 鑾峰彇缂栬緫缁撴灉骞朵繚瀛�
+		String edited = page.getResult();
 		if (edited == null) {
 			return;
 		}
 		String normalized = normalizeCoordinateInput(edited);
 		if (!saveFieldAndRefresh(dikuai, "boundaryCoordinates", normalized)) {
-			JOptionPane.showMessageDialog(this, "鏃犳硶鏇存柊鍦板潡杈圭晫鍧愭爣", "閿欒", JOptionPane.ERROR_MESSAGE);
+			JOptionPane.showMessageDialog(null, "鏃犳硶鏇存柊鍦板潡杈圭晫鍧愭爣", "閿欒", JOptionPane.ERROR_MESSAGE);
 			return;
 		}
 		String message = "-1".equals(normalized) ? "鍦板潡杈圭晫鍧愭爣宸叉竻绌�" : "鍦板潡杈圭晫鍧愭爣宸叉洿鏂�";
-		JOptionPane.showMessageDialog(this, message, "鎴愬姛", JOptionPane.INFORMATION_MESSAGE);
+		JOptionPane.showMessageDialog(null, message, "鎴愬姛", JOptionPane.INFORMATION_MESSAGE);
 	}
 
 	private void editPlannedPath(Dikuai dikuai) {
@@ -838,22 +1093,6 @@
 		JOptionPane.showMessageDialog(this, message, "鎴愬姛", JOptionPane.INFORMATION_MESSAGE);
 	}
 
-	private void editBoundaryOriginalCoordinates(Dikuai dikuai) {
-		if (dikuai == null) {
-			return;
-		}
-		String edited = promptCoordinateEditing("鏌ョ湅 / 缂栬緫杈圭晫鍘熷鍧愭爣", dikuai.getBoundaryOriginalCoordinates());
-		if (edited == null) {
-			return;
-		}
-		String normalized = normalizeCoordinateInput(edited);
-		if (!saveFieldAndRefresh(dikuai, "boundaryOriginalCoordinates", normalized)) {
-			JOptionPane.showMessageDialog(this, "鏃犳硶鏇存柊杈圭晫鍘熷鍧愭爣", "閿欒", JOptionPane.ERROR_MESSAGE);
-			return;
-		}
-		String message = "-1".equals(normalized) ? "杈圭晫鍘熷鍧愭爣宸叉竻绌�" : "杈圭晫鍘熷鍧愭爣宸叉洿鏂�";
-		JOptionPane.showMessageDialog(this, message, "鎴愬姛", JOptionPane.INFORMATION_MESSAGE);
-	}
 
 	private void editMowingPattern(Dikuai dikuai) {
 		if (dikuai == null) {
@@ -1544,15 +1783,31 @@
 	}
 
 	private JButton createDeleteButton() {
-		JButton button = createStyledButton("鍒犻櫎", RED_COLOR, false); // 杞粨椋庢牸
-		ImageIcon deleteIcon = loadIcon("image/delete.png", 16, 16);
+		JButton button = new JButton();
+		ImageIcon deleteIcon = loadIcon("image/delete.png", 25, 25);
 		if (deleteIcon != null) {
 			button.setIcon(deleteIcon);
-			button.setIconTextGap(6);
+		} else {
+			button.setText("鍒犻櫎");
 		}
+		button.setFont(new Font("寰蒋闆呴粦", Font.PLAIN, 11));
+		button.setForeground(RED_COLOR);
+		button.setBorder(BorderFactory.createEmptyBorder());
+		button.setContentAreaFilled(false);
+		button.setFocusPainted(false);
+		button.setCursor(new Cursor(Cursor.HAND_CURSOR));
+		button.addMouseListener(new MouseAdapter() {
+			public void mouseEntered(MouseEvent e) { button.setOpaque(true); button.setBackground(new Color(255, 240, 240)); }
+			public void mouseExited(MouseEvent e) { button.setOpaque(false); }
+		});
 		return button;
 	}
 
+	private JButton createViewButton(ActionListener listener) {
+		// 浣跨敤 Lookbutton 绫诲垱寤烘煡鐪嬫寜閽�
+		return Lookbutton.createViewButton(listener, new Color(230, 250, 240));
+	}
+
 	private JButton createPrimaryFooterButton(String text) {
 		return createStyledButton(text, PRIMARY_COLOR, true); // 瀹炲績椋庢牸
 	}
@@ -1771,13 +2026,52 @@
 		});
 	}
 
-	private void editReturnPoint(Dikuai dikuai) {
-		FanhuiDialog fd = new FanhuiDialog(SwingUtilities.getWindowAncestor(this), dikuai);
-		fd.setVisible(true);
-		// 濡傛灉瀵硅瘽妗嗗凡鏇存柊鏁版嵁锛屽埛鏂版樉绀�
-		if (fd.isUpdated()) {
-			loadDikuaiData();
+	private void editReturnPath(Dikuai dikuai) {
+		if (dikuai == null) {
+			return;
 		}
+		String edited = promptCoordinateEditing("鏌ョ湅 / 缂栬緫寰�杩旂偣璺緞", dikuai.getReturnPathCoordinates(), dikuai);
+		if (edited == null) {
+			return;
+		}
+		// 妫�鏌ユ槸鍚︽槸鐗规畩鏍囪锛岃〃绀虹偣鍑讳簡"鍘荤粯鍒�"鎸夐挳
+		if ("__OPEN_DRAW_PAGE__".equals(edited) || "__OPEN_DRAW_PAGE_REFRESH__".equals(edited)) {
+			// 鑾峰彇鍦板潡绠$悊瀵硅瘽妗�
+			Window owner = SwingUtilities.getWindowAncestor(this);
+			Window managementWindow = null;
+			if (owner instanceof JDialog) {
+				managementWindow = owner;
+			}
+			
+			// 鑾峰彇鍦板潡绠$悊瀵硅瘽妗嗙殑鐖剁獥鍙o紙涓荤獥鍙o級锛屼綔涓虹粯鍒堕〉闈㈢殑鐖剁獥鍙�
+			Window drawPageOwner = null;
+			if (managementWindow != null) {
+				drawPageOwner = managementWindow.getOwner();
+			}
+			if (drawPageOwner == null && owner != null) {
+				drawPageOwner = owner.getOwner();
+			}
+			if (drawPageOwner == null) {
+				drawPageOwner = owner;
+			}
+			
+			// 鍏堝叧闂湴鍧楃鐞嗛〉闈�
+			if (managementWindow != null) {
+				managementWindow.dispose();
+			}
+			
+			// 鐒跺悗鎵撳紑缁樺埗椤甸潰锛屽鏋滄槸閲嶆柊缁樺埗锛屼紶閫掓爣璁�
+			boolean isRefresh = "__OPEN_DRAW_PAGE_REFRESH__".equals(edited);
+			Huizhiwanfanpath.showDrawReturnPathDialog(drawPageOwner, dikuai, isRefresh);
+			return;
+		}
+		String normalized = normalizeCoordinateInput(edited);
+		if (!saveFieldAndRefresh(dikuai, "returnPathCoordinates", normalized)) {
+			JOptionPane.showMessageDialog(this, "鏃犳硶鏇存柊寰�杩旂偣璺緞", "閿欒", JOptionPane.ERROR_MESSAGE);
+			return;
+		}
+		String message = "-1".equals(normalized) ? "寰�杩旂偣璺緞宸叉竻绌�" : "寰�杩旂偣璺緞宸叉洿鏂�";
+		JOptionPane.showMessageDialog(this, message, "鎴愬姛", JOptionPane.INFORMATION_MESSAGE);
 	}
 
 	/**
@@ -2175,4 +2469,6 @@
 			return new ArrayList<>(names);
 		}
 	}
+
+
 }
\ No newline at end of file

--
Gitblit v1.10.0