@Override\r
public void load(ReadGraph graph, final ICanvasContext canvas, final IDiagram diagram, final Resource connection,\r
IElement element) throws DatabaseException {\r
- \r
+\r
// Do we need this?\r
element.setHint(DiagramHints.ROUTE_ALGORITHM, new Router4(false));\r
- \r
+\r
IModelingRules modelingRules = diagram.getHint(DiagramModelHints.KEY_MODELING_RULES);\r
\r
IElement mappedElement = ElementUtils.getByData(diagram, connection);\r
color = G2DUtils.getColor(graph, colorResource);\r
element.setHint(ElementHints.KEY_TEXT_COLOR, color);\r
}\r
- \r
+\r
RouteGraph rg = new RouteGraph();\r
\r
Set<Resource> nodes = new HashSet<Resource>();\r
\r
// Get element bounds to decide allowed terminal direction(s)\r
IElement te = graph.syncRequest(DiagramRequests.getElement(canvas, diagram, terminalElement, null));\r
- \r
+\r
ElementUtils.getElementBounds(te, bounds);\r
- \r
+\r
{\r
Shape shp = org.simantics.g2d.utils.GeometryUtils.transformShape(bounds, terminalElementTr);\r
bounds.setFrame(shp.getBounds2D());\r
}\r
- \r
+\r
// Valve behaves differently. The flow must start inside the valve bounds\r
if(te.getElementClass().containsClass(ValveSceneGraph.class)) {\r
bounds.setFrame(new Rectangle2D.Double(bounds.getCenterX() - 1, bounds.getCenterY() - 1, 2, 2));\r
\r
x = bounds.getCenterX();\r
y = bounds.getCenterY();\r
- \r
+\r
// Expand bounds by 4mm to make the connections enter the terminals\r
// at a straight angle and from a distance instead of coming in\r
// "horizontally".\r
miny = bounds.getMinY();\r
maxx = bounds.getMaxX();\r
maxy = bounds.getMaxY();\r
- \r
+\r
\r
Integer allowedDirections = graph.getPossibleRelatedValue(terminal, DIA.Terminal_AllowedDirections, Bindings.INTEGER);\r
- \r
+\r
// Valve behaves differently. Allowed directions depend on the orientation of the valve\r
if(te.getElementClass().containsClass(ValveSceneGraph.class)) {\r
SysdynResource sr = SysdynResource.getInstance(graph);\r
if (connectionType != null)\r
cv = graph.syncRequest(DiagramRequests.getConnectionVisuals(connectionType),\r
TransientCacheListener.<ConnectionVisuals> instance());\r
- \r
- \r
+\r
+\r
Color lineColor = element.getHint(ElementHints.KEY_TEXT_COLOR);\r
if (lineColor == null)\r
- lineColor = cv != null ? cv.toColor() : Color.DARK_GRAY;\r
- \r
- Stroke lineStroke = cv != null ? cv.stroke : null;\r
- if (lineStroke == null)\r
- lineStroke = new BasicStroke(0.1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10, null, 0);\r
-\r
- return new FlowConnectionStyle(\r
- lineColor,\r
- lineStroke);\r
+ lineColor = (cv != null && cv.toColor() != null) ? cv.toColor() : Color.DARK_GRAY;\r
+\r
+ Stroke lineStroke = cv != null ? cv.stroke : null;\r
+ if (lineStroke == null)\r
+ lineStroke = new BasicStroke(0.1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10, null, 0);\r
+\r
+ return new FlowConnectionStyle(\r
+ lineColor,\r
+ lineStroke);\r
}\r
\r
/**\r
import org.simantics.objmap.annotations.RelatedElements;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.representation.expressions.StockExpression;\r
+import org.simantics.sysdyn.representation.utils.SheetFormatUtils;\r
import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
\r
/**\r
// Start parameter is used. Parameter guarantees that there is only one expression.\r
StockExpression e = (StockExpression)getExpressions().getExpressions().get(0);\r
String initialEquation = e.getExpression(this);\r
+ initialEquation = SheetFormatUtils.reformatSheetReferences(this, initialEquation);\r
\r
if(ai != null && !ai.getEnumerations().isEmpty())\r
each = "each";\r