1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 package net.jbeans.j3d.universe;
53
54 /* ------------------ Import classes (packages) ------------------- *//package-summary/html">class="comment"> ------------------ Import classes (packages) ------------------- *//package-summary.html">class="comment">/* ------------------ Import classes (packages) ------------------- *//package-summary.html">class="comment"> ------------------ Import classes (packages) ------------------- */
55 import java.util.*;
56 import net.jbeans.j3d.scenegraph.*;
57
58
59
60
61 /***
62 * Replace javax.media.j3d.Locale with this class in an app to view the
63 * SceneGraph.
64 * When you include this class in place of javax.media.j3d.Locale and run
65 * the application an extra window will be displayed with a graphical
66 * representation of the Scene Graph.
67 *
68 * The tool uses the NodeEditors to allow users to edit parameters in the
69 * scene graph nodes. <b>NOTE</b> the changes only take effect in the running
70 * app, the source code is not update.
71 *
72 * For Scene Graph Nodes that have a Bounds object, the user can ask for
73 * the bounds to be displayed while the application runs.
74 *
75 * A common bug in Java3D applications is the ommision of Bounds on Lights,
76 * Behaviors etc. When you use ViewerLocale all nodes in the SceneGraph are
77 * checked to ensure that the Bounds are not null.
78 *
79 * @version $Revision: 1.3 $
80 * @author Masahiro Takatsuka (masa@jbeans.net)
81 * @see javax.media.j3d.Locale
82 * @see BranchGroupDetachable
83 */
84
85
86
87
88 final class Locale extends javax.media.j3d.Locale implements BranchGroupDetachable {
89
90 private javax.media.j3d.BranchGroup editorBG = new javax.media.j3d.BranchGroup();
91
92
93
94 private Vector detachBG = new Vector();
95
96 /***
97 * Construct a new Locale object
98 */
99 Locale(javax.media.j3d.VirtualUniverse vu) {
100 super(vu);
101 setup();
102 }
103
104 /***
105 * Construct a new Locale object
106 */
107 Locale(javax.media.j3d.VirtualUniverse vu, javax.media.j3d.HiResCoord hrc) {
108 super(vu, hrc);
109 setup();
110 }
111
112 /***
113 * Construct a new Locale object
114 */
115 Locale(javax.media.j3d.VirtualUniverse vu, int[] x, int[] y, int[] z) {
116 super(vu, x, y, z);
117 setup();
118 }
119
120 /***
121 * Get a list of all the detachable subgraphs.
122 */
123 public final Vector getDetachableBranchGroups() {
124 return this.detachBG;
125 }
126
127 /***
128 // * Returns an index number of the next branch group.
129 // */
130
131
132
133
134 /***
135 // * Sets a new index number of the next branch group.
136 // */
137
138
139
140
141
142
143
144 private final void setup() {
145 this.editorBG = new BranchGroup();
146 this.editorBG.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND );
147 this.editorBG.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE );
148 super.addBranchGraph(this.editorBG);
149
150
151
152 }
153
154 /***
155 * Sets a View object for scene graph editing.
156 */
157 public final void setView(javax.media.j3d.View v) {
158
159
160
161 }
162
163 /***
164 * Adds a new BranchGroup object.
165 */
166 public final void addBranchGraph(javax.media.j3d.BranchGroup bg) {
167 javax.media.j3d.BranchGroup newBG = BranchGroupUtil.addBranchGroup(this, bg);
168
169
170
171 super.addBranchGraph(newBG);
172 }
173
174 /***
175 * Detaches the specified BranchGroup object.
176 */
177 public final void detachBranchGraph(javax.media.j3d.BranchGroup bg) {
178 BranchGroupUtil.detachBranchGroup(this, bg);
179 }
180 }