Source Code Cross Referenced for FloatTraitAnim.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:        import org.w3c.dom.DOMException;
030:
031:        /**
032:         * @version $Id: FloatTraitAnim.java,v 1.3 2006/06/29 10:47:31 ln156897 Exp $
033:         */
034:        class FloatTraitAnim extends TraitAnim {
035:            /**
036:             * Constructs a new FloatTraitAnim for a given ElementNode trait.
037:             *
038:             * @param targetElement the ElementNode whose trait is animated.
039:             * @param targetTrait the name of the animated trait.
040:             * @param traitType the trait type.
041:             */
042:            public FloatTraitAnim(final ElementNode targetElement,
043:                    final String traitName, final String traitType) {
044:                super (targetElement, ElementNode.NULL_NS, traitName, traitType);
045:            }
046:
047:            /**
048:             * Returns the BaseValue as an array of objects.
049:             *
050:             * @return the base value as an object array. The dimensions of the
051:             *         returned array depend on the trait.
052:             * @see com.sun.perseus.model.BaseValue
053:             */
054:            public Object[] getBaseValue() {
055:                return targetElement
056:                        .validateFloatArrayTrait(traitName,
057:                                getSpecifiedTraitNS(), targetElement
058:                                        .getNamespaceURI(), targetElement
059:                                        .getLocalName(), traitNamespace,
060:                                traitName);
061:            }
062:
063:            /**
064:             * Applies the animation effect. The implementation makes sure it 
065:             * implements the sandwich model by 'pulling' values from the 
066:             * root animation (i.e., the animation with the highest priority).
067:             */
068:            void apply() {
069:                float[][] v = (float[][]) rootAnim.compute();
070:                targetElement.setFloatArrayTrait(traitName, v);
071:            }
072:
073:            /**
074:             * @return the trait's value, as a String.
075:             */
076:            protected String getTraitImpl() {
077:                // This returns the computed trait value, using the specified 
078:                // trait value.
079:                float[][] v = targetElement
080:                        .validateFloatArrayTrait(traitName,
081:                                specifiedTraitValue, targetElement
082:                                        .getNamespaceURI(), targetElement
083:                                        .getLocalName(), traitNamespace,
084:                                traitName);
085:
086:                // Now, convert that value to a string.
087:                return targetElement.toStringTrait(traitName, v);
088:            }
089:
090:            /**
091:             * Sets the trait's base value, as a String.
092:             * 
093:             * @param value the new trait base value.
094:             *
095:             * @throws DOMException with error code INVALID_ACCESS_ERR if the input
096:             * value is an invalid value for the given trait or null.
097:             */
098:            void setTraitImpl(String value) throws DOMException {
099:                targetElement.validateFloatArrayTrait(traitName, value,
100:                        targetElement.getNamespaceURI(), targetElement
101:                                .getLocalName(), traitNamespace, traitName);
102:
103:                specifiedTraitValue = value;
104:            }
105:
106:            /**
107:             * Converts the input values set to a RefValues object.
108:             *
109:             * @param anim the <code>Animation</code> for which the values should be
110:             *        converted.
111:             * @param values a semi-colon seperated list of values which need to be
112:             * validated.
113:             * @param reqTraitNamespace the namespace of the trait which has the values
114:             *        value on the requesting element.
115:             * @param reqTraitName the name of the trait which has the values value on 
116:             *        the requesting element.
117:             * @throws DOMException with error code INVALID_ACCESS_ERR if the input
118:             * value is incompatible with the given trait.
119:             * @throws NullPointerException if values is null.
120:             */
121:            RefValues toRefValues(final Animation anim, String[] values,
122:                    final String reqTraitNamespace, final String reqTraitName)
123:                    throws DOMException {
124:                FloatRefValues refValues = new FloatRefValues();
125:
126:                if (values.length < 1) {
127:                    throw new IllegalArgumentException();
128:                }
129:
130:                if (values.length == 1) {
131:                    String[] tmpValues = new String[2];
132:                    tmpValues[0] = values[0];
133:                    tmpValues[1] = values[0];
134:                    values = tmpValues;
135:                }
136:
137:                int nSegments = values.length - 1;
138:                refValues.segments = new FloatSegment[nSegments];
139:
140:                // Build the first segment.
141:                refValues.segments[0] = new FloatSegment();
142:                refValues.segments[0].start = targetElement
143:                        .validateFloatArrayTrait(anim.traitName, values[0],
144:                                anim.getNamespaceURI(), anim.getLocalName(),
145:                                reqTraitNamespace, reqTraitName);
146:                refValues.segments[0].end = targetElement
147:                        .validateFloatArrayTrait(anim.traitName, values[1],
148:                                anim.getNamespaceURI(), anim.getLocalName(),
149:                                reqTraitNamespace, reqTraitName);
150:
151:                FloatSegment prevSegment = refValues.segments[0];
152:
153:                for (int i = 1; i < nSegments; i++) {
154:                    refValues.segments[i] = new FloatSegment();
155:                    refValues.segments[i].start = prevSegment.end;
156:                    refValues.segments[i].end = targetElement
157:                            .validateFloatArrayTrait(anim.traitName,
158:                                    values[i + 1], anim.getNamespaceURI(), anim
159:                                            .getLocalName(), reqTraitNamespace,
160:                                    reqTraitName);
161:                    prevSegment = refValues.segments[i];
162:                }
163:
164:                return refValues;
165:            }
166:
167:            /**
168:             * Used to sum two animated trait values.
169:             *
170:             * @param valueA the base value. May be null.
171:             * @param valueB the value to add to the base value. If the baseValue 
172:             */
173:            public Object[] sum(Object[] valueA, Object[] valueB) {
174:                if (valueA == null) {
175:                    return valueB;
176:                }
177:
178:                float[][] fva = (float[][]) valueA;
179:                float[][] fvb = (float[][]) valueB;
180:
181:                for (int ci = 0; ci < fva.length; ci++) {
182:                    for (int di = 0; di < fva[ci].length; di++) {
183:                        fvb[ci][di] += fva[ci][di];
184:                    }
185:                }
186:
187:                return valueB;
188:            }
189:
190:            /**
191:             * Used to multiply an animated trait value by a number of iterations.
192:             *
193:             * @param value the animated trait value to multiply.
194:             * @param iter the number of iteration to account for.
195:             * @return the multiply result.
196:             */
197:            public Object[] multiply(Object[] value, int iter) {
198:                float[][] fv = (float[][]) value;
199:                float[][] r = new float[fv.length][];
200:
201:                for (int ci = 0; ci < fv.length; ci++) {
202:                    r[ci] = new float[fv[ci].length];
203:                    for (int di = 0; di < fv[ci].length; di++) {
204:                        r[ci][di] = fv[ci][di] * iter;
205:                    }
206:                }
207:
208:                return r;
209:            }
210:
211:            /**
212:             * @return true, because FloatTraitAnim support interpolation.
213:             */
214:            boolean supportsInterpolation() {
215:                return true;
216:            }
217:
218:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.