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