From: Tuukka Lehtonen Date: Fri, 22 Nov 2019 23:48:48 +0000 (+0200) Subject: Fixed edge arrows to always be rendered above the edge X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=9b72e2f7a188fcb04add07251cbb0081edc3bfbe;p=simantics%2Fdistrict.git Fixed edge arrows to always be rendered above the edge Optimized MidBranchEdgeSetRequest memory use by using CollectionSupport to create a ResourceSet instead of using HashSet. gitlab #47 Change-Id: Ic763cb1ea8976ca3ff5c933e8de5f18aa29f6579 (cherry picked from commit e9e4d5aa42316eda7f4f21577801f94fce90c0a7) --- 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 1c677316..e724a68d 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 @@ -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)); diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkStaticInfoNode.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkStaticInfoNode.java index 4ce35a27..c8eae515 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkStaticInfoNode.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkStaticInfoNode.java @@ -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); diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/MidBranchEdgeSetRequest.java b/org.simantics.district.network/src/org/simantics/district/network/profile/MidBranchEdgeSetRequest.java index c1a9394f..ac66b88f 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/MidBranchEdgeSetRequest.java +++ b/org.simantics.district.network/src/org/simantics/district/network/profile/MidBranchEdgeSetRequest.java @@ -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> { public MidBranchEdgeSetRequest(Resource resource) { @@ -18,6 +18,7 @@ public class MidBranchEdgeSetRequest extends ResourceRead> { @Override public Set perform(ReadGraph graph) throws DatabaseException { List edges = Simantics.applySCL("Simantics/District/Algorithm", "midBranchEdges", graph, resource); - return new HashSet<>(edges); + CollectionSupport cs = graph.getService(CollectionSupport.class); + return cs.getResourceSet(graph, edges); } }