From 87d7cf316e983b0398b270de03a8092412af8487 Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期五, 19 十二月 2025 16:56:30 +0800
Subject: [PATCH] 新增了收到绘制边界模式
---
src/zhuye/LegendDialog.java | 35 ++++++++++++++++++++++++++++++++++-
1 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/src/zhuye/LegendDialog.java b/src/zhuye/LegendDialog.java
index d595034..096e239 100644
--- a/src/zhuye/LegendDialog.java
+++ b/src/zhuye/LegendDialog.java
@@ -61,7 +61,7 @@
contentPanel.remove(contentPanel.getComponentCount() - 1);
}
- // 鐩存帴娣诲姞鍐呭闈㈡澘锛屼笉浣跨敤婊氬姩鏉�
+ // 娣诲姞鍥句緥鍐呭闈㈡澘
mainPanel.add(contentPanel, BorderLayout.CENTER);
getContentPane().add(mainPanel);
@@ -154,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