From 64928178377170b7734fb84a06f5854b1b6f20ea Mon Sep 17 00:00:00 2001 From: Jussi Koskela Date: Fri, 16 Oct 2020 10:33:49 +0300 Subject: [PATCH] Option set connection stroke scale gitlab #622 Change-Id: I547b51395c5832708df5c55ca4ce358c922da348 --- .../graph/Diagram.pgraph | 6 ++++ .../graph/DiagramConnections.pgraph | 2 ++ .../diagram/adapter/RouteGraphUtils.java | 33 ++++++++++++++----- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/bundles/org.simantics.diagram.ontology/graph/Diagram.pgraph b/bundles/org.simantics.diagram.ontology/graph/Diagram.pgraph index a38de5bc9..52fc8db3f 100644 --- a/bundles/org.simantics.diagram.ontology/graph/Diagram.pgraph +++ b/bundles/org.simantics.diagram.ontology/graph/Diagram.pgraph @@ -180,3 +180,9 @@ DIA.ConnectionLineStyle instance()); } /** * A request for caching ConnectionStyle results. */ - public static class ReadConnectionStyleFromConnectionType extends UnaryRead { + public static class ReadConnectionStyleFromConnectionType extends BinaryRead { public ReadConnectionStyleFromConnectionType(Resource connectionType) { - super(connectionType); + this(connectionType, 1.0); + } + public ReadConnectionStyleFromConnectionType(Resource connectionType, Double scale) { + super(connectionType, scale); } @Override public ConnectionStyle perform(ReadGraph graph) throws DatabaseException { - return readConnectionStyleFromConnectionType0(graph, parameter); + return readConnectionStyleFromConnectionType0(graph, parameter, parameter2); } } protected static ConnectionStyle readConnectionStyleFromConnectionType0(ReadGraph graph, Resource connectionType) throws DatabaseException { + return readConnectionStyleFromConnectionType0(graph, connectionType, 1.0); + } + + protected static ConnectionStyle readConnectionStyleFromConnectionType0(ReadGraph graph, Resource connectionType, double scale) throws DatabaseException { ConnectionVisuals cv = null; if (connectionType != null) cv = graph.syncRequest(DiagramRequests.getConnectionVisuals(connectionType), @@ -607,9 +621,12 @@ public class RouteGraphUtils { Stroke lineStroke = cv != null ? cv.stroke : null; if (lineStroke == null) lineStroke = new BasicStroke(0.1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10, null, 0); + if (scale != 1.0) { + lineStroke = GeometryUtils.scaleStroke(lineStroke, (float)scale); + } Stroke routeLineStroke = GeometryUtils.scaleStrokeWidth(lineStroke, 2); double rounding = cv.rounding == null ? 0.0 : cv.rounding; - double offset = cv.offset == null ? 0.0 : cv.offset; + double offset = cv.offset == null ? 0.0 : cv.offset * scale; return new BasicConnectionStyle( lineColor, -- 2.43.2