View Javadoc

1   /* -------------------------------------------------------------------
2    * Java source file for the class Locale
3    * 
4    * Copyright (c), 2003, Masahiro Takatsuka.
5    * All Rights Researved.
6    * 
7    * Original Author: Masahiro Takatsuka (masa@jbeans.net)
8    * $Author: takatsukam $
9    * 
10   * $Date: 2004/03/03 11:53:06 $
11   * 
12   * $Id: Locale.java,v 1.3 2004/03/03 11:53:06 takatsukam Exp $
13   * 
14   * Reference:		Document no:
15   * ___				___
16   * 
17   * To Do:
18   * ___
19   * 
20  ------------------------------------------------------------------- */
21  /*
22   *  @(#)ViewerLocale.java 1.6 98/10/22 12:42:56
23   *
24   * Copyright (c) 1996-1998 Sun Microsystems, Inc. All Rights Reserved.
25   *
26   * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
27   * modify and redistribute this software in source and binary code form,
28   * provided that i) this copyright notice and license appear on all copies of
29   * the software; and ii) Licensee does not utilize the software in a manner
30   * which is disparaging to Sun.
31   *
32   * This software is provided "AS IS," without a warranty of any kind. ALL
33   * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
34   * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
35   * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
36   * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
37   * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
38   * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
39   * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
40   * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
41   * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
42   * POSSIBILITY OF SUCH DAMAGES.
43   *
44   * This software is not designed or intended for use in on-line control of
45   * aircraft, air traffic, aircraft navigation or aircraft communications; or in
46   * the design, construction, operation or maintenance of any nuclear
47   * facility. Licensee represents and warrants that it will not use or
48   * redistribute the Software for such purposes.
49   */
50  
51  /* --------------------------- Package ---------------------------- */
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                      Implementation of class Locale                    
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   * this class is ok to be package.
87   */
88  final class Locale extends javax.media.j3d.Locale implements BranchGroupDetachable {
89  	//private SceneGraphEditor sgEditor;
90  	private javax.media.j3d.BranchGroup editorBG = new javax.media.j3d.BranchGroup();
91  
92  //      private List detachBG = new ArrayList();
93  //      private int nextBranchGroup = 0;
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 //  	public final int getNextBranchGroup() {
131 //  		return this.nextBranchGroup;
132 //  	}
133 
134 //  	/***
135 //  	 * Sets a new index number of the next branch group.
136 //  	 */
137 //  	public final void setNextBranchGroup(int next) {
138 //  		this.nextBranchGroup = next;
139 //  	}
140 
141 	/*
142 	 * Prepare for the use.
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 // 		if (this.sgEditor != null) {
150 // 			this.sgEditor.setLocale(this);
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 // 		if (this.sgEditor != null) {
159 // 			this.sgEditor.setView(v);
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 // 		if (this.sgEditor != null) {
169 // 			this.sgEditor.newBranchGraph(bg, newBG);
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 }