From b315a6943e6c0d6bdf0d5f7565c570d719154d6c Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期三, 17 十二月 2025 14:56:58 +0800
Subject: [PATCH] 新增了障碍物管理页面

---
 src/zhuye/LegendDialog.java |   51 +++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/src/zhuye/LegendDialog.java b/src/zhuye/LegendDialog.java
index 40998de..096e239 100644
--- a/src/zhuye/LegendDialog.java
+++ b/src/zhuye/LegendDialog.java
@@ -8,10 +8,11 @@
 public class LegendDialog extends JDialog {
 
     public LegendDialog(Component parent, Color ignoredThemeColor) {
-        super(parent != null ? (JFrame) SwingUtilities.getWindowAncestor(parent) : null,
-              "鍥句緥", true);
-    // 浣跨敤缁熶竴瀹藉害锛岄珮搴︾缉鍑忎负涓�鍗�
-    initializeDialog(UIConfig.DIALOG_WIDTH, UIConfig.DIALOG_HEIGHT / 2);
+      super(parent != null ? (JFrame) SwingUtilities.getWindowAncestor(parent) : null,
+          "鍥句緥", true);
+      int adjustedWidth = (int) Math.round(UIConfig.DIALOG_WIDTH * 0.8);
+    int adjustedHeight = (int) Math.round(UIConfig.DIALOG_HEIGHT * 0.4);
+    initializeDialog(adjustedWidth, adjustedHeight);
         initializeLegendContent();
         if (parent == null) {
             setLocationRelativeTo(null); // 灞呬腑鏄剧ず
@@ -31,13 +32,6 @@
         mainPanel.setBackground(Color.WHITE);
         mainPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 10, 15));
         
-        // 鏍囬 - 淇敼涓�"鍥句緥"
-        JLabel titleLabel = new JLabel("鍥句緥", JLabel.CENTER);
-        titleLabel.setFont(new Font("寰蒋闆呴粦", Font.BOLD, 14));
-        titleLabel.setForeground(new Color(60, 60, 60));
-        titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
-        mainPanel.add(titleLabel, BorderLayout.NORTH);
-        
         // 鍥句緥鍐呭闈㈡澘 - 鐩存帴娣诲姞锛屼笉浣跨敤婊氬姩鏉�
         JPanel contentPanel = new JPanel();
         contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
@@ -67,7 +61,7 @@
             contentPanel.remove(contentPanel.getComponentCount() - 1);
         }
         
-        // 鐩存帴娣诲姞鍐呭闈㈡澘锛屼笉浣跨敤婊氬姩鏉�
+        // 娣诲姞鍥句緥鍐呭闈㈡澘
         mainPanel.add(contentPanel, BorderLayout.CENTER);
         
         getContentPane().add(mainPanel);
@@ -160,4 +154,37 @@
         
         return itemPanel;
     }
+    
+    /**
+     * 鍔犺浇骞剁缉鏀惧浘鏍�
+     * @param iconPath 鍥炬爣璺緞
+     * @param width 鐩爣瀹藉害
+     * @param height 鐩爣楂樺害
+     * @return 缂╂斁鍚庣殑鍥炬爣
+     */
+    private ImageIcon loadIcon(String iconPath, int width, int height) {
+        try {
+            java.net.URL imgURL = getClass().getClassLoader().getResource(iconPath);
+            if (imgURL == null) {
+                // 灏濊瘯浠庢枃浠剁郴缁熷姞杞�
+                java.io.File imgFile = new java.io.File(iconPath);
+                if (imgFile.exists()) {
+                    ImageIcon originalIcon = new ImageIcon(imgFile.getAbsolutePath());
+                    Image scaledImage = originalIcon.getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH);
+                    ImageIcon scaledIcon = new ImageIcon(scaledImage);
+                    scaledIcon.setDescription(iconPath);
+                    return scaledIcon;
+                }
+            } else {
+                ImageIcon originalIcon = new ImageIcon(imgURL);
+                Image scaledImage = originalIcon.getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH);
+                ImageIcon scaledIcon = new ImageIcon(scaledImage);
+                scaledIcon.setDescription(iconPath);
+                return scaledIcon;
+            }
+        } catch (Exception e) {
+            System.err.println("鏃犳硶鍔犺浇鍥炬爣: " + iconPath + " - " + e.getMessage());
+        }
+        return null;
+    }
 }
\ No newline at end of file

--
Gitblit v1.10.0