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


001:        /*
002:         * $Id: FOToSWF.java,v 1.3 2002/02/24 02:10:19 skavish Exp $
003:         *
004:         * ==========================================================================
005:         * The JGenerator Software License, Version 1.0
006:         *
007:         * Copyright (c) 2000 Dmitry Skavish (skavish@usa.net). All rights reserved.
008:         *
009:         * Redistribution and use in source and binary forms, with or without
010:         * modification, are permitted provided that the following conditions are met:
011:         *
012:         * 1. Redistributions of source code must retain the above copyright
013:         *    notice, this list of conditions and the following disclaimer.
014:         *
015:         * 2. Redistributions in binary form must reproduce the above copyright
016:         *    notice, this list of conditions and the following disclaimer in
017:         *    the documentation and/or other materials provided with the
018:         *    distribution.
019:         *
020:         * 3. The end-user documentation included with the redistribution, if
021:         *    any, must include the following acknowlegement:
022:         *    "This product includes software developed by Dmitry Skavish
023:         *     (skavish@usa.net, http://www.flashgap.com/)."
024:         *    Alternately, this acknowlegement may appear in the software itself,
025:         *    if and wherever such third-party acknowlegements normally appear.
026:         *
027:         * 4. The name "The JGenerator" must not be used to endorse or promote
028:         *    products derived from this software without prior written permission.
029:         *    For written permission, please contact skavish@usa.net.
030:         *
031:         * 5. Products derived from this software may not be called "The JGenerator"
032:         *    nor may "The JGenerator" appear in their names without prior written
033:         *    permission of Dmitry Skavish.
034:         *
035:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
036:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
037:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
038:         * DISCLAIMED.  IN NO EVENT SHALL DMITRY SKAVISH OR THE OTHER
039:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
040:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
041:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
042:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
043:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
044:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
045:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
046:         * SUCH DAMAGE.
047:         *
048:         */
049:
050:        package org.openlaszlo.iv.flash.fop;
051:
052:        import org.openlaszlo.iv.flash.util.*;
053:
054:        import org.openlaszlo.iv.flash.api.*;
055:
056:        import org.apache.fop.apps.*;
057:        import org.apache.fop.messaging.MessageHandler;
058:        import org.apache.fop.viewer.*;
059:
060:        import org.xml.sax.*;
061:        import org.apache.xerces.parsers.*;
062:
063:        import java.io.*;
064:        import java.net.*;
065:        import java.util.*;
066:
067:        /**
068:         * A command line launcher using FOPHelper to convert FO input to SWF output.
069:         * Mostly ripped out of "SWFStarter" right now.
070:         *
071:         * @author James Taylor
072:         * @author Johan "Spocke" Sörlin
073:         */
074:
075:        class FOToSWF {
076:            private InputSource xslFOInput;
077:            private OutputStream swfOutputStream;
078:
079:            /**
080:             * Changes the XSLFO InputSource, this input source is
081:             * requierd in order to generate a SWF movie.
082:             *
083:             * @param input_source inputsource pointing to the XSLFO file/stream
084:             */
085:
086:            public void setXSLFOInputSource(InputSource input_source) {
087:                this .xslFOInput = input_source;
088:            }
089:
090:            /**
091:             * Changes the output stream, this stream is where the output SWF movie
092:             * will be stored.
093:             *
094:             * @param output_stream stream to write finished SWF movie to
095:             */
096:
097:            public void setOutputStream(OutputStream output_stream) {
098:                this .swfOutputStream = output_stream;
099:            }
100:
101:            /**
102:             * Generates the SWF movie from the passed inputparameters using FOP.
103:             */
104:
105:            public void generate() throws IVException, IOException,
106:                    FOPException {
107:                FOPHelper fh = new FOPHelper();
108:
109:                fh.setXSLFOInputSource(this .xslFOInput);
110:
111:                fh.render();
112:
113:                Script s = fh.getScript();
114:
115:                FlashFile f = FlashFile.newFlashFile();
116:
117:                s.setMain();
118:
119:                f.setMainScript(s);
120:
121:                f.setFrameSize(fh.getMaxPageBounds());
122:
123:                FlashOutput fob = f.generate();
124:
125:                BufferedOutputStream bos = new BufferedOutputStream(
126:                        this .swfOutputStream);
127:                bos.write(fob.getBuf(), 0, fob.getSize());
128:                bos.flush();
129:                bos.close();
130:            }
131:
132:            /**
133:             * Console main method, this method is executed when running in console mode.
134:             *
135:             * @param args application arguments
136:             */
137:
138:            public static void main(String args[]) {
139:                FOToSWF starter = new FOToSWF();
140:                String temp;
141:                boolean inputFilePassed = false;
142:
143:                try {
144:                    Util.init();
145:                    Log.setLogToConsole();
146:
147:                    // Check num arguments
148:                    if (args.length < 3) {
149:                        printHelp("Requierd arguments missing.");
150:                    }
151:
152:                    // Get XSL-FO parameter
153:                    temp = getParameterByName(args, "-fo");
154:                    if (temp != null) {
155:                        starter.setXSLFOInputSource(new InputSource(temp));
156:                        inputFilePassed = true;
157:                    }
158:
159:                    // If no input file, pass error
160:
161:                    if (!inputFilePassed) {
162:                        printHelp("Input file missing, use argument \"-fo <infile>\".");
163:                    }
164:
165:                    // Get SWF output path
166:
167:                    temp = getParameterByName(args, "-swf");
168:                    if (temp != null) {
169:                        starter.setOutputStream(new FileOutputStream(temp));
170:                    } else {
171:                        printHelp("Output file missing, use argument \"-swf <outfile>\".");
172:                    }
173:
174:                    // Do the generation
175:
176:                    starter.generate();
177:
178:                    System.exit(0);
179:                } catch (Exception e) {
180:                    e.printStackTrace();
181:                }
182:            }
183:
184:            // * * Private class methods
185:
186:            /**
187:             * Returns a parameter value by a parameter name.
188:             *
189:             * @param args application arguments
190:             * @param name name of parameter to get
191:             * @return parameter value or null if it wasn't found
192:             */
193:            private static String getParameterByName(String args[], String name) {
194:                for (int i = 0; i < args.length; i++) {
195:                    if (args[i].equals(name)) {
196:                        if ((i + 1) < args.length)
197:                            return args[i + 1];
198:                        else
199:                            return null;
200:                    }
201:                }
202:
203:                return null;
204:            }
205:
206:            /**
207:             * Checks the existance of a parameter by a parameter name.
208:             *
209:             * @param args application arguments
210:             * @param name name of parameter to get
211:             * @return true - it exists, false - it doesn't exist
212:             */
213:            private static boolean checkParameterByName(String args[],
214:                    String name) {
215:                for (int i = 0; i < args.length; i++) {
216:                    if (args[i].equals(name))
217:                        return true;
218:                }
219:
220:                return false;
221:            }
222:
223:            /**
224:             * Prints the usage text.
225:             *
226:             * @param error_msg Error message to write with usage text
227:             */
228:            private static void printHelp(String error_msg) {
229:                System.out.println("USAGE");
230:                System.out.println("");
231:                System.out
232:                        .println("SWFStarter [options] -fo infile -swf outfile");
233:                System.out.println("");
234:                System.out.println("  [INPUT]");
235:                System.out.println("   -fo  infile       xsl:fo input file");
236:                System.out.println("");
237:                System.out.println("  [OUTPUT]");
238:                System.out
239:                        .println("   -swf outfile      input will be rendered as swf format into the outfile");
240:                System.out.println("");
241:                System.out.println("  [Examples]");
242:                System.out.println("   SWFStarter -fo myfile.fo myfile.swf");
243:                System.out.println("");
244:                System.out.println("ERROR: " + error_msg);
245:                System.out.println("");
246:
247:                System.exit(-1);
248:            }
249:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.