Source Code Cross Referenced for copyswf.java in  » Ajax » Laszlo-4.0.10 » org » openlaszlo » test » 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 » Ajax » Laszlo 4.0.10 » org.openlaszlo.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* *****************************************************************************
002:         * copyswf.java
003:         * ****************************************************************************/
004:
005:        /* J_LZ_COPYRIGHT_BEGIN *******************************************************
006:         * Copyright 2001-2004 Laszlo Systems, Inc.  All Rights Reserved.              *
007:         * Use is subject to license terms.                                            *
008:         * J_LZ_COPYRIGHT_END *********************************************************/
009:
010:        package org.openlaszlo.test;
011:
012:        import java.io.*;
013:        import org.openlaszlo.iv.flash.api.*;
014:        import org.openlaszlo.iv.flash.api.text.*;
015:        import org.openlaszlo.iv.flash.util.*;
016:        import org.openlaszlo.utils.FileUtils;
017:
018:        public class copyswf {
019:            static public void main(String args[]) {
020:                try {
021:                    FlashFile f = FlashFile.parse(args[0]);
022:                    OutputStream out = new FileOutputStream(args[1]);
023:
024:                    java.util.Enumeration defs = f.definitions();
025:                    FontsCollector fc = new FontsCollector();
026:                    FontsCollector pfc = new FontsCollector();
027:
028:                    // Start out writing ito the preloader fc
029:                    FontsCollector curfc = pfc;
030:
031:                    // A lps-2.0 generated SWF has either 
032:                    //     1 block of fonts or
033:                    //     2 blocks of fonts
034:                    // If there are 2 blocks, then we know there's a preloader.
035:                    // If there's only 1 block, then they're either all inthe
036:                    // preloader or there's no preloader.
037:                    //
038:                    // If the first tag isn't a definefont tag, then we know
039:                    // we have a preloader, too and can short circuit that
040:                    // case.  Otherwise, we need to look for a break in
041:                    // the defs for one that isn't a font.  
042:
043:                    int index = 0;
044:                    int lastIndex = -1;
045:
046:                    boolean hasPreloader = false;
047:
048:                    while (defs.hasMoreElements()) {
049:                        FlashDef def = (FlashDef) defs.nextElement();
050:                        index++;
051:
052:                        // Here we know we definitely have a preloader
053:                        // but no preloader fonts
054:                        if (index == 1 && !(def instanceof  FontDef)) {
055:                            hasPreloader = true;
056:                        }
057:
058:                        if (def instanceof  FontDef) {
059:                            // If we don't have a preloader 
060:                            // (or we don't know if we have a preloader)
061:                            if (!hasPreloader) {
062:                                // First time in
063:                                if (lastIndex == -1) {
064:                                    lastIndex = index;
065:                                } else {
066:                                    // All other times
067:                                    // See if we're on to a second group of fonts
068:                                    if (index > lastIndex + 1) {
069:                                        hasPreloader = true;
070:                                        curfc = fc;
071:                                    }
072:                                }
073:                            }
074:                            FontDef fontDef = (FontDef) def;
075:                            Font font = fontDef.getFont();
076:                            String bold = ((font.BOLD & font.flags) > 0 ? "bold"
077:                                    : "");
078:                            String italic = ((font.ITALIC & font.flags) > 0 ? "italic"
079:                                    : "");
080:                            System.out.println("Copying font "
081:                                    + font.getFontName() + bold + italic);
082:                            FontDef fdef = curfc.addFont(font, null);
083:                            fdef.setWriteAllChars(true);
084:                            fdef.setWriteLayout(true);
085:                        }
086:                        index++;
087:                    }
088:                    InputStream input;
089:
090:                    // Ok we didn't have a preloader to the pfc is the regular
091:                    // fc and the pfc should be empty.
092:                    if (!hasPreloader) {
093:                        fc = pfc;
094:                        pfc = null;
095:                    }
096:                    input = f.generate(fc, pfc, hasPreloader).getInputStream();
097:                    FileUtils.send(input, out);
098:                    input.close();
099:                    out.close();
100:                } catch (Exception e) {
101:                    e.printStackTrace();
102:                }
103:            }
104:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.