| | |
| | | import zhuye.MapRenderer; |
| | | import zhuye.Shouye; |
| | | import zhuye.buttonset; |
| | | import set.Setsys; |
| | | |
| | | import javax.swing.*; |
| | | import javax.swing.filechooser.FileNameExtensionFilter; |
| | |
| | | private JButton baseStationIdEditBtn; |
| | | private JButton handheldEditBtn; |
| | | private JButton checkUpdateBtn; |
| | | private JButton systemDebugButton; |
| | | private JButton feedbackButton; |
| | | private JButton idleTrailEditBtn; |
| | | |
| | |
| | | addRowWithSpacing(panel, idleTrailPanel); |
| | | addRowWithSpacing(panel, feedbackPanel); |
| | | addRowWithSpacing(panel, appVersionPanel); |
| | | panel.add(createDebugPanel()); |
| | | |
| | | return panel; |
| | | } |
| | |
| | | return panel; |
| | | } |
| | | |
| | | private JPanel createDebugPanel() { |
| | | JPanel panel = new JPanel(new GridBagLayout()); |
| | | panel.setBackground(PANEL_BACKGROUND); |
| | | panel.setAlignmentX(Component.LEFT_ALIGNMENT); |
| | | panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, ROW_HEIGHT)); |
| | | panel.setPreferredSize(new Dimension(Integer.MAX_VALUE, ROW_HEIGHT)); |
| | | panel.setMinimumSize(new Dimension(0, ROW_HEIGHT)); |
| | | |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | |
| | | JLabel titleLabel = new JLabel("系统调试"); |
| | | titleLabel.setFont(new Font("微软雅黑", Font.BOLD, 14)); |
| | | titleLabel.setForeground(Color.BLACK); |
| | | titleLabel.setHorizontalAlignment(SwingConstants.RIGHT); |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 0; |
| | | gbc.weightx = 0; |
| | | gbc.anchor = GridBagConstraints.EAST; |
| | | gbc.insets = new Insets(0, 0, 0, 12); |
| | | panel.add(titleLabel, gbc); |
| | | |
| | | Color darkerTheme = new Color( |
| | | Math.max(THEME_COLOR.getRed() - 20, 0), |
| | | Math.max(THEME_COLOR.getGreen() - 20, 0), |
| | | Math.max(THEME_COLOR.getBlue() - 20, 0)); |
| | | systemDebugButton = buttonset.createStyledButton("系统调试", darkerTheme); |
| | | systemDebugButton.setFont(new Font("微软雅黑", Font.PLAIN, 12)); |
| | | |
| | | gbc = new GridBagConstraints(); |
| | | gbc.gridx = 1; |
| | | gbc.gridy = 0; |
| | | gbc.weightx = 1.0; |
| | | gbc.anchor = GridBagConstraints.EAST; |
| | | panel.add(systemDebugButton, gbc); |
| | | |
| | | return panel; |
| | | } |
| | | |
| | | private JPanel createFeedbackPanel() { |
| | | JPanel panel = new JPanel(new GridBagLayout()); |
| | | panel.setBackground(PANEL_BACKGROUND); |
| | |
| | | setData.initializeFromProperties(); |
| | | baseStation.load(); |
| | | updateDisplay(); |
| | | // 加载并应用上次保存的视图中心坐标 |
| | | loadViewCenterFromProperties(); |
| | | } |
| | | |
| | | /** |
| | | * 从配置文件加载视图中心坐标并应用到MapRenderer |
| | | */ |
| | | private void loadViewCenterFromProperties() { |
| | | Shouye shouye = Shouye.getInstance(); |
| | | if (shouye == null) { |
| | | return; |
| | | } |
| | | MapRenderer renderer = shouye.getMapRenderer(); |
| | | if (renderer == null) { |
| | | return; |
| | | } |
| | | |
| | | // 从配置文件读取视图中心坐标 |
| | | String viewCenterXValue = Setsys.getPropertyValue("viewCenterX"); |
| | | String viewCenterYValue = Setsys.getPropertyValue("viewCenterY"); |
| | | |
| | | double savedTranslateX = 0.0; |
| | | double savedTranslateY = 0.0; |
| | | |
| | | if (viewCenterXValue != null && !viewCenterXValue.trim().isEmpty()) { |
| | | try { |
| | | savedTranslateX = Double.parseDouble(viewCenterXValue.trim()); |
| | | } catch (NumberFormatException e) { |
| | | savedTranslateX = 0.0; |
| | | } |
| | | } |
| | | if (viewCenterYValue != null && !viewCenterYValue.trim().isEmpty()) { |
| | | try { |
| | | savedTranslateY = Double.parseDouble(viewCenterYValue.trim()); |
| | | } catch (NumberFormatException e) { |
| | | savedTranslateY = 0.0; |
| | | } |
| | | } |
| | | |
| | | // 应用视图中心坐标(保持当前缩放比例) |
| | | double currentScale = renderer.getScale(); |
| | | renderer.setViewTransform(currentScale, savedTranslateX, savedTranslateY); |
| | | } |
| | | |
| | | private void updateDisplay() { |
| | |
| | | feedbackButton.addActionListener(e -> showFeedbackDialog()); |
| | | } |
| | | |
| | | if (systemDebugButton != null) { |
| | | systemDebugButton.addActionListener(e -> openSystemDebugDialog()); |
| | | } |
| | | |
| | | if (idleTrailEditBtn != null) { |
| | | idleTrailEditBtn.addActionListener(e -> editIdleTrailDuration()); |
| | | } |
| | |
| | | timer.setRepeats(false); |
| | | timer.start(); |
| | | } |
| | | |
| | | private void openSystemDebugDialog() { |
| | | debug dialog = new debug(this, THEME_COLOR); |
| | | dialog.setLocationRelativeTo(this); |
| | | dialog.setVisible(true); |
| | | } |
| | | |
| | | @Override |
| | | public void setVisible(boolean visible) { |