| | |
| | | private Runnable pathPreviewReturnAction; |
| | | private JButton settingsReturnButton; // 返回系统设置页面的悬浮按钮 |
| | | private JButton saveManualBoundaryButton; // 保存手动绘制边界的按钮 |
| | | private JButton toggleBoundaryDisplayButton; // 切换边界显示按钮(只显示原始边界/显示全部) |
| | | private String previewRestoreLandNumber; |
| | | private String previewRestoreLandName; |
| | | private Dikuai currentBoundaryPreviewDikuai; // 当前边界预览的地块引用 |
| | |
| | | floatingButtonColumn.add(pathPreviewReturnButton); |
| | | added = true; |
| | | } |
| | | if (toggleBoundaryDisplayButton != null && toggleBoundaryDisplayButton.isVisible()) { |
| | | if (added) { |
| | | floatingButtonColumn.add(Box.createRigidArea(new Dimension(0, 10))); |
| | | } |
| | | floatingButtonColumn.add(toggleBoundaryDisplayButton); |
| | | added = true; |
| | | } |
| | | if (saveManualBoundaryButton != null && saveManualBoundaryButton.isVisible()) { |
| | | if (added) { |
| | | floatingButtonColumn.add(Box.createRigidArea(new Dimension(0, 10))); |
| | |
| | | shouye.pathPreviewReturnButton.setToolTipText("返回边界编辑页面"); |
| | | } |
| | | |
| | | // 创建或显示切换边界显示按钮 |
| | | if (shouye.toggleBoundaryDisplayButton == null) { |
| | | shouye.toggleBoundaryDisplayButton = shouye.createToggleBoundaryDisplayButton(); |
| | | } |
| | | |
| | | // 重置切换按钮状态(默认显示全部边界) |
| | | if (shouye.mapRenderer != null) { |
| | | shouye.mapRenderer.setShowOnlyOriginalBoundary(false); |
| | | } |
| | | shouye.updateToggleBoundaryDisplayButtonText(); |
| | | |
| | | // 隐藏其他悬浮按钮 |
| | | shouye.hideFloatingDrawingControls(); |
| | | |
| | | // 显示返回按钮 |
| | | // 显示返回按钮和切换按钮 |
| | | shouye.pathPreviewReturnButton.setVisible(true); |
| | | shouye.toggleBoundaryDisplayButton.setVisible(true); |
| | | if (shouye.floatingButtonPanel != null) { |
| | | shouye.floatingButtonPanel.setVisible(true); |
| | | if (shouye.floatingButtonPanel.getParent() != shouye.visualizationPanel) { |
| | |
| | | mapRenderer.setIdleTrailSuppressed(false); |
| | | } |
| | | |
| | | // 清除边界预览 |
| | | // 清除边界预览并重置显示状态 |
| | | if (mapRenderer != null) { |
| | | mapRenderer.clearBoundaryPreview(); |
| | | mapRenderer.setBoundaryPreviewUpdateCallback(null); |
| | | mapRenderer.setShowOnlyOriginalBoundary(false); // 重置为显示全部边界 |
| | | } |
| | | |
| | | // 隐藏返回按钮 |
| | | // 隐藏返回按钮和切换按钮 |
| | | if (pathPreviewReturnButton != null) { |
| | | pathPreviewReturnButton.setVisible(false); |
| | | } |
| | | if (toggleBoundaryDisplayButton != null) { |
| | | toggleBoundaryDisplayButton.setVisible(false); |
| | | } |
| | | |
| | | // 隐藏悬浮面板 |
| | | if (floatingButtonPanel != null) { |
| | |
| | | visualizationPanel.revalidate(); |
| | | visualizationPanel.repaint(); |
| | | } |
| | | |
| | | /** |
| | | * 创建切换边界显示按钮 |
| | | */ |
| | | private JButton createToggleBoundaryDisplayButton() { |
| | | JButton button = new JButton("隐藏优化边界"); |
| | | button.setFont(new Font("微软雅黑", Font.PLAIN, 13)); |
| | | button.setBackground(new Color(46, 139, 87)); |
| | | button.setForeground(Color.WHITE); |
| | | button.setBorder(BorderFactory.createEmptyBorder(8, 16, 8, 16)); |
| | | button.setFocusPainted(false); |
| | | button.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
| | | button.setToolTipText("切换显示:只显示原始边界/显示全部边界"); |
| | | |
| | | button.addActionListener(e -> { |
| | | if (mapRenderer == null) { |
| | | return; |
| | | } |
| | | // 切换显示状态 |
| | | boolean currentState = mapRenderer.isShowOnlyOriginalBoundary(); |
| | | mapRenderer.setShowOnlyOriginalBoundary(!currentState); |
| | | updateToggleBoundaryDisplayButtonText(); |
| | | }); |
| | | |
| | | button.addMouseListener(new java.awt.event.MouseAdapter() { |
| | | public void mouseEntered(java.awt.event.MouseEvent e) { |
| | | button.setBackground(new Color(30, 107, 69)); |
| | | } |
| | | |
| | | public void mouseExited(java.awt.event.MouseEvent e) { |
| | | button.setBackground(new Color(46, 139, 87)); |
| | | } |
| | | }); |
| | | |
| | | return button; |
| | | } |
| | | |
| | | /** |
| | | * 更新切换边界显示按钮的文本 |
| | | */ |
| | | private void updateToggleBoundaryDisplayButtonText() { |
| | | if (toggleBoundaryDisplayButton == null || mapRenderer == null) { |
| | | return; |
| | | } |
| | | if (mapRenderer.isShowOnlyOriginalBoundary()) { |
| | | toggleBoundaryDisplayButton.setText("显示全部边界"); |
| | | } else { |
| | | toggleBoundaryDisplayButton.setText("隐藏优化边界"); |
| | | } |
| | | } |
| | | |
| | | // 测试方法 |
| | | public static void main(String[] args) { |