| | |
| | | private String boundaryName; |
| | | private boolean boundaryPointsVisible; |
| | | private boolean obstaclePointsVisible; |
| | | private boolean boundaryLengthVisible = false; // 是否显示边界距离,默认关闭 |
| | | private double boundaryPointSizeScale = 1.0d; |
| | | private boolean previewSizingEnabled; |
| | | private String currentBoundaryLandNumber; |
| | |
| | | Obstacledraw.drawObstacles(g2d, currentObstacles, scale, selectedObstacleName); |
| | | } |
| | | |
| | | if (boundaryPointsVisible && hasBoundary) { |
| | | // 显示边界点(如果边界点可见,或者边界距离可见) |
| | | if ((boundaryPointsVisible || boundaryLengthVisible) && hasBoundary) { |
| | | // 预览模式下显示序号 |
| | | if (previewSizingEnabled) { |
| | | drawBoundaryPointsWithNumbers(g2d, currentBoundary, scale); |
| | |
| | | ); |
| | | } |
| | | } |
| | | |
| | | |
| | | // 绘制障碍物坐标点(带序号) |
| | | if (obstaclePointsVisible && hasObstacles) { |
| | | drawObstaclePointsWithNumbers(g2d, currentObstacles, scale); |
| | |
| | | |
| | | drawMower(g2d); |
| | | |
| | | // 保存当前变换(包含视图变换)用于坐标转换 |
| | | AffineTransform currentTransformForLength = g2d.getTransform(); |
| | | |
| | | // 恢复原始变换 |
| | | g2d.setTransform(originalTransform); |
| | | |
| | | // 绘制边界长度(如果启用)- 在恢复原始变换后绘制 |
| | | if (boundaryLengthVisible && hasBoundary) { |
| | | bianjie.BoundaryLengthDrawer.drawBoundaryLengths(g2d, currentBoundary, scale, |
| | | visualizationPanel.getWidth(), visualizationPanel.getHeight(), translateX, translateY); |
| | | } |
| | | |
| | | // 绘制视图信息 |
| | | drawViewInfo(g2d); |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | // 设置点的大小(随缩放变化) |
| | | // 设置点的大小(与边界线宽度一致) |
| | | // 边界线宽度:3 / Math.max(0.5, scale) |
| | | double scaleFactor = Math.max(0.5, scale); |
| | | double clampedScale = boundaryPointSizeScale * (previewSizingEnabled ? PREVIEW_BOUNDARY_MARKER_SCALE : 1.0d); |
| | | if (!Double.isFinite(clampedScale) || clampedScale <= 0.0d) { |
| | | clampedScale = 1.0d; |
| | | } |
| | | double minimumDiameter = clampedScale < 1.0 ? 0.5 : 1.0; |
| | | double markerDiameter = Math.max(minimumDiameter, (10.0 / scaleFactor) * 0.2 * clampedScale); |
| | | double markerDiameter = 3.0 / scaleFactor; // 与边界线宽度一致 |
| | | double markerRadius = markerDiameter / 2.0; |
| | | |
| | | // 设置字体(与障碍物序号一致,不随缩放变化) |
| | |
| | | this.obstaclePointsVisible = visible; |
| | | visualizationPanel.repaint(); |
| | | } |
| | | |
| | | /** |
| | | * 设置是否显示边界距离 |
| | | */ |
| | | public void setBoundaryLengthVisible(boolean visible) { |
| | | boundaryLengthVisible = visible; |
| | | if (visualizationPanel != null) { |
| | | visualizationPanel.repaint(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取是否显示边界距离 |
| | | */ |
| | | public boolean isBoundaryLengthVisible() { |
| | | return boundaryLengthVisible; |
| | | } |
| | | |
| | | public void setBoundaryPointSizeScale(double sizeScale) { |
| | | double normalized = (Double.isFinite(sizeScale) && sizeScale > 0.0d) ? sizeScale : 1.0d; |