import org.simantics.db.Session;
import org.simantics.db.Statement;
import org.simantics.db.common.procedure.adapter.TransientCacheListener;
+import org.simantics.db.common.request.BinaryRead;
import org.simantics.db.common.request.ResourceRead2;
import org.simantics.db.common.request.UnaryRead;
import org.simantics.db.common.utils.ListUtils;
protected static ConnectionStyle readConnectionStyle(ReadGraph graph, IModelingRules modelingRules, Resource connection, StructuralResource2 STR, DiagramResource DIA) throws DatabaseException {
Resource connectionStyle = graph.getPossibleObject(connection, DIA.HasConnectionStyle);
Resource connectionType = null;
+ Double scale = graph.getPossibleRelatedValue(connection, DIA.HasStrokeScale);
+ if (scale == null) scale = 1.0;
if (connectionStyle == null) {
if (modelingRules != null)
connectionType = modelingRules.getConnectionType(graph, connection);
if (lineStyles.size() != 1) {
AggregateConnectionStyle aggregate = new AggregateConnectionStyle();
for (Resource connectionLine : ListUtils.toList(graph, connectionStyle)) {
- aggregate.addStyle(readConnectionStyleFromConnectionType(graph, connectionLine));
+ aggregate.addStyle(readConnectionStyleFromConnectionType(graph, connectionLine, scale));
}
return aggregate;
} else {
- return readConnectionStyleFromConnectionType(graph, lineStyles.get(0));
+ return readConnectionStyleFromConnectionType(graph, lineStyles.get(0), scale);
}
} else {
- return connectionType != null ? readConnectionStyleFromConnectionType(graph, connectionType) : DEFAULT_CONNECTION_STYLE;
+ return connectionType != null ? readConnectionStyleFromConnectionType(graph, connectionType, scale) : DEFAULT_CONNECTION_STYLE;
}
}
protected static ConnectionStyle readConnectionStyleFromConnectionType(ReadGraph graph, Resource connectionType) throws DatabaseException {
- return graph.syncRequest(new ReadConnectionStyleFromConnectionType(connectionType),
+ return readConnectionStyleFromConnectionType(graph, connectionType, 1.0);
+ }
+
+ protected static ConnectionStyle readConnectionStyleFromConnectionType(ReadGraph graph, Resource connectionType, double scale) throws DatabaseException {
+ return graph.syncRequest(new ReadConnectionStyleFromConnectionType(connectionType, scale),
TransientCacheListener.<ConnectionStyle>instance());
}
/**
* A request for caching ConnectionStyle results.
*/
- public static class ReadConnectionStyleFromConnectionType extends UnaryRead<Resource, ConnectionStyle> {
+ public static class ReadConnectionStyleFromConnectionType extends BinaryRead<Resource, Double, ConnectionStyle> {
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),
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,