From 7881cef5c3dcea8e6037101db2c3eeb2fd3ba5da Mon Sep 17 00:00:00 2001
From: 826220679@qq.com <826220679@qq.com>
Date: 星期六, 27 十二月 2025 23:42:36 +0800
Subject: [PATCH] 1211

---
 src/gecaoji/lujingdraw.java |  384 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 361 insertions(+), 23 deletions(-)

diff --git a/src/gecaoji/lujingdraw.java b/src/gecaoji/lujingdraw.java
index 15a4c46..4d14fda 100644
--- a/src/gecaoji/lujingdraw.java
+++ b/src/gecaoji/lujingdraw.java
@@ -1,5 +1,4 @@
 package gecaoji; // 鍖呭0鏄�
-
 import java.awt.BasicStroke; // 寮曞叆鍩虹鎻忚竟绫�
 import java.awt.Color; // 寮曞叆棰滆壊绫�
 import java.awt.Graphics2D; // 寮曞叆2D鍥惧舰涓婁笅鏂�
@@ -8,18 +7,38 @@
 import java.awt.geom.Point2D; // 寮曞叆浜岀淮鐐圭被
 import java.util.ArrayList; // 寮曞叆鍔ㄦ�佹暟缁�
 import java.util.List; // 寮曞叆鍒楄〃鎺ュ彛
+import org.locationtech.jts.geom.Coordinate; // 寮曞叆鍧愭爣绫�
+import org.locationtech.jts.geom.GeometryFactory; // 寮曞叆鍑犱綍宸ュ巶绫�
+import org.locationtech.jts.geom.Polygon; // 寮曞叆澶氳竟褰㈢被
 
 /** // 鏂囨。娉ㄩ噴寮�澶�
  * Helper class to parse and render planned mowing paths. // 杈呭姪绫昏鏄�
  */ // 鏂囨。娉ㄩ噴缁撳熬
 public final class lujingdraw { // 绫诲畾涔夛紝闃叉缁ф壙
-    private static final Color PATH_COLOR = new Color(255, 0, 0, 220); // 璺緞棰滆壊锛堢孩鑹插崐閫忔槑锛�
+    // 椹皵鏂豢鑹� (RGB: 102, 205, 170) - 鐢ㄤ簬鍐呯缉杈圭晫锛堝洿杈癸級
+    private static final Color INNER_BOUNDARY_COLOR = new Color(102, 205, 170);
+    // 鎻愰绾㈤�忔槑搴�70% (RGB: 210, 4, 45, alpha: 178) - 鐢ㄤ簬鍓茶崏浣滀笟璺緞
+    private static final Color MOWING_PATH_COLOR = new Color(210, 4, 45, 178);
+    // 钃濊壊 - 鐢ㄤ簬闈炰綔涓氱Щ鍔ㄨ矾寰�
+    private static final Color TRAVEL_PATH_COLOR = new Color(0, 0, 255);
+    // 铏氱嚎鏍峰紡 - 鐢ㄤ簬闈炰綔涓氱Щ鍔ㄨ矾寰�
+    private static final float[] DASH_PATTERN = {5.0f, 5.0f};
     private static final Color START_POINT_COLOR = new Color(0, 0, 0, 220); // 璧风偣绠ご棰滆壊
     private static final Color END_POINT_COLOR = new Color(0, 0, 0, 220); // 缁堢偣绠ご棰滆壊
 
     private lujingdraw() { // 绉佹湁鏋勯�犻槻姝㈠疄渚嬪寲
     } // 绌哄疄鐜�
 
+    // 瑙f瀽缁撴灉锛氬寘鍚偣涓庢瘡涓浉閭绘鐨勪綔涓氭爣娉紙size=points.size()-1锛�
+    public static final class ParsedPath {
+        public final List<Point2D.Double> points;
+        public final List<Boolean> isMowingFlags; // 姣忔瀵瑰簲鏍囨敞锛歵rue=浣滀笟娈碉紝false=鏃呰娈�
+        public ParsedPath(List<Point2D.Double> points, List<Boolean> flags) {
+            this.points = points;
+            this.isMowingFlags = flags;
+        }
+    }
+
     /** // 鏂囨。娉ㄩ噴寮�濮�
      * Parse the planned path string (semicolon-separated "x,y" pairs) into a list of points in meters. // 鏂规硶璇存槑
      */ // 鏂囨。娉ㄩ噴缁撴潫
@@ -67,43 +86,329 @@
         return points; // 杩斿洖缁撴灉
     } // 鏂规硶缁撴潫
 
+    /**
+     * 瑙f瀽甯︽鏍囨敞鐨勮矾寰勫瓧绗︿覆銆傛牸寮忥細绗竴涓偣 "x,y"锛涘悗缁偣鍙负 "x,y,M" 鎴� "x,y,T"锛屽垎鍒〃绀轰笂涓�鐐硅嚦褰撳墠鐐逛负浣滀笟娈垫垨鏃呰娈点��
+     * 鍏煎鏃ф牸寮忥紙鏃犵涓夊瓧娈碉級锛屾鏃� flags 杩斿洖 null銆�
+     */
+    public static ParsedPath parsePlannedPathWithFlags(String plannedPath) {
+        List<Point2D.Double> points = new ArrayList<>();
+        List<Boolean> flags = new ArrayList<>();
+        if (plannedPath == null) {
+            return new ParsedPath(points, null);
+        }
+        String normalized = plannedPath.trim();
+        if (normalized.isEmpty() || "-1".equals(normalized)) {
+            return new ParsedPath(points, null);
+        }
+        int commentIndex = normalized.indexOf('#');
+        if (commentIndex >= 0) {
+            normalized = normalized.substring(0, commentIndex).trim();
+        }
+        if (normalized.isEmpty()) {
+            return new ParsedPath(points, null);
+        }
+        String[] segments = normalized.split(";");
+        boolean sawTypeField = false;
+        for (int i = 0; i < segments.length; i++) {
+            String segment = segments[i];
+            if (segment == null) continue;
+            String trimmed = segment.trim();
+            if (trimmed.isEmpty()) continue;
+            String[] parts = trimmed.split(",");
+            if (parts.length < 2) continue;
+            try {
+                double x = Double.parseDouble(parts[0].trim());
+                double y = Double.parseDouble(parts[1].trim());
+                points.add(new Point2D.Double(x, y));
+                if (i > 0) {
+                    // 绗竴涓偣鏃犳爣娉紱鍚庣画鑻ュ瓨鍦ㄧ涓夊瓧娈靛垯瑙f瀽
+                    if (parts.length >= 3) {
+                        String t = parts[2].trim();
+                        boolean isMowing = t.equalsIgnoreCase("M") || t.equalsIgnoreCase("m") || t.equals("1") || t.equalsIgnoreCase("WORK");
+                        flags.add(isMowing);
+                        sawTypeField = true;
+                    } else {
+                        flags.add(Boolean.TRUE); // 榛樿浣滀笟娈碉紝渚夸簬鍚戝悗鍏煎
+                    }
+                }
+            } catch (NumberFormatException ignored) {
+                // 蹇界暐闈炴硶鍧愭爣
+            }
+        }
+        return new ParsedPath(points, sawTypeField ? flags : null);
+    }
+
     /** // 鏂囨。娉ㄩ噴寮�濮�
      * 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) { // 缁樺埗涓绘柟娉�
+        drawPlannedPath(g2d, path, scale, arrowScale, null, null, null, null, null); // 璋冪敤閲嶈浇鏂规硶
+    } // 鏂规硶缁撴潫
+    
+    /** // 鏂囨。娉ㄩ噴寮�濮�
+     * Draw the planned mowing path with segment information. // 缁樺埗璺緞锛堝甫娈典俊鎭級
+     * @param boundaryCoords 鍦板潡杈圭晫鍧愭爣瀛楃涓诧紝鐢ㄤ簬缁樺埗鍐呯缉杈圭晫
+     * @param mowingWidth 鍓茶崏瀹藉害锛堢背锛夛紝瀛楃涓叉牸寮�
+     * @param safetyDistance 瀹夊叏璺濈锛堢背锛夛紝瀛楃涓叉牸寮�
+     * @param obstaclesCoords 闅滅鐗╁潗鏍囧瓧绗︿覆
+     * @param mowingPattern 鍓茶崏妯″紡锛�"parallel"鎴�"spiral"锛�
+     */ // 鏂囨。娉ㄩ噴缁撴潫
+    public static void drawPlannedPath(Graphics2D g2d, List<Point2D.Double> path, double scale, double arrowScale, 
+                                      String boundaryCoords, String mowingWidth, String safetyDistance, String obstaclesCoords, String mowingPattern) { // 缁樺埗涓绘柟娉曪紙閲嶈浇锛�
         if (path == null || path.size() < 2) { // 鍒ゅ畾鐐规暟
             return; // 鏁版嵁涓嶈冻鐩存帴杩斿洖
         } // if缁撴潫
 
-        Path2D polyline = new Path2D.Double(); // 鍒涘缓鎶樼嚎
-        boolean move = true; // 棣栨鏍囪
-        for (Point2D.Double point : path) { // 閬嶅巻鐐归泦
-            if (move) { // 绗竴娈�
-                polyline.moveTo(point.x, point.y); // 绉诲姩鍒伴鐐�
-                move = false; // 鏇存柊鏍囪
-            } else { // 鍚庣画娈�
-                polyline.lineTo(point.x, point.y); // 杩炵嚎鍒颁笅涓�鐐�
-            } // if缁撴潫
-        } // for缁撴潫
-
         Stroke previous = g2d.getStroke(); // 淇濆瓨鍘熸弿杈�
         float strokeWidth = (float) (2.5 / Math.max(0.5, scale)); // 鏍规嵁缂╂斁璁$畻绾垮
-        g2d.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); // 璁剧疆鍦嗗ご鍦嗚鎻忚竟
-        g2d.setColor(PATH_COLOR); // 璁剧疆绾胯矾棰滆壊
-        g2d.draw(polyline); // 缁樺埗鎶樼嚎
+        
+        // 1. 缁樺埗鍐呯缉杈圭晫锛堝洿杈癸級- 椹皵鏂豢鑹�
+        if (boundaryCoords != null && !boundaryCoords.trim().isEmpty() && !"-1".equals(boundaryCoords.trim())) {
+            drawInnerBoundary(g2d, boundaryCoords, safetyDistance, scale);
+        }
+        
+        // 2. 鎸夋缁樺埗璺緞锛堥�愭缁樺埗锛岄伩鍏嶅皢涓嶇浉閭绘棣栧熬杩炴垚瓒婄晫鐩寸嚎锛�
+        org.locationtech.jts.geom.Geometry innerBoundaryGeom = buildInnerBoundaryGeom(boundaryCoords, safetyDistance);
+        for (int i = 1; i < path.size(); i++) {
+            Point2D.Double a = path.get(i - 1);
+            Point2D.Double b = path.get(i);
 
+            Path2D segment = new Path2D.Double();
+            segment.moveTo(a.x, a.y);
+            segment.lineTo(b.x, b.y);
+
+            boolean inside = true; // 榛樿鎸変綔涓氭缁樺埗
+            if (innerBoundaryGeom != null) {
+                inside = isSegmentInsideInnerBoundary(innerBoundaryGeom, a, b);
+            }
+
+            if (inside) {
+                // 浣滀笟娈碉細瀹炵嚎 + 鎻愰绾�
+                g2d.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
+                g2d.setColor(MOWING_PATH_COLOR);
+            } else {
+                // 鏃呰娈碉紙鎴栨部杈圭晫娈碉級锛氳櫄绾� + 钃濊壊
+                g2d.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 10.0f, DASH_PATTERN, 0.0f));
+                g2d.setColor(TRAVEL_PATH_COLOR);
+            }
+            g2d.draw(segment);
+        }
+        
         Point2D.Double start = path.get(0); // 璧风偣
-        Point2D.Double second = path.get(1); // 绗簩涓偣
+        Point2D.Double second = path.size() > 1 ? path.get(1) : path.get(0); // 绗簩涓偣
         Point2D.Double end = path.get(path.size() - 1); // 缁堢偣
-        Point2D.Double prev = path.get(path.size() - 2); // 鍊掓暟绗簩涓偣
+        Point2D.Double prev = path.size() > 1 ? path.get(path.size() - 2) : path.get(path.size() - 1); // 鍊掓暟绗簩涓偣
 
-        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) { // 缁樺埗绠ご杈呭姪
+    /**
+     * 浣跨敤绠楁硶绔彁渚涚殑娈垫爣娉ㄧ粯鍒惰矾寰勶紙浼樺厛浣跨敤鏍囨敞锛屼笉鍋氬唴缂╄竟鐣屾帹鏂級銆�
+     * flags.size() 蹇呴』涓� path.size()-1銆�
+     */
+    public static void drawPlannedPath(Graphics2D g2d, List<Point2D.Double> path, List<Boolean> flags,
+                                       double scale, double arrowScale,
+                                       String boundaryCoords, String mowingWidth, String safetyDistance,
+                                       String obstaclesCoords, String mowingPattern) {
+        if (path == null || path.size() < 2 || flags == null || flags.size() != path.size() - 1) {
+            // 鍥為��鍒版帹鏂増鏈�
+            drawPlannedPath(g2d, path, scale, arrowScale, boundaryCoords, mowingWidth, safetyDistance, obstaclesCoords, mowingPattern);
+            return;
+        }
+
+        Stroke previous = g2d.getStroke();
+        float strokeWidth = (float) (2.5 / Math.max(0.5, scale));
+
+        // 1. 缁樺埗鍐呯缉杈圭晫锛堝洿杈癸級
+        if (boundaryCoords != null && !boundaryCoords.trim().isEmpty() && !"-1".equals(boundaryCoords.trim())) {
+            drawInnerBoundary(g2d, boundaryCoords, safetyDistance, scale);
+        }
+
+        // 2. 鎸夋缁樺埗锛屽畬鍏ㄩ伒寰畻娉曠鏍囨敞
+        for (int i = 1; i < path.size(); i++) {
+            Point2D.Double a = path.get(i - 1);
+            Point2D.Double b = path.get(i);
+            boolean isMowing = Boolean.TRUE.equals(flags.get(i - 1));
+
+            Path2D segment = new Path2D.Double();
+            segment.moveTo(a.x, a.y);
+            segment.lineTo(b.x, b.y);
+
+            if (isMowing) {
+                g2d.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
+                g2d.setColor(MOWING_PATH_COLOR);
+            } else {
+                g2d.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 10.0f, DASH_PATTERN, 0.0f));
+                g2d.setColor(TRAVEL_PATH_COLOR);
+            }
+            g2d.draw(segment);
+        }
+
+        Point2D.Double start = path.get(0);
+        Point2D.Double second = path.size() > 1 ? path.get(1) : path.get(0);
+        Point2D.Double end = path.get(path.size() - 1);
+        Point2D.Double prev = path.size() > 1 ? path.get(path.size() - 2) : path.get(path.size() - 1);
+
+        drawArrowMarker(g2d, start, second, START_POINT_COLOR, scale, arrowScale);
+        drawArrowMarker(g2d, prev, end, END_POINT_COLOR, scale, arrowScale);
+
+        g2d.setStroke(previous);
+    }
+
+    // 鏋勫缓鍐呯缉杈圭晫鍑犱綍浣擄紝鐢ㄤ簬瀹夊叏妫�娴嬩笌鍒嗘缁樺埗
+    private static org.locationtech.jts.geom.Geometry buildInnerBoundaryGeom(String boundaryCoords, String safetyDistanceStr) {
+        try {
+            if (boundaryCoords == null || boundaryCoords.trim().isEmpty() || "-1".equals(boundaryCoords.trim())) {
+                return null;
+            }
+            List<Coordinate> boundary = parseCoordinates(boundaryCoords);
+            if (boundary.size() < 4) {
+                return null; // 杈圭晫鐐逛笉瓒�
+            }
+            double safetyDistance = 0.2; // 榛樿0.2绫�
+            if (safetyDistanceStr != null && !safetyDistanceStr.trim().isEmpty()) {
+                try {
+                    safetyDistance = Double.parseDouble(safetyDistanceStr.trim());
+                } catch (NumberFormatException ignored) {}
+            }
+            GeometryFactory gf = new GeometryFactory();
+            Polygon poly = gf.createPolygon(gf.createLinearRing(boundary.toArray(new Coordinate[0])));
+            if (!poly.isValid()) {
+                poly = (Polygon) poly.buffer(0);
+            }
+            org.locationtech.jts.geom.Geometry innerBoundary = poly.buffer(-safetyDistance);
+            if (innerBoundary == null || innerBoundary.isEmpty()) {
+                return null;
+            }
+            return innerBoundary;
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    // 鍒ゆ柇涓�娈垫槸鍚﹀湪鍐呯缉杈圭晫鍐呮垨娌胯竟鐣岋紙涓嶈秺鐣岋級
+    private static boolean isSegmentInsideInnerBoundary(org.locationtech.jts.geom.Geometry innerBoundary, Point2D.Double a, Point2D.Double b) {
+        try {
+            GeometryFactory gf = new GeometryFactory();
+            Coordinate[] seg = new Coordinate[] { new Coordinate(a.x, a.y), new Coordinate(b.x, b.y) };
+            org.locationtech.jts.geom.LineString ls = gf.createLineString(seg);
+            // 鍖呭惈鎴栬鐩栧潎瑙嗕负鍚堟硶锛屼笉涓庡唴杈圭晫澶栭儴浜ゅ弶
+            if (innerBoundary.contains(ls) || innerBoundary.covers(ls)) {
+                return true;
+            }
+            // 濡備笌鍐呰竟鐣岃竟鐣岀浉浜わ紝瑙嗕负涓嶅湪鍐呴儴锛堢敤浜庢敼鍙樻牱寮忓苟鏂紑杩炵嚎锛�
+            return !ls.crosses(innerBoundary.getBoundary());
+        } catch (Exception e) {
+            return true; // 妫�娴嬪紓甯告椂锛屾寜浣滀笟娈靛鐞嗕互涓嶄腑鏂粯鍒�
+        }
+    }
+    
+    /** // 鏂囨。娉ㄩ噴寮�濮�
+     * 缁樺埗鍐呯缉杈圭晫锛堝洿杈癸級- 椹皵鏂豢鑹�
+     */ // 鏂囨。娉ㄩ噴缁撴潫
+    private static void drawInnerBoundary(Graphics2D g2d, String boundaryCoords, String safetyDistanceStr, double scale) {
+        try {
+            List<Coordinate> boundary = parseCoordinates(boundaryCoords);
+            if (boundary.size() < 4) {
+                return; // 杈圭晫鐐逛笉瓒�
+            }
+            
+            // 瑙f瀽瀹夊叏璺濈
+            double safetyDistance = 0.2; // 榛樿0.2绫�
+            if (safetyDistanceStr != null && !safetyDistanceStr.trim().isEmpty()) {
+                try {
+                    safetyDistance = Double.parseDouble(safetyDistanceStr.trim());
+                } catch (NumberFormatException e) {
+                    // 浣跨敤榛樿鍊�
+                }
+            }
+            
+            // 鍒涘缓澶氳竟褰㈠苟鍐呯缉
+            GeometryFactory gf = new GeometryFactory();
+            Polygon poly = gf.createPolygon(gf.createLinearRing(boundary.toArray(new Coordinate[0])));
+            if (!poly.isValid()) {
+                poly = (Polygon) poly.buffer(0);
+            }
+            
+            // 鍐呯缉鐢熸垚瀹夊叏杈圭晫
+            org.locationtech.jts.geom.Geometry innerBoundary = poly.buffer(-safetyDistance);
+            if (innerBoundary == null || innerBoundary.isEmpty()) {
+                return;
+            }
+            
+            // 缁樺埗鍐呯缉杈圭晫
+            g2d.setColor(INNER_BOUNDARY_COLOR); // 椹皵鏂豢鑹�
+            float strokeWidth = (float) (3.0 / Math.max(0.5, scale));
+            g2d.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
+            
+            // 灏咼TS鍑犱綍浣撹浆鎹负Path2D骞剁粯鍒�
+            Path2D.Double innerPath = geometryToPath2D(innerBoundary);
+            if (innerPath != null) {
+                g2d.draw(innerPath);
+            }
+        } catch (Exception e) {
+            // 缁樺埗澶辫触鏃跺拷鐣ワ紝涓嶅奖鍝嶅叾浠栬矾寰勭粯鍒�
+        }
+    } // 鏂规硶缁撴潫
+    
+    /** // 鏂囨。娉ㄩ噴寮�濮�
+     * 灏咼TS鍑犱綍浣撹浆鎹负Path2D
+     */ // 鏂囨。娉ㄩ噴缁撴潫
+    private static Path2D.Double geometryToPath2D(org.locationtech.jts.geom.Geometry geom) {
+        if (geom == null) {
+            return null;
+        }
+        Path2D.Double path = new Path2D.Double();
+        if (geom instanceof Polygon) {
+            Polygon poly = (Polygon) geom;
+            addRingToPath(path, poly.getExteriorRing().getCoordinates(), true);
+            for (int i = 0; i < poly.getNumInteriorRing(); i++) {
+                addRingToPath(path, poly.getInteriorRingN(i).getCoordinates(), true);
+            }
+        } else if (geom instanceof org.locationtech.jts.geom.MultiPolygon) {
+            org.locationtech.jts.geom.MultiPolygon mp = (org.locationtech.jts.geom.MultiPolygon) geom;
+            for (int i = 0; i < mp.getNumGeometries(); i++) {
+                Polygon poly = (Polygon) mp.getGeometryN(i);
+                addRingToPath(path, poly.getExteriorRing().getCoordinates(), true);
+                for (int j = 0; j < poly.getNumInteriorRing(); j++) {
+                    addRingToPath(path, poly.getInteriorRingN(j).getCoordinates(), true);
+                }
+            }
+        }
+        return path;
+    } // 鏂规硶缁撴潫
+    
+    /** // 鏂囨。娉ㄩ噴寮�濮�
+     * 灏嗗潗鏍囩幆娣诲姞鍒癙ath2D
+     */ // 鏂囨。娉ㄩ噴缁撴潫
+    private static void addRingToPath(Path2D.Double path, Coordinate[] coords, boolean close) {
+        if (coords == null || coords.length < 2) {
+            return;
+        }
+        path.moveTo(coords[0].x, coords[0].y);
+        for (int i = 1; i < coords.length; i++) {
+            path.lineTo(coords[i].x, coords[i].y);
+        }
+        if (close) {
+            path.closePath();
+        }
+    } // 鏂规硶缁撴潫
+    
+
+    
+    /** // 鏂囨。娉ㄩ噴寮�濮�
+     * 姣旇緝涓や釜鍧愭爣鏄惁鐩稿悓锛堝宸級
+     */ // 鏂囨。娉ㄩ噴缁撴潫
+    private static boolean equals2D(Coordinate a, Coordinate b) {
+        if (a == b) return true;
+        if (a == null || b == null) return false;
+        return a.distance(b) < 1e-4;
+    } // 鏂规硶缁撴潫
+
+    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 +420,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
@@ -143,4 +449,36 @@
         g2d.setColor(color); // 璁剧疆棰滆壊
         g2d.fill(arrow); // 濉厖绠ご
     } // 鏂规硶缁撴潫
+
+    /**
+     * 瑙f瀽鍧愭爣瀛楃涓�
+     */
+    private static List<Coordinate> parseCoordinates(String s) {
+        List<Coordinate> list = new ArrayList<>();
+        if (s == null || s.trim().isEmpty()) return list;
+        // 澧炲己姝e垯锛氬鐞嗗彲鑳藉瓨鍦ㄧ殑澶氱鍒嗛殧绗�
+        String[] pts = s.split("[;\\s]+");
+        for (String p : pts) {
+            String trimmed = p.trim().replace("(", "").replace(")", "");
+            if (trimmed.isEmpty()) continue;
+            String[] xy = trimmed.split("[,锛孿\s]+");
+            if (xy.length >= 2) {
+                try {
+                    double x = Double.parseDouble(xy[0].trim());
+                    double y = Double.parseDouble(xy[1].trim());
+                    // 杩囨护鏃犳晥鍧愭爣
+                    if (!Double.isNaN(x) && !Double.isNaN(y) && !Double.isInfinite(x) && !Double.isInfinite(y)) {
+                        list.add(new Coordinate(x, y));
+                    }
+                } catch (NumberFormatException ex) {
+                    // 蹇界暐瑙f瀽閿欒鐨勭偣
+                }
+            }
+        }
+        // 纭繚澶氳竟褰㈤棴鍚�
+        if (list.size() > 2 && !list.get(0).equals2D(list.get(list.size() - 1))) {
+            list.add(new Coordinate(list.get(0)));
+        }
+        return list;
+    }
 } // 绫荤粨鏉�

--
Gitblit v1.10.0