张世豪
10 小时以前 13d032241e1a2938a8be4f64c9171e1240e9ea1e
src/zhuye/Shouye.java
@@ -4296,6 +4296,90 @@
            pathPreviewReturnAction.run();
        }
    }
    /**
     * 显示边界预览(原始边界-紫色,优化后边界-绿色)
     * @param dikuai 地块对象
     * @param optimizedBoundary 优化后的边界坐标字符串
     * @param returnCallback 返回回调
     */
    public static void showBoundaryPreview(dikuai.Dikuai dikuai, String optimizedBoundary, Runnable returnCallback) {
        Shouye shouye = getInstance();
        if (shouye == null || shouye.mapRenderer == null || dikuai == null) {
            return;
        }
        // 获取原始边界XY坐标
        String originalBoundaryXY = dikuai.getBoundaryOriginalXY();
        // 设置边界预览
        shouye.mapRenderer.setBoundaryPreview(originalBoundaryXY, optimizedBoundary);
        // 设置返回回调
        shouye.pathPreviewReturnAction = returnCallback;
        shouye.pathPreviewActive = true;
        // 确保悬浮按钮基础设施已创建
        shouye.ensureFloatingButtonInfrastructure();
        // 创建或显示返回按钮
        if (shouye.pathPreviewReturnButton == null) {
            shouye.pathPreviewReturnButton = publicway.Fanhuibutton.createReturnButton(e -> shouye.handleBoundaryPreviewReturn());
            shouye.pathPreviewReturnButton.setToolTipText("返回边界编辑页面");
        }
        // 隐藏其他悬浮按钮
        shouye.hideFloatingDrawingControls();
        // 显示返回按钮
        shouye.pathPreviewReturnButton.setVisible(true);
        if (shouye.floatingButtonPanel != null) {
            shouye.floatingButtonPanel.setVisible(true);
            if (shouye.floatingButtonPanel.getParent() != shouye.visualizationPanel) {
                shouye.visualizationPanel.add(shouye.floatingButtonPanel, BorderLayout.SOUTH);
            }
        }
        shouye.rebuildFloatingButtonColumn();
        shouye.visualizationPanel.revalidate();
        shouye.visualizationPanel.repaint();
    }
    /**
     * 处理边界预览返回
     */
    private void handleBoundaryPreviewReturn() {
        Runnable callback = pathPreviewReturnAction;
        exitBoundaryPreview();
        if (callback != null) {
            callback.run();
        }
    }
    /**
     * 退出边界预览
     */
    private void exitBoundaryPreview() {
        pathPreviewActive = false;
        // 清除边界预览
        if (mapRenderer != null) {
            mapRenderer.clearBoundaryPreview();
        }
        // 隐藏返回按钮
        if (pathPreviewReturnButton != null) {
            pathPreviewReturnButton.setVisible(false);
        }
        // 隐藏悬浮面板
        if (floatingButtonPanel != null) {
            floatingButtonPanel.setVisible(false);
        }
        visualizationPanel.revalidate();
        visualizationPanel.repaint();
    }
   // 测试方法
    public static void main(String[] args) {