]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/graph/TransformSynchronizer.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / synchronization / graph / TransformSynchronizer.java
index 2ca67978a0e8027181611ddc38ddcf6585ed3d12..8bd3332333b80651fa7c4a028fbb881e7eea53dc 100644 (file)
@@ -1,66 +1,66 @@
-/*******************************************************************************\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.diagram.synchronization.graph;\r
-\r
-import java.awt.geom.AffineTransform;\r
-import java.awt.geom.Rectangle2D;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.Resource;\r
-import org.simantics.diagram.synchronization.IModificationQueue;\r
-import org.simantics.diagram.synchronization.ISynchronizationContext;\r
-import org.simantics.g2d.element.ElementHints;\r
-import org.simantics.utils.datastructures.hints.IHintObservable;\r
-import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class TransformSynchronizer extends ResourceSynchronizer {\r
-\r
-    public static final TransformSynchronizer INSTANCE = new TransformSynchronizer();\r
-\r
-    private static final Key[] SYNCHRONIZED_HINTS = {\r
-        ElementHints.KEY_TRANSFORM,\r
-        ElementHints.KEY_BOUNDS\r
-    };\r
-\r
-    @Override\r
-    public Key[] getSynchronizedHints() {\r
-        return SYNCHRONIZED_HINTS;\r
-    }\r
-\r
-    @Override\r
-    public boolean hintChanged(ISynchronizationContext context, IModificationQueue queue, Resource object, IHintObservable sender, Key key, Object oldValue, Object newValue) {\r
-       if(newValue == null) return false;\r
-       if (ElementHints.KEY_TRANSFORM.equals(key)) {\r
-            BasicResources br = context.get(GraphSynchronizationHints.BASIC_RESOURCES);\r
-\r
-            final double[] flatmatrix = new double[6];\r
-            ((AffineTransform) newValue).getMatrix(flatmatrix);\r
-\r
-            return queue.offer(new PropertyModification(object, br.DIA.HasTransform, br.G2D.Transform, flatmatrix, Bindings.DOUBLE_ARRAY), null);\r
-        } else if (ElementHints.KEY_BOUNDS.equals(key)) {\r
-            BasicResources br = context.get(GraphSynchronizationHints.BASIC_RESOURCES);\r
-\r
-            final double[] flatmatrix = new double[4];\r
-            flatmatrix[0] = ((Rectangle2D)newValue).getMinX();\r
-            flatmatrix[1] = ((Rectangle2D)newValue).getMinY();\r
-            flatmatrix[2] = ((Rectangle2D)newValue).getWidth();\r
-            flatmatrix[3] = ((Rectangle2D)newValue).getHeight();\r
-            return queue.offer(new PropertyModification(object, br.G2D.HasBounds, br.G2D.Rectangle2D, flatmatrix, Bindings.DOUBLE_ARRAY), null);\r
-        }\r
-        \r
-        return false;\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.diagram.synchronization.graph;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.db.Resource;
+import org.simantics.diagram.synchronization.IModificationQueue;
+import org.simantics.diagram.synchronization.ISynchronizationContext;
+import org.simantics.g2d.element.ElementHints;
+import org.simantics.utils.datastructures.hints.IHintObservable;
+import org.simantics.utils.datastructures.hints.IHintContext.Key;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class TransformSynchronizer extends ResourceSynchronizer {
+
+    public static final TransformSynchronizer INSTANCE = new TransformSynchronizer();
+
+    private static final Key[] SYNCHRONIZED_HINTS = {
+        ElementHints.KEY_TRANSFORM,
+        ElementHints.KEY_BOUNDS
+    };
+
+    @Override
+    public Key[] getSynchronizedHints() {
+        return SYNCHRONIZED_HINTS;
+    }
+
+    @Override
+    public boolean hintChanged(ISynchronizationContext context, IModificationQueue queue, Resource object, IHintObservable sender, Key key, Object oldValue, Object newValue) {
+       if(newValue == null) return false;
+       if (ElementHints.KEY_TRANSFORM.equals(key)) {
+            BasicResources br = context.get(GraphSynchronizationHints.BASIC_RESOURCES);
+
+            final double[] flatmatrix = new double[6];
+            ((AffineTransform) newValue).getMatrix(flatmatrix);
+
+            return queue.offer(new PropertyModification(object, br.DIA.HasTransform, br.G2D.Transform, flatmatrix, Bindings.DOUBLE_ARRAY), null);
+        } else if (ElementHints.KEY_BOUNDS.equals(key)) {
+            BasicResources br = context.get(GraphSynchronizationHints.BASIC_RESOURCES);
+
+            final double[] flatmatrix = new double[4];
+            flatmatrix[0] = ((Rectangle2D)newValue).getMinX();
+            flatmatrix[1] = ((Rectangle2D)newValue).getMinY();
+            flatmatrix[2] = ((Rectangle2D)newValue).getWidth();
+            flatmatrix[3] = ((Rectangle2D)newValue).getHeight();
+            return queue.offer(new PropertyModification(object, br.G2D.HasBounds, br.G2D.Rectangle2D, flatmatrix, Bindings.DOUBLE_ARRAY), null);
+        }
+        
+        return false;
+    }
+
+}