]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Attempt to fix a svn commit error
authorjkauttio <jkauttio@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 10 Mar 2014 09:15:29 +0000 (09:15 +0000)
committerjkauttio <jkauttio@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 10 Mar 2014 09:15:29 +0000 (09:15 +0000)
refs #2924

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/branches/dev-jkauttio@29059 ac1ea38d-2e2b-0410-8846-a27921b304fc

38 files changed:
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Auxiliary.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Auxiliary2.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Cloud.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Cloud2.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Comment2.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Connection.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Connection2.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Dependency.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Dependency2.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Element.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Element2.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/EquivalenceSubscript.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Expression.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Flow.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Flow2.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Function.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/IWriteableMDLElement.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/IWriteableMDLObject.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/IWriteableObject.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Model.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Model2.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/ModelVariable.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Range.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Sketch2.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/SketchComment.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/SketchConnection.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/SketchElement.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/SketchObject.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/SketchValve.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/SketchVariable.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Stock.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Stock2.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Subscript.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Valve.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Valve2.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Variable.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Variable2.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/View.java [deleted file]

diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Auxiliary.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Auxiliary.java
deleted file mode 100644 (file)
index 663b1cf..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.mdlImport.model;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.utils.direct.GraphUtils;\r
-import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.mdlImport.ImportUtils;\r
-\r
-public class Auxiliary extends Variable {\r
-\r
-       @Override\r
-       public Resource getExpression(WriteGraph graph, Expression expression) throws DatabaseException {\r
-               \r
-               SysdynResource sr = SysdynResource.getInstance(graph);\r
-               Resource e = GraphUtils.create2(graph, \r
-                               sr.NormalExpression,\r
-                               sr.Expression_equation, ImportUtils.escapeExpression(expression.getExpression()).trim());\r
-               return e;\r
-       }\r
-\r
-       @Override\r
-       public void write(WriteGraph graph, Resource parent, double xOffset,\r
-                       double yOffset) {\r
-               if(parent == null || graph == null)\r
-                       return;\r
-               \r
-               try {\r
-                       SysdynResource sr = SysdynResource.getInstance(graph);\r
-                       if(!graph.isInstanceOf(parent, sr.Configuration))\r
-                               return;\r
-                       createVariable(graph, parent, sr.Auxiliary, sr.AuxiliarySymbol, xOffset, yOffset);\r
-               } catch (DatabaseException e) {\r
-                       e.printStackTrace();\r
-               }\r
-       }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Auxiliary2.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Auxiliary2.java
deleted file mode 100644 (file)
index e75d945..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.simantics.sysdyn.mdlImport.model;\r
-\r
-import java.util.Arrays;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.utils.ListUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.layer0.utils.direct.GraphUtils;\r
-import org.simantics.sysdyn.SysdynResource;\r
-\r
-public class Auxiliary2 extends ModelVariable {\r
-       \r
-       protected String equation;\r
-\r
-       public Auxiliary2(double x, double y, \r
-                       String name, String unit, Range range, String description, \r
-                       String equation) {\r
-               this.equation = equation;\r
-       }\r
-       \r
-       public Auxiliary2(double x, double y, Variable2 variable, String equation) {\r
-               this.equation = equation;\r
-       }\r
-\r
-       @Override\r
-       public void write(WriteGraph graph, Resource parent) throws DatabaseException {\r
-               Layer0 l0 = Layer0.getInstance(graph);\r
-               SysdynResource sr = SysdynResource.getInstance(graph);\r
-\r
-               Resource variable = createVariable(graph, sr.Auxiliary, parent);\r
-\r
-               Resource expression = GraphUtils.create2(graph, sr.NormalExpression,\r
-                               sr.Expression_equation, equation,\r
-                               l0.PartOf, variable);\r
-               // TODO: why is the expressoin stored in two places?\r
-               graph.claim(variable, sr.Variable_expressionList, ListUtils.create(graph, Arrays.asList(expression)));\r
-\r
-               createSymbol(graph, sr.AuxiliarySymbol, variable, parent);\r
-\r
-               setResource(variable);\r
-       }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Cloud.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Cloud.java
deleted file mode 100644 (file)
index 143a93d..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.mdlImport.model;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.diagram.stubs.DiagramResource;\r
-import org.simantics.diagram.stubs.G2DResource;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.layer0.utils.direct.GraphUtils;\r
-import org.simantics.modeling.ModelingResources;\r
-import org.simantics.sysdyn.SysdynResource;\r
-\r
-public class Cloud extends Element {\r
-\r
-       @Override\r
-       public void write(WriteGraph graph, Resource parent, double xOffset,\r
-                       double yOffset) {\r
-               if(parent == null || graph == null)\r
-                       return;\r
-               \r
-               try {\r
-                       SysdynResource sr = SysdynResource.getInstance(graph);\r
-                       Layer0 l0 = Layer0.getInstance(graph); \r
-                       ModelingResources mr = ModelingResources.getInstance(graph);\r
-                       DiagramResource dr = DiagramResource.getInstance(graph);\r
-                       G2DResource g2d = G2DResource.getInstance(graph);\r
-                       \r
-                       if(!graph.isInstanceOf(parent, sr.Configuration))\r
-                               return;\r
-                       \r
-                       Resource diagram = graph.getSingleObject(parent, mr.CompositeToDiagram);\r
-\r
-                       if(diagram == null)\r
-                               return;\r
-                       \r
-                       Resource cloud = GraphUtils.create2(graph, \r
-                                       sr.Cloud);\r
-\r
-                       graph.claim(parent, l0.ConsistsOf, cloud);\r
-\r
-                       \r
-\r
-                       Resource symbol = GraphUtils.create2(graph, \r
-                                       sr.CloudSymbol,\r
-                                       mr.ElementToComponent, cloud);\r
-\r
-                       double[] transform = {1.0, 0.0, 0.0, 1.0, getX() + xOffset, getY() + yOffset};\r
-                       graph.claimLiteral(symbol, dr.HasTransform, g2d.Transform, transform);\r
-\r
-                       OrderedSetUtils.add(graph, diagram, symbol);\r
-\r
-                       setResource(cloud);\r
-\r
-               } catch (DatabaseException e) {\r
-                       e.printStackTrace();\r
-               }\r
-       }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Cloud2.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Cloud2.java
deleted file mode 100644 (file)
index fbf0c3e..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.simantics.sysdyn.mdlImport.model;\r
-\r
-public class Cloud2 extends Element2 {\r
-       \r
-       public Cloud2() {\r
-               \r
-       }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Comment2.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Comment2.java
deleted file mode 100644 (file)
index 7b93b96..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.simantics.sysdyn.mdlImport.model;\r
-\r
-public class Comment2 extends Element2 {\r
-\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Connection.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Connection.java
deleted file mode 100644 (file)
index 2e14ca9..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.mdlImport.model;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.diagram.stubs.DiagramResource;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.layer0.utils.direct.GraphUtils;\r
-import org.simantics.modeling.ModelingResources;\r
-import org.simantics.structural.stubs.StructuralResource2;\r
-import org.simantics.sysdyn.SysdynResource;\r
-\r
-public abstract class Connection implements IWriteableMDLObject {\r
-       protected Element start, end;\r
-       \r
-       public Resource writeConnection(WriteGraph graph, Resource configuration, Resource connectionType, Resource connectionSymbol) throws DatabaseException {\r
-               if(configuration == null || graph == null \r
-                               || start.getResource() == null || end.getResource() == null) {\r
-                       return null;\r
-               }\r
-               SysdynResource sr = SysdynResource.getInstance(graph);\r
-               Layer0 l0 = Layer0.getInstance(graph); \r
-               ModelingResources mr = ModelingResources.getInstance(graph);\r
-               DiagramResource dr = DiagramResource.getInstance(graph);\r
-               StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
-               \r
-               Resource diagram = graph.getPossibleObject(configuration, mr.CompositeToDiagram);\r
-               Resource startElement = graph.getPossibleObject(start.getResource(), mr.ComponentToElement);\r
-               Resource endElement = graph.getPossibleObject(end.getResource(), mr.ComponentToElement);\r
-               if(diagram == null || startElement == null || endElement == null)\r
-                       return null;\r
-               \r
-               \r
-               if(connectionType == null)\r
-                       connectionType = sr.Dependency;\r
-               \r
-               if(connectionSymbol == null)\r
-                       connectionSymbol = sr.DependencyConnection;\r
-               \r
-               // Build the connection to configuration\r
-               Resource connection = GraphUtils.create2(graph, \r
-                               connectionType,\r
-                               sr.Variable_HasHead, end.getResource(),\r
-                               sr.Variable_HasTail, start.getResource(),\r
-                               l0.PartOf, configuration);\r
-               graph.claim(connection, mr.Mapped, connection);\r
-               \r
-               \r
-               // Build diagram connectors and connection\r
-               Resource tailConnector = GraphUtils.create2(graph, \r
-                               dr.Connector,\r
-                               sr.HasTailTerminal, startElement);\r
-               \r
-               Resource headConnector = GraphUtils.create2(graph,\r
-                               dr.Connector,\r
-                               sr.HasHeadTerminal, endElement,\r
-                               dr.AreConnected, tailConnector);\r
-               \r
-               Resource diagramConnection = GraphUtils.create2(graph, \r
-                               connectionSymbol,\r
-                               sr2.HasConnectionType, sr.SysdynConnectionType,\r
-                               mr.DiagramConnectionToConnection, connection,\r
-                               dr.HasArrowConnector, headConnector,\r
-                               dr.HasPlainConnector, tailConnector);\r
-               \r
-               OrderedSetUtils.add(graph, diagram, diagramConnection);\r
-               \r
-               return connection;\r
-       }\r
-\r
-       public Element getStart() {\r
-               return start;\r
-       }\r
-\r
-       public void setStart(Element start) {\r
-               this.start = start;\r
-       }\r
-\r
-       public Element getEnd() {\r
-               return end;\r
-       }\r
-\r
-       public void setEnd(Element end) {\r
-               this.end = end;\r
-       }\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Connection2.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Connection2.java
deleted file mode 100644 (file)
index eb01d50..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.simantics.sysdyn.mdlImport.model;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-\r
-public abstract class Connection2 implements IWriteableObject {\r
-       \r
-       protected Element2 head;\r
-       protected Element2 tail;\r
-\r
-       @Override\r
-       public void write(WriteGraph graph, Resource parent) throws DatabaseException {\r
-               System.err.println("Writing connection");\r
-       }\r
-       \r
-       protected void writeConnection() {\r
-               \r
-       }\r
-       \r
-       public void setHead(Element2 head) {\r
-               this.head = head;\r
-       }\r
-       \r
-       public void setTail(Element2 tail) {\r
-               this.tail = tail;\r
-       }\r
-       \r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Dependency.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Dependency.java
deleted file mode 100644 (file)
index b9b41d6..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.mdlImport.model;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.modeling.ModelingResources;\r
-import org.simantics.sysdyn.SysdynResource;\r
-\r
-public class Dependency extends Connection {\r
-       \r
-       private double angle;\r
-       \r
-       public Dependency() {\r
-               this(-0.1);\r
-       }\r
-       \r
-       public Dependency(double angle) {\r
-               this.angle = angle; \r
-       }\r
-\r
-       @Override\r
-       public void write(WriteGraph graph, Resource parent) {\r
-               if(parent == null || graph == null || start == null || end == null)\r
-                       return;\r
-               try {\r
-                       SysdynResource sr = SysdynResource.getInstance(graph);\r
-                       Resource connection = writeConnection(graph, parent, sr.Dependency, sr.DependencyConnection);\r
-\r
-                       if(connection != null) {\r
-                               ModelingResources mr = ModelingResources.getInstance(graph);\r
-                               Resource diagramConnection = graph.getSingleObject(connection, mr.ConnectionToDiagramConnection);\r
-                               graph.claimLiteral(diagramConnection, sr.Dependency_angle, angle);\r
-                       }\r
-\r
-               } catch (DatabaseException e) {\r
-                       e.printStackTrace();\r
-               }\r
-\r
-       }\r
-\r
-       public double getAngle() {\r
-               return angle;\r
-       }\r
-\r
-       public void setAngle(double angle) {\r
-               this.angle = angle;\r
-       }\r
-       \r
-       \r
-       \r
-    /**\r
-     * Returns an angle in radians between straight line from (x0,y0) to (x2,y2)\r
-     * and an arc from (x0,y0) to (x2,y2) thru (x1,y1). The angle\r
-     * is measured at (x0,y0) and is between -PI and PI.\r
-     */\r
-    public static double angleOfArc(\r
-        double x0, double y0, \r
-        double x1, double y1,\r
-        double x2, double y2) {\r
-        double dx0 = x1-x0;\r
-        double dy0 = y1-y0;\r
-        double dx1 = x1-x2;\r
-        double dy1 = y1-y2;\r
-        double dx = x2-x0;\r
-        double dy = y2-y0;\r
-        // Length of cross product (p1-p0)x(p2-p0)\r
-        double dd = dx0*dy - dy0*dx; \r
-        \r
-        if(Math.abs(dd) < 1e-6) // Points are (almost) collinear\r
-            return 0.0;\r
-        else {            \r
-            // (p1-p0)*(p1-p2) / dd\r
-            double offset = (dx0*dx1 + dy0*dy1) / dd;\r
-            double angle = Math.PI*0.5 - Math.atan(offset);\r
-            if(dd > 0.0)\r
-                angle = angle-Math.PI;\r
-            return angle;\r
-            \r
-        }\r
-    }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Dependency2.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Dependency2.java
deleted file mode 100644 (file)
index 14f2d5b..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.simantics.sysdyn.mdlImport.model;\r
-\r
-public class Dependency2 extends Connection2 {\r
-       \r
-       private boolean showArrow;\r
-       private boolean showDelay;\r
-       \r
-       public Dependency2(boolean showArrow, boolean showDelay) {\r
-               this.showArrow = showArrow;\r
-               this.showDelay = showDelay;\r
-       }\r
-\r
-       @Override\r
-       public void setHead(Element2 head) {\r
-               // TODO: make sure head is of the right type\r
-               super.setHead(head);\r
-       }\r
-\r
-       @Override\r
-       public void setTail(Element2 Tail) {\r
-               // TODO: make sure tail is of the right type\r
-               super.setTail(tail);\r
-       }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Element.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Element.java
deleted file mode 100644 (file)
index c431f20..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.mdlImport.model;\r
-\r
-import java.util.ArrayList;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-\r
-public abstract class Element implements IWriteableMDLElement {\r
-       \r
-       protected int x, y;\r
-       protected Resource resource;\r
-       protected String name;\r
-       protected ArrayList<Connection> connections;\r
-       \r
-       protected Resource getExpression(WriteGraph graph, Expression expression)\r
-                       throws DatabaseException {\r
-               return null;\r
-       }       \r
-       \r
-       public int getX() {\r
-               return x;\r
-       }\r
-\r
-       public void setX(int x) {\r
-               this.x = x;\r
-       }\r
-\r
-       public int getY() {\r
-               return y;\r
-       }\r
-\r
-       public void setY(int y) {\r
-               this.y = y;\r
-       }\r
-\r
-       public String getName() {\r
-               if(name == null)\r
-                       return "Name";\r
-               return name;\r
-       }\r
-\r
-       public void setName(String name) {\r
-               this.name = name;\r
-       }\r
-\r
-       public Resource getResource() {\r
-               return resource;\r
-       }\r
-\r
-       public void setResource(Resource resource) {\r
-               this.resource = resource;\r
-       }\r
-       \r
-       public ArrayList<Connection> getConnections() {\r
-               if(connections == null)\r
-                       connections = new ArrayList<Connection>();\r
-               return connections;\r
-       }\r
-\r
-       public void setConnections(ArrayList<Connection> connections) {\r
-               this.connections = connections;\r
-       }\r
-       \r
-       public void addConnection(Connection connection) {\r
-               getConnections().add(connection);\r
-       }\r
-}\r
-\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Element2.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Element2.java
deleted file mode 100644 (file)
index b04010f..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.simantics.sysdyn.mdlImport.model;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.diagram.stubs.DiagramResource;\r
-import org.simantics.diagram.stubs.G2DResource;\r
-import org.simantics.layer0.utils.direct.GraphUtils;\r
-import org.simantics.modeling.ModelingResources;\r
-\r
-public class Element2 implements IWriteableObject {\r
-\r
-       private int x;\r
-       private int y;\r
-\r
-       private Resource resource;\r
-\r
-       public Element2() {\r
-\r
-       }\r
-\r
-       //      public Element2(int x, int y, int width, int height) {\r
-       //              this.x = x;\r
-       //              this.y = y;\r
-       //              this.width = width;\r
-       //              this.height = height;\r
-       //              \r
-       //              this.resource = null;\r
-       //      }\r
-\r
-       @Override\r
-       public void write(WriteGraph graph, Resource parent) throws DatabaseException {\r
-               System.err.println("Writing element");\r
-       }\r
-\r
-       // TODO: is this the right place for this?\r
-\r
-       public Resource getResource() {\r
-               return resource;\r
-       }\r
-\r
-       public void setResource(Resource resource) {\r
-               this.resource = resource;\r
-       }\r
-\r
-       public Resource createSymbol(WriteGraph graph, Resource type, Resource variable, Resource parent) throws DatabaseException {\r
-               DiagramResource dr = DiagramResource.getInstance(graph);\r
-               G2DResource g2d = G2DResource.getInstance(graph);\r
-               ModelingResources mr = ModelingResources.getInstance(graph);\r
-\r
-               Resource symbol = GraphUtils.create2(graph, type, \r
-                               mr.ElementToComponent, variable);\r
-\r
-               double[] transform = { 1.0, 0.0, 0.0, 1.0, x, y };\r
-               graph.claimLiteral(symbol, dr.HasTransform, g2d.Transform, transform, Bindings.DOUBLE_ARRAY);\r
-\r
-               Resource diagram = graph.getSingleObject(parent, mr.CompositeToDiagram);\r
-               OrderedSetUtils.add(graph, diagram, symbol);\r
-\r
-               return symbol;\r
-       }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/EquivalenceSubscript.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/EquivalenceSubscript.java
deleted file mode 100644 (file)
index 41d2eb5..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.mdlImport.model;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-\r
-public class EquivalenceSubscript extends Subscript {\r
-       \r
-       public String getEquivalentToName() {\r
-               String name = "";\r
-               if(expressions != null && expressions.get(0) != null) {\r
-                       name = expressions.get(0).getExpression().trim();\r
-               }\r
-               return name;\r
-       }\r
-\r
-       public void setEquivalentTo(Subscript equivalentTo) {\r
-               setExpressions(equivalentTo.getExpressions());\r
-       }\r
-\r
-       @Override\r
-       public void write(WriteGraph graph, Resource parent, double xOffset,\r
-                       double yOffset) {\r
-               super.write(graph, parent, xOffset, yOffset);\r
-       }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Expression.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Expression.java
deleted file mode 100644 (file)
index fe6e975..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.mdlImport.model;\r
-\r
-\r
-public class Expression {\r
-       \r
-       private String range, expression;\r
-       \r
-       @Override\r
-       public String toString() {\r
-               return (range != null ? "[" + range + "]: " : "") + expression; \r
-       }\r
-\r
-       public String getRange() {\r
-               return range;\r
-       }\r
-\r
-       public void setRange(String range) {\r
-               this.range = range;\r
-       }\r
-\r
-       public String getExpression() {\r
-               if (expression == null)\r
-                       return "";\r
-               return expression;\r
-       }\r
-\r
-       public void setExpression(String expression) {\r
-               this.expression = expression;\r
-       }\r
-       \r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Flow.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Flow.java
deleted file mode 100644 (file)
index 6067029..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.mdlImport.model;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.sysdyn.SysdynResource;\r
-\r
-public class Flow extends Connection {\r
-\r
-       @Override\r
-       public void write(WriteGraph graph, Resource parent) {\r
-               if(parent == null || graph == null)\r
-                       return;\r
-               try {\r
-                       SysdynResource sr = SysdynResource.getInstance(graph);\r
-                       writeConnection(graph, parent, sr.Flow, sr.FlowConnection);\r
-               } catch (DatabaseException e) {\r
-                       e.printStackTrace();\r
-               }\r
-       }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Flow2.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Flow2.java
deleted file mode 100644 (file)
index a257e07..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.simantics.sysdyn.mdlImport.model;\r
-\r
-public class Flow2 extends Connection2 {\r
-       \r
-       public Flow2() {\r
-               \r
-       }\r
-\r
-       @Override\r
-       public void setHead(Element2 head) {\r
-               // TODO: make sure head is of the right type\r
-               super.setHead(head);\r
-       }\r
-\r
-       @Override\r
-       public void setTail(Element2 tail) {\r
-               // TODO: make sure tail is of the right type\r
-               super.setTail(tail);\r
-       }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Function.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Function.java
deleted file mode 100644 (file)
index 6d5e402..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.mdlImport.model;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.layer0.utils.direct.GraphUtils;\r
-import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.mdlImport.ImportUtils;\r
-\r
-public class Function extends Variable {\r
-\r
-       @Override\r
-       public void write(WriteGraph graph, Resource parent, double xOffset,\r
-                       double yOffset) {\r
-               if(parent == null || graph == null)\r
-                       return;\r
-               \r
-               try {\r
-                       SysdynResource sr = SysdynResource.getInstance(graph);\r
-                       if(!graph.isInstanceOf(parent, sr.SysdynModel))\r
-                               return;\r
-                       Layer0 l0 = Layer0.getInstance(graph); \r
-                       \r
-                       Resource function = GraphUtils.create2(graph, \r
-                                       sr.SysdynModelicaFunction,\r
-                                       l0.HasName, ImportUtils.escapeName(this.getName()));\r
-                       \r
-                       if(comments != null && comments.length() > 0)\r
-                               graph.claimLiteral(function, l0.HasDescription, comments);\r
-                       \r
-                       if(expressions != null && expressions.get(0) != null) {\r
-                               StringBuilder sb = new StringBuilder();\r
-                               sb.append("    input Real a;\n");\r
-                               sb.append("    output Real result;\n");\r
-                               sb.append("algorithm\n");\r
-                               sb.append("    result := interpolate(a, " + expressions.get(0).getExpression() + ");");\r
-                               graph.claimLiteral(function, sr.SysdynModelicaFunction_modelicaFunctionCode, sb.toString());\r
-                       }\r
-\r
-                       graph.claim(parent, l0.ConsistsOf, function);\r
-                       resource = function;\r
-               } catch (DatabaseException e) {\r
-                       e.printStackTrace();\r
-               }\r
-               \r
-       }\r
-\r
-\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/IWriteableMDLElement.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/IWriteableMDLElement.java
deleted file mode 100644 (file)
index d21f539..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.mdlImport.model;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-\r
-public interface IWriteableMDLElement {\r
-\r
-       /**\r
-        * Writes an element with coordinates (variable, cloud) to the given resource.\r
-        * \r
-        * Offsets determine where the parent view is located in the combined diagram\r
-        * \r
-        * @param graph WriteGraph\r
-        * @param parent The resource where the object is located\r
-        * @param xOffset xOffset of the view in the diagram\r
-        * @param yOffset yOffset of the view in the diagram\r
-        */\r
-       public void write(WriteGraph graph, Resource parent, double xOffset, double yOffset);\r
-}
\ No newline at end of file
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/IWriteableMDLObject.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/IWriteableMDLObject.java
deleted file mode 100644 (file)
index 67b9d06..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.mdlImport.model;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-\r
-public interface IWriteableMDLObject {\r
-       \r
-       /**\r
-        * Writes an object with no coordinates (connection, model, view) to the given resource\r
-        * \r
-        * @param graph WriteGraph\r
-        * @param parent The resource where the object is located\r
-        */\r
-       public void write(WriteGraph graph, Resource parent);\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/IWriteableObject.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/IWriteableObject.java
deleted file mode 100644 (file)
index 996fbf4..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.mdlImport.model;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-\r
-public interface IWriteableObject {\r
-       \r
-       /**\r
-        * @param graph WriteGraph\r
-        * @param parent The resource where the object is located\r
-        * @throws DatabaseException \r
-        */\r
-       public void write(WriteGraph graph, Resource parent) throws DatabaseException;\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Model.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Model.java
deleted file mode 100644 (file)
index 0b5013f..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.mdlImport.model;\r
-\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.simulation.ontology.SimulationResource;\r
-import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.utils.ModelUtils;\r
-\r
-public class Model implements IWriteableMDLObject {\r
-\r
-       private String name, timeUnit, saveper;\r
-       private double startTime = 0, endTime = 10, timeStep = 1;\r
-       \r
-       private HashMap<String, Element> elementMap = new HashMap<String, Element>();\r
-       private ArrayList<Subscript> subscripts = new ArrayList<Subscript>();\r
-       private ArrayList<Function> functions = new ArrayList<Function>();\r
-       private ArrayList<Connection> connections = new ArrayList<Connection>();\r
-       private ArrayList<View> views = new ArrayList<View>();\r
-       private ArrayList<Element> unlocatedElements = new ArrayList<Element>();\r
-       \r
-       public void addElement(Element element) {\r
-               if(element instanceof Subscript)\r
-                       addSubscript((Subscript)element);\r
-               else if(element instanceof Function)\r
-                       addFunction((Function)element);\r
-               else\r
-                       unlocatedElements.add(element);\r
-               if(element.getName() != null)\r
-                       elementMap.put(element.getName(), element);\r
-       }\r
-       \r
-       public void addSubscript(Subscript subscript) {\r
-               subscripts.add(subscript);\r
-       }\r
-       \r
-       public void addFunction(Function function) {\r
-               functions.add(function);\r
-       }\r
-       \r
-       public void addElement(View view, Element element) {\r
-               if(element instanceof Subscript)\r
-                       addSubscript((Subscript)element);\r
-               else {\r
-                       if(unlocatedElements.contains(element))\r
-                               unlocatedElements.remove(element);\r
-                       view.addElement(element);\r
-               }\r
-               if(element.getName() != null)\r
-                       elementMap.put(element.getName(), element);\r
-       }\r
-       \r
-       public void relocateElement(View view, Element element) {\r
-               if(unlocatedElements.contains(element))\r
-                       unlocatedElements.remove(element);\r
-               for(View v : views) {\r
-                       if(v.getElements().contains(element))\r
-                               v.getElements().remove(element);\r
-               }\r
-               view.addElement(element);\r
-       }\r
-       \r
-       public void removeElement(Element element) {\r
-               if(unlocatedElements.contains(element))\r
-                       unlocatedElements.remove(element);\r
-               \r
-               for(View view : views) {\r
-                       if(view.getElements().contains(element)) {\r
-                               view.getElements().remove(element);\r
-                       }\r
-               }\r
-               \r
-               // just to be sure: loop the whole elementMap and don't trust the element's name\r
-               String toBeRemoved = null;\r
-               for(String key : elementMap.keySet()) {\r
-                       if(element.equals(elementMap.get(key))) {\r
-                               toBeRemoved = key;\r
-                               break;\r
-                       }\r
-               }\r
-               if(toBeRemoved != null)\r
-                       elementMap.remove(toBeRemoved);\r
-       }\r
-       \r
-       public ArrayList<Element> getUnlocatedElements() {\r
-               return unlocatedElements;\r
-       }\r
-       \r
-       public Element getElement(String name) {\r
-               return elementMap.get(name);\r
-       }\r
-       \r
-       public void addConnection(Connection connection) {\r
-               connections.add(connection);\r
-               if(connection.getStart() != null &&\r
-                               !connection.getStart().getConnections().contains(connection)) {\r
-                       connection.getStart().addConnection(connection);\r
-               }\r
-               if(connection.getEnd() != null &&\r
-                               !connection.getEnd().getConnections().contains(connection)) {\r
-                       connection.getEnd().addConnection(connection);\r
-               }\r
-       }\r
-       \r
-       public ArrayList<Connection> getConnections() {\r
-               return connections;\r
-       }\r
-       \r
-       public ArrayList<Subscript> getSubscripts() {\r
-               return subscripts;\r
-       }\r
-\r
-       public String getName() {\r
-               if(name == null)\r
-                       return "ModelName";\r
-               return name;\r
-       }\r
-\r
-       public void setName(String name) {\r
-               this.name = name;\r
-       }\r
-\r
-       public String getTimeUnit() {\r
-               return timeUnit;\r
-       }\r
-\r
-       public void setTimeUnit(String timeUnit) {\r
-               this.timeUnit = timeUnit;\r
-       }\r
-\r
-       public String getSaveper() {\r
-               return saveper;\r
-       }\r
-\r
-       public void setSaveper(String saveper) {\r
-               this.saveper = saveper;\r
-       }\r
-\r
-       public double getStartTime() {\r
-               return startTime;\r
-       }\r
-\r
-       public void setStartTime(double startTime) {\r
-               this.startTime = startTime;\r
-       }\r
-\r
-       public double getEndTime() {\r
-               return endTime;\r
-       }\r
-\r
-       public void setEndTime(double endTime) {\r
-               this.endTime = endTime;\r
-       }\r
-\r
-       public double getTimeStep() {\r
-               return timeStep;\r
-       }\r
-\r
-       public void setTimeStep(double timeStep) {\r
-               this.timeStep = timeStep;\r
-       }\r
-\r
-       public HashMap<String, Element> getElementMap() {\r
-               return elementMap;\r
-       }\r
-\r
-       public void setElementMap(HashMap<String, Element> elementMap) {\r
-               this.elementMap = elementMap;\r
-       }\r
-\r
-       public void setSubscripts(ArrayList<Subscript> subscripts) {\r
-               this.subscripts = subscripts;\r
-       }\r
-\r
-       public void setConnections(ArrayList<Connection> connections) {\r
-               this.connections = connections;\r
-       }\r
-       \r
-       public void addView(View view) {\r
-               views.add(view);\r
-       }\r
-       \r
-       public ArrayList<View> getViews() {\r
-               return views;\r
-       }\r
-\r
-       /**\r
-        * Write the model to a project\r
-        * @param graph WriteGraph\r
-        * @param parent Project resource\r
-        */\r
-       @Override\r
-       public void write(WriteGraph graph, Resource parent) {\r
-               if(parent == null || graph == null)\r
-                       return;\r
-               \r
-               try {\r
-                   \r
-                   \r
-                       SysdynResource sr = SysdynResource.getInstance(graph);\r
-                       Layer0 l0 = Layer0.getInstance(graph);\r
-                       SimulationResource simu = SimulationResource.getInstance(graph);\r
-\r
-            Resource model = ModelUtils.createModelAt(graph, parent);\r
-            graph.claimLiteral(model, l0.HasLabel, getName());\r
-            graph.claimLiteral(model, sr.SysdynModel_startTime, startTime);\r
-            graph.claimLiteral(model, sr.SysdynModel_stopTime, endTime);\r
-
-\r
-            Resource conf = graph.getSingleObject(model, simu.HasConfiguration);\r
-            \r
-                       for(Subscript s : subscripts) {\r
-                               s.write(graph, conf, 0, 0);\r
-                       }\r
-\r
-                       // Create the grid n*n of views:\r
-                       \r
-                       double n = Math.sqrt(views.size());\r
-                       n = Math.ceil(n);\r
-                       \r
-                       int width = 0, height = 0;\r
-                       for(View v : views) {\r
-                               if(v.getWidth() > width)\r
-                                       width = v.getWidth();\r
-                               if(v.getHeight() > height)\r
-                                       height = v.getHeight();\r
-                       }\r
-\r
-                       for(int i = 0; i < n; i++) {\r
-                               for(int j = 0; j < n; j++) {\r
-                                       int index = i * (int)n + j;\r
-                                       if(index < views.size()) {\r
-                                               View v = views.get(index);\r
-                                               v.setxOffset(width * j);\r
-                                               v.setyOffset(height * i);\r
-                                               v.write(graph, conf);\r
-                                       }\r
-                               }\r
-                       }\r
-                       \r
-                       for(Element e : unlocatedElements) {\r
-                               e.write(graph, conf, 0, 0);\r
-                       }\r
-\r
-                       for(Connection c : connections) {\r
-                               c.write(graph, conf);\r
-                       }\r
-                       \r
-                       for(Function f : functions) {\r
-                               f.write(graph, model, 0, 0);\r
-                       }\r
-\r
-\r
-               } catch (DatabaseException e) {\r
-                       e.printStackTrace();\r
-               }\r
-       }\r
-               \r
-       \r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Model2.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Model2.java
deleted file mode 100644 (file)
index 88f1bde..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.mdlImport.model;\r
-\r
-import java.util.ArrayList;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.simulation.ontology.SimulationResource;\r
-import org.simantics.sysdyn.utils.ModelUtils;\r
-\r
-public class Model2 implements IWriteableObject {\r
-       \r
-       private String name;\r
-       // necessary simulation parameters\r
-       private double start, stop, step;\r
-       \r
-       // the structure of the model\r
-       private ArrayList<Element2> elements;\r
-       private ArrayList<Connection2> connections;\r
-       \r
-       public Model2(String name) {\r
-               this.name = name;\r
-               \r
-               elements = new ArrayList<Element2>();\r
-               connections = new ArrayList<Connection2>();\r
-       }\r
-\r
-       public double getStart() {\r
-               return start;\r
-       }\r
-\r
-       public void setStart(double start) {\r
-               this.start = start;\r
-       }\r
-\r
-       public double getStop() {\r
-               return stop;\r
-       }\r
-\r
-       public void setStop(double stop) {\r
-               this.stop = stop;\r
-       }\r
-\r
-       public double getStep() {\r
-               return step;\r
-       }\r
-\r
-       public void setStep(double step) {\r
-               this.step = step;\r
-       }\r
-               \r
-       public void addElement(Element2 element) {\r
-               elements.add(element);\r
-       }\r
-       \r
-       public void addConnection(Connection2 connection) {\r
-               connections.add(connection);\r
-       }\r
-\r
-       @Override\r
-       public void write(WriteGraph graph, Resource parent) throws DatabaseException {         \r
-               Layer0 l0 = Layer0.getInstance(graph);\r
-               SimulationResource sim = SimulationResource.getInstance(graph);\r
-               \r
-               Resource model = ModelUtils.createModel(graph);\r
-               graph.claimLiteral(model, l0.HasLabel, name, Bindings.STRING);\r
-               \r
-               // TODO: set simulatin parameters\r
-               \r
-               Resource configuration = graph.getSingleObject(model, sim.HasConfiguration);\r
-               \r
-               for (Element2 e : elements) {\r
-                       e.write(graph, configuration);\r
-               }\r
-               \r
-               for (Connection2 c : connections) {\r
-                       c.write(graph, configuration);\r
-               }\r
-       }\r
-       \r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/ModelVariable.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/ModelVariable.java
deleted file mode 100644 (file)
index bbd818e..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.simantics.sysdyn.mdlImport.model;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.layer0.utils.direct.GraphUtils;\r
-import org.simantics.modeling.ModelingResources;\r
-import org.simantics.sysdyn.SysdynResource;\r
-\r
-public class ModelVariable extends Element2 {\r
-\r
-       protected String name;\r
-       protected Range range;\r
-       protected String unit;\r
-       protected String description;\r
-\r
-       public ModelVariable() {\r
-\r
-       }\r
-\r
-       public Resource createVariable(WriteGraph graph, Resource type, Resource parent) throws DatabaseException {\r
-               Layer0 l0 = Layer0.getInstance(graph);\r
-               ModelingResources mr = ModelingResources.getInstance(graph);\r
-               SysdynResource sr = SysdynResource.getInstance(graph);\r
-\r
-               Resource variable = GraphUtils.create2(graph, type, \r
-                               l0.HasName, name,\r
-                               l0.PartOf, parent);\r
-               graph.claim(variable, mr.Mapped, variable);\r
-               \r
-               if (unit != null && !unit.isEmpty()) {\r
-                       graph.claimLiteral(variable, sr.Variable_unit, unit, Bindings.STRING);\r
-               }\r
-               if (description != null && !description.isEmpty()) {\r
-                       graph.claimLiteral(variable, l0.HasDescription, description, Bindings.STRING);\r
-               }\r
-               if (range != null) {\r
-                       //graph.claimLiteral(variable, sr.HasRangeStart, rangeStart);\r
-                       //graph.claimLiteral(variable, sr.HasRangeEnd, rangeEnd);\r
-                       //graph.claimLiteral(variable, sr.HasRangeStep, rangeStep);\r
-               }\r
-\r
-               return variable;\r
-       }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Range.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Range.java
deleted file mode 100644 (file)
index 43c7eea..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.simantics.sysdyn.mdlImport.model;\r
-\r
-public class Range {\r
-       \r
-       private double start;\r
-       private double end;\r
-       private double step;\r
-       \r
-       public Range(double start, double end, double step) {\r
-               this.start = start;\r
-               this.end = end;\r
-               this.step = step;\r
-       }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Sketch2.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Sketch2.java
deleted file mode 100644 (file)
index 1408125..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-package org.simantics.sysdyn.mdlImport.model;\r
-\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-\r
-public class Sketch2 {\r
-       \r
-       private String name;\r
-       \r
-       private HashMap<Integer, SketchObject> objectMap;\r
-       private ArrayList<SketchConnection> unfinished;\r
-       \r
-       public Sketch2() {\r
-               objectMap = new HashMap<Integer, SketchObject>();\r
-               unfinished = new ArrayList<SketchConnection>();\r
-       }\r
-       \r
-       public String getName() {\r
-               return name;\r
-       }\r
-\r
-       public void setName(String name) {\r
-               this.name = name;\r
-       }\r
-       \r
-       public SketchObject getSketchObject(int index) {\r
-               return objectMap.get(index);\r
-       }\r
-\r
-       public void addSketchObject(SketchConnection object) {\r
-               unfinished.add(object);\r
-               \r
-               addSketchObject((SketchObject)object);\r
-       }\r
-       \r
-       public void addSketchObject(SketchObject object) {\r
-               if (objectMap.get(object.getId()) != null) {\r
-                       System.err.println("duplicate object with id "+object.getId());\r
-                       return;\r
-               }\r
-               objectMap.put(object.getId(), object);\r
-               \r
-               // NOTE: could just do another pass to update connections at the end \r
-               // or just use a priority queue or something but the number of \r
-               // unfinished connections at any given time should be relatively \r
-               // small in practice so it does not matter that this is inefficient\r
-               Iterator<SketchConnection> i = unfinished.iterator();\r
-               while (i.hasNext()) {\r
-                       SketchConnection connection = i.next();\r
-                       \r
-                       SketchObject from = objectMap.get(connection.getFromId());\r
-                       SketchObject to   = objectMap.get(connection.getToId());\r
-                       \r
-                       if (from != null && to != null) {\r
-                               // connections can only connect elements so if this is not the \r
-                               // case something has gone wrong with the indexing\r
-                               assert from instanceof SketchElement;\r
-                               assert to instanceof SketchElement;\r
-                               \r
-                               connection.setFrom((SketchElement)from);\r
-                               connection.setTo((SketchElement)to);\r
-                               \r
-                               i.remove();\r
-                       }\r
-               }\r
-       }\r
-\r
-       // TODO: ugly and inefficient\r
-       \r
-       public List<SketchElement> getElements() {\r
-               ArrayList<SketchElement> list = new ArrayList<SketchElement>();\r
-               for (SketchObject o : objectMap.values()) {\r
-                       if (o instanceof SketchElement) {\r
-                               list.add((SketchElement)o);\r
-                       }\r
-               }\r
-               return list;\r
-       }\r
-       \r
-       public List<SketchConnection> getConnections() {\r
-               ArrayList<SketchConnection> list = new ArrayList<SketchConnection>();\r
-               for (SketchObject o : objectMap.values()) {\r
-                       if (o instanceof SketchConnection) {\r
-                               list.add((SketchConnection)o);\r
-                       }\r
-               }\r
-               return list;\r
-       }\r
-       \r
-       public int getWidth() {\r
-               int width = 0;\r
-               for (SketchElement e : getElements()) {\r
-                       width = Math.max(width, e.getX()+e.getWidth());\r
-               }\r
-               return width;\r
-       }\r
-       \r
-       public int getHeight() {\r
-               int height = 0;\r
-               for (SketchElement e : getElements()) {\r
-                       height = Math.max(height, e.getY()+e.getHeight());\r
-               }\r
-               return height;\r
-       }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/SketchComment.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/SketchComment.java
deleted file mode 100644 (file)
index 3baa5fb..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.simantics.sysdyn.mdlImport.model;\r
-\r
-import org.simantics.sysdyn.mdlImport.MdlUtils.CommentIcon;\r
-\r
-public class SketchComment extends SketchElement {\r
-       \r
-       private String text;\r
-       private CommentIcon icon;\r
-       private boolean nextLine;\r
-       private boolean isIO;\r
-\r
-       public SketchComment(int id, CommentIcon icon, boolean nextLine, boolean isIO) {\r
-               super(id);\r
-               this.icon = icon;\r
-               this.nextLine = nextLine;\r
-               this.isIO = isIO;\r
-       }\r
-\r
-       public String getText() {\r
-               return text;\r
-       }\r
-       \r
-       public void setText(String text) {\r
-               this.text = text;\r
-       }\r
-       \r
-       public CommentIcon getIcon() {\r
-               return this.icon;\r
-       }\r
-       \r
-       public boolean isCloud() {\r
-               return this.icon.equals(CommentIcon.CLOUD);\r
-       }\r
-       \r
-       public boolean hasTextNextLine() {\r
-               return nextLine;\r
-       }\r
-       \r
-       public boolean isIOElement() {\r
-               return this.isIO;\r
-       }\r
-       \r
-       public Comment2 getWriteableElement(int xOffset, int yOffset) {\r
-               return null;\r
-       }\r
-       \r
-       @Override\r
-       public String toString() {\r
-               return text != null ? "\""+text+"\"" : "(empty comment)";\r
-       }\r
-       \r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/SketchConnection.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/SketchConnection.java
deleted file mode 100644 (file)
index 4ab5965..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.simantics.sysdyn.mdlImport.model;\r
-\r
-import org.simantics.sysdyn.mdlImport.MdlUtils.ConnectionType;\r
-\r
-public class SketchConnection extends SketchObject {\r
-\r
-       private int fromId;\r
-       private SketchElement from;\r
-       private int toId;\r
-       private SketchElement to;\r
-       private ConnectionType type;\r
-       \r
-       public SketchConnection(int id, int fromId, int toId, ConnectionType type) {\r
-               super(id);\r
-               this.fromId = fromId;\r
-               this.toId = toId;\r
-               this.type = type;\r
-       }\r
-       \r
-       public int getFromId() {\r
-               return fromId;\r
-       }\r
-       \r
-       public int getToId() {\r
-               return toId;\r
-       }\r
-\r
-       public SketchElement getFrom() {\r
-               if (from == null) {\r
-                       System.err.println("endpoint "+fromId+" for connection "+getId()+" is unset");\r
-               }\r
-               return from;\r
-       }\r
-\r
-       public void setFrom(SketchElement from) {\r
-               this.from = from;\r
-       }\r
-\r
-       public SketchElement getTo() {\r
-               if (to == null) {\r
-                       System.err.println("endpoint "+toId+" for connection "+getId()+" is unset");\r
-               }\r
-               return to;\r
-       }\r
-\r
-       public void setTo(SketchElement to) {\r
-               this.to = to;\r
-       }\r
-       \r
-       public ConnectionType getType() {\r
-               return type;\r
-       }\r
-       \r
-       public Connection2 getWriteableConnection() {\r
-               // return dependency or flow\r
-               return null;\r
-       }\r
-       \r
-       @Override\r
-       public String toString() {\r
-               return from.toString() + " --> " + to.toString();\r
-       }\r
-       \r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/SketchElement.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/SketchElement.java
deleted file mode 100644 (file)
index 1625ae6..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.simantics.sysdyn.mdlImport.model;\r
-\r
-public abstract class SketchElement extends SketchObject {\r
-\r
-       private int x;\r
-       private int y;\r
-       private int width;\r
-       private int height;\r
-       \r
-       public SketchElement(int id) {\r
-               super(id);\r
-       }\r
-       \r
-       public void setLocationAndSize(int x, int y, int width, int height) {\r
-               this.x = x;\r
-               this.y = y;\r
-               this.width = width;\r
-               this.height = height;\r
-       }\r
-\r
-       public int getX() {\r
-               return x;\r
-       }\r
-\r
-       public int getY() {\r
-               return y;\r
-       }\r
-\r
-       public int getWidth() {\r
-               return width;\r
-       }\r
-\r
-       public int getHeight() {\r
-               return height;\r
-       }\r
-       \r
-       public abstract Element2 getWriteableElement(int xOffset, int yOffset);\r
-       \r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/SketchObject.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/SketchObject.java
deleted file mode 100644 (file)
index bb9608d..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.simantics.sysdyn.mdlImport.model;\r
-\r
-public abstract class SketchObject {\r
-       \r
-       // TODO: some type stuff here maybe?\r
-       \r
-       private int id;\r
-       \r
-       SketchObject(int id) {\r
-               this.id = id;\r
-       }\r
-       \r
-       public int getId() {\r
-               return id;\r
-       }\r
-       \r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/SketchValve.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/SketchValve.java
deleted file mode 100644 (file)
index f4f1210..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.simantics.sysdyn.mdlImport.model;\r
-\r
-public class SketchValve extends SketchElement {\r
-       \r
-       private SketchVariable variable;\r
-       \r
-       public SketchValve(int id) {\r
-               super(id);\r
-       }\r
-\r
-       public SketchVariable getAttachedVariable() {\r
-               return variable;\r
-       }\r
-\r
-       public void setAttachedVariable(SketchVariable variable) {\r
-               this.variable = variable;\r
-       }\r
-       \r
-       @Override\r
-       public Valve2 getWriteableElement(int xOffset, int yOffset) {\r
-               return null;\r
-       }\r
-       \r
-       @Override\r
-       public String toString() {\r
-               return "X("+variable.toString()+")";\r
-       }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/SketchVariable.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/SketchVariable.java
deleted file mode 100644 (file)
index 5be5f83..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.simantics.sysdyn.mdlImport.model;\r
-\r
-import org.simantics.sysdyn.mdlImport.MdlUtils;\r
-import org.simantics.utils.datastructures.Pair;\r
-\r
-public class SketchVariable extends SketchElement {\r
-       \r
-       private Variable2 variable;\r
-       boolean isAttached;\r
-       boolean allowsInBound;\r
-       boolean allowsOutBound;\r
-\r
-       public SketchVariable(int id, Variable2 variable, boolean isAttached, boolean in, boolean out) {\r
-               super(id);\r
-               this.variable = variable;\r
-               this.isAttached = isAttached;\r
-               this.allowsInBound = in;\r
-               this.allowsOutBound = out;\r
-       }\r
-       \r
-       public Variable2 getVariable() {\r
-               return this.variable;\r
-       }\r
-       \r
-       public boolean isAttached() {\r
-               return isAttached;\r
-       }\r
-       \r
-       public boolean allowsInBound() {\r
-               return allowsInBound;\r
-       }\r
-       \r
-       public boolean allowsOutBound() {\r
-               return allowsOutBound;\r
-       }\r
-       \r
-       @Override\r
-       public Element2 getWriteableElement(int xOffset, int yOffset) {\r
-               Pair<String, String> integral = MdlUtils.getPossibleIntegral(variable.getEquation());\r
-               if (integral != null) {\r
-                       return new Stock2(getX(), getY(), variable, integral);\r
-               }\r
-               else {\r
-                       return new Auxiliary2(getX(), getY(), variable, variable.getEquation());\r
-               }\r
-       }\r
-       \r
-       @Override\r
-       public String toString() {\r
-               return (allowsInBound?"":"<")+variable.getName()+(allowsInBound?"":">");\r
-       }\r
-       \r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Stock.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Stock.java
deleted file mode 100644 (file)
index ec88915..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.mdlImport.model;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.utils.direct.GraphUtils;\r
-import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.mdlImport.ImportUtils;\r
-\r
-public class Stock extends Variable {\r
-\r
-       @Override\r
-       public Resource getExpression(WriteGraph graph, Expression expression) throws DatabaseException {               \r
-\r
-               String integralEquation = ImportUtils.escapeExpression(getIntegralParts(expression)[1]);\r
-               SysdynResource sr = SysdynResource.getInstance(graph);\r
-               Resource e = GraphUtils.create2(graph, \r
-                               sr.StockExpression,\r
-                               sr.StockExpression_initialEquation, integralEquation);\r
-               \r
-               return e;\r
-       }\r
-       \r
-       public String[] getIntegralParts(Expression expression) {\r
-               // Does not work, if the integral has some other logic than +inflows -outflows!\r
-               \r
-               // Parsing the possible functions. Searching ',' that divides the INTEG -function\r
-               int parenthesiscount = 0;\r
-               int location = 0;\r
-               char[] charArray = expression.getExpression().toCharArray();\r
-               for(int i = 0; i < charArray.length; i++) {\r
-                       char c = charArray[i];\r
-                       if(c == '(')\r
-                               parenthesiscount++;\r
-                       else if(c == ')')\r
-                               parenthesiscount--;\r
-                       else if(c == ',' && parenthesiscount == 1) {\r
-                               location = i + 1;\r
-                               break;\r
-                       }\r
-               }\r
-               \r
-               String exp = expression.getExpression();\r
-               String initialEquation = exp.substring(location,  exp.lastIndexOf(')')).trim();\r
-               String integral = exp.substring(exp.indexOf("(") + 1, location - 1).trim();\r
-               \r
-               \r
-               return new String[] {integral, initialEquation};\r
-       }\r
-\r
-       @Override\r
-       public void write(WriteGraph graph, Resource parent, double xOffset,\r
-                       double yOffset) {\r
-               if(parent == null || graph == null)\r
-                       return;\r
-               \r
-               try {\r
-                       SysdynResource sr = SysdynResource.getInstance(graph);\r
-                       if(!graph.isInstanceOf(parent, sr.Configuration))\r
-                               return;\r
-                       createVariable(graph, parent, sr.Stock, sr.StockSymbol, xOffset, yOffset);\r
-               } catch (DatabaseException e) {\r
-                       e.printStackTrace();\r
-               }\r
-               \r
-       }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Stock2.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Stock2.java
deleted file mode 100644 (file)
index 8b827e3..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.simantics.sysdyn.mdlImport.model;\r
-\r
-import java.util.Arrays;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.utils.ListUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.layer0.utils.direct.GraphUtils;\r
-import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.utils.datastructures.Pair;\r
-\r
-public class Stock2 extends ModelVariable {\r
-       \r
-       protected String integral;\r
-       protected String initial;\r
-\r
-       public Stock2(double x, double y, \r
-                       String name, String unit, Range range, String description, \r
-                       String integral, String initial) {\r
-               this.integral = integral;\r
-               this.initial = initial;\r
-       }\r
-       \r
-       public Stock2(double x, double y, Variable2 variable, Pair<String, String> equation) {\r
-               this.integral = equation.first;\r
-               this.initial = equation.second;\r
-       }\r
-       \r
-       public void write(WriteGraph graph, Resource parent) throws DatabaseException {\r
-               Layer0 l0 = Layer0.getInstance(graph);\r
-               SysdynResource sr = SysdynResource.getInstance(graph);\r
-\r
-               Resource stock = createVariable(graph, sr.Stock, parent);\r
-\r
-               Resource expression = GraphUtils.create2(graph, sr.StockExpression,\r
-                               sr.StockExpression_integralEquation, integral,\r
-                               sr.StockExpression_initialEquation, initial,\r
-                               l0.PartOf, stock);\r
-               // TODO: why is the expressoin stored in two places?\r
-               graph.claim(stock, sr.Variable_expressionList, ListUtils.create(graph, Arrays.asList(expression)));\r
-\r
-               createSymbol(graph, sr.StockSymbol, stock, parent);\r
-\r
-               setResource(stock);\r
-       }\r
-       \r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Subscript.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Subscript.java
deleted file mode 100644 (file)
index 5a96d94..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.mdlImport.model;\r
-\r
-import java.util.ArrayList;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.utils.ListUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.layer0.utils.direct.GraphUtils;\r
-import org.simantics.sysdyn.SysdynResource;\r
-\r
-public class Subscript extends Variable {\r
-\r
-       @Override\r
-       public Resource getExpression(WriteGraph graph, Expression expression)\r
-                       throws DatabaseException {\r
-               return null;\r
-       }\r
-\r
-       @Override\r
-       public void write(WriteGraph graph, Resource parent, double xOffset,\r
-                       double yOffset) {\r
-               if(parent == null || graph == null)\r
-                       return;\r
-               \r
-               try {\r
-                       SysdynResource sr = SysdynResource.getInstance(graph);\r
-                       if(!graph.isInstanceOf(parent, sr.Configuration))\r
-                               return;\r
-                       Layer0 l0 = Layer0.getInstance(graph); \r
-                       ArrayList<Resource> enumerationIndexes = new ArrayList<Resource>();\r
-                       if(expressions != null && expressions.get(0) != null) {\r
-                               String[] indexes = expressions.get(0).getExpression().split(",");\r
-                               for(String s : indexes) {\r
-                                       Resource ei = GraphUtils.create2(graph, \r
-                                                       sr.EnumerationIndex,\r
-                                                       l0.HasName, s.trim());\r
-                                       enumerationIndexes.add(ei);\r
-                               }\r
-                       }\r
-\r
-                       Resource enumeration = GraphUtils.create2(graph, \r
-                                       sr.Enumeration,\r
-                                       l0.HasName, this.getName(),\r
-                                       sr.Enumeration_enumerationIndexList, ListUtils.create(graph, enumerationIndexes));\r
-\r
-                       graph.claim(parent, l0.ConsistsOf, enumeration);\r
-\r
-                       resource = enumeration;\r
-               } catch (DatabaseException e) {\r
-                       e.printStackTrace();\r
-               }\r
-       }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Valve.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Valve.java
deleted file mode 100644 (file)
index 6b93e5d..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.mdlImport.model;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.utils.direct.GraphUtils;\r
-import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.mdlImport.ImportUtils;\r
-\r
-public class Valve extends Variable {\r
-\r
-       @Override\r
-       public Resource getExpression(WriteGraph graph, Expression expression) throws DatabaseException {\r
-               SysdynResource sr = SysdynResource.getInstance(graph);\r
-               String expressionString =  ImportUtils.escapeExpression(expression.getExpression());\r
-               Resource e = GraphUtils.create2(graph, \r
-                               sr.NormalExpression,\r
-                               sr.Expression_equation, expressionString.trim());\r
-               return e;\r
-       }\r
-\r
-       @Override\r
-       public void write(WriteGraph graph, Resource parent, double xOffset,\r
-                       double yOffset) {\r
-               try {\r
-                       SysdynResource sr = SysdynResource.getInstance(graph);\r
-                       if(!graph.isInstanceOf(parent, sr.Configuration))\r
-                               return;\r
-                       createVariable(graph, parent, sr.Valve, sr.ValveSymbol, xOffset, yOffset);\r
-               } catch (DatabaseException e) {\r
-                       e.printStackTrace();\r
-               }\r
-       }\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Valve2.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Valve2.java
deleted file mode 100644 (file)
index c08eb56..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.simantics.sysdyn.mdlImport.model;\r
-\r
-public class Valve2 extends Element2 {\r
-       \r
-       public enum Orientation {\r
-               HORIZONTAL, VERTICAL\r
-       }\r
-       \r
-       public enum TextPosition {\r
-               INSIDE, BELOW, LEFT, ABOVE, RIGHT, UNSET\r
-       }\r
-       \r
-       public Valve2(String equation, Orientation orientation, TextPosition position, String unit, Range range, String description) {\r
-               \r
-       }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Variable.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Variable.java
deleted file mode 100644 (file)
index f0e579a..0000000
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.mdlImport.model;\r
-\r
-import java.util.ArrayList;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.utils.ListUtils;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.diagram.stubs.DiagramResource;\r
-import org.simantics.diagram.stubs.G2DResource;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.layer0.utils.direct.GraphUtils;\r
-import org.simantics.modeling.ModelingResources;\r
-import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.mdlImport.ImportUtils;\r
-\r
-public abstract class Variable extends Element {\r
-       protected String units;\r
-       protected String comments;\r
-       protected ArrayList<Expression> expressions;\r
-       protected ArrayList<Subscript> subscripts;\r
-\r
-       private Double rangeStart, rangeEnd, rangeStep;\r
-       \r
-       protected void createVariable(WriteGraph graph, Resource configuration, Resource variableType, Resource symbolType, double xOffset, double yOffset) throws DatabaseException {\r
-               SysdynResource sr = SysdynResource.getInstance(graph);\r
-               Layer0 l0 = Layer0.getInstance(graph); \r
-               ModelingResources mr = ModelingResources.getInstance(graph);\r
-               DiagramResource dr = DiagramResource.getInstance(graph);\r
-               G2DResource g2d = G2DResource.getInstance(graph);\r
-               \r
-               Resource diagram = graph.getSingleObject(configuration, mr.CompositeToDiagram);\r
-               if(diagram == null)\r
-                       return;\r
-               \r
-               // Make sure at least one expression exist\r
-               if(getExpressions().isEmpty()) {\r
-                       Expression e = new Expression();\r
-                       e.setExpression("");\r
-                       getExpressions().add(e);\r
-               }\r
-               \r
-               Resource variable = GraphUtils.create2(graph, \r
-                               variableType,\r
-                               l0.HasName, ImportUtils.escapeName(name));\r
-               graph.claim(variable, mr.Mapped, variable);\r
-\r
-               ArrayList<Resource> expressions = new ArrayList<Resource>();\r
-               for(Expression e : getExpressions()) {\r
-\r
-                   // Get expression from the variable. They have different types\r
-                   Resource expression = getExpression(graph, e);\r
-\r
-                   if(e.getRange() != null) {\r
-                       graph.claimLiteral(expression, sr.Expression_arrayRange, "[" + e.getRange().trim() + "]");\r
-                   }\r
-                   expressions.add(expression);\r
-                   graph.claim(variable, l0.ConsistsOf, expression);\r
-               }\r
-               graph.claim(variable, sr.Variable_expressionList, ListUtils.create(graph, expressions));\r
-\r
-               if(subscripts != null) {\r
-                   ArrayList<Resource> arrayIndexes = new ArrayList<Resource>();\r
-                   for(Subscript sub : subscripts) {\r
-                       if(sub.getResource() != null)\r
-                           arrayIndexes.add(sub.getResource());\r
-                       }\r
-                       graph.claim(variable, sr.Variable_arrayIndexesList, ListUtils.create(graph, arrayIndexes));\r
-               }\r
-               \r
-               if(units != null && units.length() > 0)\r
-                       graph.claimLiteral(variable, sr.Variable_unit, units);\r
-               if(comments != null && comments.length() > 0)\r
-                       graph.claimLiteral(variable, l0.HasDescription, comments);\r
-               if(rangeStart != null)\r
-                       graph.claimLiteral(variable, sr.HasRangeStart, rangeStart);\r
-               if(rangeEnd != null)\r
-                       graph.claimLiteral(variable, sr.HasRangeEnd, rangeEnd);\r
-               if(rangeStep != null)\r
-                       graph.claimLiteral(variable, sr.HasRangeStep, rangeStep);\r
-       \r
-               graph.claim(configuration, l0.ConsistsOf, variable);\r
-               \r
-               \r
-               Resource symbol = GraphUtils.create2(graph, \r
-                               symbolType,\r
-                               mr.ElementToComponent, variable);\r
-               \r
-               double[] transform = {1.0, 0.0, 0.0, 1.0, x + xOffset, y + yOffset};\r
-               graph.claimLiteral(symbol, dr.HasTransform, g2d.Transform, transform);\r
-               \r
-               OrderedSetUtils.add(graph, diagram, symbol);\r
-                               \r
-               resource = variable;\r
-       }\r
-       \r
-       \r
-       public String getUnits() {\r
-               return units;\r
-       }\r
-\r
-       public void setUnits(String units) {\r
-               this.units = units;\r
-       }\r
-\r
-       public String getComments() {\r
-               return comments;\r
-       }\r
-\r
-       public void setComments(String comments) {\r
-               this.comments = comments;\r
-       }\r
-\r
-       public ArrayList<Expression> getExpressions() {\r
-               if(expressions == null) {\r
-                       expressions = new ArrayList<Expression>();\r
-               }\r
-               return expressions;\r
-       }\r
-\r
-       public void setExpressions(ArrayList<Expression> expressions) {\r
-               this.expressions = expressions;\r
-       }\r
-\r
-       public ArrayList<Subscript> getSubscripts() {\r
-               if(subscripts == null)\r
-                       subscripts = new ArrayList<Subscript>();\r
-               return subscripts;\r
-       }\r
-\r
-       public void setSubscripts(ArrayList<Subscript> subscripts) {\r
-               this.subscripts = subscripts;\r
-       }\r
-       \r
-\r
-       public Double getRangeStart() {\r
-               return rangeStart;\r
-       }\r
-\r
-       public void setRangeStart(Double rangeStart) {\r
-               this.rangeStart = rangeStart;\r
-       }\r
-\r
-       public Double getRangeEnd() {\r
-               return rangeEnd;\r
-       }\r
-\r
-       public void setRangeEnd(Double rangeEnd) {\r
-               this.rangeEnd = rangeEnd;\r
-       }\r
-\r
-       public Double getRangeStep() {\r
-               return rangeStep;\r
-       }\r
-\r
-       public void setRangeStep(Double rangeStep) {\r
-               this.rangeStep = rangeStep;\r
-       }\r
-       \r
-       /**\r
-        * Use this to set subscripts after all elements have been read\r
-        * \r
-        * @param model The model where the variable is located\r
-        */\r
-       public void initializeSubscripts(Model model) {\r
-               for(Expression ex : getExpressions()) {\r
-                       if(ex.getRange() != null) {\r
-                               \r
-                               // Subscripts exist, check that subscripts -array is initialized\r
-                               getSubscripts();\r
-                               \r
-                               String[] elements = ex.getRange().split(",");\r
-                               // Search the corresponding subscript for each element, if it has not been searched already\r
-                               for(int i = 0; i < elements.length; i++) {\r
-                                       // The subscript has been defined, move to next\r
-                                       if(subscripts.size() > i)\r
-                                               continue;\r
-                                       \r
-                                       String element = elements[i].trim();\r
-                                       for(Subscript sub : model.getSubscripts()) {\r
-                                               if(sub.getName().equals(element)) {\r
-                                                       subscripts.add(sub);\r
-                                                       break;\r
-                                               }\r
-                                               for(String index : sub.getExpressions().get(0).getExpression().split(",")) {\r
-                                                       if(index.trim().equals(element)) {\r
-                                                               subscripts.add(sub);\r
-                                                               break;\r
-                                                       }\r
-                                               }\r
-                                               // Subscript was defined for this index in previous for-loop\r
-                                               if(subscripts.size() == i + 1)\r
-                                                       break;\r
-                                       }\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Variable2.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/Variable2.java
deleted file mode 100644 (file)
index f478b44..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.simantics.sysdyn.mdlImport.model;\r
-\r
-public class Variable2 {\r
-       \r
-       private String name;\r
-       private String equation;\r
-       private String unit;\r
-       private String description;\r
-       \r
-       public Variable2(String name, String equation, String unit, String description) {\r
-               this.name = name;\r
-               this.equation = equation;\r
-               this.unit = unit;\r
-               this.description = description;\r
-       }\r
-       \r
-       public String getName() {\r
-               return name;\r
-       }\r
-       \r
-       public void setName(String name) {\r
-               this.name = name;\r
-       }\r
-       \r
-       public String getEquation() {\r
-               return equation;\r
-       }\r
-\r
-       public void setEquation(String equation) {\r
-               this.equation = equation;\r
-       }\r
-\r
-       public String getUnit() {\r
-               return unit;\r
-       }\r
-\r
-       public void setUnit(String unit) {\r
-               this.unit = unit;\r
-       }\r
-\r
-       public String getDescription() {\r
-               return description;\r
-       }\r
-\r
-       public void setDescription(String description) {\r
-               this.description = description;\r
-       }\r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/View.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/model/View.java
deleted file mode 100644 (file)
index acfa849..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.mdlImport.model;\r
-\r
-import java.util.ArrayList;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-\r
-public class View implements IWriteableMDLObject {\r
-       \r
-       private int minX = 0, maxX = 0, minY = 0, maxY = 0;\r
-       private double xOffset = 0, yOffset = 0;\r
-       private String name, fontParameters;\r
-       \r
-       private ArrayList<Element> elements = new ArrayList<Element>();\r
-\r
-       @Override\r
-       public void write(WriteGraph graph, Resource parent) {\r
-               xOffset = xOffset - minX;\r
-               yOffset = yOffset - minY;\r
-               for(Element e : elements) {\r
-                       e.write(graph, parent, xOffset, yOffset);\r
-               }\r
-       }\r
-       \r
-       public void addElement(Element e) {\r
-               if (e instanceof Subscript || e instanceof Function)\r
-                       return;\r
-               \r
-               if (e.getX() < minX)\r
-                       minX = e.getX();\r
-               if (e.getX() > maxX)\r
-                       maxX = e.getX();\r
-               if (e.getY() < minY)\r
-                       minY = e.getY();\r
-               if (e.getY() > maxY)\r
-                       maxY = e.getY();\r
-               \r
-               this.elements.add(e);\r
-       }\r
-       \r
-       public ArrayList<Element> getElements() {\r
-               return elements;\r
-       }\r
-\r
-       public void setElements(ArrayList<Element> elements) {\r
-               this.elements = elements;\r
-       }\r
-       \r
-       public String getName() {\r
-               return name;\r
-       }\r
-\r
-       public void setName(String name) {\r
-               this.name = name;\r
-       }\r
-\r
-\r
-       public String getFontParameters() {\r
-               return fontParameters;\r
-       }\r
-\r
-\r
-       public void setFontParameters(String fontParameters) {\r
-               this.fontParameters = fontParameters;\r
-       }\r
-\r
-\r
-       public int getMinX() {\r
-               return minX;\r
-       }\r
-\r
-       public void setMinX(int minX) {\r
-               this.minX = minX;\r
-       }\r
-\r
-       public int getMaxX() {\r
-               return maxX;\r
-       }\r
-\r
-       public void setMaxX(int maxX) {\r
-               this.maxX = maxX;\r
-       }\r
-\r
-       public int getMinY() {\r
-               return minY;\r
-       }\r
-\r
-       public void setMinY(int minY) {\r
-               this.minY = minY;\r
-       }\r
-\r
-       public int getMaxY() {\r
-               return maxY;\r
-       }\r
-\r
-       public void setMaxY(int maxY) {\r
-               this.maxY = maxY;\r
-       }\r
-\r
-       public double getxOffset() {\r
-               return xOffset;\r
-       }\r
-\r
-       public void setxOffset(double xOffset) {\r
-               this.xOffset = xOffset;\r
-       }\r
-\r
-       public double getyOffset() {\r
-               return yOffset;\r
-       }\r
-\r
-       public void setyOffset(double yOffset) {\r
-               this.yOffset = yOffset;\r
-       }\r
-       \r
-       public int getWidth() {\r
-               return maxX - minX;\r
-       }\r
-       \r
-       public int getHeight() {\r
-               return maxY - minY;\r
-       }\r
-}\r