From: Reino Ruusu Date: Thu, 21 Mar 2019 10:50:55 +0000 (+0200) Subject: Eliminate scaling of arrow widths based on dynamic edge thickness. X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=7ce96159ac6670ad4ba54f8faf93c167c35283fc;p=simantics%2Fdistrict.git Eliminate scaling of arrow widths based on dynamic edge thickness. gitlab #39 Change-Id: Iafd81090cdb6a793e983f0c00d1ccafacd64913b --- diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeNode.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeNode.java index 21f3d741..74e8acdc 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeNode.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeNode.java @@ -77,8 +77,9 @@ public class DistrictNetworkEdgeNode extends G2DParentNode implements ISelection BasicStroke oldStroke = (BasicStroke) g2d.getStroke(); BasicStroke bs = null; + double scale = 1.0; if (scaleStroke) { - double scale = GeometryUtils.getScale(g2d.getTransform()); + 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)); @@ -101,12 +102,13 @@ public class DistrictNetworkEdgeNode extends G2DParentNode implements ISelection // Draw arrow if (arrowLength != null) { g2d.setColor(Color.BLACK); - g2d.setStroke(new BasicStroke(bs.getLineWidth(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); + float lw = STROKE.getLineWidth() / (float)scale; + g2d.setStroke(new BasicStroke(lw, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); double l = arrowLength; - double w = 2 * (double) bs.getLineWidth() * Math.signum(l); + double w = 2 * (double) lw * Math.signum(l); if (Math.abs(w) > Math.abs(l)) w = l; - double offset = 2 * (double) bs.getLineWidth(); + double offset = 2 * (double) lw; double centerX = (startX + endX) / 2, centerY = (startY + endY) / 2; double deltaX = endX - startX, deltaY = endY - startY; @@ -136,8 +138,6 @@ public class DistrictNetworkEdgeNode extends G2DParentNode implements ISelection // Render SVG symbol double viewScaleRecip = 10; if (scaleStroke) { - double scale = GeometryUtils.getScale(g2d.getTransform()); - scale = Math.max(10000, Math.min(scale, 50000)); viewScaleRecip /= scale; }