]> gerrit.simantics Code Review - simantics/district.git/commitdiff
Fixed edge arrows to always be rendered above the edge 04/3604/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 22 Nov 2019 23:48:48 +0000 (01:48 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 22 Nov 2019 23:48:48 +0000 (01:48 +0200)
Optimized MidBranchEdgeSetRequest memory use by using CollectionSupport
to create a ResourceSet instead of using HashSet<Resource>.

gitlab #47

Change-Id: Ic763cb1ea8976ca3ff5c933e8de5f18aa29f6579

org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeNode.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkStaticInfoNode.java
org.simantics.district.network/src/org/simantics/district/network/profile/MidBranchEdgeSetRequest.java

index 1c677316a26c167751150d21d290fb33fe53cbbb..e724a68dc46b0063e1129ae9d31ba744083416fc 100644 (file)
@@ -135,10 +135,19 @@ public class DistrictNetworkEdgeNode extends G2DParentNode implements ISelection
                 double centerX = centerPoint.getX(), centerY = centerPoint.getY();
                 double deltaX = direction.getX(), deltaY = direction.getY();
 
-                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;
+                // Ensure the line is always rendered on top of the edge
+                // to prevent overlap with static info rendered below it.
+                double odx = offset * deltaY;
+                double ody = offset * deltaX;
+                if (odx < 0) {
+                    odx = -odx;
+                    ody = -ody;
+                }
+
+                double x0 = centerX - l/2 * deltaX + ody;
+                double y0 = centerY - l/2 * deltaY - odx;
+                double x1 = centerX + (l/2 - w) * deltaX + ody;
+                double y1 = centerY + (l/2 - w) * deltaY - odx;
 
                 g2d.draw(new Line2D.Double(x0, y0, x1, y1));
 
index 4ce35a27344450de02942cf3607036829f64f20c..c8eae515375b843d6879d17643e442461536bc2f 100644 (file)
@@ -86,7 +86,7 @@ public class DistrictNetworkStaticInfoNode extends G2DNode implements DeferredNo
                int ascent = fm.getMaxAscent();
 
                g.transform(AffineTransform.getRotateInstance(direction.getX(), direction.getY()));
-               g.translate(0, ascent);
+               g.translate(0, ascent+2);
 
 //             int height = fm.getHeight();
 //             g.setColor(Color.WHITE);
index c1a9394fb5e043d00936635fb66f755de636ef4d..ac66b88ffaf89c0c5dbcbf109afa24ebb5e2c447 100644 (file)
@@ -1,6 +1,5 @@
 package org.simantics.district.network.profile;
 
-import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -9,6 +8,7 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.common.request.ResourceRead;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.service.CollectionSupport;
 
 public class MidBranchEdgeSetRequest extends ResourceRead<Set<Resource>> {
        public MidBranchEdgeSetRequest(Resource resource) {
@@ -18,6 +18,7 @@ public class MidBranchEdgeSetRequest extends ResourceRead<Set<Resource>> {
        @Override
        public Set<Resource> perform(ReadGraph graph) throws DatabaseException {
                List<Resource> edges = Simantics.applySCL("Simantics/District/Algorithm", "midBranchEdges", graph, resource);
-               return new HashSet<>(edges);
+               CollectionSupport cs = graph.getService(CollectionSupport.class);
+               return cs.getResourceSet(graph, edges);
        }
 }