From: Jussi Koskela Date: Fri, 16 Oct 2020 07:33:49 +0000 (+0300) Subject: Option set connection stroke scale X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fheads%2Fprivate%2Fsolvo;p=simantics%2Fplatform.git Option set connection stroke scale gitlab #622 Change-Id: I547b51395c5832708df5c55ca4ce358c922da348 --- 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,