-// boolean selected = isSelected();
-// if (selected) {
-// Path2D selectionPath = edge.getPath();
-// Shape selectionShape = SELECTION_STROKE.createStrokedShape(selectionPath);
-// g2d.setColor(SELECTION_COLOR);
-// g2d.fill(selectionShape);
-// }
-//
- g2d.setColor(color);
- if (STROKE != null) {
- if (scaleStroke && STROKE instanceof BasicStroke) {
- BasicStroke bs = GeometryUtils.scaleStroke(STROKE, (float) (1.0 / GeometryUtils.getScale(g2d.getTransform())));
- g2d.setStroke(bs);
- } else {
- g2d.setStroke(STROKE);
- }
+
+ BasicStroke bs = null;
+ double scale = 1.0;
+ if (scaleStroke) {
+ scale = GeometryUtils.getScale(g2d.getTransform());
+ scale = Math.max(10000, Math.min(scale, 50000));
+ double str = stroke != null ? Math.abs(stroke) : 1.0;
+ bs = GeometryUtils.scaleStroke(STROKE, (float) (str / scale));
+ } else {
+ bs = STROKE;
+ }
+ int zoomLevel = MapScalingTransform.zoomLevel(ot);
+ path = calculatePath(edge, path, zoomLevel > 15);
+
+ if (isSelected()) {
+ g2d.setColor(SELECTION_COLOR);
+ g2d.setStroke(GeometryUtils.scaleStroke(bs, 4f));
+ g2d.draw(path);
+ }
+
+ g2d.setColor(dynamicColor != null ? dynamicColor : color);
+ g2d.setStroke(bs);
+ g2d.draw(path);
+
+ // Draw arrow
+ if (arrowLength != null) {
+ g2d.setColor(Color.BLACK);
+ float lw = STROKE.getLineWidth() / (float)scale;
+ g2d.setStroke(new BasicStroke(lw, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
+
+ double l = arrowLength;
+ double w = 2 * (double) lw * Math.signum(l);
+ if (Math.abs(w) > Math.abs(l)) w = l;
+ double offset = 2 * (double) lw;
+
+ double centerX = (startX + endX) / 2, centerY = (startY + endY) / 2;
+ double deltaX = endX - startX, deltaY = endY - startY;
+ double length = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
+ deltaX /= length;
+ deltaY /= length;
+
+ double x0 = centerX - l/2 * deltaX + offset * deltaY;
+ double y0 = centerY - l/2 * deltaY - offset * deltaX;
+ double x1 = centerX + (l/2 - w) * deltaX + offset * deltaY;
+ double y1 = centerY + (l/2 - w) * deltaY - offset * deltaX;
+
+ g2d.draw(new Line2D.Double(x0, y0, x1, y1));
+
+ Path2D path = new Path2D.Double();
+ path.moveTo(x1 + w * deltaX, y1 + w * deltaY);
+ path.lineTo(x1 + w * deltaY, y1 - w * deltaX);
+ path.lineTo(x1 - w * deltaY, y1 + w * deltaX);
+ path.closePath();
+ g2d.fill(path);