]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/SceneGraph.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / SceneGraph.java
diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/SceneGraph.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/SceneGraph.java
new file mode 100644 (file)
index 0000000..d63aefd
--- /dev/null
@@ -0,0 +1,71 @@
+/*******************************************************************************\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.element.handler;\r
+\r
+import org.simantics.g2d.diagram.participant.ElementPainter;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.SceneGraphNodeKey;\r
+import org.simantics.scenegraph.g2d.G2DNode;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+\r
+/**\r
+ * Scene graph node update handler of an element.\r
+ * \r
+ * <p>\r
+ * This handler is responsible for making sure that the scene graph is in sync\r
+ * with the element's current state.\r
+ * \r
+ * <p>\r
+ * An element may have multiple scene graph handlers. Painting order of the\r
+ * scene graph nodes is defined by the z-indexes given to the nodes created by\r
+ * each {@link SceneGraph} handler.\r
+ * \r
+ * @author J-P Laine\r
+ * \r
+ * @see {@link G2DNode} for scene graph\r
+ * @see ElementPainter\r
+ */\r
+public interface SceneGraph extends ElementHandler {\r
+\r
+    /**\r
+     * Updates the renderable representation of the specified element, i.e. its\r
+     * scene graph parts to match the current state of the element.\r
+     * \r
+     * <p>\r
+     * This method will be called whenever the g2d framework decides that an\r
+     * element is dirty. This means that implementations must be prepared to\r
+     * have this method be called multiple times.\r
+     * \r
+     * <p>\r
+     * Generally implementations should create a scene graph node or nodes only\r
+     * on the first invocation, store that in the element with a\r
+     * {@link SceneGraphNodeKey} and on each call initialize the created\r
+     * node/nodes with the values stored in the element.\r
+     * \r
+     * @param e element to update into the scene graph\r
+     * @param parent scene graph parent node for this element\r
+     * \r
+     * TODO: the method is badly named since it can be invoked multiple\r
+     * times. initOrUpdate would be more suitable but that just sounds\r
+     * bad and the whole thing feels like bad design anyway.\r
+     */\r
+    void init(final IElement e, final G2DParentNode parent);\r
+\r
+    /**\r
+     * Remove any scene graph node references from the specified element and\r
+     * from the scene graph.\r
+     * \r
+     * @param e the element whose scene graph references to clean up\r
+     */\r
+    void cleanup(final IElement e);\r
+\r
+}\r