]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/participant/RenderingQualityInteractor.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / participant / RenderingQualityInteractor.java
index 645308c63cb939343f1af5080b36b27c82ed1392..a150b611134cb81f7451469225d2e8fdeed80dd4 100644 (file)
@@ -1,88 +1,88 @@
-/*******************************************************************************\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 org.simantics.g2d.canvas.impl.AbstractCanvasParticipant;\r
-import org.simantics.g2d.canvas.impl.HintReflection.HintListener;\r
-import org.simantics.g2d.scenegraph.SceneGraphConstants;\r
-import org.simantics.scenegraph.INode;\r
-import org.simantics.scenegraph.g2d.G2DSceneGraph;\r
-import org.simantics.scenegraph.g2d.nodes.NavigationNode;\r
-import org.simantics.scenegraph.utils.Quality;\r
-import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
-import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;\r
-import org.simantics.utils.datastructures.hints.IHintObservable;\r
-\r
-/**\r
- * Rendering quality interactor controls dynamic/static rendering quality of\r
- * the canvas context's scene graph through {@link NavigationNode}.\r
- * \r
- * @author Tuukka Lehtonen\r
- */\r
-public class RenderingQualityInteractor extends AbstractCanvasParticipant {\r
-\r
-    /**\r
-     * Interpreted to be true if value is TRUE or not defined, false otherwise.\r
-     */\r
-    public static final Key KEY_QUALITY_INTERACTOR_ENABLED = new KeyOf(Boolean.class);\r
-\r
-    /**\r
-     * \r
-     */\r
-    public static final Key KEY_STATIC_QUALITY = new KeyOf(Quality.class);\r
-\r
-    public RenderingQualityInteractor() {\r
-        super();\r
-    }\r
-\r
-    public Quality setStaticQuality(Quality staticQuality) {\r
-        Quality old = getHint(KEY_STATIC_QUALITY);\r
-        if (staticQuality != null)\r
-            setHint(KEY_STATIC_QUALITY, staticQuality);\r
-        else\r
-            removeHint(KEY_STATIC_QUALITY);\r
-        return old;\r
-    }\r
-\r
-    private void setStaticQuality0(Quality staticQuality) {\r
-        if (!isEnabled())\r
-            return;\r
-        NavigationNode nav = getNavigationNode();\r
-        if (nav == null)\r
-            return;\r
-        //System.out.println("static rendering quality: " + staticQuality);\r
-        nav.setStaticQualityMode(staticQuality);\r
-        nav.setDynamicQuality(staticQuality == null);\r
-    }\r
-\r
-    public boolean isEnabled() {\r
-        Boolean qualityPaint = getHint(KEY_QUALITY_INTERACTOR_ENABLED);\r
-        return !Boolean.FALSE.equals(qualityPaint);\r
-    }\r
-\r
-    private NavigationNode getNavigationNode() {\r
-        G2DSceneGraph sg = getContext().getSceneGraph();\r
-        INode node = sg.lookupNode(SceneGraphConstants.NAVIGATION_NODE_NAME);\r
-        return node instanceof NavigationNode ? (NavigationNode) node : null;\r
-    }\r
-\r
-    @HintListener(Class = RenderingQualityInteractor.class, Field = "KEY_STATIC_QUALITY")\r
-    public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) {\r
-        setStaticQuality0((Quality) newValue);\r
-    }\r
-\r
-    @HintListener(Class = RenderingQualityInteractor.class, Field = "KEY_STATIC_QUALITY")\r
-    public void hintRemoved(IHintObservable sender, Key key, Object oldValue) {\r
-        setStaticQuality0(null);\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 org.simantics.g2d.canvas.impl.AbstractCanvasParticipant;
+import org.simantics.g2d.canvas.impl.HintReflection.HintListener;
+import org.simantics.g2d.scenegraph.SceneGraphConstants;
+import org.simantics.scenegraph.INode;
+import org.simantics.scenegraph.g2d.G2DSceneGraph;
+import org.simantics.scenegraph.g2d.nodes.NavigationNode;
+import org.simantics.scenegraph.utils.Quality;
+import org.simantics.utils.datastructures.hints.IHintContext.Key;
+import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;
+import org.simantics.utils.datastructures.hints.IHintObservable;
+
+/**
+ * Rendering quality interactor controls dynamic/static rendering quality of
+ * the canvas context's scene graph through {@link NavigationNode}.
+ * 
+ * @author Tuukka Lehtonen
+ */
+public class RenderingQualityInteractor extends AbstractCanvasParticipant {
+
+    /**
+     * Interpreted to be true if value is TRUE or not defined, false otherwise.
+     */
+    public static final Key KEY_QUALITY_INTERACTOR_ENABLED = new KeyOf(Boolean.class);
+
+    /**
+     * 
+     */
+    public static final Key KEY_STATIC_QUALITY = new KeyOf(Quality.class);
+
+    public RenderingQualityInteractor() {
+        super();
+    }
+
+    public Quality setStaticQuality(Quality staticQuality) {
+        Quality old = getHint(KEY_STATIC_QUALITY);
+        if (staticQuality != null)
+            setHint(KEY_STATIC_QUALITY, staticQuality);
+        else
+            removeHint(KEY_STATIC_QUALITY);
+        return old;
+    }
+
+    private void setStaticQuality0(Quality staticQuality) {
+        if (!isEnabled())
+            return;
+        NavigationNode nav = getNavigationNode();
+        if (nav == null)
+            return;
+        //System.out.println("static rendering quality: " + staticQuality);
+        nav.setStaticQualityMode(staticQuality);
+        nav.setDynamicQuality(staticQuality == null);
+    }
+
+    public boolean isEnabled() {
+        Boolean qualityPaint = getHint(KEY_QUALITY_INTERACTOR_ENABLED);
+        return !Boolean.FALSE.equals(qualityPaint);
+    }
+
+    private NavigationNode getNavigationNode() {
+        G2DSceneGraph sg = getContext().getSceneGraph();
+        INode node = sg.lookupNode(SceneGraphConstants.NAVIGATION_NODE_NAME);
+        return node instanceof NavigationNode ? (NavigationNode) node : null;
+    }
+
+    @HintListener(Class = RenderingQualityInteractor.class, Field = "KEY_STATIC_QUALITY")
+    public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) {
+        setStaticQuality0((Quality) newValue);
+    }
+
+    @HintListener(Class = RenderingQualityInteractor.class, Field = "KEY_STATIC_QUALITY")
+    public void hintRemoved(IHintObservable sender, Key key, Object oldValue) {
+        setStaticQuality0(null);
+    }
+
+}