From b518f895dec5264fd25e22a68300c40ceba6f43d Mon Sep 17 00:00:00 2001
From: 826220679@qq.com <826220679@qq.com>
Date: 星期六, 20 十二月 2025 15:30:20 +0800
Subject: [PATCH] 新增了按钮功能
---
src/dikuai/Dikuaiguanli.java | 494 ++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 383 insertions(+), 111 deletions(-)
diff --git a/src/dikuai/Dikuaiguanli.java b/src/dikuai/Dikuaiguanli.java
index c84eecb..740ccf8 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;
@@ -30,6 +28,10 @@
import zhuye.MapRenderer;
import zhuye.Shouye;
import zhuye.Coordinate;
+import zhuye.buttonset;
+import zhuye.Fuzhibutton;
+import zhuye.Lookbutton;
+import gecaoji.Device;
/**
* 鍦板潡绠$悊闈㈡澘 - 鍗$墖寮忓竷灞�璁捐
@@ -71,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) {
@@ -165,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)));
}
}
@@ -245,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();
@@ -259,23 +261,69 @@
landArea = "鏈煡";
}
contentPanel.add(createCardInfoItem("鍦板潡闈㈢Н:", landArea));
- contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
+ contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
- // 杩斿洖鐐瑰潗鏍囷紙甯︿慨鏀规寜閽級
- contentPanel.add(createCardInfoItemWithButton("杩斿洖鐐瑰潗鏍�:",
- getDisplayValue(dikuai.getReturnPointCoordinates(), "鏈缃�"),
- "淇敼", e -> editReturnPoint(dikuai)));
- contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
+ JPanel mowingPatternPanel = createCardInfoItem("鍓茶崏妯″紡:",
+ formatMowingPatternForDisplay(dikuai.getMowingPattern()));
+ configureInteractiveLabel(getInfoItemTitleLabel(mowingPatternPanel),
+ () -> editMowingPattern(dikuai),
+ "鐐瑰嚮鏌ョ湅/缂栬緫鍓茶崏妯″紡");
+ contentPanel.add(mowingPatternPanel);
+ contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
- // 鍦板潡杈圭晫鍧愭爣锛堝甫鏄剧ず椤剁偣鎸夐挳锛�
- JPanel boundaryPanel = createBoundaryInfoItem(dikuai,
- getTruncatedValue(dikuai.getBoundaryCoordinates(), 12, "鏈缃�"));
- setInfoItemTooltip(boundaryPanel, dikuai.getBoundaryCoordinates());
- configureInteractiveLabel(getInfoItemTitleLabel(boundaryPanel),
- () -> editBoundaryCoordinates(dikuai),
- "鐐瑰嚮鏌ョ湅/缂栬緫鍦板潡杈圭晫鍧愭爣");
- contentPanel.add(boundaryPanel);
- contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
+ // 鍓茶崏鏈哄壊鍒�瀹藉害
+ String mowingBladeWidthValue = dikuai.getMowingBladeWidth();
+ String displayBladeWidth = "鏈缃�";
+ if (mowingBladeWidthValue != null && !"-1".equals(mowingBladeWidthValue) && !mowingBladeWidthValue.trim().isEmpty()) {
+ try {
+ double bladeWidthMeters = Double.parseDouble(mowingBladeWidthValue.trim());
+ double bladeWidthCm = bladeWidthMeters * 100.0;
+ displayBladeWidth = String.format("%.2f鍘樼背", bladeWidthCm);
+ } catch (NumberFormatException e) {
+ displayBladeWidth = "鏈缃�";
+ }
+ }
+ JPanel mowingBladeWidthPanel = createCardInfoItem("鍓茶崏鏈哄壊鍒�瀹藉害:", displayBladeWidth);
+ contentPanel.add(mowingBladeWidthPanel);
+ contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
+
+ String mowingWidthValue = dikuai.getMowingWidth();
+ String displayWidth = "鏈缃�";
+ if (mowingWidthValue != null && !"-1".equals(mowingWidthValue) && !mowingWidthValue.trim().isEmpty()) {
+ displayWidth = mowingWidthValue + "鍘樼背";
+ }
+ JPanel mowingWidthPanel = createCardInfoItem("鍓茶崏瀹藉害:", displayWidth);
+ contentPanel.add(mowingWidthPanel);
+ contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
+
+ // 鍓茶崏瀹夊叏璺濈
+ String 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, 10)));
+
+ // 寰�杩旂偣璺緞锛堝甫鏌ョ湅鍥炬爣鎸夐挳锛�
+ JPanel returnPathPanel = createCardInfoItemWithButton("寰�杩旂偣璺緞:",
+ getDisplayValue(dikuai.getReturnPathCoordinates(), "鏈缃�"),
+ 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("闅滅鐗�:",
@@ -288,65 +336,44 @@
() -> showObstacleManagementPage(dikuai),
"鐐瑰嚮鏌ョ湅/绠$悊闅滅鐗�");
contentPanel.add(obstaclePanel);
- contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
+ contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
+
+ // 鍦板潡杈圭晫鍧愭爣锛堝甫鏄剧ず椤剁偣鎸夐挳锛�
+ JPanel boundaryPanel = createBoundaryInfoItem(dikuai);
+ configureInteractiveLabel(getInfoItemTitleLabel(boundaryPanel),
+ () -> editBoundaryCoordinates(dikuai),
+ "鐐瑰嚮鏌ョ湅/缂栬緫鍦板潡杈圭晫鍧愭爣");
+ contentPanel.add(boundaryPanel);
+ contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
// 璺緞鍧愭爣锛堝甫鏌ョ湅鎸夐挳锛�
- JPanel pathPanel = createCardInfoItemWithButton("璺緞鍧愭爣:",
- getTruncatedValue(dikuai.getPlannedPath(), 12, "鏈缃�"),
- "澶嶅埗", e -> copyCoordinatesAction("璺緞鍧愭爣", dikuai.getPlannedPath()));
- setInfoItemTooltip(pathPanel, dikuai.getPlannedPath());
+ JPanel pathPanel = createCardInfoItemWithIconButton("璺緞鍧愭爣:",
+ createViewButton(e -> editPlannedPath(dikuai)));
configureInteractiveLabel(getInfoItemTitleLabel(pathPanel),
() -> editPlannedPath(dikuai),
"鐐瑰嚮鏌ョ湅/缂栬緫璺緞鍧愭爣");
contentPanel.add(pathPanel);
- contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
+ contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
- JPanel baseStationPanel = createCardInfoItemWithButton("鍩虹珯鍧愭爣:",
- getTruncatedValue(dikuai.getBaseStationCoordinates(), 12, "鏈缃�"),
- "澶嶅埗", e -> copyCoordinatesAction("鍩虹珯鍧愭爣", dikuai.getBaseStationCoordinates()));
- setInfoItemTooltip(baseStationPanel, dikuai.getBaseStationCoordinates());
- configureInteractiveLabel(getInfoItemTitleLabel(baseStationPanel),
- () -> editBaseStationCoordinates(dikuai),
- "鐐瑰嚮鏌ョ湅/缂栬緫鍩虹珯鍧愭爣");
- contentPanel.add(baseStationPanel);
- contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
+ JPanel baseStationPanel = createCardInfoItemWithIconButton("鍩虹珯鍧愭爣:",
+ createViewButton(e -> editBaseStationCoordinates(dikuai)));
+ configureInteractiveLabel(getInfoItemTitleLabel(baseStationPanel),
+ () -> editBaseStationCoordinates(dikuai),
+ "鐐瑰嚮鏌ョ湅/缂栬緫鍩虹珯鍧愭爣");
+ contentPanel.add(baseStationPanel);
+ contentPanel.add(Box.createRigidArea(new Dimension(0, 10)));
- JPanel boundaryOriginalPanel = createCardInfoItemWithButton("杈圭晫鍘熷鍧愭爣:",
- getTruncatedValue(dikuai.getBoundaryOriginalCoordinates(), 12, "鏈缃�"),
- "澶嶅埗", e -> copyCoordinatesAction("杈圭晫鍘熷鍧愭爣", dikuai.getBoundaryOriginalCoordinates()));
- setInfoItemTooltip(boundaryOriginalPanel, dikuai.getBoundaryOriginalCoordinates());
- configureInteractiveLabel(getInfoItemTitleLabel(boundaryOriginalPanel),
- () -> editBoundaryOriginalCoordinates(dikuai),
- "鐐瑰嚮鏌ョ湅/缂栬緫杈圭晫鍘熷鍧愭爣");
- contentPanel.add(boundaryOriginalPanel);
- contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
-
- JPanel mowingPatternPanel = createCardInfoItemWithButton("鍓茶崏妯″紡:",
- getTruncatedValue(dikuai.getMowingPattern(), 12, "鏈缃�"),
- "澶嶅埗", e -> copyCoordinatesAction("鍓茶崏妯″紡", dikuai.getMowingPattern()));
- setInfoItemTooltip(mowingPatternPanel, dikuai.getMowingPattern());
- configureInteractiveLabel(getInfoItemTitleLabel(mowingPatternPanel),
- () -> editMowingPattern(dikuai),
- "鐐瑰嚮鏌ョ湅/缂栬緫鍓茶崏妯″紡");
- contentPanel.add(mowingPatternPanel);
- contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
-
- String mowingWidthValue = dikuai.getMowingWidth();
- String widthSource = null;
- if (mowingWidthValue != null && !"-1".equals(mowingWidthValue) && !mowingWidthValue.trim().isEmpty()) {
- widthSource = mowingWidthValue + "鍘樼背";
- }
- String displayWidth = getTruncatedValue(widthSource, 12, "鏈缃�");
- JPanel mowingWidthPanel = createCardInfoItemWithButton("鍓茶崏瀹藉害:",
- displayWidth,
- "缂栬緫", e -> editMowingWidth(dikuai));
- setInfoItemTooltip(mowingWidthPanel, widthSource);
- contentPanel.add(mowingWidthPanel);
- contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
+ JPanel boundaryOriginalPanel = createCardInfoItemWithIconButton("杈圭晫鍘熷鍧愭爣:",
+ createViewButton(e -> editBoundaryOriginalCoordinates(dikuai)));
+ configureInteractiveLabel(getInfoItemTitleLabel(boundaryOriginalPanel),
+ () -> editBoundaryOriginalCoordinates(dikuai),
+ "鐐瑰嚮鏌ョ湅/缂栬緫杈圭晫鍘熷鍧愭爣");
+ contentPanel.add(boundaryOriginalPanel);
+ 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),
@@ -361,11 +388,16 @@
JButton generatePathBtn = createPrimaryFooterButton("璺緞瑙勫垝");
generatePathBtn.addActionListener(e -> showPathPlanningPage(dikuai));
+ JButton navigationPreviewBtn = createPrimaryFooterButton("瀵艰埅棰勮");
+ navigationPreviewBtn.addActionListener(e -> startNavigationPreview(dikuai));
+
JPanel footerPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
footerPanel.setBackground(CARD_BACKGROUND);
footerPanel.setBorder(BorderFactory.createEmptyBorder(15, 0, 0, 0));
footerPanel.add(generatePathBtn);
footerPanel.add(Box.createHorizontalStrut(12));
+ footerPanel.add(navigationPreviewBtn);
+ footerPanel.add(Box.createHorizontalStrut(12));
footerPanel.add(deleteBtn);
card.add(footerPanel, BorderLayout.SOUTH);
@@ -387,6 +419,7 @@
itemPanel.add(labelComp, BorderLayout.WEST);
itemPanel.add(valueComp, BorderLayout.EAST);
+ itemPanel.putClientProperty("titleLabel", labelComp);
return itemPanel;
}
@@ -425,15 +458,101 @@
return itemPanel;
}
- private JPanel createBoundaryInfoItem(Dikuai dikuai, String displayValue) {
+ 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);
+ // 澧炲姞楂樺害浠ョ‘淇濇寜閽畬鏁存樉绀猴紙鎸夐挳楂樺害绾�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));
+
+ JButton button = createSmallLinkButton(buttonText, listener);
+
+ rightPanel.add(button);
+
+ itemPanel.add(labelComp, BorderLayout.WEST);
+ itemPanel.add(rightPanel, BorderLayout.CENTER);
+ itemPanel.putClientProperty("titleLabel", labelComp);
+
+ 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));
@@ -445,18 +564,25 @@
rightPanel.setBackground(CARD_BACKGROUND);
rightPanel.setBorder(BorderFactory.createEmptyBorder(verticalPadding, 0, verticalPadding, 0));
- JLabel valueComp = new JLabel(displayValue);
- valueComp.setFont(new Font("寰蒋闆呴粦", Font.PLAIN, 14));
- valueComp.setForeground(TEXT_COLOR);
+ // 鐘舵�佹彁绀烘枃瀛楁爣绛�
+ JLabel statusLabel = new JLabel();
+ statusLabel.setFont(new Font("寰蒋闆呴粦", Font.PLAIN, 13));
+ statusLabel.setForeground(LIGHT_TEXT);
JButton toggleButton = createBoundaryToggleButton(dikuai);
+ // 灏嗙姸鎬佹爣绛惧拰鎸夐挳鍏宠仈锛屼互渚垮湪鎸夐挳鐘舵�佸彉鍖栨椂鏇存柊鏍囩
+ toggleButton.putClientProperty("statusLabel", statusLabel);
- rightPanel.add(valueComp);
+ // 鍒濆鍖栫姸鎬佹枃瀛�
+ String landNumber = dikuai.getLandNumber();
+ boolean isVisible = boundaryPointVisibility.getOrDefault(landNumber, false);
+ updateBoundaryStatusLabel(statusLabel, isVisible);
+
+ rightPanel.add(statusLabel);
rightPanel.add(toggleButton);
itemPanel.add(labelComp, BorderLayout.WEST);
itemPanel.add(rightPanel, BorderLayout.CENTER);
- itemPanel.putClientProperty("valueLabel", valueComp);
itemPanel.putClientProperty("titleLabel", labelComp);
return itemPanel;
@@ -471,7 +597,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);
@@ -499,6 +625,24 @@
button.setOpaque(true);
}
button.setToolTipText(active ? "闅愯棌杈圭晫鐐瑰簭鍙�" : "鏄剧ず杈圭晫鐐瑰簭鍙�");
+
+ // 鏇存柊鐘舵�佹彁绀烘枃瀛�
+ Object statusLabelObj = button.getClientProperty("statusLabel");
+ if (statusLabelObj instanceof JLabel) {
+ JLabel statusLabel = (JLabel) statusLabelObj;
+ updateBoundaryStatusLabel(statusLabel, active);
+ }
+ }
+
+ private void updateBoundaryStatusLabel(JLabel statusLabel, boolean active) {
+ if (statusLabel == null) {
+ return;
+ }
+ if (active) {
+ statusLabel.setText("宸插紑鍚竟鐣岀偣鏄剧ず");
+ } else {
+ statusLabel.setText("宸插叧闂竟鐣岀偣鏄剧ず");
+ }
}
private void ensureBoundaryToggleIconsLoaded() {
@@ -637,9 +781,80 @@
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("澶嶅埗");
+
+ // 鍒ゆ柇鏄惁鏄線杩旂偣璺緞瀵硅瘽妗�
+ boolean isReturnPathDialog = title != null && title.contains("寰�杩旂偣璺緞");
+ JButton okButton;
+ JButton cancelButton;
+ JButton copyButton;
+
+ 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 = Fuzhibutton.createCopyButton(
+ (java.util.function.Supplier<String>) () -> {
+ String text = textArea.getText();
+ if (text == null) {
+ text = "";
+ }
+ String trimmed = text.trim();
+ if (trimmed.isEmpty() || "-1".equals(trimmed)) {
+ return null; // 杩斿洖null浼氳Е鍙�"鏈缃澶嶅埗鐨勫唴瀹�"鎻愮ず
+ }
+ return text;
+ },
+ "澶嶅埗" + title,
+ new Color(230, 250, 240)
+ );
+
+ } 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];
@@ -652,26 +867,6 @@
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);
@@ -680,6 +875,18 @@
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);
@@ -859,6 +1066,31 @@
}
/**
+ * 鍚姩瀵艰埅棰勮
+ */
+ private void startNavigationPreview(Dikuai dikuai) {
+ if (dikuai == null) {
+ return;
+ }
+
+ Window owner = SwingUtilities.getWindowAncestor(this);
+
+ // 鑾峰彇鍦板潡绠$悊瀵硅瘽妗嗭紝鍑嗗鍦ㄦ墦寮�瀵艰埅棰勮鏃跺叧闂�
+ Window managementWindow = null;
+ if (owner instanceof JDialog) {
+ managementWindow = owner;
+ }
+
+ // 鍏抽棴鍦板潡绠$悊椤甸潰
+ if (managementWindow != null) {
+ managementWindow.dispose();
+ }
+
+ // 鍚姩瀵艰埅棰勮
+ daohangyulan.getInstance().startNavigationPreview(dikuai);
+ }
+
+ /**
* 鏄剧ず璺緞瑙勫垝椤甸潰
*/
private void showPathPlanningPage(Dikuai dikuai) {
@@ -940,6 +1172,7 @@
dialog.setVisible(true);
}
+
private void generateMowingPath(Dikuai dikuai) {
if (dikuai == null) {
return;
@@ -1183,6 +1416,21 @@
return section;
}
+ private String formatMowingPatternForDisplay(String patternValue) {
+ String sanitized = sanitizeValueOrNull(patternValue);
+ if (sanitized == null) {
+ return "鏈缃�";
+ }
+ String normalized = normalizeExistingMowingPattern(sanitized);
+ if ("parallel".equals(normalized)) {
+ return "骞宠妯″紡 (parallel)";
+ }
+ if ("spiral".equals(normalized)) {
+ return "铻烘棆妯″紡 (spiral)";
+ }
+ return sanitized;
+ }
+
private String formatMowingPatternForDialog(String patternValue) {
String sanitized = sanitizeValueOrNull(patternValue);
if (sanitized == null) {
@@ -1419,15 +1667,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); // 瀹炲績椋庢牸
}
@@ -1646,13 +1910,21 @@
});
}
- 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());
+ if (edited == null) {
+ 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);
}
/**
--
Gitblit v1.10.0