]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.template2d.ui/src/org/simantics/modeling/template2d/ui/actions/NewSVGImage.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.modeling.template2d.ui / src / org / simantics / modeling / template2d / ui / actions / NewSVGImage.java
index aa9de2e7411296a4e19442a97f88b6630b3f9775..5a64bdc902285b47f8cba62bd0b4dc95583020af 100644 (file)
@@ -1,78 +1,78 @@
-/*******************************************************************************\r
- * Copyright (c) 2012 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.modeling.template2d.ui.actions;\r
-\r
-import java.util.Arrays;\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.request.WriteRequest;\r
-import org.simantics.db.common.utils.ListUtils;\r
-import org.simantics.db.common.utils.NameUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.adapter.ActionFactory;\r
-import org.simantics.diagram.stubs.DiagramResource;\r
-import org.simantics.diagram.stubs.G2DResource;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.modeling.template2d.ontology.Template2dResource;\r
-import org.simantics.scenegraph.ontology.ScenegraphResources;\r
-import org.simantics.ui.SimanticsUI;\r
-\r
-public class NewSVGImage implements ActionFactory {\r
-\r
-    @Override\r
-    public Runnable create(Object target) {\r
-        if(!(target instanceof Resource))\r
-            return null;\r
-        final Resource parent = (Resource)target;\r
-\r
-        return new Runnable() {\r
-            @Override\r
-            public void run() {\r
-                SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
-                    @Override\r
-                    public void perform(WriteGraph g) throws DatabaseException {\r
-                        g.markUndoPoint();\r
-                       createNewSVGImage(g, parent);\r
-                    }\r
-                });\r
-            }\r
-        };\r
-    }\r
-    \r
-    public static Resource createNewSVGImage(WriteGraph g, Resource parent) throws DatabaseException {\r
-       \r
-        Layer0 L0 = Layer0.getInstance(g);\r
-        Template2dResource TEMPLATE2D = Template2dResource.getInstance(g);\r
-        DiagramResource DIA = DiagramResource.getInstance(g);\r
-        G2DResource G2D = G2DResource.getInstance(g);\r
-        ScenegraphResources SG = ScenegraphResources.getInstance(g);\r
-\r
-        Resource ref = g.newResource();\r
-        g.claim(ref, L0.InstanceOf, null, TEMPLATE2D.Profiles_VariableReference);\r
-        // This works only when experiment is running!\r
-        g.claimLiteral(ref, TEMPLATE2D.Profiles_VariableReference_path, "", Bindings.STRING);\r
-\r
-        Resource svgImage = g.newResource();\r
-        g.claim(svgImage, L0.InstanceOf, null, DIA.Scenegraph_SVGImage);\r
-        String name = NameUtils.findFreshName(g, "Image", parent, L0.ConsistsOf);\r
-        g.addLiteral(svgImage, L0.HasName, L0.NameOf, L0.String, name, Bindings.STRING);\r
-        g.claim(svgImage, DIA.Scenegraph_SVGImage_document, ref);\r
-        g.addLiteral(svgImage, DIA.Scenegraph_SVGImage_transform, DIA.Scenegraph_SVGImage_transform_Inverse, G2D.Transform, new Double[] { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 }, Bindings.getBindingUnchecked(Double[].class));\r
-        g.claim(svgImage, L0.PartOf, parent);\r
-        Resource list = g.getPossibleObject(parent, SG.Node_children);\r
-        if (list != null)\r
-               ListUtils.insertBack(g, list, Arrays.asList(svgImage));\r
-       return svgImage;\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Association for Decentralized Information Management in
+ * Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.modeling.template2d.ui.actions;
+
+import java.util.Arrays;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.WriteRequest;
+import org.simantics.db.common.utils.ListUtils;
+import org.simantics.db.common.utils.NameUtils;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.adapter.ActionFactory;
+import org.simantics.diagram.stubs.DiagramResource;
+import org.simantics.diagram.stubs.G2DResource;
+import org.simantics.layer0.Layer0;
+import org.simantics.modeling.template2d.ontology.Template2dResource;
+import org.simantics.scenegraph.ontology.ScenegraphResources;
+import org.simantics.ui.SimanticsUI;
+
+public class NewSVGImage implements ActionFactory {
+
+    @Override
+    public Runnable create(Object target) {
+        if(!(target instanceof Resource))
+            return null;
+        final Resource parent = (Resource)target;
+
+        return new Runnable() {
+            @Override
+            public void run() {
+                SimanticsUI.getSession().asyncRequest(new WriteRequest() {
+                    @Override
+                    public void perform(WriteGraph g) throws DatabaseException {
+                        g.markUndoPoint();
+                       createNewSVGImage(g, parent);
+                    }
+                });
+            }
+        };
+    }
+    
+    public static Resource createNewSVGImage(WriteGraph g, Resource parent) throws DatabaseException {
+       
+        Layer0 L0 = Layer0.getInstance(g);
+        Template2dResource TEMPLATE2D = Template2dResource.getInstance(g);
+        DiagramResource DIA = DiagramResource.getInstance(g);
+        G2DResource G2D = G2DResource.getInstance(g);
+        ScenegraphResources SG = ScenegraphResources.getInstance(g);
+
+        Resource ref = g.newResource();
+        g.claim(ref, L0.InstanceOf, null, TEMPLATE2D.Profiles_VariableReference);
+        // This works only when experiment is running!
+        g.claimLiteral(ref, TEMPLATE2D.Profiles_VariableReference_path, "", Bindings.STRING);
+
+        Resource svgImage = g.newResource();
+        g.claim(svgImage, L0.InstanceOf, null, DIA.Scenegraph_SVGImage);
+        String name = NameUtils.findFreshName(g, "Image", parent, L0.ConsistsOf);
+        g.addLiteral(svgImage, L0.HasName, L0.NameOf, L0.String, name, Bindings.STRING);
+        g.claim(svgImage, DIA.Scenegraph_SVGImage_document, ref);
+        g.addLiteral(svgImage, DIA.Scenegraph_SVGImage_transform, DIA.Scenegraph_SVGImage_transform_Inverse, G2D.Transform, new Double[] { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 }, Bindings.getBindingUnchecked(Double[].class));
+        g.claim(svgImage, L0.PartOf, parent);
+        Resource list = g.getPossibleObject(parent, SG.Node_children);
+        if (list != null)
+               ListUtils.insertBack(g, list, Arrays.asList(svgImage));
+       return svgImage;
+    }
+}