| | |
| | | import zhuye.Shouye; |
| | | import zhuye.Coordinate; |
| | | import zhuye.buttonset; |
| | | import gecaoji.Device; |
| | | |
| | | /** |
| | | * 新增地块对话框 - 多步骤表单设计 |
| | |
| | | private JComboBox<String> mowingPatternCombo; |
| | | private JTextField mowingWidthField; // 割草机割刀宽度 |
| | | private JTextField overlapDistanceField; // 相邻行重叠距离 |
| | | private JTextField mowingSafetyDistanceField; // 割草安全距离 |
| | | private JLabel calculatedMowingWidthLabel; // 计算后的割草宽度显示 |
| | | private JPanel previewPanel; |
| | | private Map<String, JPanel> drawingOptionPanels = new HashMap<>(); |
| | |
| | | |
| | | calculatedWidthPanel.add(calculatedWidthDisplayPanel); |
| | | settingsPanel.add(calculatedWidthPanel); |
| | | settingsPanel.add(Box.createRigidArea(new Dimension(0, 10))); |
| | | |
| | | // 割草安全距离 |
| | | JPanel safetyDistancePanel = createFormGroupWithoutHint("割草安全距离"); |
| | | JPanel safetyDistanceInputPanel = new JPanel(new BorderLayout()); |
| | | safetyDistanceInputPanel.setBackground(WHITE); |
| | | safetyDistanceInputPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 48)); |
| | | safetyDistanceInputPanel.setAlignmentX(Component.LEFT_ALIGNMENT); |
| | | |
| | | // 获取默认值 |
| | | String defaultSafetyDistance = "0.5"; // 默认值 |
| | | try { |
| | | Device device = Device.getGecaoji(); |
| | | if (device != null) { |
| | | String safetyDistance = device.getMowingSafetyDistance(); |
| | | if (safetyDistance != null && !safetyDistance.trim().isEmpty() && !"-1".equals(safetyDistance.trim())) { |
| | | defaultSafetyDistance = safetyDistance.trim(); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | // 如果获取失败,使用默认值 |
| | | } |
| | | |
| | | mowingSafetyDistanceField = new JTextField(defaultSafetyDistance); |
| | | mowingSafetyDistanceField.setFont(new Font("微软雅黑", Font.PLAIN, 16)); |
| | | mowingSafetyDistanceField.setBorder(BorderFactory.createCompoundBorder( |
| | | BorderFactory.createLineBorder(BORDER_COLOR, 2), |
| | | BorderFactory.createEmptyBorder(10, 12, 10, 12) |
| | | )); |
| | | |
| | | // 添加文本框焦点效果 |
| | | mowingSafetyDistanceField.addFocusListener(new FocusAdapter() { |
| | | @Override |
| | | public void focusGained(FocusEvent e) { |
| | | mowingSafetyDistanceField.setBorder(BorderFactory.createCompoundBorder( |
| | | BorderFactory.createLineBorder(PRIMARY_COLOR, 2), |
| | | BorderFactory.createEmptyBorder(10, 12, 10, 12) |
| | | )); |
| | | } |
| | | |
| | | @Override |
| | | public void focusLost(FocusEvent e) { |
| | | mowingSafetyDistanceField.setBorder(BorderFactory.createCompoundBorder( |
| | | BorderFactory.createLineBorder(BORDER_COLOR, 2), |
| | | BorderFactory.createEmptyBorder(10, 12, 10, 12) |
| | | )); |
| | | } |
| | | }); |
| | | |
| | | JLabel safetyDistanceUnitLabel = new JLabel("米"); |
| | | safetyDistanceUnitLabel.setFont(new Font("微软雅黑", Font.PLAIN, 14)); |
| | | safetyDistanceUnitLabel.setForeground(LIGHT_TEXT); |
| | | safetyDistanceUnitLabel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0)); |
| | | |
| | | safetyDistanceInputPanel.add(mowingSafetyDistanceField, BorderLayout.CENTER); |
| | | safetyDistanceInputPanel.add(safetyDistanceUnitLabel, BorderLayout.EAST); |
| | | |
| | | safetyDistancePanel.add(safetyDistanceInputPanel); |
| | | settingsPanel.add(safetyDistancePanel); |
| | | settingsPanel.add(Box.createRigidArea(new Dimension(0, 25))); |
| | | |
| | | stepPanel.add(settingsPanel); |