]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/participant/SymbolUtil.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / participant / SymbolUtil.java
index a12c700d7003ac1d11411fcd8d7994d8a0730476..47309369b42e19470a06b87c3758292699390393 100644 (file)
@@ -1,85 +1,85 @@
-/*******************************************************************************\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.participant;\r
-\r
-import java.awt.GraphicsConfiguration;\r
-\r
-import org.simantics.g2d.canvas.ICanvasContext;\r
-import org.simantics.g2d.canvas.impl.AbstractCanvasParticipant;\r
-import org.simantics.g2d.image.Image;\r
-import org.simantics.utils.datastructures.cache.IProvider;\r
-import org.simantics.utils.datastructures.hints.HintContext;\r
-import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
-\r
-/**\r
- * Utility participant used for acquiring and storing symbols.\r
- * \r
- * //@deprecated\r
- * //TODO: Toni, explain why this is deprecated ??\r
- * @author Toni Kalajainen\r
- */\r
-public class SymbolUtil extends AbstractCanvasParticipant {\r
-\r
-    static class SymbolKey extends Key {\r
-        public final IProvider<Image> provider;\r
-        public final GraphicsConfiguration gc;\r
-        private final int hash;\r
-        public SymbolKey(GraphicsConfiguration gc,\r
-                IProvider<Image> provider) {\r
-            assert(gc!=null && provider!=null);\r
-            this.gc = gc;\r
-            this.provider = provider;\r
-            this.hash = gc.hashCode() ^provider.hashCode();\r
-        }\r
-        @Override\r
-        public boolean equals(Object obj) {\r
-            if (!(obj instanceof SymbolKey)) return false;\r
-            SymbolKey other = (SymbolKey) obj;\r
-            if (!other.provider.equals(provider)) return false;\r
-            if (!other.gc.equals(gc)) return false;\r
-            return true;\r
-        }\r
-        @Override\r
-        public int hashCode() {\r
-            return hash;\r
-        }\r
-        @Override\r
-        public boolean isValueAccepted(Object value) {\r
-            return value instanceof Image;\r
-        }\r
-    }\r
-\r
-    HintContext hintCtx = new HintContext();\r
-\r
-    @Override\r
-    public void removedFromContext(ICanvasContext ctx) {\r
-        hintCtx = null;\r
-        super.removedFromContext(ctx);\r
-    }\r
-\r
-    /**\r
-     * Acquire and store symbol.\r
-     * \r
-     * @param provider\r
-     * @param gc\r
-     * @return\r
-     */\r
-    public Image get(IProvider<Image> provider, GraphicsConfiguration gc) {\r
-        SymbolKey key = new SymbolKey(gc, provider);\r
-        Image ps = hintCtx.getHint(key);\r
-        if (ps!=null) return ps;\r
-        ps = provider.get();\r
-        hintCtx.setHint(key, ps);\r
-        return ps;\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.participant;
+
+import java.awt.GraphicsConfiguration;
+
+import org.simantics.g2d.canvas.ICanvasContext;
+import org.simantics.g2d.canvas.impl.AbstractCanvasParticipant;
+import org.simantics.g2d.image.Image;
+import org.simantics.utils.datastructures.cache.IProvider;
+import org.simantics.utils.datastructures.hints.HintContext;
+import org.simantics.utils.datastructures.hints.IHintContext.Key;
+
+/**
+ * Utility participant used for acquiring and storing symbols.
+ * 
+ * //@deprecated
+ * //TODO: Toni, explain why this is deprecated ??
+ * @author Toni Kalajainen
+ */
+public class SymbolUtil extends AbstractCanvasParticipant {
+
+    static class SymbolKey extends Key {
+        public final IProvider<Image> provider;
+        public final GraphicsConfiguration gc;
+        private final int hash;
+        public SymbolKey(GraphicsConfiguration gc,
+                IProvider<Image> provider) {
+            assert(gc!=null && provider!=null);
+            this.gc = gc;
+            this.provider = provider;
+            this.hash = gc.hashCode() ^provider.hashCode();
+        }
+        @Override
+        public boolean equals(Object obj) {
+            if (!(obj instanceof SymbolKey)) return false;
+            SymbolKey other = (SymbolKey) obj;
+            if (!other.provider.equals(provider)) return false;
+            if (!other.gc.equals(gc)) return false;
+            return true;
+        }
+        @Override
+        public int hashCode() {
+            return hash;
+        }
+        @Override
+        public boolean isValueAccepted(Object value) {
+            return value instanceof Image;
+        }
+    }
+
+    HintContext hintCtx = new HintContext();
+
+    @Override
+    public void removedFromContext(ICanvasContext ctx) {
+        hintCtx = null;
+        super.removedFromContext(ctx);
+    }
+
+    /**
+     * Acquire and store symbol.
+     * 
+     * @param provider
+     * @param gc
+     * @return
+     */
+    public Image get(IProvider<Image> provider, GraphicsConfiguration gc) {
+        SymbolKey key = new SymbolKey(gc, provider);
+        Image ps = hintCtx.getHint(key);
+        if (ps!=null) return ps;
+        ps = provider.get();
+        hintCtx.setHint(key, ps);
+        return ps;
+    }
+
+}