张世豪
2025-12-09 32524195d474b74e48916867b2a6c2f022a40d98
src/gecaoji/lujingdraw.java
@@ -70,7 +70,7 @@
    /** // 文档注释开始
     * Draw the planned mowing path. // 绘制路径
     */ // 文档注释结束
    public static void drawPlannedPath(Graphics2D g2d, List<Point2D.Double> path, double scale) { // 绘制主方法
    public static void drawPlannedPath(Graphics2D g2d, List<Point2D.Double> path, double scale, double arrowScale) { // 绘制主方法
        if (path == null || path.size() < 2) { // 判定点数
            return; // 数据不足直接返回
        } // if结束
@@ -97,13 +97,13 @@
        Point2D.Double end = path.get(path.size() - 1); // 终点
        Point2D.Double prev = path.get(path.size() - 2); // 倒数第二个点
        drawArrowMarker(g2d, start, second, START_POINT_COLOR, scale); // 绘制起点箭头
        drawArrowMarker(g2d, prev, end, END_POINT_COLOR, scale); // 绘制终点箭头
    drawArrowMarker(g2d, start, second, START_POINT_COLOR, scale, arrowScale); // 绘制起点箭头
    drawArrowMarker(g2d, prev, end, END_POINT_COLOR, scale, arrowScale); // 绘制终点箭头
        g2d.setStroke(previous); // 恢复原描边
    } // 方法结束
    private static void drawArrowMarker(Graphics2D g2d, Point2D.Double from, Point2D.Double to, Color color, double scale) { // 绘制箭头辅助
    private static void drawArrowMarker(Graphics2D g2d, Point2D.Double from, Point2D.Double to, Color color, double scale, double sizeScale) { // 绘制箭头辅助
        if (from == null || to == null) { // 判空
            return; // 数据不足返回
        } // if结束
@@ -115,7 +115,8 @@
        } // if结束
    double arrowLength = Math.max(2.5, 5.5 / Math.max(0.5, scale)); // 计算箭头长度
    arrowLength *= 0.5; // 缩小箭头尺寸为原来的一半
    double clampedScale = sizeScale > 0 ? sizeScale : 1.0; // 防止非法缩放
    arrowLength *= 0.25 * clampedScale; // 缩小箭头至原来的一半
        double arrowWidth = arrowLength * 0.45; // 计算箭头宽度
        double ux = dx / length; // 单位向量X