From 3d415216b8d8f101ab543dbbf22e313507a402ca Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期二, 23 十二月 2025 12:14:30 +0800
Subject: [PATCH] 优化了地块边界管理页面

---
 src/zhuye/Shouye.java |   80 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 77 insertions(+), 3 deletions(-)

diff --git a/src/zhuye/Shouye.java b/src/zhuye/Shouye.java
index 14c9fd5..a59e71d 100644
--- a/src/zhuye/Shouye.java
+++ b/src/zhuye/Shouye.java
@@ -131,6 +131,7 @@
 	private Runnable pathPreviewReturnAction;
 	private JButton settingsReturnButton;  // 杩斿洖绯荤粺璁剧疆椤甸潰鐨勬偓娴寜閽�
 	private JButton saveManualBoundaryButton;  // 淇濆瓨鎵嬪姩缁樺埗杈圭晫鐨勬寜閽�
+	private JButton toggleBoundaryDisplayButton;  // 鍒囨崲杈圭晫鏄剧ず鎸夐挳锛堝彧鏄剧ず鍘熷杈圭晫/鏄剧ず鍏ㄩ儴锛�
 	private String previewRestoreLandNumber;
 	private String previewRestoreLandName;
 	private Dikuai currentBoundaryPreviewDikuai;  // 褰撳墠杈圭晫棰勮鐨勫湴鍧楀紩鐢�
@@ -3239,6 +3240,13 @@
 			floatingButtonColumn.add(pathPreviewReturnButton);
 			added = true;
 		}
+		if (toggleBoundaryDisplayButton != null && toggleBoundaryDisplayButton.isVisible()) {
+			if (added) {
+				floatingButtonColumn.add(Box.createRigidArea(new Dimension(0, 10)));
+			}
+			floatingButtonColumn.add(toggleBoundaryDisplayButton);
+			added = true;
+		}
 		if (saveManualBoundaryButton != null && saveManualBoundaryButton.isVisible()) {
 			if (added) {
 				floatingButtonColumn.add(Box.createRigidArea(new Dimension(0, 10)));
@@ -4354,11 +4362,23 @@
             shouye.pathPreviewReturnButton.setToolTipText("杩斿洖杈圭晫缂栬緫椤甸潰");
         }
         
+        // 鍒涘缓鎴栨樉绀哄垏鎹㈣竟鐣屾樉绀烘寜閽�
+        if (shouye.toggleBoundaryDisplayButton == null) {
+            shouye.toggleBoundaryDisplayButton = shouye.createToggleBoundaryDisplayButton();
+        }
+        
+        // 閲嶇疆鍒囨崲鎸夐挳鐘舵�侊紙榛樿鏄剧ず鍏ㄩ儴杈圭晫锛�
+        if (shouye.mapRenderer != null) {
+            shouye.mapRenderer.setShowOnlyOriginalBoundary(false);
+        }
+        shouye.updateToggleBoundaryDisplayButtonText();
+        
         // 闅愯棌鍏朵粬鎮诞鎸夐挳
         shouye.hideFloatingDrawingControls();
         
-        // 鏄剧ず杩斿洖鎸夐挳
+        // 鏄剧ず杩斿洖鎸夐挳鍜屽垏鎹㈡寜閽�
         shouye.pathPreviewReturnButton.setVisible(true);
+        shouye.toggleBoundaryDisplayButton.setVisible(true);
         if (shouye.floatingButtonPanel != null) {
             shouye.floatingButtonPanel.setVisible(true);
             if (shouye.floatingButtonPanel.getParent() != shouye.visualizationPanel) {
@@ -4396,16 +4416,20 @@
             mapRenderer.setIdleTrailSuppressed(false);
         }
         
-        // 娓呴櫎杈圭晫棰勮
+        // 娓呴櫎杈圭晫棰勮骞堕噸缃樉绀虹姸鎬�
         if (mapRenderer != null) {
             mapRenderer.clearBoundaryPreview();
             mapRenderer.setBoundaryPreviewUpdateCallback(null);
+            mapRenderer.setShowOnlyOriginalBoundary(false); // 閲嶇疆涓烘樉绀哄叏閮ㄨ竟鐣�
         }
         
-        // 闅愯棌杩斿洖鎸夐挳
+        // 闅愯棌杩斿洖鎸夐挳鍜屽垏鎹㈡寜閽�
         if (pathPreviewReturnButton != null) {
             pathPreviewReturnButton.setVisible(false);
         }
+        if (toggleBoundaryDisplayButton != null) {
+            toggleBoundaryDisplayButton.setVisible(false);
+        }
         
         // 闅愯棌鎮诞闈㈡澘
         if (floatingButtonPanel != null) {
@@ -4415,6 +4439,56 @@
         visualizationPanel.revalidate();
         visualizationPanel.repaint();
     }
+    
+    /**
+     * 鍒涘缓鍒囨崲杈圭晫鏄剧ず鎸夐挳
+     */
+    private JButton createToggleBoundaryDisplayButton() {
+        JButton button = new JButton("闅愯棌浼樺寲杈圭晫");
+        button.setFont(new Font("寰蒋闆呴粦", Font.PLAIN, 13));
+        button.setBackground(new Color(46, 139, 87));
+        button.setForeground(Color.WHITE);
+        button.setBorder(BorderFactory.createEmptyBorder(8, 16, 8, 16));
+        button.setFocusPainted(false);
+        button.setCursor(new Cursor(Cursor.HAND_CURSOR));
+        button.setToolTipText("鍒囨崲鏄剧ず锛氬彧鏄剧ず鍘熷杈圭晫/鏄剧ず鍏ㄩ儴杈圭晫");
+        
+        button.addActionListener(e -> {
+            if (mapRenderer == null) {
+                return;
+            }
+            // 鍒囨崲鏄剧ず鐘舵��
+            boolean currentState = mapRenderer.isShowOnlyOriginalBoundary();
+            mapRenderer.setShowOnlyOriginalBoundary(!currentState);
+            updateToggleBoundaryDisplayButtonText();
+        });
+        
+        button.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseEntered(java.awt.event.MouseEvent e) {
+                button.setBackground(new Color(30, 107, 69));
+            }
+            
+            public void mouseExited(java.awt.event.MouseEvent e) {
+                button.setBackground(new Color(46, 139, 87));
+            }
+        });
+        
+        return button;
+    }
+    
+    /**
+     * 鏇存柊鍒囨崲杈圭晫鏄剧ず鎸夐挳鐨勬枃鏈�
+     */
+    private void updateToggleBoundaryDisplayButtonText() {
+        if (toggleBoundaryDisplayButton == null || mapRenderer == null) {
+            return;
+        }
+        if (mapRenderer.isShowOnlyOriginalBoundary()) {
+            toggleBoundaryDisplayButton.setText("鏄剧ず鍏ㄩ儴杈圭晫");
+        } else {
+            toggleBoundaryDisplayButton.setText("闅愯棌浼樺寲杈圭晫");
+        }
+    }
 
 	// 娴嬭瘯鏂规硶
     public static void main(String[] args) {

--
Gitblit v1.10.0