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
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.g2d.element.handler;
\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
21 * Scene graph node update handler of an element.
\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
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
34 * @see {@link G2DNode} for scene graph
\r
35 * @see ElementPainter
\r
37 public interface SceneGraph extends ElementHandler {
\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
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
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
54 * @param e element to update into the scene graph
\r
55 * @param parent scene graph parent node for this element
\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
61 void init(final IElement e, final G2DParentNode parent);
\r
64 * Remove any scene graph node references from the specified element and
\r
65 * from the scene graph.
\r
67 * @param e the element whose scene graph references to clean up
\r
69 void cleanup(final IElement e);
\r