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));
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);
package org.simantics.district.network.profile;
-import java.util.HashSet;
import java.util.List;
import java.util.Set;
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) {
@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);
}
}