]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/scenegraph/NonTransformableNode.java
2c0209712212cf9ca1a55787259de1e078431b8b
[simantics/3d.git] / org.simantics.proconf.g3d / src / org / simantics / proconf / g3d / scenegraph / NonTransformableNode.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.\r
3  * All rights reserved. This program and the accompanying materials\r
4  * are made available under the terms of the Eclipse Public License v1.0\r
5  * which accompanies this distribution, and is available at\r
6  * http://www.eclipse.org/legal/epl-v10.html\r
7  *\r
8  * Contributors:\r
9  *     VTT Technical Research Centre of Finland - initial API and implementation\r
10  *******************************************************************************/\r
11 package org.simantics.proconf.g3d.scenegraph;\r
12 \r
13 import java.util.ArrayList;\r
14 import java.util.Collection;\r
15 \r
16 import org.simantics.proconf.g3d.stubs.G3DNode;\r
17 \r
18 import com.jme.scene.Node;\r
19 \r
20 import org.simantics.db.Graph;\r
21 import org.simantics.db.Resource;\r
22 \r
23 public abstract class NonTransformableNode implements IGraphicsNode {\r
24 \r
25     private IGraphicsNode parent;\r
26     private ArrayList<IGraphicsNode> children = new ArrayList<IGraphicsNode>();\r
27     protected Node parentGroup = null;\r
28     protected Resource nodeResource;\r
29 \r
30     public NonTransformableNode(IGraphicsNode parent, Resource nodeResource) {\r
31         this.parent = parent;\r
32         this.nodeResource = nodeResource;\r
33         parentGroup = parent.getGroup();\r
34         parent.addChild(this);\r
35     }\r
36 \r
37     public void addChild(IGraphicsNode node) {\r
38         children.add(node);\r
39         \r
40     }\r
41     \r
42     public Collection<IGraphicsNode> getChildren() {\r
43         return children;\r
44     }\r
45     \r
46     public void removeChild(IGraphicsNode node) {\r
47         children.remove(node);\r
48         \r
49     }\r
50 \r
51     public void dispose() {\r
52         assert(children.size() == 0);\r
53         if (parent != null)\r
54             parent.removeChild(this);       \r
55     }\r
56 \r
57     public G3DNode getG3DNode(Graph graph) {\r
58         return new G3DNode(graph, nodeResource);\r
59     }\r
60     \r
61     public Node getGroup() {\r
62         return parentGroup;\r
63     }\r
64 \r
65 \r
66     public IGraphicsNode getParent() {\r
67         return parent;\r
68     }\r
69 \r
70 \r
71     public Resource getResource() {\r
72         return nodeResource;\r
73     }\r
74 \r
75     public void updateTransform(Graph graph) {\r
76         \r
77     }\r
78 \r
79 }