| | |
| | | import java.util.Collections; |
| | | import java.util.Objects; |
| | | import java.util.Properties; |
| | | import java.util.Locale; |
| | | |
| | | import lujing.Lunjingguihua; |
| | | import lujing.MowingPathGenerationPage; |
| | |
| | | contentPanel.add(mowingPatternPanel); |
| | | contentPanel.add(Box.createRigidArea(new Dimension(0, 10))); |
| | | |
| | | // 割草机割刀宽度 |
| | | // 割草机割刀宽度(单位:米,保留2位小数) |
| | | 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); |
| | | // 如果值大于100,认为是厘米,需要转换为米 |
| | | if (bladeWidthMeters > 100) { |
| | | bladeWidthMeters = bladeWidthMeters / 100.0; |
| | | } |
| | | displayBladeWidth = String.format(Locale.US, "%.2fm", bladeWidthMeters); |
| | | } catch (NumberFormatException e) { |
| | | displayBladeWidth = "未设置"; |
| | | } |
| | |
| | | contentPanel.add(mowingBladeWidthPanel); |
| | | contentPanel.add(Box.createRigidArea(new Dimension(0, 10))); |
| | | |
| | | // 割草宽度(单位:米,保留2位小数) |
| | | String mowingWidthValue = dikuai.getMowingWidth(); |
| | | String displayWidth = "未设置"; |
| | | if (mowingWidthValue != null && !"-1".equals(mowingWidthValue) && !mowingWidthValue.trim().isEmpty()) { |
| | | displayWidth = mowingWidthValue + "厘米"; |
| | | try { |
| | | double widthCm = Double.parseDouble(mowingWidthValue.trim()); |
| | | // 将厘米转换为米,保留2位小数 |
| | | double widthMeters = widthCm / 100.0; |
| | | displayWidth = String.format(Locale.US, "%.2fm", widthMeters); |
| | | } catch (NumberFormatException e) { |
| | | displayWidth = "未设置"; |
| | | } |
| | | } |
| | | JPanel mowingWidthPanel = createCardInfoItem("割草宽度:", displayWidth); |
| | | contentPanel.add(mowingWidthPanel); |
| | |
| | | if (distanceMeters > 100) { |
| | | distanceMeters = distanceMeters / 100.0; |
| | | } |
| | | displaySafetyDistance = String.format("%.2f米", distanceMeters); |
| | | displaySafetyDistance = String.format(Locale.US, "%.2fm", distanceMeters); |
| | | } catch (NumberFormatException e) { |
| | | displaySafetyDistance = "未设置"; |
| | | } |
| | |
| | | contentPanel.add(obstaclePanel); |
| | | contentPanel.add(Box.createRigidArea(new Dimension(0, 10))); |
| | | |
| | | // 地块边界坐标(带显示顶点按钮) |
| | | JPanel boundaryPanel = createBoundaryInfoItem(dikuai); |
| | | // 地块边界坐标(带查看按钮) |
| | | JPanel boundaryPanel = createCardInfoItemWithIconButton("地块边界:", |
| | | createViewButton(e -> editBoundaryCoordinates(dikuai))); |
| | | configureInteractiveLabel(getInfoItemTitleLabel(boundaryPanel), |
| | | () -> editBoundaryCoordinates(dikuai), |
| | | "点击查看/编辑地块边界坐标"); |
| | |
| | | contentPanel.add(baseStationPanel); |
| | | contentPanel.add(Box.createRigidArea(new Dimension(0, 10))); |
| | | |
| | | 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, "未记录"), |
| | | createViewButton(e -> showCompletedMowingTrackDialog(dikuai))); |
| | |
| | | if (dikuai == null) { |
| | | return; |
| | | } |
| | | String edited = promptCoordinateEditing("查看 / 编辑地块边界坐标", dikuai.getBoundaryCoordinates()); |
| | | Window owner = SwingUtilities.getWindowAncestor(this); |
| | | |
| | | // 获取地块管理对话框,准备在打开边界编辑页面时关闭 |
| | | Window managementWindow = null; |
| | | if (owner instanceof JDialog) { |
| | | managementWindow = owner; |
| | | } |
| | | |
| | | // 打开边界编辑页面 |
| | | Dikuanbianjipage page = new Dikuanbianjipage(owner, "边界管理页面", dikuai.getBoundaryCoordinates(), dikuai); |
| | | page.setVisible(true); |
| | | |
| | | // 关闭地块管理页面 |
| | | if (managementWindow != null) { |
| | | managementWindow.dispose(); |
| | | } |
| | | |
| | | // 获取编辑结果并保存 |
| | | String edited = page.getResult(); |
| | | if (edited == null) { |
| | | return; |
| | | } |
| | | String normalized = normalizeCoordinateInput(edited); |
| | | if (!saveFieldAndRefresh(dikuai, "boundaryCoordinates", normalized)) { |
| | | JOptionPane.showMessageDialog(this, "无法更新地块边界坐标", "错误", JOptionPane.ERROR_MESSAGE); |
| | | JOptionPane.showMessageDialog(null, "无法更新地块边界坐标", "错误", JOptionPane.ERROR_MESSAGE); |
| | | return; |
| | | } |
| | | String message = "-1".equals(normalized) ? "地块边界坐标已清空" : "地块边界坐标已更新"; |
| | | JOptionPane.showMessageDialog(this, message, "成功", JOptionPane.INFORMATION_MESSAGE); |
| | | JOptionPane.showMessageDialog(null, message, "成功", JOptionPane.INFORMATION_MESSAGE); |
| | | } |
| | | |
| | | private void editPlannedPath(Dikuai dikuai) { |
| | |
| | | JOptionPane.showMessageDialog(this, message, "成功", JOptionPane.INFORMATION_MESSAGE); |
| | | } |
| | | |
| | | private void editBoundaryOriginalCoordinates(Dikuai dikuai) { |
| | | if (dikuai == null) { |
| | | return; |
| | | } |
| | | String edited = promptCoordinateEditing("查看 / 编辑边界原始坐标", dikuai.getBoundaryOriginalCoordinates()); |
| | | if (edited == null) { |
| | | return; |
| | | } |
| | | String normalized = normalizeCoordinateInput(edited); |
| | | if (!saveFieldAndRefresh(dikuai, "boundaryOriginalCoordinates", normalized)) { |
| | | JOptionPane.showMessageDialog(this, "无法更新边界原始坐标", "错误", JOptionPane.ERROR_MESSAGE); |
| | | return; |
| | | } |
| | | String message = "-1".equals(normalized) ? "边界原始坐标已清空" : "边界原始坐标已更新"; |
| | | JOptionPane.showMessageDialog(this, message, "成功", JOptionPane.INFORMATION_MESSAGE); |
| | | } |
| | | |
| | | private void editMowingPattern(Dikuai dikuai) { |
| | | if (dikuai == null) { |