From 64e0880d2d81ce2b3f0e366b1537c5efe2f2c4ea Mon Sep 17 00:00:00 2001
From: 826220679@qq.com <826220679@qq.com>
Date: 星期日, 21 十二月 2025 20:49:24 +0800
Subject: [PATCH] 需改优化了绘制往返路径
---
src/zhuye/LegendDialog.java | 56 ++++++++++++++++++++++++++------------------------------
1 files changed, 26 insertions(+), 30 deletions(-)
diff --git a/src/zhuye/LegendDialog.java b/src/zhuye/LegendDialog.java
index 7469b67..f3c852f 100644
--- a/src/zhuye/LegendDialog.java
+++ b/src/zhuye/LegendDialog.java
@@ -32,29 +32,6 @@
mainPanel.setBackground(Color.WHITE);
mainPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 10, 15));
- // 璁$畻鍥句緥鍐呭闈㈡澘鐨勫搴︼紙鐢ㄤ簬璁剧疆鍥炬爣灏哄锛�
- // 鍥句緥瀵硅瘽妗嗗搴� = DIALOG_WIDTH * 0.8
- // 涓婚潰鏉垮乏鍙宠竟妗嗗悇15鍍忕礌锛屽浘渚嬪唴瀹归潰鏉垮乏鍙冲唴杈硅窛鍚�10鍍忕礌
- int adjustedWidth = (int) Math.round(UIConfig.DIALOG_WIDTH * 0.8);
- int iconSize = adjustedWidth - 30 - 20; // 鍑忓幓涓婚潰鏉垮乏鍙宠竟妗�(15*2)鍜屽浘渚嬪唴瀹归潰鏉垮乏鍙冲唴杈硅窛(10*2)
-
- // 鍒涘缓鍓茶崏鏈哄浘鏍囬潰鏉�
- JPanel iconPanel = new JPanel(new BorderLayout());
- iconPanel.setBackground(Color.WHITE);
- iconPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); // 搴曢儴闂磋窛10鍍忕礌
-
- JLabel gecaojiLabel = new JLabel();
- gecaojiLabel.setHorizontalAlignment(SwingConstants.CENTER);
- ImageIcon gecaojiIcon = loadIcon("image/gecaoji.png", iconSize, iconSize);
- if (gecaojiIcon != null) {
- gecaojiLabel.setIcon(gecaojiIcon);
- } else {
- // 濡傛灉鍥炬爣鍔犺浇澶辫触锛屾樉绀哄崰浣嶆枃鏈�
- gecaojiLabel.setText("鍓茶崏鏈哄浘鏍�");
- gecaojiLabel.setFont(new Font("寰蒋闆呴粦", Font.PLAIN, 12));
- }
- iconPanel.add(gecaojiLabel, BorderLayout.CENTER);
-
// 鍥句緥鍐呭闈㈡澘 - 鐩存帴娣诲姞锛屼笉浣跨敤婊氬姩鏉�
JPanel contentPanel = new JPanel();
contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
@@ -71,6 +48,7 @@
{"璺緞鏂瑰悜", "255,0,0", "arrow"},
{"闅滅鐗╁尯鍩�", "255,0,0", "obstacle_fill"},
{"鍓茶崏鏈轰綅缃�", "0,150,0", "mow"},
+ {"寰�杩旇矾寰�", "0,0,0", "railway"},
{"鍓茶崏杞ㄨ抗", "100,150,200", "trail"}
};
@@ -84,8 +62,7 @@
contentPanel.remove(contentPanel.getComponentCount() - 1);
}
- // 娣诲姞鍥炬爣闈㈡澘鍜屽浘渚嬪唴瀹归潰鏉�
- mainPanel.add(iconPanel, BorderLayout.NORTH);
+ // 娣诲姞鍥句緥鍐呭闈㈡澘
mainPanel.add(contentPanel, BorderLayout.CENTER);
getContentPane().add(mainPanel);
@@ -144,11 +121,30 @@
g2d.fillPolygon(xPoints, yPoints, 3);
break;
case "mow":
- g2d.setColor(itemColor);
- g2d.fillOval(x, y, size, size);
- g2d.setColor(new Color(100, 100, 100));
- g2d.setStroke(new BasicStroke(1));
- g2d.drawOval(x, y, size, size);
+ ImageIcon icon = loadIcon("image/gecaoji.png", size + 8, size + 8);
+ if (icon != null) {
+ icon.paintIcon(this, g2d, x - 4, y - 4);
+ } else {
+ g2d.setColor(itemColor);
+ g2d.fillOval(x, y, size, size);
+ g2d.setColor(new Color(100, 100, 100));
+ g2d.setStroke(new BasicStroke(1));
+ g2d.drawOval(x, y, size, size);
+ }
+ break;
+ case "railway":
+ // 1. 缁樺埗搴曞眰榛戣壊瀹炵嚎
+ g2d.setColor(Color.BLACK);
+ g2d.setStroke(new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
+ g2d.drawLine(x, y + size/2, x + size, y + size/2);
+
+ // 2. 缁樺埗椤跺眰鐧借壊铏氱嚎
+ float dashLen = 3.0f * 2.0f;
+ float dashSpace = 3.0f * 2.0f;
+ float[] dashPattern = {dashLen, dashSpace};
+ g2d.setColor(Color.WHITE);
+ g2d.setStroke(new BasicStroke(1.2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 10.0f, dashPattern, 0.0f));
+ g2d.drawLine(x, y + size/2, x + size, y + size/2);
break;
case "trail":
g2d.setColor(itemColor);
--
Gitblit v1.10.0