Source Code Cross Referenced for TransformInterpolator.java in  » 6.0-JDK-Modules » java-3d » javax » media » j3d » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » java 3d » javax.media.j3d 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: TransformInterpolator.java,v $
003:         *
004:         * Copyright 2001-2008 Sun Microsystems, Inc.  All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
006:         *
007:         * This code is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU General Public License version 2 only, as
009:         * published by the Free Software Foundation.  Sun designates this
010:         * particular file as subject to the "Classpath" exception as provided
011:         * by Sun in the LICENSE file that accompanied this code.
012:         *
013:         * This code is distributed in the hope that it will be useful, but WITHOUT
014:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
015:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
016:         * version 2 for more details (a copy is included in the LICENSE file that
017:         * accompanied this code).
018:         *
019:         * You should have received a copy of the GNU General Public License version
020:         * 2 along with this work; if not, write to the Free Software Foundation,
021:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
022:         *
023:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
024:         * CA 95054 USA or visit www.sun.com if you need additional information or
025:         * have any questions.
026:         *
027:         * $Revision: 1.5 $
028:         * $Date: 2008/02/28 20:17:32 $
029:         * $State: Exp $
030:         */
031:
032:        package javax.media.j3d;
033:
034:        import java.util.Enumeration;
035:
036:        /**
037:         * TransformInterpolator is an abstract class that extends
038:         * Interpolator to provide common methods used by various transform
039:         * related interpolator subclasses.  These include methods to set/get
040:         * the target of TransformGroup, and set/get transform of axis.
041:         *
042:         * @since Java 3D 1.3
043:         */
044:
045:        public abstract class TransformInterpolator extends Interpolator {
046:            /**
047:             * The TransformGroup node affected by this transformInterpolator
048:             */
049:            protected TransformGroup target = null;
050:
051:            /**
052:             * The transform that defines the local coordinate
053:             */
054:            protected Transform3D axis = new Transform3D();
055:
056:            /**
057:             * The inverse transform that defines the local coordinate
058:             */
059:            protected Transform3D axisInverse = new Transform3D();
060:
061:            /**
062:             * The transform which is passed into computeTransform() when computeTransform()
063:             * is called implicitly from processStimulus()
064:             */
065:            private Transform3D currentTransform = new Transform3D();
066:
067:            // We can't use a boolean flag since it is possible 
068:            // that after alpha change, this procedure only run
069:            // once at alpha.finish(). So the best way is to
070:            // detect alpha value change.
071:            private float prevAlphaValue = Float.NaN;
072:            private WakeupCriterion passiveWakeupCriterion = (WakeupCriterion) new WakeupOnElapsedFrames(
073:                    0, true);
074:
075:            /**
076:             * Constructs a TransformInterpolator node with a null alpha value and
077:             * a null target of TransformGroup
078:             */
079:            public TransformInterpolator() {
080:            }
081:
082:            /**
083:             * Constructs a trivial transform interpolator with a specified alpha,
084:             * a specified target and an default axis set to Identity.
085:             * @param alpha The alpha object for this transform Interpolator
086:             * @param target The target TransformGroup for this TransformInterpolator 
087:             */
088:            public TransformInterpolator(Alpha alpha, TransformGroup target) {
089:                super (alpha);
090:                this .target = target;
091:                axis.setIdentity();
092:                axisInverse.setIdentity();
093:            }
094:
095:            /**
096:             * Constructs a new transform interpolator that set an specified alpha,
097:             * a specified targe and a specified axisOfTransform.
098:             * @param alpha the alpha object for this interpolator
099:             * @param target the transformGroup node affected by this transformInterpolator
100:             * @param axisOfTransform the transform that defines the local coordinate
101:             * system in which this interpolator operates.  
102:             */
103:            public TransformInterpolator(Alpha alpha, TransformGroup target,
104:                    Transform3D axisOfTransform) {
105:
106:                super (alpha);
107:                this .target = target;
108:                axis.set(axisOfTransform);
109:                axisInverse.invert(axis);
110:            }
111:
112:            /**
113:             * This method sets the target TransformGroup node for this 
114:             * interpolator.
115:             * @param target The target TransformGroup
116:             */
117:            public void setTarget(TransformGroup target) {
118:                this .target = target;
119:            }
120:
121:            /**
122:             * This method retrieves this interpolator's TransformGroup
123:             * node reference.
124:             * @return the Interpolator's target TransformGroup
125:             */
126:            public TransformGroup getTarget() {
127:                return target;
128:            }
129:
130:            /**
131:             * This method sets the axis of transform for this interpolator.
132:             * @param axisOfTransform the transform that defines the local coordinate
133:             * system in which this interpolator operates
134:             */
135:            public void setTransformAxis(Transform3D axisOfTransform) {
136:                this .axis.set(axisOfTransform);
137:                this .axisInverse.invert(this .axis);
138:            }
139:
140:            /**
141:             * This method retrieves this interpolator's axis of transform.
142:             * @return the interpolator's axis of transform
143:             */
144:            public Transform3D getTransformAxis() {
145:                return new Transform3D(this .axis);
146:            }
147:
148:            /**
149:             * Computes the new transform for this interpolator for a given
150:             * alpha value.
151:             *
152:             * @param alphaValue alpha value between 0.0 and 1.0
153:             * @param transform object that receives the computed transform for
154:             * the specified alpha value
155:             */
156:            public abstract void computeTransform(float alphaValue,
157:                    Transform3D transform);
158:
159:            /**
160:             * This method is invoked by the behavior scheduler every frame.
161:             * First it gets the alpha value that corresponds to the current time.
162:             * Then it calls computeTransform() method to computes the transform based on this
163:             * alpha vaule,  and updates the specified TransformGroup node with this new transform.
164:             * @param criteria an enumeration of the criteria that caused the
165:             * stimulus
166:             */
167:            public void processStimulus(Enumeration criteria) {
168:                // Handle stimulus
169:                WakeupCriterion criterion = passiveWakeupCriterion;
170:
171:                if (alpha != null) {
172:                    float value = alpha.value();
173:                    if (value != prevAlphaValue) {
174:                        computeTransform(value, currentTransform);
175:                        target.setTransform(currentTransform);
176:                        prevAlphaValue = value;
177:                    }
178:                    if (!alpha.finished() && !alpha.isPaused()) {
179:                        criterion = defaultWakeupCriterion;
180:                    }
181:                }
182:                wakeupOn(criterion);
183:            }
184:
185:            /**
186:             * Copies all TransformInterpolator information from
187:             * <code>originalNode</code> into
188:             * the current node.  This method is called from the
189:             * <code>cloneNode</code> method which is, in turn, called by the
190:             * <code>cloneTree</code> method.<P> 
191:             *
192:             * @param originalNode the original node to duplicate.
193:             * @param forceDuplicate when set to <code>true</code>, causes the
194:             *  <code>duplicateOnCloneTree</code> flag to be ignored.  When
195:             *  <code>false</code>, the value of each node's
196:             *  <code>duplicateOnCloneTree</code> variable determines whether
197:             *  NodeComponent data is duplicated or copied.
198:             *
199:             * @exception RestrictedAccessException if this object is part of a live
200:             *  or compiled scenegraph.
201:             *
202:             * @see Node#duplicateNode
203:             * @see Node#cloneTree
204:             * @see NodeComponent#setDuplicateOnCloneTree
205:             */
206:            void duplicateAttributes(Node originalNode, boolean forceDuplicate) {
207:                super .duplicateAttributes(originalNode, forceDuplicate);
208:
209:                TransformInterpolator ti = (TransformInterpolator) originalNode;
210:
211:                setTransformAxis(ti.getTransformAxis());
212:
213:                // this reference will be updated in updateNodeReferences()
214:                setTarget(ti.getTarget());
215:            }
216:
217:            /**
218:             * Callback used to allow a node to check if any scene graph objects
219:             * referenced
220:             * by that node have been duplicated via a call to <code>cloneTree</code>.
221:             * This method is called by <code>cloneTree</code> after all nodes in
222:             * the sub-graph have been duplicated. The cloned Leaf node's method
223:             * will be called and the Leaf node can then look up any object references
224:             * by using the <code>getNewObjectReference</code> method found in the
225:             * <code>NodeReferenceTable</code> object.  If a match is found, a
226:             * reference to the corresponding object in the newly cloned sub-graph
227:             * is returned.  If no corresponding reference is found, either a
228:             * DanglingReferenceException is thrown or a reference to the original
229:             * object is returned depending on the value of the
230:             * <code>allowDanglingReferences</code> parameter passed in the
231:             * <code>cloneTree</code> call.
232:             * <p>
233:             * NOTE: Applications should <i>not</i> call this method directly.
234:             * It should only be called by the cloneTree method.
235:             *
236:             * @param referenceTable a NodeReferenceTableObject that contains the
237:             *  <code>getNewObjectReference</code> method needed to search for
238:             *  new object instances.
239:             * @see NodeReferenceTable
240:             * @see Node#cloneTree
241:             * @see DanglingReferenceException
242:             */
243:            public void updateNodeReferences(NodeReferenceTable referenceTable) {
244:                super .updateNodeReferences(referenceTable);
245:
246:                // check TransformGroup
247:                Node n = getTarget();
248:
249:                if (n != null) {
250:                    setTarget((TransformGroup) referenceTable
251:                            .getNewObjectReference(n));
252:                }
253:            }
254:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.