]> gerrit.simantics Code Review - simantics/district.git/commitdiff
Provide Path2D for calculating path of DistrictNetworkEdgeElement 24/3224/1
authorjsimomaa <jani.simomaa@gmail.com>
Fri, 6 Sep 2019 12:07:32 +0000 (15:07 +0300)
committerjsimomaa <jani.simomaa@gmail.com>
Fri, 6 Sep 2019 12:07:32 +0000 (15:07 +0300)
gitlab #61

Change-Id: I2d1195c3e1107e22ab26ef5d61c55da05cdae71b

org.simantics.district.network.ui/src/org/simantics/district/network/ui/adapters/DistrictNetworkEdgeElement.java

index ef2e21fed709518ca5c7c21075018526f0474dc6..8fb105d8870f8f077b9f67407440e3c3b5bd89a7 100644 (file)
@@ -102,13 +102,17 @@ public class DistrictNetworkEdgeElement {
 
         public static final DNEdgeInternalSize INSTANCE = new DNEdgeInternalSize();
 
+        private ThreadLocal<Path2D> path = new ThreadLocal<Path2D>() {
+            protected Path2D initialValue() { return new Path2D.Double(); }
+        };
+
         @Override
         public Rectangle2D getBounds(IElement e, Rectangle2D size) {
             DistrictNetworkEdge edge = e.getHint(KEY_DN_EDGE);
             if (size == null)
                 size = new Rectangle2D.Double();
             if (edge != null)
-                size.setFrame(DistrictNetworkEdgeNode.calculatePath(edge, null, false).getBounds2D());
+                size.setFrame(DistrictNetworkEdgeNode.calculatePath(edge, path.get(), false).getBounds2D());
             else
                 LOGGER.debug("Element {} does not have edge!", e);