Source Code Cross Referenced for FloatRefValues.java in  » 6.0-JDK-Modules » j2me » com » sun » perseus » model » 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 » j2me » com.sun.perseus.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *
003:         *
004:         * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation.
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt).
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions.
025:         */
026:
027:        package com.sun.perseus.model;
028:
029:        /**
030:         * @version $Id: FloatRefValues.java,v 1.3 2006/04/21 06:37:00 st125089 Exp $
031:         */
032:        public class FloatRefValues implements  RefValues {
033:            /**
034:             * This RefValues FloatSegments.
035:             */
036:            FloatSegment[] segments;
037:
038:            /**
039:             * A working array to return a value from the compute method.
040:             */
041:            float[][] w;
042:
043:            /**
044:             * Used to store the length of this RefValues
045:             */
046:            float length;
047:
048:            /**
049:             * Used to store the length of each segment.
050:             */
051:            float[] segLength;
052:
053:            /**
054:             * @param i requested segment index.
055:             * @return Segment at index i
056:             */
057:            public Segment getSegment(int i) {
058:                return segments[i];
059:            }
060:
061:            /**
062:             * @return the number of segments in refValues
063:             */
064:            public int getSegments() {
065:                return segments.length;
066:            }
067:
068:            /**
069:             * FloatRefValues only have one component. This returns the number of
070:             * components in the start value of the first segment.
071:             *
072:             * @return the number of components. There is an array of float for each 
073:             *         component.
074:             */
075:            public int getComponents() {
076:                return segments[0].start.length;
077:            }
078:
079:            /**
080:             * Computes the value for the input interpolated values.
081:             * There should be as many entries in the return array as there
082:             * are components in the RefValues.
083:             *
084:             * @param si the current segment index
085:             * @param p the current penetration
086:             */
087:            public Object[] compute(int si, float p) {
088:                segments[si].compute(p, w);
089:                return w;
090:            }
091:
092:            /**
093:             * Adds a new time segment so accomodate for discreet behavior.
094:             * If there is only one segment for discreet animations, the
095:             * last value is never shown. To accomodate for that, this 
096:             * method should add a segment to the RefValues so that the 
097:             * last animation value is shown during the last value interval
098:             * of a discreet animation.
099:             */
100:            public void makeDiscrete() {
101:                FloatSegment[] tmpSegments = new FloatSegment[segments.length + 1];
102:                System.arraycopy(segments, 0, tmpSegments, 0, segments.length);
103:                FloatSegment lastSeg = segments[segments.length - 1];
104:                FloatSegment newSeg = new FloatSegment();
105:                newSeg.start = lastSeg.end;
106:                newSeg.end = lastSeg.end;
107:                tmpSegments[tmpSegments.length - 1] = newSeg;
108:                segments = tmpSegments;
109:            }
110:
111:            /**
112:             * Computes the length of the RefValues. This is meant for paced timing 
113:             * computation.
114:             *
115:             * @return the total length of this FloatRefValues. The distance is defined
116:             *         as the average distance between 
117:             *         r
118:             */
119:            public float getLength() {
120:                return length;
121:            }
122:
123:            /**
124:             * Computes the length of segment at index si
125:             *
126:             * @param si the segment index.
127:             */
128:            public float getLength(final int si) {
129:                return segLength[si];
130:            }
131:
132:            /**
133:             * Should be called after the RefValue's configuration is complete
134:             * to give the implementation a chance to initialize 
135:             * internal data and cache values.
136:             */
137:            public void initialize() {
138:                // Initialize the working buffer
139:                final int nc = segments[0].start.length;
140:
141:                w = new float[nc][];
142:
143:                final int ns = segments.length;
144:
145:                // Initialize the segments.
146:                for (int si = 0; si < ns; si++) {
147:                    segments[si].initialize();
148:                }
149:
150:                segLength = new float[ns];
151:
152:                // The length of a FloatSegment, is the average distance between each
153:                // component.
154:                for (int ci = 0; ci < nc; ci++) {
155:                    w[ci] = new float[segments[0].start[ci].length];
156:                }
157:
158:                length = 0;
159:                for (int si = 0; si < ns; si++) {
160:                    segLength[si] = segments[si].getLength();
161:                    length += segLength[si];
162:                }
163:            }
164:
165:            /**
166:             * Debug helper.
167:             */
168:            public String toString() {
169:                StringBuffer sb = new StringBuffer();
170:                sb.append("FloatRefValues[" + getSegments() + "]\n");
171:                for (int si = 0; si < getSegments(); si++) {
172:                    Segment seg = getSegment(si);
173:                    sb.append("seg[" + si + "] : " + seg.toString() + "\n");
174:                }
175:                return sb.toString();
176:            }
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.