]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/SceneGraph.java
Sync git svn branch with SVN repository r33324.
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / SceneGraph.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.g2d.element.handler;\r
13 \r
14 import org.simantics.g2d.diagram.participant.ElementPainter;\r
15 import org.simantics.g2d.element.IElement;\r
16 import org.simantics.g2d.element.SceneGraphNodeKey;\r
17 import org.simantics.scenegraph.g2d.G2DNode;\r
18 import org.simantics.scenegraph.g2d.G2DParentNode;\r
19 \r
20 /**\r
21  * Scene graph node update handler of an element.\r
22  * \r
23  * <p>\r
24  * This handler is responsible for making sure that the scene graph is in sync\r
25  * with the element's current state.\r
26  * \r
27  * <p>\r
28  * An element may have multiple scene graph handlers. Painting order of the\r
29  * scene graph nodes is defined by the z-indexes given to the nodes created by\r
30  * each {@link SceneGraph} handler.\r
31  * \r
32  * @author J-P Laine\r
33  * \r
34  * @see {@link G2DNode} for scene graph\r
35  * @see ElementPainter\r
36  */\r
37 public interface SceneGraph extends ElementHandler {\r
38 \r
39     /**\r
40      * Updates the renderable representation of the specified element, i.e. its\r
41      * scene graph parts to match the current state of the element.\r
42      * \r
43      * <p>\r
44      * This method will be called whenever the g2d framework decides that an\r
45      * element is dirty. This means that implementations must be prepared to\r
46      * have this method be called multiple times.\r
47      * \r
48      * <p>\r
49      * Generally implementations should create a scene graph node or nodes only\r
50      * on the first invocation, store that in the element with a\r
51      * {@link SceneGraphNodeKey} and on each call initialize the created\r
52      * node/nodes with the values stored in the element.\r
53      * \r
54      * @param e element to update into the scene graph\r
55      * @param parent scene graph parent node for this element\r
56      * \r
57      * TODO: the method is badly named since it can be invoked multiple\r
58      * times. initOrUpdate would be more suitable but that just sounds\r
59      * bad and the whole thing feels like bad design anyway.\r
60      */\r
61     void init(final IElement e, final G2DParentNode parent);\r
62 \r
63     /**\r
64      * Remove any scene graph node references from the specified element and\r
65      * from the scene graph.\r
66      * \r
67      * @param e the element whose scene graph references to clean up\r
68      */\r
69     void cleanup(final IElement e);\r
70 \r
71 }\r