Source Code Cross Referenced for SensorRead.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: SensorRead.java,v $
003:         *
004:         * Copyright 1997-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.6 $
028:         * $Date: 2008/02/28 20:17:29 $
029:         * $State: Exp $
030:         */
031:
032:        package javax.media.j3d;
033:
034:        import javax.vecmath.*;
035:
036:        /**
037:         * A SensorRead encapsulates all the information associated with a single
038:         * reading of a sensor, including a timestamp, a transform, and,
039:         * optionally, button values.
040:         */
041:
042:        public class SensorRead {
043:
044:            /**
045:             * The maximum number of sensor-attached buttons tracked on a per
046:             * sensor basis.
047:             */
048:            public static final int MAXIMUM_SENSOR_BUTTON_COUNT = 12;
049:
050:            /**
051:             * This reading's time stamp
052:             */
053:            long time;
054:
055:            /**
056:             * The six-degree-of-freedom reading
057:             */
058:            Transform3D read;
059:
060:            /**
061:             * The state of the sensor's buttons
062:             */
063:            int[] buttonValues;
064:
065:            /**
066:             *  The number of buttons associated with this SensorRead
067:             */
068:            int numButtons;
069:
070:            /**
071:             * Constructs a SensorRead object with default parameters.
072:             * The default values are as follows:
073:             * <ul>
074:             * number of buttons : 0<br>
075:             * button values : 0 (for all array elements)<br>
076:             * transform : identity<br>
077:             * time : current time<br>
078:             * </ul>
079:             */
080:            public SensorRead() {
081:                this (0);
082:            }
083:
084:            /**
085:             * Constructs a SensorRead object with the specified number
086:             * of buttons.
087:             * @param numButtons the number of buttons for this SensorRead 
088:             */
089:            public SensorRead(int numButtons) {
090:                this .read = new Transform3D();
091:                this .numButtons = numButtons;
092:                this .buttonValues = new int[numButtons];
093:
094:                // Do this last
095:                this .time = J3dClock.currentTimeMillis();
096:            }
097:
098:            final void set(SensorRead sensorRead) {
099:                this .time = sensorRead.time;
100:                this .numButtons = sensorRead.numButtons;
101:                this .read.set(sensorRead.read);
102:                if (numButtons > 0)
103:                    System.arraycopy(sensorRead.buttonValues, 0,
104:                            this .buttonValues, 0, sensorRead.numButtons);
105:            }
106:
107:            /**
108:             * Set the SensorRead's transform to the value specified
109:             * @param t1 this sensor's reading
110:             */
111:            public void set(Transform3D t1) {
112:                read.set(t1);
113:            }
114:
115:            /**
116:             * Retrieve the SensorRead's transform and place it in result
117:             * @param result the recipient of the this sensor's reading
118:             */
119:            public void get(Transform3D result) {
120:                result.set(read);
121:            }
122:
123:            /**
124:             * Sets this SensorRead's time stamp to the specified argument
125:             * @param time the time to associate with this reading
126:             */
127:            public void setTime(long time) {
128:                this .time = time;
129:            }
130:
131:            /**
132:             * Retrieve this SensorRead's associated time stamp
133:             * @return the SensorRead's time as a long
134:             */
135:            public long getTime() {
136:                return this .time;
137:            }
138:
139:            /**
140:             *  Sets the values of all buttons for this SensorRead object.  
141:             *  @param values array contining the new buttons for this SensorRead
142:             *  @exception ArrayIndexOutOfBoundsException if this object 
143:             *  has 0 buttons or if values.length is less than the number of 
144:             *  buttons in this object.
145:             */
146:            public void setButtons(int[] values) {
147:                if (numButtons == 0)
148:
149:                    throw new ArrayIndexOutOfBoundsException(J3dI18N
150:                            .getString("SensorRead1"));
151:
152:                else if (values.length < numButtons)
153:
154:                    throw new ArrayIndexOutOfBoundsException(J3dI18N
155:                            .getString("SensorRead0"));
156:                System.arraycopy(values, 0, buttonValues, 0, numButtons);
157:            }
158:
159:            /**
160:             * Copies the array of button values for this SensorRead object into
161:             * the specified array.
162:             * This method has no effect
163:             * if this SensorRead object has 0 buttons. The array must be
164:             * large enough to hold all of the buttons.
165:             * @param values array that will receive the values of all buttons
166:             * for this SensorRead
167:             */
168:            public void getButtons(int[] values) {
169:                if (numButtons > 0)
170:                    System.arraycopy(buttonValues, 0, values, 0, numButtons);
171:            }
172:
173:            /**
174:             * Returns the number of buttons associated with this SensorRead
175:             * object.
176:             *
177:             * @return the number of buttons associated with this SensorRead
178:             * object
179:             *
180:             * @since Java 3D 1.2
181:             */
182:            public int getNumButtons() {
183:                return numButtons;
184:            }
185:
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.