Source Code Cross Referenced for Text.java in  » 6.0-JDK-Modules » java-3d » org » jdesktop » j3d » loaders » vrml97 » impl » 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 » org.jdesktop.j3d.loaders.vrml97.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: Text.java,v $
003:         *
004:         *      @(#)Text.java 1.16 98/11/05 20:35:24
005:         *
006:         * Copyright (c) 1996-1998 Sun Microsystems, Inc. All Rights Reserved.
007:         *
008:         * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
009:         * modify and redistribute this software in source and binary code form,
010:         * provided that i) this copyright notice and license appear on all copies of
011:         * the software; and ii) Licensee does not utilize the software in a manner
012:         * which is disparaging to Sun.
013:         *
014:         * This software is provided "AS IS," without a warranty of any kind. ALL
015:         * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
016:         * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
017:         * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
018:         * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
019:         * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
020:         * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
021:         * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
022:         * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
023:         * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
024:         * POSSIBILITY OF SUCH DAMAGES.
025:         *
026:         * This software is not designed or intended for use in on-line control of
027:         * aircraft, air traffic, aircraft navigation or aircraft communications; or in
028:         * the design, construction, operation or maintenance of any nuclear
029:         * facility. Licensee represents and warrants that it will not use or
030:         * redistribute the Software for such purposes.
031:         *
032:         * $Revision: 1.2 $
033:         * $Date: 2005/02/03 23:07:03 $
034:         * $State: Exp $
035:         */
036:        /*
037:         * @Author: Rick Goldberg
038:         * @Author: Doug Gehringer
039:         *
040:         */
041:        package org.jdesktop.j3d.loaders.vrml97.impl;
042:
043:        import com.sun.j3d.utils.geometry.Text2D;
044:        import java.awt.Font;
045:        import javax.media.j3d.Shape3D;
046:        import javax.media.j3d.Transform3D;
047:
048:        import javax.media.j3d.TransformGroup;
049:        import javax.vecmath.Color3f;
050:
051:        /**  Description of the Class */
052:        public class Text extends Geometry {
053:
054:            // exposedField
055:            MFString string;
056:            SFNode fontStyle;
057:            MFFloat length;
058:            SFFloat maxExtent;
059:
060:            static String vrmlSerif = "SERIF";
061:            static String vrmlSans = "SANS";
062:            static String vrmlFixed = "TYPEWRITER";
063:
064:            static String j3dSerif = "Serif";
065:            static String j3dSans = "Sans";
066:            static String j3dFixed = "Courier";
067:
068:            static String vrmlPlain = "PLAIN";
069:            static String vrmlBold = "BOLD";
070:            static String vrmlItalic = "ITALIC";
071:            static String vrmlBoldItalic = "BOLDITALIC";
072:
073:            final static int RASTER_SIZE = 24;
074:
075:            TransformGroup impl = null;
076:
077:            /**
078:             *Constructor for the Text object
079:             *
080:             *@param  loader Description of the Parameter
081:             */
082:            public Text(Loader loader) {
083:                super (loader);
084:                string = new MFString();
085:                fontStyle = new SFNode();
086:                length = new MFFloat();
087:                maxExtent = new SFFloat(0.0f);
088:                initFields();
089:            }
090:
091:            /**
092:             *Constructor for the Text object
093:             *
094:             *@param  loader Description of the Parameter
095:             *@param  string Description of the Parameter
096:             *@param  fontStyle Description of the Parameter
097:             *@param  length Description of the Parameter
098:             *@param  maxExtent Description of the Parameter
099:             */
100:            public Text(Loader loader, MFString string, SFNode fontStyle,
101:                    MFFloat length, SFFloat maxExtent) {
102:
103:                super (loader);
104:                this .string = string;
105:                this .fontStyle = fontStyle;
106:                this .length = length;
107:                this .maxExtent = maxExtent;
108:                initFields();
109:            }
110:
111:            /**
112:             *  Description of the Method
113:             *
114:             *@param  app Description of the Parameter
115:             *@return  Description of the Return Value
116:             */
117:            javax.media.j3d.Node createText2D(javax.media.j3d.Appearance app) {
118:                if (loader.debug) {
119:                    System.out.println("Text.createText2D() called");
120:                }
121:                if ((string.strings != null) && (string.strings.length > 0)) {
122:                    if (loader.debug) {
123:                        System.out.println("creating Text2D object");
124:                    }
125:
126:                    FontStyle fs = null;
127:                    if ((fontStyle.node != null)
128:                            && (fontStyle.node instanceof  FontStyle)) {
129:                        fs = (FontStyle) fontStyle.node;
130:                    } else {
131:                        fs = new FontStyle(loader);
132:                    }
133:
134:                    // Derive color from Appearance
135:                    Color3f fontColor = new Color3f(1.0f, 1.0f, 1.0f);
136:                    if (app != null) {
137:                        javax.media.j3d.Material mat = app.getMaterial();
138:                        if (mat != null) {
139:                            mat.getDiffuseColor(fontColor);
140:                        }
141:                    }
142:
143:                    String fontName = j3dSerif;
144:                    if (fs.family.strings.length > 0) {
145:                        boolean found = false;
146:                        for (int i = 0; ((i < fs.family.strings.length) && !found); i++) {
147:                            if (vrmlSerif.equals(fs.family.strings[i])) {
148:                                fontName = j3dSerif;
149:                                found = true;
150:                            } else if (vrmlSans.equals(fs.family.strings[i])) {
151:                                fontName = j3dSans;
152:                                found = true;
153:                            } else if (vrmlFixed.equals(fs.family.strings[i])) {
154:                                fontName = j3dFixed;
155:                                found = true;
156:                            }
157:                        }
158:                    }
159:                    int fontStyleId = Font.PLAIN;
160:                    if (fs.style.string != null) {
161:                        if (vrmlPlain.equals(fs.style.string)) {
162:                            fontStyleId = Font.PLAIN;
163:                        } else if (vrmlBold.equals(fs.style.string)) {
164:                            fontStyleId = Font.BOLD;
165:                        } else if (vrmlItalic.equals(fs.style.string)) {
166:                            fontStyleId = Font.ITALIC;
167:                        } else if (vrmlBoldItalic.equals(fs.style.string)) {
168:                            fontStyleId = Font.BOLD + Font.ITALIC;
169:                        }
170:                    }
171:
172:                    impl = new TransformGroup();
173:
174:                    // TODO: handle multiple strings by making multiple Text3D's
175:                    // in transform groups to offset them correctly
176:                    Text2D text = new Text2D(string.strings[0], fontColor,
177:                            fontName, RASTER_SIZE, fontStyleId);
178:
179:                    impl.addChild(text);
180:
181:                    Transform3D textXform = new Transform3D();
182:
183:                    float fontSize = RASTER_SIZE
184:                            * text.getRectangleScaleFactor();
185:                    float scale = fs.size.value / fontSize;
186:
187:                    textXform.setScale(scale);
188:                    impl.setTransform(textXform);
189:
190:                    implNode = impl;
191:                }
192:                return impl;
193:            }
194:
195:            /**
196:             *  Gets the implGeom attribute of the Text object
197:             *
198:             *@return  The implGeom value
199:             */
200:            public javax.media.j3d.Geometry getImplGeom() {
201:                return null;
202:            }
203:
204:            /**
205:             *  Description of the Method
206:             *
207:             *@return  Description of the Return Value
208:             */
209:            public boolean haveTexture() {
210:                return false;
211:            }
212:
213:            /**
214:             *  Gets the numTris attribute of the Text object
215:             *
216:             *@return  The numTris value
217:             */
218:            public int getNumTris() {
219:                return 0;
220:            }
221:
222:            /**
223:             *  Gets the boundingBox attribute of the Text object
224:             *
225:             *@return  The boundingBox value
226:             */
227:            public javax.media.j3d.BoundingBox getBoundingBox() {
228:                return null;
229:            }
230:
231:            /**
232:             *  Gets the type attribute of the Text object
233:             *
234:             *@return  The type value
235:             */
236:            public String getType() {
237:                return "Text";
238:            }
239:
240:            /**
241:             *  Description of the Method
242:             *
243:             *@return  Description of the Return Value
244:             */
245:            public Object clone() {
246:                return new Text(loader, (MFString) string.clone(),
247:                        (SFNode) fontStyle.clone(), (MFFloat) length.clone(),
248:                        (SFFloat) maxExtent.clone());
249:            }
250:
251:            /**
252:             *  Description of the Method
253:             *
254:             *@param  eventInName Description of the Parameter
255:             *@param  time Description of the Parameter
256:             */
257:            public void notifyMethod(String eventInName, double time) {
258:                System.out.println("Text: unimplemented event " + eventInName);
259:            }
260:
261:            /**  Description of the Method */
262:            void initFields() {
263:                string.init(this , FieldSpec, Field.EXPOSED_FIELD, "string");
264:                fontStyle.init(this , FieldSpec, Field.EXPOSED_FIELD,
265:                        "fontStyle");
266:                length.init(this , FieldSpec, Field.EXPOSED_FIELD, "length");
267:                maxExtent.init(this , FieldSpec, Field.EXPOSED_FIELD,
268:                        "maxExtent");
269:            }
270:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.