1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.g2d.element.handler;
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;
21 * Scene graph node update handler of an element.
24 * This handler is responsible for making sure that the scene graph is in sync
25 * with the element's current state.
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.
34 * @see {@link G2DNode} for scene graph
37 public interface SceneGraph extends ElementHandler {
40 * Updates the renderable representation of the specified element, i.e. its
41 * scene graph parts to match the current state of the element.
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.
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.
54 * @param e element to update into the scene graph
55 * @param parent scene graph parent node for this element
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.
61 void init(final IElement e, final G2DParentNode parent);
64 * Remove any scene graph node references from the specified element and
65 * from the scene graph.
67 * @param e the element whose scene graph references to clean up
69 void cleanup(final IElement e);