-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.diagram.query;\r
-\r
-import java.awt.Stroke;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.ResourceRead;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.diagram.G2DUtils;\r
-import org.simantics.diagram.connection.ConnectionVisuals;\r
-import org.simantics.diagram.stubs.G2DResource;\r
-import org.simantics.g2d.element.handler.EdgeVisuals.StrokeType;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class ConnectionVisualsRequest extends ResourceRead<ConnectionVisuals> {\r
-\r
- G2DResource g2d;\r
-\r
- public ConnectionVisualsRequest(Resource connectionType) {\r
- super(connectionType);\r
- assert connectionType != null;\r
- }\r
-\r
- @Override\r
- public ConnectionVisuals perform(ReadGraph g) throws DatabaseException {\r
- g2d = G2DResource.getInstance(g);\r
- Resource structuralConnectionType = resource;\r
-\r
- // Load edge visual aspects\r
- Resource c = g.getPossibleObject(structuralConnectionType, g2d.HasColor);\r
- float[] color = null;\r
- if (c != null) {\r
- float[] col = g.getPossibleValue(c, Bindings.FLOAT_ARRAY);\r
- if (col != null && col.length >= 3) {\r
- color = col;\r
- }\r
- }\r
-\r
- StrokeType strokeType = toStrokeType(g.getPossibleObject(structuralConnectionType, g2d.HasStrokeType));\r
- Stroke stroke = G2DUtils.getStroke(g, g.getPossibleObject(structuralConnectionType, g2d.HasStroke));\r
-\r
- return new ConnectionVisuals(color, strokeType, stroke);\r
- }\r
-\r
- StrokeType toStrokeType(Resource strokeType) {\r
- if (strokeType != null) {\r
- if (strokeType.equals(g2d.StrokeType_Scaling))\r
- return StrokeType.Absolute;\r
- if (strokeType.equals(g2d.StrokeType_Nonscaling))\r
- return StrokeType.Relative;\r
- }\r
- return null;\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.diagram.query;
+
+import java.awt.Stroke;
+
+import org.simantics.databoard.Bindings;
+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.diagram.G2DUtils;
+import org.simantics.diagram.connection.ConnectionVisuals;
+import org.simantics.diagram.stubs.G2DResource;
+import org.simantics.g2d.element.handler.EdgeVisuals.StrokeType;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class ConnectionVisualsRequest extends ResourceRead<ConnectionVisuals> {
+
+ G2DResource g2d;
+
+ public ConnectionVisualsRequest(Resource connectionType) {
+ super(connectionType);
+ assert connectionType != null;
+ }
+
+ @Override
+ public ConnectionVisuals perform(ReadGraph g) throws DatabaseException {
+ g2d = G2DResource.getInstance(g);
+ Resource structuralConnectionType = resource;
+
+ // Load edge visual aspects
+ Resource c = g.getPossibleObject(structuralConnectionType, g2d.HasColor);
+ float[] color = null;
+ if (c != null) {
+ float[] col = g.getPossibleValue(c, Bindings.FLOAT_ARRAY);
+ if (col != null && col.length >= 3) {
+ color = col;
+ }
+ }
+
+ StrokeType strokeType = toStrokeType(g.getPossibleObject(structuralConnectionType, g2d.HasStrokeType));
+ Stroke stroke = G2DUtils.getStroke(g, g.getPossibleObject(structuralConnectionType, g2d.HasStroke));
+ Double branchPointRadius = g.getPossibleRelatedValue(structuralConnectionType, g2d.HasBranchPointRadius, Bindings.DOUBLE);
+ Double rounding = g.getPossibleRelatedValue(structuralConnectionType, g2d.HasRounding, Bindings.DOUBLE);
+
+ return new ConnectionVisuals(color, strokeType, stroke, branchPointRadius, rounding);
+ }
+
+ StrokeType toStrokeType(Resource strokeType) {
+ if (strokeType != null) {
+ if (strokeType.equals(g2d.StrokeType_Scaling))
+ return StrokeType.Absolute;
+ if (strokeType.equals(g2d.StrokeType_Nonscaling))
+ return StrokeType.Relative;
+ }
+ return null;
+ }
+
+}