]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/example/LoadingMessageDiagram.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / example / LoadingMessageDiagram.java
index b69938d02f392526e92ad1c2866a2a3b9d5c642f..e01273049c989c6cf48e5c2b2946035a43c459e1 100644 (file)
@@ -1,96 +1,96 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.g2d.example;\r
-\r
-import java.awt.Color;\r
-import java.awt.geom.Rectangle2D;\r
-\r
-import org.simantics.g2d.canvas.ICanvasContext;\r
-import org.simantics.g2d.diagram.DiagramClass;\r
-import org.simantics.g2d.diagram.DiagramHints;\r
-import org.simantics.g2d.diagram.IDiagram;\r
-import org.simantics.g2d.diagram.impl.Diagram;\r
-import org.simantics.g2d.element.ElementClass;\r
-import org.simantics.g2d.element.ElementUtils;\r
-import org.simantics.g2d.element.IElement;\r
-import org.simantics.g2d.element.handler.Heartbeat;\r
-import org.simantics.g2d.element.handler.Text;\r
-import org.simantics.g2d.element.handler.impl.DefaultTransform;\r
-import org.simantics.g2d.element.handler.impl.FixedSize;\r
-import org.simantics.g2d.element.handler.impl.TextColorImpl;\r
-import org.simantics.g2d.element.handler.impl.TextPainter;\r
-import org.simantics.g2d.element.impl.Element;\r
-import org.simantics.g2d.elementclass.FilmClass;\r
-\r
-/**\r
- * Diagram with LOADING... text\r
- * \r
- * @author Toni Kalajainen\r
- */\r
-public class LoadingMessageDiagram {\r
-\r
-    public static final ElementClass LOADING_CLASS =\r
-        ElementClass.compile(\r
-                TextColorImpl.WHITE,\r
-                DefaultTransform.INSTANCE,\r
-                FixedSize.of(30, 20),\r
-                Text.INSTANCE,\r
-                new TextPainter(),\r
-                new LoadingAnimation()\r
-        );\r
-\r
-    public static final IDiagram LOADING_DIAGRAM = createLoadingDiagram();\r
-\r
-    /**\r
-     * Create diagram where flashing "LOADING" text\r
-     * @return\r
-     */\r
-    public static IDiagram createLoadingDiagram()\r
-    {\r
-        String name = "Loading...";\r
-        IDiagram d = Diagram.spawnNew(DiagramClass.DEFAULT);\r
-        d.setHint(DiagramHints.KEY_TEXT, name);\r
-\r
-        IElement film = Element.spawnNew(FilmClass.FILM_CLASS);\r
-        ElementUtils.fitToRectangle(film, new Rectangle2D.Double(0, 4, 40, 30));\r
-        d.addElement(film);\r
-        ElementUtils.setFillColor(film, new Color(0.3f, 0.3f, 0.8f, 0.5f));\r
-\r
-        IElement lbl = Element.spawnNew( LOADING_CLASS );\r
-        d.addElement(lbl);\r
-        ElementUtils.setPos(lbl, 5,7);\r
-        ElementUtils.setText(lbl, "Loading");\r
-        ElementUtils.setTextColor(lbl, Color.WHITE);\r
-\r
-        return d;\r
-    }\r
-\r
-\r
-\r
-    private static class LoadingAnimation implements Heartbeat {\r
-\r
-        private static final long serialVersionUID = 2721735864087380222L;\r
-\r
-        @Override\r
-        public void heartbeat(IElement e, long time, long deltaTime, ICanvasContext ctx) {\r
-            int dotCount = (int) ((time % 1000L) / 200L);\r
-            String dots = "";\r
-            for (int i=0; i<dotCount; i++)\r
-                dots += ".";\r
-            ElementUtils.setText(e, "Loading"+dots);\r
-\r
-            ctx.getContentContext().setDirty();\r
-        }\r
-\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.g2d.example;
+
+import java.awt.Color;
+import java.awt.geom.Rectangle2D;
+
+import org.simantics.g2d.canvas.ICanvasContext;
+import org.simantics.g2d.diagram.DiagramClass;
+import org.simantics.g2d.diagram.DiagramHints;
+import org.simantics.g2d.diagram.IDiagram;
+import org.simantics.g2d.diagram.impl.Diagram;
+import org.simantics.g2d.element.ElementClass;
+import org.simantics.g2d.element.ElementUtils;
+import org.simantics.g2d.element.IElement;
+import org.simantics.g2d.element.handler.Heartbeat;
+import org.simantics.g2d.element.handler.Text;
+import org.simantics.g2d.element.handler.impl.DefaultTransform;
+import org.simantics.g2d.element.handler.impl.FixedSize;
+import org.simantics.g2d.element.handler.impl.TextColorImpl;
+import org.simantics.g2d.element.handler.impl.TextPainter;
+import org.simantics.g2d.element.impl.Element;
+import org.simantics.g2d.elementclass.FilmClass;
+
+/**
+ * Diagram with LOADING... text
+ * 
+ * @author Toni Kalajainen
+ */
+public class LoadingMessageDiagram {
+
+    public static final ElementClass LOADING_CLASS =
+        ElementClass.compile(
+                TextColorImpl.WHITE,
+                DefaultTransform.INSTANCE,
+                FixedSize.of(30, 20),
+                Text.INSTANCE,
+                new TextPainter(),
+                new LoadingAnimation()
+        );
+
+    public static final IDiagram LOADING_DIAGRAM = createLoadingDiagram();
+
+    /**
+     * Create diagram where flashing "LOADING" text
+     * @return
+     */
+    public static IDiagram createLoadingDiagram()
+    {
+        String name = "Loading...";
+        IDiagram d = Diagram.spawnNew(DiagramClass.DEFAULT);
+        d.setHint(DiagramHints.KEY_TEXT, name);
+
+        IElement film = Element.spawnNew(FilmClass.FILM_CLASS);
+        ElementUtils.fitToRectangle(film, new Rectangle2D.Double(0, 4, 40, 30));
+        d.addElement(film);
+        ElementUtils.setFillColor(film, new Color(0.3f, 0.3f, 0.8f, 0.5f));
+
+        IElement lbl = Element.spawnNew( LOADING_CLASS );
+        d.addElement(lbl);
+        ElementUtils.setPos(lbl, 5,7);
+        ElementUtils.setText(lbl, "Loading");
+        ElementUtils.setTextColor(lbl, Color.WHITE);
+
+        return d;
+    }
+
+
+
+    private static class LoadingAnimation implements Heartbeat {
+
+        private static final long serialVersionUID = 2721735864087380222L;
+
+        @Override
+        public void heartbeat(IElement e, long time, long deltaTime, ICanvasContext ctx) {
+            int dotCount = (int) ((time % 1000L) / 200L);
+            String dots = "";
+            for (int i=0; i<dotCount; i++)
+                dots += ".";
+            ElementUtils.setText(e, "Loading"+dots);
+
+            ctx.getContentContext().setDirty();
+        }
+
+    }
+
+}