Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
import WebCat swf parser custom source package This package is not available as jar (used jar is a custom compile as we use just a portion of the package) WebCat package is not maintained. To be able to fix bugs, source extract of swf parser imported here.
reger4213ff84d488
diff --git a/libbuild/WebCat-swf/pom.xml b/libbuild/WebCat-swf/pom.xmlnew file mode 100644index 000000000..c0fdca940--- /dev/null+++ b/libbuild/WebCat-swf/pom.xml@@ -0,0 +1,38 @@+<?xml version="1.0" encoding="UTF-8"?>+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">+ <modelVersion>4.0.0</modelVersion>+ <groupId>pt.tumba</groupId>+ <artifactId>webcat</artifactId>+ <version>0.1</version>+ <packaging>jar</packaging>+ <name>WebCat swf parser</name>+ <description>extract of swf parser from WebCat source package</description>+ <parent>+ <groupId>net.yacy</groupId>+ <artifactId>extlib</artifactId>+ <version>1.0</version>+ </parent>+ <url>http://webcat.sourceforge.net/</url>+ <licenses>+ <license>+ <name>BSD</name>+ <url>http://opensource.org/licenses/bsd-license.php</url>+ </license>+ </licenses>+ <scm>+ <url>http://webcat.cvs.sourceforge.net/viewvc/webcat/</url>+ </scm>+ <developers>+ <developer>+ <name>Bruno Martins</name>+ </developer>+ </developers>+ <properties>+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>+ <maven.compiler.source>1.7</maven.compiler.source>+ <maven.compiler.target>1.7</maven.compiler.target>+ </properties>+ <build>+ <sourceDirectory>src</sourceDirectory>+ </build>+</project>\ No newline at end of filediff --git a/libbuild/WebCat-swf/readme.txt b/libbuild/WebCat-swf/readme.txtnew file mode 100644index 000000000..232f5ddab--- /dev/null+++ b/libbuild/WebCat-swf/readme.txt@@ -0,0 +1,53 @@+What is WebCAT?++WebCAT is an extensible tool to extract meta-data and generate RDF descriptions from existing Web documents.+Implemented in Java, it provides a set of APIs (Application Programming Interfaces) that allow one to analyse+text documents from the Web without having to write complicated parsers.++Among other things, WebCAT provides:++ - Language and encoding detection.+ - Hyperlink extraction.+ - Text tokenization (words, n-grams, sentences).+ - Document fingerprinting.+ - Format conversion.+ - Metadata extraction and normalization.+ - Named Entity Extraction.+ - Document classification.++The considered meta-data elements are particularly suited to the domain of automated search, making this a+good tool to use in other information retrieval and extraction projects. The software is currently in use+at the tumba! Portuguese Web search engine, as part of the crawling module and as the basis of several text+mining tools.++People+WebCAT was developed at the XLDB group of the Department of Informatics of the Faculty of Sciences of the University of Lisbon in Portugal.+WebCAT was written by Bruno Martins.+++Research+WebCAT is a Java package for extracting and mining meta-data from Web documents. It is an important building+block in several other text mining tools, handling most of the low level processing operations.++The software is divided in three "core" blocks: the parser, the miners and the output generator. The parser+performs the "low-level" processing operations, receiving Web documents in HTML or converted from other+different file formats. It analyzes the textual contents, divides the text into atomic units, and extracts+hyper-links and meta-data. Afterwards, the miners make use of the parsed information, generating additional+meta-data properties for the documents. Examples of miners include the language identification and+classification modules. Finally, the output module produces RDF documents from the extracted/mined metadata.++Since the content and encoding of information on the Web is still mainly natural language (as oposed to more+machine understandable formats such as RDF), automated large scale information extraction can bootstrap and+accelerate the creation of a semantic web.++Availability+WebCAT is released under the BSD License, which basically states that you can do anything you like with it+as long as you mention the authors and make it clear that the library is covered by the BSD License. It also+exempts us from any liability, should this library eat your hard disc or kill your cat.++Source code, samples and detailed documentation are provided in the download. The Java API documentation is+also available online.++The package is relatively simple install and run. We encourage you to try it out and let us know of any+problems you find.+We would also be very happy to hear from people who are using this software package.diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/DocFilter.java b/libbuild/WebCat-swf/src/pt/tumba/parser/DocFilter.javanew file mode 100644index 000000000..f61beedd6--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/DocFilter.java@@ -0,0 +1,20 @@+package pt.tumba.parser;++/**+ *+ * Generic interface for all document filters, converting a source format into HTML+ *+ * @author Bruno Martins+ *+ */++public interface DocFilter {++/**+ * Return the original size of the document, before the filtering process.+ *+ * @return The original size of the document, before the filtering process.+ */+ public int originalSize();++}\ No newline at end of filediff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ActionParser.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ActionParser.javanew file mode 100644index 000000000..ab49afa96--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ActionParser.java@@ -0,0 +1,686 @@+package pt.tumba.parser.swf;++import java.io.IOException;+import java.util.Enumeration;+import java.util.Hashtable;+import java.util.Iterator;+import java.util.List;+import java.util.Stack;+import java.util.Vector;++/**+ * Parse action bytes and drive a SWFActions interface+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class ActionParser implements SWFActionCodes {+ /**+ * Description of the Field+ */+ protected SWFActions actions;+ /**+ * Description of the Field+ */+ protected int blockDepth = 0;+++ /**+ * Constructor for the ActionParser object+ *+ *@param actions Description of the Parameter+ */+ public ActionParser(SWFActions actions) {+ this.actions = actions;+ }+++ /**+ * Description of the Method+ *+ *@param bytes Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public synchronized void parse(byte[] bytes) throws IOException {+ List records = createRecords(bytes);+ processRecords(records);+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public synchronized void parse(InStream in) throws IOException {+ List records = createRecords(in);+ processRecords(records);+ }+++ /**+ * Description of the Method+ *+ *@param records Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void processRecords(List records) throws IOException {+ //--process action records+ for (Iterator enumerator = records.iterator(); enumerator.hasNext(); ) {+ ActionRecord rec = (ActionRecord) enumerator.next();++ //actions.comment( "depth=" + rec.blockDepth );++ //detect end of block+ if (rec.blockDepth < blockDepth) {+ blockDepth--;+ actions.endBlock();+ }++ if (rec.label != null) {+ actions.jumpLabel(rec.label);+ }++ int code = rec.code;+ byte[] data = rec.data;++ InStream in = (data != null && data.length > 0) ? new InStream(data) : null;++ switch (code) {+ case 0:+ actions.end();+ break;+ //--Flash 3+ case GOTO_FRAME:+ actions.gotoFrame(in.readUI16());+ break;+ case GET_URL:+ actions.getURL(in.readString(), in.readString());+ break;+ case NEXT_FRAME:+ actions.nextFrame();+ break;+ case PREVIOUS_FRAME:+ actions.prevFrame();+ break;+ case PLAY:+ actions.play();+ break;+ case STOP:+ actions.stop();+ break;+ case TOGGLE_QUALITY:+ actions.toggleQuality();+ break;+ case STOP_SOUNDS:+ actions.stopSounds();+ break;+ case WAIT_FOR_FRAME:+ actions.waitForFrame(in.readUI16(), rec.jumpLabel);+ break;+ case SET_TARGET:+ actions.setTarget(in.readString());+ break;+ case GOTO_LABEL:+ actions.gotoFrame(in.readString());+ break;+ //--Flash 4+ case IF:+ actions.ifJump(rec.jumpLabel);+ break;+ case JUMP:+ actions.jump(rec.jumpLabel);+ break;+ case WAIT_FOR_FRAME_2:+ actions.waitForFrame(rec.jumpLabel);+ break;+ case POP:+ actions.pop();+ break;+ case PUSH:+ parsePush(data.length, in);+ break;+ case ADD:+ actions.add();+ break;+ case SUBTRACT:+ actions.substract();+ break;+ case MULTIPLY:+ actions.multiply();+ break;+ case DIVIDE:+ actions.divide();+ break;+ case EQUALS:+ actions.equals();+ break;+ case LESS:+ actions.lessThan();+ break;+ case AND:+ actions.and();+ break;+ case OR:+ actions.or();+ break;+ case NOT:+ actions.not();+ break;+ case STRING_EQUALS:+ actions.stringEquals();+ break;+ case STRING_LENGTH:+ actions.stringLength();+ break;+ case STRING_ADD:+ actions.concat();+ break;+ case STRING_EXTRACT:+ actions.substring();+ break;+ case STRING_LESS:+ actions.stringLessThan();+ break;+ case MB_STRING_EXTRACT:+ actions.substringMB();+ break;+ case MB_STRING_LENGTH:+ actions.stringLengthMB();+ break;+ case TO_INTEGER:+ actions.toInteger();+ break;+ case CHAR_TO_ASCII:+ actions.charToAscii();+ break;+ case ASCII_TO_CHAR:+ actions.asciiToChar();+ break;+ case MB_CHAR_TO_ASCII:+ actions.charMBToAscii();+ break;+ case MB_ASCII_TO_CHAR:+ actions.asciiToCharMB();+ break;+ case CALL:+ actions.call();+ break;+ case GET_VARIABLE:+ actions.getVariable();+ break;+ case SET_VARIABLE:+ actions.setVariable();+ break;+ case GET_URL_2:+ parseGetURL2(in.readUI8());+ break;+ case GOTO_FRAME_2:+ actions.gotoFrame(in.readUI8() != 0);+ break;+ case SET_TARGET_2:+ actions.setTarget();+ break;+ case GET_PROPERTY:+ actions.getProperty();+ break;+ case SET_PROPERTY:+ actions.setProperty();+ break;+ case CLONE_SPRITE:+ actions.cloneSprite();+ break;+ case REMOVE_SPRITE:+ actions.removeSprite();+ break;+ case START_DRAG:+ actions.startDrag();+ break;+ case END_DRAG:+ actions.endDrag();+ break;+ case TRACE:+ actions.trace();+ break;+ case GET_TIME:+ actions.getTime();+ break;+ case RANDOM_NUMBER:+ actions.randomNumber();+ break;+ //--Flash 5+ case INIT_ARRAY:+ actions.initArray();+ break;+ case LOOKUP_TABLE:+ parseLookupTable(in);+ break;+ case CALL_FUNCTION:+ actions.callFunction();+ break;+ case CALL_METHOD:+ actions.callMethod();+ break;+ case DEFINE_FUNCTION:+ parseDefineFunction(in);+ break;+ case DEFINE_LOCAL_VAL:+ actions.defineLocalValue();+ break;+ case DEFINE_LOCAL:+ actions.defineLocal();+ break;+ case DEL_VAR:+ actions.deleteProperty();+ break;+ case DEL_THREAD_VARS:+ actions.deleteThreadVars();+ break;+ case ENUMERATE:+ actions.enumerate();+ break;+ case TYPED_EQUALS:+ actions.typedEquals();+ break;+ case GET_MEMBER:+ actions.getMember();+ break;+ case INIT_OBJECT:+ actions.initObject();+ break;+ case CALL_NEW_METHOD:+ actions.newMethod();+ break;+ case NEW_OBJECT:+ actions.newObject();+ break;+ case SET_MEMBER:+ actions.setMember();+ break;+ case GET_TARGET_PATH:+ actions.getTargetPath();+ break;+ case WITH:+ parseWith(in);+ break;+ case DUPLICATE:+ actions.duplicate();+ break;+ case RETURN:+ actions.returnValue();+ break;+ case SWAP:+ actions.swap();+ break;+ case REGISTER:+ actions.storeInRegister(in.readUI8());+ break;+ case MODULO:+ actions.modulo();+ break;+ case TYPEOF:+ actions.typeOf();+ break;+ case TYPED_ADD:+ actions.typedAdd();+ break;+ case TYPED_LESS_THAN:+ actions.typedLessThan();+ break;+ case CONVERT_TO_NUMBER:+ actions.convertToNumber();+ break;+ case CONVERT_TO_STRING:+ actions.convertToString();+ break;+ case INCREMENT:+ actions.increment();+ break;+ case DECREMENT:+ actions.decrement();+ break;+ case BIT_AND:+ actions.bitAnd();+ break;+ case BIT_OR:+ actions.bitOr();+ break;+ case BIT_XOR:+ actions.bitXor();+ break;+ case SHIFT_LEFT:+ actions.shiftLeft();+ break;+ case SHIFT_RIGHT:+ actions.shiftRight();+ break;+ case SHIFT_UNSIGNED:+ actions.shiftRightUnsigned();+ break;+ default:+ actions.unknown(code, data);+ break;+ }+ }+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseDefineFunction(InStream in) throws IOException {+ String name = in.readString();+ int paramCount = in.readUI16();++ String[] params = new String[paramCount];+ for (int i = 0; i < params.length; i++) {+ params[i] = in.readString();+ }++ //int codesize = in.readUI16();++ //System.out.println( "codesize=" + codesize ); System.out.flush();++ actions.startFunction(name, params);+ blockDepth++;+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseWith(InStream in) throws IOException {+ // int codesize = in.readUI16();++ actions.startWith();+ blockDepth++;+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseLookupTable(InStream in) throws IOException {+ String[] strings = new String[in.readUI16()];++ for (int i = 0; i < strings.length; i++) {+ strings[i] = in.readString();+ }++ actions.lookupTable(strings);+ }+++ /**+ * Description of the Method+ *+ *@param flags Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseGetURL2(int flags) throws IOException {+ int sendVars = flags & 0x03;+ int mode = 0;++ switch (flags & 0xF0) {+ case 0x40:+ mode = SWFActions.GET_URL_MODE_LOAD_MOVIE_INTO_SPRITE;+ break;+ case 0x80:+ mode = SWFActions.GET_URL_MODE_LOAD_VARS_INTO_LEVEL;+ break;+ case 0xC0:+ mode = SWFActions.GET_URL_MODE_LOAD_VARS_INTO_SPRITE;+ break;+ default:+ mode = SWFActions.GET_URL_MODE_LOAD_MOVIE_INTO_LEVEL;+ break;+ }++ actions.getURL(sendVars, mode);+ }+++ /**+ * Description of the Method+ *+ *@param length Description of the Parameter+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parsePush(int length, InStream in) throws IOException {+ while (in.getBytesRead() < length) {+ int pushType = in.readUI8();++ switch (pushType) {+ case PUSHTYPE_STRING:+ actions.push(in.readString());+ break;+ case PUSHTYPE_FLOAT:+ actions.push(in.readFloat());+ break;+ case PUSHTYPE_NULL:+ actions.pushNull();+ break;+ case PUSHTYPE_03:+ break;+ case PUSHTYPE_REGISTER:+ actions.pushRegister(in.readUI8());+ break;+ case PUSHTYPE_BOOLEAN:+ actions.push((in.readUI8() != 0) ? true : false);+ break;+ case PUSHTYPE_DOUBLE:+ actions.push(in.readDouble());+ break;+ case PUSHTYPE_INTEGER:+ actions.push(in.readSI32());+ break;+ case PUSHTYPE_LOOKUP:+ actions.lookup(in.readUI8());+ break;+ default:+ }+ }+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ protected static class ActionRecord {+ /**+ * Description of the Field+ */+ public int offset;+ //byte offset from start of the action array+ /**+ * Description of the Field+ */+ public int code;+ /**+ * Description of the Field+ */+ public String label;+ /**+ * Description of the Field+ */+ public String jumpLabel;+ /**+ * Description of the Field+ */+ public byte[] data;+ /**+ * Description of the Field+ */+ public int blockDepth = 0;+++ /**+ * Constructor for the ActionRecord object+ *+ *@param offset Description of the Parameter+ *@param code Description of the Parameter+ *@param data Description of the Parameter+ */+ protected ActionRecord(int offset, int code, byte[] data) {+ this.offset = offset;+ this.code = code;+ this.data = data;+ }+ }+++ /**+ * First Pass to determine action offsets and jumps+ *+ *@param bytes Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ protected List createRecords(byte[] bytes) throws IOException {+ return createRecords(new InStream(bytes));+ }+++ /**+ * First Pass to determine action offsets and jumps+ *+ *@param in Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ protected List createRecords(InStream in) throws IOException {+ Vector records = new Vector();+ Vector jumpers = new Vector();+ Vector skippers = new Vector();+ Hashtable offsetTable = new Hashtable();++ Stack blockSizes = new Stack();++ int labelIndex = 0;++ while (true) {+ int offset = (int) in.getBytesRead();++ //System.out.println( "read=" + offset ); System.out.flush();++ int code = in.readUI8();+ int dataLength = (code >= 0x80) ? in.readUI16() : 0;+ byte[] data = (dataLength > 0) ? in.read(dataLength) : null;++ //System.out.println( "size=" + dataLength ); System.out.flush();++ ActionRecord rec = new ActionRecord(offset, code, data);+ records.addElement(rec);+ offsetTable.put(new Integer(offset), rec);++ if (!blockSizes.isEmpty()) {+ int depth = blockSizes.size();+ rec.blockDepth = depth;+ int blockDecrement = (dataLength > 0) ? (dataLength + 3) : 1;++ //--subtract the size of this action from all the block sizes+ // in the block stack+ for (int i = depth - 1; i >= 0; i--) {+ int[] blockSize = (int[]) blockSizes.elementAt(i);+ int size = blockSize[0];++ size -= blockDecrement;++ //--reached end of block ?+ if (size <= 0) {+ blockSizes.pop();+ } else {+ blockSize[0] = size;+ }+ }+ }++ if (code == 0) {+ break;+ }+ //end of actions+ else if (code == DEFINE_FUNCTION) {+ InStream in2 = new InStream(rec.data);+ in2.readString();+ int params = in2.readUI16();+ for (int i = 0; i < params; i++) {+ in2.readString();+ }+ int blockSize = in2.readUI16();+ blockSizes.push(new int[]{blockSize});+ } else if (code == WITH) {+ InStream in2 = new InStream(rec.data);+ int blockSize = in2.readUI16();+ blockSizes.push(new int[]{blockSize});+ } else if (code == WAIT_FOR_FRAME || code == WAIT_FOR_FRAME_2) {+ skippers.addElement(new Integer(records.size() - 1));+ } else if (code == IF || code == JUMP) {+ jumpers.addElement(rec);+ }+ }++ //--Tie up the jumpers with the offsets+ for (Enumeration enumumerator = jumpers.elements(); enumumerator.hasMoreElements(); ) {+ ActionRecord rec = (ActionRecord) enumumerator.nextElement();++ InStream in2 = new InStream(rec.data);+ int jumpOffset = in2.readSI16();+ int offset = rec.offset + 5;+ int absoluteOffset = offset + jumpOffset;++ ActionRecord target =+ (ActionRecord) offsetTable.get(new Integer(absoluteOffset));++ if (target != null) {+ if (target.label == null) {+ target.label = rec.jumpLabel = "label" + (labelIndex++);+ } else {+ rec.jumpLabel = target.label;+ }+ }+ }++ //--Tie up the skippers with labels+ for (Enumeration enumumerator = skippers.elements(); enumumerator.hasMoreElements(); ) {+ int idx = ((Integer) enumumerator.nextElement()).intValue();++ ActionRecord rec = (ActionRecord) records.elementAt(idx);++ InStream in2 = new InStream(rec.data);++ if (rec.code == WAIT_FOR_FRAME) {+ in2.readUI16();+ }+ //skip frame number+ int skip = in2.readUI8();+ int skipIndex = idx + skip + 1;++ if (skipIndex < records.size()) {+ ActionRecord target = (ActionRecord) records.elementAt(skipIndex);++ if (target.label == null) {+ target.label = rec.jumpLabel = "label" + (labelIndex++);+ } else {+ rec.jumpLabel = target.label;+ }+ }+ }++ return records;+ }++}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ActionTextWriter.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ActionTextWriter.javanew file mode 100644index 000000000..3f53dea0c--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ActionTextWriter.java@@ -0,0 +1,1208 @@+package pt.tumba.parser.swf;++import java.io.IOException;+import java.io.PrintWriter;++/**+ * A writer that implements the SWFActions interface and writes actions to a+ * text format+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class ActionTextWriter implements SWFActions, SWFActionCodes {+ /**+ * Description of the Field+ */+ protected PrintWriter printer;+ /**+ * Description of the Field+ */+ protected String indent = "";+++ /**+ * Constructor for the ActionTextWriter object+ *+ *@param printer Description of the Parameter+ */+ public ActionTextWriter(PrintWriter printer) {+ this.printer = printer;+ }+++ /**+ * Description of the Method+ *+ *@param mnemonic Description of the Parameter+ *@param args Description of the Parameter+ */+ protected void print(String mnemonic, String[] args) {+ printer.print(indent + " ");+ writePaddedString(mnemonic + " ", 15);++ if (args != null) {+ for (int i = 0; i < args.length; i++) {+ if (i > 0) {+ printer.print(", ");+ }+ printer.print(args[i]);+ }+ }++ printer.println();+ }+++ /**+ * Description of the Method+ *+ *@param s Description of the Parameter+ *@param length Description of the Parameter+ */+ protected void writePaddedString(String s, int length) {+ int pad = length - s.length();++ printer.print(s);+ while (pad > 0) {+ printer.print(" ");+ pad--;+ }+ }+++ /**+ * Description of the Method+ *+ *@param conditions Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void start(int conditions) throws IOException {+ print("conditions", new String[]{Integer.toBinaryString(conditions)});+ printer.flush();+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void end() throws IOException {+ print("end", null);+ printer.println();+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void done() throws IOException {+ printer.flush();+ }+++ /**+ * Description of the Method+ *+ *@param blob Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void blob(byte[] blob) throws IOException {+ print("(blob)", null);+ printer.println();+ }+++ /**+ * Description of the Method+ *+ *@param code Description of the Parameter+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void unknown(int code, byte[] data) throws IOException {+ print("unknown code =", new String[]{Integer.toString(code)});+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void initArray() throws IOException {+ print("initArray", null);+ }+++ /**+ * Description of the Method+ *+ *@param label Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void jumpLabel(String label) throws IOException {+ printer.println(indent + label + ":");+ }+++ /**+ * Description of the Method+ *+ *@param frameNumber Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void gotoFrame(int frameNumber) throws IOException {+ print("gotoFrame", new String[]{Integer.toString(frameNumber)});+ }+++ /**+ * Description of the Method+ *+ *@param label Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void gotoFrame(String label) throws IOException {+ print("gotoFrame", new String[]{"\"" + label + "\""});+ }+++ /**+ * Gets the uRL attribute of the ActionTextWriter object+ *+ *@param url Description of the Parameter+ *@param target Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void getURL(String url, String target) throws IOException {+ print("getURL", new String[]{"\"" + url + "\"", "\"" + target + "\""});+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void nextFrame() throws IOException {+ print("nextFrame", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void prevFrame() throws IOException {+ print("previousFrame", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void play() throws IOException {+ print("play", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void stop() throws IOException {+ print("stop", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void toggleQuality() throws IOException {+ print("toggleQuality", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void stopSounds() throws IOException {+ print("stopSounds", null);+ }+++ /**+ * Sets the target attribute of the ActionTextWriter object+ *+ *@param target The new target value+ *@exception IOException Description of the Exception+ */+ public void setTarget(String target) throws IOException {+ print("setTarget", new String[]{"\"" + target + "\""});+ }+++ /**+ * Description of the Method+ *+ *@param jumpLabel Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void jump(String jumpLabel) throws IOException {+ print("jump", new String[]{"\"" + jumpLabel + "\""});+ }+++ /**+ * Description of the Method+ *+ *@param jumpLabel Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void ifJump(String jumpLabel) throws IOException {+ print("ifJump", new String[]{"\"" + jumpLabel + "\""});+ }+++ /**+ * Description of the Method+ *+ *@param frameNumber Description of the Parameter+ *@param jumpLabel Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void waitForFrame(int frameNumber, String jumpLabel) throws IOException {+ print("waitForFrame", new String[]{Integer.toString(frameNumber),+ "\"" + jumpLabel + "\""});+ }+++ /**+ * Description of the Method+ *+ *@param jumpLabel Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void waitForFrame(String jumpLabel) throws IOException {+ print("waitForFrame", new String[]{"\"" + jumpLabel + "\""});+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void pop() throws IOException {+ print("pop", null);+ }+++ /**+ * Description of the Method+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(String value) throws IOException {+ print("push", new String[]{"\"" + value + "\""});+ }+++ /**+ * Description of the Method+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(float value) throws IOException {+ print("push", new String[]{"float " + value});+ }+++ /**+ * Description of the Method+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(double value) throws IOException {+ print("push", new String[]{"double " + value});+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void pushNull() throws IOException {+ print("push", new String[]{"null"});+ }+++ /**+ * Description of the Method+ *+ *@param registerNumber Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void pushRegister(int registerNumber) throws IOException {+ print("push", new String[]{"register( " + registerNumber + " )"});+ }+++ /**+ * Description of the Method+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(boolean value) throws IOException {+ print("push", new String[]{value ? "true" : "false"});+ }+++ /**+ * Description of the Method+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(int value) throws IOException {+ print("push", new String[]{"" + value});+ }+++ /**+ * Description of the Method+ *+ *@param dictionaryIndex Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void lookup(int dictionaryIndex) throws IOException {+ print("push", new String[]{"lookup( " + dictionaryIndex + " )"});+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void add() throws IOException {+ print("add", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void substract() throws IOException {+ print("substract", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void multiply() throws IOException {+ print("multiply", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void divide() throws IOException {+ print("divide", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void equals() throws IOException {+ print("equals", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void lessThan() throws IOException {+ print("lessThan", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void and() throws IOException {+ print("and", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void or() throws IOException {+ print("or", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void not() throws IOException {+ print("not", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void stringEquals() throws IOException {+ print("stringEquals", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void stringLength() throws IOException {+ print("stringLength", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void concat() throws IOException {+ print("concat", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void substring() throws IOException {+ print("substring", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void stringLessThan() throws IOException {+ print("stringLessThan", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void stringLengthMB() throws IOException {+ print("stringLengthMB", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void substringMB() throws IOException {+ print("substringMB", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void toInteger() throws IOException {+ print("toInteger", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void charToAscii() throws IOException {+ print("charToAscii", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void asciiToChar() throws IOException {+ print("asciiToChar", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void charMBToAscii() throws IOException {+ print("charMBToAscii", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void asciiToCharMB() throws IOException {+ print("asciiToCharMB", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void call() throws IOException {+ print("call", null);+ }+++ /**+ * Gets the variable attribute of the ActionTextWriter object+ *+ *@exception IOException Description of the Exception+ */+ public void getVariable() throws IOException {+ print("getVariable", null);+ }+++ /**+ * Sets the variable attribute of the ActionTextWriter object+ *+ *@exception IOException Description of the Exception+ */+ public void setVariable() throws IOException {+ print("setVariable", null);+ }+++ /**+ * Gets the uRL attribute of the ActionTextWriter object+ *+ *@param sendVars Description of the Parameter+ *@param loadMode Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void getURL(int sendVars, int loadMode) throws IOException {+ String sendVars_ = null;+ switch (sendVars) {+ case GET_URL_SEND_VARS_GET:+ sendVars_ = "send vars via GET";+ break;+ case GET_URL_SEND_VARS_POST:+ sendVars_ = "send vars via POST";+ break;+ case GET_URL_SEND_VARS_NONE:+ default:+ sendVars_ = "no send";+ break;+ }++ String mode = null;+ switch (loadMode) {+ case GET_URL_MODE_LOAD_MOVIE_INTO_LEVEL:+ mode = "load movie into level";+ break;+ case GET_URL_MODE_LOAD_MOVIE_INTO_SPRITE:+ mode = "load movie into sprite";+ break;+ case GET_URL_MODE_LOAD_VARS_INTO_LEVEL:+ mode = "load vars into level";+ break;+ case GET_URL_MODE_LOAD_VARS_INTO_SPRITE:+ mode = "load vars into sprite";+ break;+ default:+ mode = "???";+ break;+ }++ print("getURL", new String[]{sendVars_, mode});+ }+++ /**+ * Description of the Method+ *+ *@param play Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void gotoFrame(boolean play) throws IOException {+ print("gotoFrame", new String[]{play ? "and play" : "and stop"});+ }+++ /**+ * Sets the target attribute of the ActionTextWriter object+ *+ *@exception IOException Description of the Exception+ */+ public void setTarget() throws IOException {+ print("setTarget", null);+ }+++ /**+ * Gets the property attribute of the ActionTextWriter object+ *+ *@exception IOException Description of the Exception+ */+ public void getProperty() throws IOException {+ print("getProperty", null);+ }+++ /**+ * Sets the property attribute of the ActionTextWriter object+ *+ *@exception IOException Description of the Exception+ */+ public void setProperty() throws IOException {+ print("setProperty", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void cloneSprite() throws IOException {+ print("cloneSprite", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void removeSprite() throws IOException {+ print("removeSprite", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void startDrag() throws IOException {+ print("startDrag", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void endDrag() throws IOException {+ print("endDrag", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void trace() throws IOException {+ print("trace", null);+ }+++ /**+ * Gets the time attribute of the ActionTextWriter object+ *+ *@exception IOException Description of the Exception+ */+ public void getTime() throws IOException {+ print("getTime", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void randomNumber() throws IOException {+ print("randomNumber", null);+ }+++ /**+ * Description of the Method+ *+ *@param values Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void lookupTable(String[] values) throws IOException {+ print("lookupTable", null);++ for (int i = 0; i < values.length; i++) {+ printer.print(indent + " ");+ writePaddedString(Integer.toString(i) + ":", 5);+ printer.println("\"" + values[i] + "\"");+ }+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void callFunction() throws IOException {+ print("callFunction", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void callMethod() throws IOException {+ print("callMethod", null);+ }+++ /**+ * Description of the Method+ *+ *@param name Description of the Parameter+ *@param paramNames Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void startFunction(String name, String[] paramNames) throws IOException {+ String args = name + "(";++ if (paramNames != null) {+ for (int i = 0; i < paramNames.length; i++) {+ if (i > 0) {+ args += ",";+ }+ args += " " + paramNames[i];+ }++ if (paramNames.length > 0) {+ args += " ";+ }+ }++ args += ")";++ printer.println();+ print("defineFunction", new String[]{args});+ print("{", null);++ indent += " ";+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void endBlock() throws IOException {+ if (indent.length() <= 4) {+ indent = "";+ } else if (indent.length() >= 4) {+ indent = indent.substring(4);+ }++ print("}", null);+ printer.println();+ }+++ /**+ * Description of the Method+ *+ *@param comment Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void comment(String comment) throws IOException {+ printer.println(indent + " // " + comment);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void defineLocalValue() throws IOException {+ print("defineLocalValue", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void defineLocal() throws IOException {+ print("defineLocal", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void deleteProperty() throws IOException {+ print("deleteProperty", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void deleteThreadVars() throws IOException {+ print("deleteThreadVars", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void enumerate() throws IOException {+ print("enumerate", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void typedEquals() throws IOException {+ print("typedEquals", null);+ }+++ /**+ * Gets the member attribute of the ActionTextWriter object+ *+ *@exception IOException Description of the Exception+ */+ public void getMember() throws IOException {+ print("getMember", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void initObject() throws IOException {+ print("initObject", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void newMethod() throws IOException {+ print("newMethod", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void newObject() throws IOException {+ print("newObject", null);+ }+++ /**+ * Sets the member attribute of the ActionTextWriter object+ *+ *@exception IOException Description of the Exception+ */+ public void setMember() throws IOException {+ print("setMember", null);+ }+++ /**+ * Gets the targetPath attribute of the ActionTextWriter object+ *+ *@exception IOException Description of the Exception+ */+ public void getTargetPath() throws IOException {+ print("getTargetPath", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void startWith() throws IOException {+ printer.println();+ print("with", null);+ print("{", null);++ indent += " ";+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void duplicate() throws IOException {+ print("duplicate", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void returnValue() throws IOException {+ print("return", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void swap() throws IOException {+ print("swap", null);+ }+++ /**+ * Description of the Method+ *+ *@param registerNumber Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void storeInRegister(int registerNumber) throws IOException {+ print("register", new String[]{Integer.toString(registerNumber)});+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void convertToNumber() throws IOException {+ print("convertToNumber", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void convertToString() throws IOException {+ print("convertToString", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void typeOf() throws IOException {+ print("typeOf", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void typedAdd() throws IOException {+ print("typedAdd", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void typedLessThan() throws IOException {+ print("typedLessThan", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void modulo() throws IOException {+ print("modulo", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void bitAnd() throws IOException {+ print("bitAnd", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void bitOr() throws IOException {+ print("bitOr", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void bitXor() throws IOException {+ print("bitXor", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void shiftLeft() throws IOException {+ print("shiftLeft", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void shiftRight() throws IOException {+ print("shiftRight", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void shiftRightUnsigned() throws IOException {+ print("shiftRightUnsigned", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void decrement() throws IOException {+ print("decrement", null);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void increment() throws IOException {+ print("increment", null);+ }+}+diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ActionWriter.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ActionWriter.javanew file mode 100644index 000000000..9ca8b22f5--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ActionWriter.java@@ -0,0 +1,1528 @@+package pt.tumba.parser.swf;++import java.io.ByteArrayOutputStream;+import java.io.IOException;+import java.util.Hashtable;+import java.util.Iterator;+import java.util.List;+import java.util.Stack;+import java.util.Vector;++/**+ * A writer that implements the SWFActions interface and writes action bytes to+ * an OutStream+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class ActionWriter implements SWFActions, SWFActionCodes {+ /**+ * Description of the Field+ */+ protected TagWriter tagWriter;+ /**+ * Description of the Field+ */+ protected OutStream out;+ /**+ * Description of the Field+ */+ protected ByteArrayOutputStream bout;+ /**+ * Description of the Field+ */+ protected int count;+ /**+ * Description of the Field+ */+ protected int flashVersion;++ /**+ * Description of the Field+ */+ protected List pushValues;++ /**+ * Description of the Field+ */+ protected Hashtable labels;+ /**+ * Description of the Field+ */+ protected List jumps;+ /**+ * Description of the Field+ */+ protected List skips;++ //--for fixing up functions and WITH blocks..+ /**+ * Description of the Field+ */+ protected List blocks;+ /**+ * Description of the Field+ */+ protected Stack blockStack;+++ /**+ * Constructor for the ActionWriter object+ *+ *@param tagWriter Description of the Parameter+ *@param flashVersion Description of the Parameter+ */+ public ActionWriter(TagWriter tagWriter, int flashVersion) {+ this.flashVersion = flashVersion;+ this.tagWriter = tagWriter;+ }+++ /**+ *@param code Description of the Parameter+ *@return the code count+ *@exception IOException Description of the Exception+ */+ protected int writeCode(int code) throws IOException {+ if (pushValues.size() > 0) {+ flushPushValues();+ }+ out.writeUI8(code);+ count++;+ return count;+ }+++ /**+ * SWFActions interface+ *+ *@param conditions Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void start(int conditions) throws IOException {+ //ignore conditions++ count = 0;+ bout = new ByteArrayOutputStream();+ out = new OutStream(bout);+ pushValues = new Vector();+ labels = null;+ jumps = null;+ skips = null;+ blocks = null;+ blockStack = null;+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void end() throws IOException {+ writeCode(0);+ out.flush();+ byte[] bytes = bout.toByteArray();++ //--Fix up jumps and skips+ if (labels != null) {+ if (jumps != null) {+ fixupJumps(bytes);+ }+ if (skips != null) {+ fixupSkips(bytes);+ }+ }++ if (blocks != null) {+ fixupBlocks(bytes);+ }++ writeBytes(bytes);+ }+++ /**+ * Pass through a blob of actions+ *+ *@param blob Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void blob(byte[] blob) throws IOException {+ writeBytes(blob);+ }+++ /**+ * Description of the Method+ *+ *@param bytes Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void writeBytes(byte[] bytes) throws IOException {+ tagWriter.getOutStream().write(bytes);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void done() throws IOException {+ tagWriter.completeTag();+ }+++ /**+ * Description of the Method+ *+ *@param bytes Description of the Parameter+ */+ protected void fixupBlocks(byte[] bytes2) {+ byte[] bytes = bytes2;+ for (Iterator enumerator = blocks.iterator(); enumerator.hasNext(); ) {+ int[] info = (int[]) enumerator.next();++ int codeSize = info[1];+ int offset = info[0];+ byte[] sizeBytes = OutStream.sintTo2Bytes(codeSize);++ bytes[offset] = sizeBytes[0];+ bytes[offset + 1] = sizeBytes[1];+ }+ }+++ /**+ * Description of the Method+ *+ *@param bytes Description of the Parameter+ */+ protected void fixupJumps(byte[] bytes2) {+ byte[] bytes = bytes2;+ for (Iterator enumumerator = jumps.iterator(); enumumerator.hasNext(); ) {+ Object[] obja = (Object[]) enumumerator.next();+ String label = (String) obja[0];+ int target = ((Integer) obja[1]).intValue();++ int[] labelInfo = (int[]) labels.get(label);++ if (labelInfo == null) {+ System.out.println("Missing label '" + label + "' in action code");+ continue;+ }++ int absolute = labelInfo[0];+ //offset of the label+ int relative = absolute - (target + 2);+ //relative jump++ byte[] val = OutStream.sintTo2Bytes(relative);+ bytes[target] = val[0];+ bytes[target + 1] = val[1];+ }+ }+++ /**+ * Description of the Method+ *+ *@param bytes Description of the Parameter+ */+ protected void fixupSkips(byte[] bytes2) {+ byte[] bytes = bytes2;+ for (Iterator enumerator = skips.iterator(); enumerator.hasNext(); ) {+ Object[] obja = (Object[]) enumerator.next();+ String label = (String) obja[0];++ int[] skipInfo = (int[]) obja[1];+ int skipIndex = skipInfo[0];+ int skipLoc = skipInfo[1];++ int[] labelInfo = (int[]) labels.get(label);++ if (labelInfo == null) {+ System.out.println("Missing label '" + label + "' in action code");+ continue;+ }++ int labelIndex = labelInfo[1];+ //index of the labelled action+ int skip = labelIndex - skipIndex - 1;++ byte val = OutStream.uintToByte(skip);+ bytes[skipLoc] = val;+ }+ }+++ /**+ * SWFActions interface+ *+ *@param comment Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void comment(String comment) throws IOException {+ //ignore comments+ }+++ /**+ * SWFActions interface+ *+ *@param code Description of the Parameter+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void unknown(int code, byte[] data) throws IOException {+ writeCode(code);++ int length = (data != null) ? data.length : 0;++ if (code >= 0x80 || length > 0) {+ out.writeUI16(length);+ }++ if (length > 0) {+ out.write(data);+ }+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void initArray() throws IOException {+ writeCode(INIT_ARRAY);+ }+++ /**+ * SWFActions interface+ *+ *@param label Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void jumpLabel(String label) throws IOException {+ if (pushValues.size() > 0) {+ flushPushValues();+ }++ int offset = (int) out.getBytesWritten();++ if (labels == null) {+ labels = new Hashtable();+ }+ labels.put(label, new int[]{offset, count + 1});+ }+++ /**+ * SWFActions interface+ *+ *@param frameNumber Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void gotoFrame(int frameNumber) throws IOException {+ writeCode(GOTO_FRAME);+ out.writeUI16(2);+ out.writeUI16(frameNumber);+ }+++ /**+ * SWFActions interface+ *+ *@param label Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void gotoFrame(String label) throws IOException {+ writeCode(GOTO_LABEL);+ out.writeUI16(OutStream.getStringLength(label));+ out.writeString(label);+ }+++ /**+ * SWFActions interface+ *+ *@param url Description of the Parameter+ *@param target Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void getURL(String url, String target) throws IOException {+ writeCode(GET_URL);+ out.writeUI16(OutStream.getStringLength(url) + OutStream.getStringLength(target));+ out.writeString(url);+ out.writeString(target);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void nextFrame() throws IOException {+ writeCode(NEXT_FRAME);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void prevFrame() throws IOException {+ writeCode(PREVIOUS_FRAME);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void play() throws IOException {+ writeCode(PLAY);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void stop() throws IOException {+ writeCode(STOP);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void toggleQuality() throws IOException {+ writeCode(TOGGLE_QUALITY);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void stopSounds() throws IOException {+ writeCode(STOP_SOUNDS);+ }+++ /**+ * SWFActions interface+ *+ *@param target The new target value+ *@exception IOException Description of the Exception+ */+ public void setTarget(String target) throws IOException {+ writeCode(SET_TARGET);+ out.writeUI16(OutStream.getStringLength(target));+ out.writeString(target);+ }+++ /**+ * Description of the Method+ *+ *@param label Description of the Parameter+ *@param code Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void writeJump(String label, int code) throws IOException {+ writeCode(code);+ out.writeUI16(2);++ int here = (int) out.getBytesWritten();+ out.writeUI16(0);+ //will be fixed up later++ //--save jump info for later fix-up logic+ if (jumps == null) {+ jumps = new Vector();+ }+ jumps.add(new Object[]{label, new Integer(here)});+ }+++ /**+ * SWFActions interface+ *+ *@param jumpLabel Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void jump(String jumpLabel) throws IOException {+ writeJump(jumpLabel, JUMP);+ }+++ /**+ * SWFActions interface+ *+ *@param jumpLabel Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void ifJump(String jumpLabel) throws IOException {+ writeJump(jumpLabel, IF);+ }+++ /**+ * SWFActions interface+ *+ *@param frameNumber Description of the Parameter+ *@param jumpLabel Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void waitForFrame(int frameNumber, String jumpLabel) throws IOException {+ writeCode(WAIT_FOR_FRAME);+ out.writeUI16(3);+ out.writeUI16(frameNumber);++ int here = (int) out.getBytesWritten();+ out.writeUI8(0);+ //will be fixed up later++ //--save skip info for later fix-up logic+ if (skips == null) {+ skips = new Vector();+ }+ skips.add(new Object[]{jumpLabel, new int[]{count, here}});+ }+++ /**+ * SWFActions interface+ *+ *@param jumpLabel Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void waitForFrame(String jumpLabel) throws IOException {+ writeCode(WAIT_FOR_FRAME_2);+ out.writeUI16(1);++ int here = (int) out.getBytesWritten();+ out.writeUI8(0);+ //will be fixed up later++ //--save skip info for later fix-up logic+ if (skips == null) {+ skips = new Vector();+ }+ skips.add(new Object[]{jumpLabel, new int[]{count, here}});+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void pop() throws IOException {+ writeCode(POP);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void add() throws IOException {+ writeCode(ADD);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void substract() throws IOException {+ writeCode(SUBTRACT);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void multiply() throws IOException {+ writeCode(MULTIPLY);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void divide() throws IOException {+ writeCode(DIVIDE);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void equals() throws IOException {+ writeCode(EQUALS);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void lessThan() throws IOException {+ writeCode(LESS);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void and() throws IOException {+ writeCode(AND);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void or() throws IOException {+ writeCode(OR);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void not() throws IOException {+ writeCode(NOT);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void stringEquals() throws IOException {+ writeCode(STRING_EQUALS);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void stringLength() throws IOException {+ writeCode(STRING_LENGTH);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void concat() throws IOException {+ writeCode(STRING_ADD);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void substring() throws IOException {+ writeCode(STRING_EXTRACT);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void stringLessThan() throws IOException {+ writeCode(STRING_LESS);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void stringLengthMB() throws IOException {+ writeCode(MB_STRING_LENGTH);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void substringMB() throws IOException {+ writeCode(MB_STRING_EXTRACT);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void toInteger() throws IOException {+ writeCode(TO_INTEGER);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void charToAscii() throws IOException {+ writeCode(CHAR_TO_ASCII);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void asciiToChar() throws IOException {+ writeCode(ASCII_TO_CHAR);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void charMBToAscii() throws IOException {+ writeCode(MB_CHAR_TO_ASCII);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void asciiToCharMB() throws IOException {+ writeCode(MB_ASCII_TO_CHAR);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void call() throws IOException {+ writeCode(CALL);+ out.writeUI16(0);+ //SWF File Format anomaly+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void getVariable() throws IOException {+ writeCode(GET_VARIABLE);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void setVariable() throws IOException {+ writeCode(SET_VARIABLE);+ }+++ /**+ * SWFActions interface+ *+ *@param sendVars Description of the Parameter+ *@param loadMode Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void getURL(int sendVars, int loadMode) throws IOException {+ writeCode(GET_URL_2);+ out.writeUI16(1);++ int flags = 0;++ //String sendVars_ = null;+ switch (sendVars) {+ case GET_URL_SEND_VARS_GET:+ flags = 1;+ break;+ case GET_URL_SEND_VARS_POST:+ flags = 2;+ break;+ case GET_URL_SEND_VARS_NONE:+ default:+ break;+ }++ //String mode = null;+ switch (loadMode) {+ case GET_URL_MODE_LOAD_MOVIE_INTO_LEVEL:+ break;+ case GET_URL_MODE_LOAD_MOVIE_INTO_SPRITE:+ flags |= 0x40;+ break;+ case GET_URL_MODE_LOAD_VARS_INTO_LEVEL:+ flags |= 0x80;+ break;+ case GET_URL_MODE_LOAD_VARS_INTO_SPRITE:+ flags |= 0xC0;+ break;+ default:+ break;+ }++ out.writeUI8(flags);+ }+++ /**+ * SWFActions interface+ *+ *@param play Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void gotoFrame(boolean play) throws IOException {+ writeCode(GOTO_FRAME_2);+ out.writeUI16(1);+ out.writeUI8(play ? 1 : 0);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void setTarget() throws IOException {+ writeCode(SET_TARGET_2);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void getProperty() throws IOException {+ writeCode(GET_PROPERTY);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void setProperty() throws IOException {+ writeCode(SET_PROPERTY);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void cloneSprite() throws IOException {+ writeCode(CLONE_SPRITE);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void removeSprite() throws IOException {+ writeCode(REMOVE_SPRITE);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void startDrag() throws IOException {+ writeCode(START_DRAG);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void endDrag() throws IOException {+ writeCode(END_DRAG);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void trace() throws IOException {+ writeCode(TRACE);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void getTime() throws IOException {+ writeCode(GET_TIME);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void randomNumber() throws IOException {+ writeCode(RANDOM_NUMBER);+ }+++ /**+ * SWFActions interface+ *+ *@param values Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void lookupTable(String[] values) throws IOException {+ writeCode(LOOKUP_TABLE);++ ByteArrayOutputStream baout = new ByteArrayOutputStream();+ OutStream bout = new OutStream(baout);++ bout.writeUI16(values.length);++ for (int i = 0; i < values.length; i++) {+ bout.writeString(values[i]);+ }++ bout.flush();+ byte[] data = baout.toByteArray();+ out.writeUI16(data.length);+ out.write(data);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void callFunction() throws IOException {+ writeCode(CALL_FUNCTION);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void callMethod() throws IOException {+ writeCode(CALL_METHOD);+ }+++ /**+ * SWFActions interface+ *+ *@param name Description of the Parameter+ *@param paramNames Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void startFunction(String name, String[] paramNames) throws IOException {+ if (blockStack == null) {+ blockStack = new Stack();+ }++ writeCode(DEFINE_FUNCTION);++ ByteArrayOutputStream baout = new ByteArrayOutputStream();+ OutStream bout = new OutStream(baout);++ bout.writeString(name);+ bout.writeUI16(paramNames.length);++ for (int i = 0; i < paramNames.length; i++) {+ bout.writeString(paramNames[i]);+ }++ bout.writeUI16(0);+ //code size - will be fixed up later++ bout.flush();+ byte[] data = baout.toByteArray();+ out.writeUI16(data.length);+ out.write(data);++ blockStack.push(new int[]{(int) out.getBytesWritten(), 0});+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void endBlock() throws IOException {+ if (blockStack == null || blockStack.isEmpty()) {+ return;+ }+ //nothing to do+ int[] blockInfo = (int[]) blockStack.pop();++ if (blocks == null) {+ blocks = new Vector();+ }++ int offset = blockInfo[0];+ int codeSize = ((int) out.getBytesWritten()) - offset;++ //--store this info for later fix-up+ blockInfo[0] = offset - 2;+ blockInfo[1] = codeSize;+ blocks.add(blockInfo);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void defineLocalValue() throws IOException {+ writeCode(DEFINE_LOCAL_VAL);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void defineLocal() throws IOException {+ writeCode(DEFINE_LOCAL);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void deleteProperty() throws IOException {+ writeCode(DEL_VAR);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void deleteThreadVars() throws IOException {+ writeCode(DEL_THREAD_VARS);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void enumerate() throws IOException {+ writeCode(ENUMERATE);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void typedEquals() throws IOException {+ writeCode(TYPED_EQUALS);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void getMember() throws IOException {+ writeCode(GET_MEMBER);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void initObject() throws IOException {+ writeCode(INIT_OBJECT);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void newMethod() throws IOException {+ writeCode(CALL_NEW_METHOD);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void newObject() throws IOException {+ writeCode(NEW_OBJECT);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void setMember() throws IOException {+ writeCode(SET_MEMBER);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void getTargetPath() throws IOException {+ writeCode(GET_TARGET_PATH);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void startWith() throws IOException {+ writeCode(WITH);+ out.writeUI16(2);+ out.writeUI16(0);+ //codeSize - will be fixed up later++ //--push the block start info+ if (blockStack == null) {+ blockStack = new Stack();+ }+ blockStack.push(new int[]{(int) out.getBytesWritten(), 0});+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void duplicate() throws IOException {+ writeCode(DUPLICATE);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void returnValue() throws IOException {+ writeCode(RETURN);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void swap() throws IOException {+ writeCode(SWAP);+ }+++ /**+ * SWFActions interface+ *+ *@param registerNumber Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void storeInRegister(int registerNumber) throws IOException {+ writeCode(REGISTER);+ out.writeUI16(1);+ out.writeUI8(registerNumber);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void convertToNumber() throws IOException {+ writeCode(CONVERT_TO_NUMBER);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void convertToString() throws IOException {+ writeCode(CONVERT_TO_STRING);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void typeOf() throws IOException {+ writeCode(TYPEOF);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void typedAdd() throws IOException {+ writeCode(TYPED_ADD);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void typedLessThan() throws IOException {+ writeCode(TYPED_LESS_THAN);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void modulo() throws IOException {+ writeCode(MODULO);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void bitAnd() throws IOException {+ writeCode(BIT_AND);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void bitOr() throws IOException {+ writeCode(BIT_OR);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void bitXor() throws IOException {+ writeCode(BIT_XOR);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void shiftLeft() throws IOException {+ writeCode(SHIFT_LEFT);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void shiftRight() throws IOException {+ writeCode(SHIFT_RIGHT);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void shiftRightUnsigned() throws IOException {+ writeCode(SHIFT_UNSIGNED);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void decrement() throws IOException {+ writeCode(DECREMENT);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void increment() throws IOException {+ writeCode(INCREMENT);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ protected void flushPushValues() throws IOException {+ out.writeUI8(PUSH);+ count++;++ ByteArrayOutputStream baout = new ByteArrayOutputStream();+ OutStream bout = new OutStream(baout);++ for (Iterator enumerator = pushValues.iterator(); enumerator.hasNext(); ) {+ Object value = enumerator.next();++ if (value instanceof String) {+ bout.writeUI8(PUSHTYPE_STRING);+ bout.writeString(value.toString());+ } else if (value instanceof Boolean) {+ bout.writeUI8(PUSHTYPE_BOOLEAN);+ bout.writeUI8(((Boolean) value).booleanValue() ? 1 : 0);+ } else if (value instanceof Integer) {+ bout.writeUI8(PUSHTYPE_INTEGER);+ bout.writeSI32(((Integer) value).intValue());+ } else if (value instanceof Short) {+ bout.writeUI8(PUSHTYPE_LOOKUP);+ bout.writeUI8(((Short) value).intValue());+ } else if (value instanceof Byte) {+ bout.writeUI8(SWFActionCodes.PUSHTYPE_REGISTER);+ bout.writeUI8(((Byte) value).intValue());+ } else if (value instanceof Float) {+ bout.writeUI8(PUSHTYPE_FLOAT);+ bout.writeFloat(((Float) value).floatValue());+ } else if (value instanceof Double) {+ bout.writeUI8(PUSHTYPE_DOUBLE);+ bout.writeDouble(((Double) value).doubleValue());+ } else {+ bout.writeUI8(PUSHTYPE_NULL);+ }+ }++ pushValues.clear();++ bout.flush();+ byte[] data = baout.toByteArray();+ out.writeUI16(data.length);+ out.write(data);+ }+++ /**+ * SWFActions interface+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(String value) throws IOException {+ pushValues.add(value);+ if (flashVersion < 5) {+ flushPushValues();+ }+ }+++ /**+ * SWFActions interface+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(float value) throws IOException {+ pushValues.add(new Float(value));+ if (flashVersion < 5) {+ flushPushValues();+ }+ }+++ /**+ * SWFActions interface+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(double value) throws IOException {+ pushValues.add(new Double(value));+ if (flashVersion < 5) {+ flushPushValues();+ }+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void pushNull() throws IOException {+ pushValues.add(new Object());+ if (flashVersion < 5) {+ flushPushValues();+ }+ }+++ /**+ * SWFActions interface+ *+ *@param registerNumber Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void pushRegister(int registerNumber) throws IOException {+ pushValues.add(new Byte((byte) registerNumber));+ if (flashVersion < 5) {+ flushPushValues();+ }+ }+++ /**+ * SWFActions interface+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(boolean value) throws IOException {+ pushValues.add(Boolean.valueOf(value));+ if (flashVersion < 5) {+ flushPushValues();+ }+ }+++ /**+ * SWFActions interface+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(int value) throws IOException {+ pushValues.add(new Integer(value));+ if (flashVersion < 5) {+ flushPushValues();+ }+ }+++ /**+ * SWFActions interface+ *+ *@param dictionaryIndex Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void lookup(int dictionaryIndex) throws IOException {+ pushValues.add(new Short((short) dictionaryIndex));+ if (flashVersion < 5) {+ flushPushValues();+ }+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Actions.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Actions.javanew file mode 100644index 000000000..2187af025--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Actions.java@@ -0,0 +1,120 @@+package pt.tumba.parser.swf;++import java.io.ByteArrayOutputStream;+import java.io.IOException;+import java.util.Vector;++/**+ * A set of actions+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class Actions extends ActionWriter {+ /**+ * Description of the Field+ */+ protected int conditions;+ /**+ * Description of the Field+ */+ protected byte[] bytes;+++ /**+ * Constructor for the Actions object+ *+ *@param conditions Description of the Parameter+ *@param flashVersion Description of the Parameter+ */+ public Actions(int conditions, int flashVersion) {+ super(null, flashVersion);++ this.conditions = conditions;+ count = 0;+ bout = new ByteArrayOutputStream();+ out = new OutStream(bout);+ pushValues = new Vector();+ labels = null;+ jumps = null;+ skips = null;+ blocks = null;+ blockStack = null;+ }+++ /**+ * Constructor for the Actions object+ *+ *@param flashVersion Description of the Parameter+ */+ public Actions(int flashVersion) {+ this(0, flashVersion);+ }+++ /**+ * Parse the action contents and write them to the SWFActions interface+ *+ *@param swfactions Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void write(SWFActions swfactions) throws IOException {+ ActionParser parser = new ActionParser(swfactions);+ swfactions.start(conditions);+ parser.parse(bytes);+ swfactions.done();+ }+++ /**+ * The condition flags depend on context - frame, button or clip actions+ *+ *@return The conditions value+ */+ public int getConditions() {+ return conditions;+ }+++ /**+ * Sets the conditions attribute of the Actions object+ *+ *@param conds The new conditions value+ */+ public void setConditions(int conds) {+ this.conditions = conds;+ }+++ /**+ * SWFActions interface+ *+ *@param conditions Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void start(int conditions) throws IOException {+ //do nothing+ }+++ /**+ * Description of the Method+ *+ *@param bytes Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void writeBytes(byte[] bytes) throws IOException {+ this.bytes = bytes;+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void done() throws IOException {+ //do nothing+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/AlphaColor.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/AlphaColor.javanew file mode 100644index 000000000..fc8bac7c3--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/AlphaColor.java@@ -0,0 +1,121 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * A Color with an Alpha component+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class AlphaColor extends Color {+ /**+ * Description of the Field+ */+ protected int alpha;+++ /**+ * Gets the alpha attribute of the AlphaColor object+ *+ *@return The alpha value+ */+ public int getAlpha() {+ return alpha;+ }+++ /**+ * Sets the alpha attribute of the AlphaColor object+ *+ *@param alpha The new alpha value+ */+ public void setAlpha(int alpha) {+ this.alpha = alpha;+ }+++ /**+ * Constructor for the AlphaColor object+ *+ *@param red Description of the Parameter+ *@param green Description of the Parameter+ *@param blue Description of the Parameter+ *@param alpha Description of the Parameter+ */+ public AlphaColor(int red, int green, int blue, int alpha) {+ super(red, green, blue);+ this.alpha = alpha;+ }+++ /**+ * Constructor for the AlphaColor object+ *+ *@param color Description of the Parameter+ *@param alpha Description of the Parameter+ */+ public AlphaColor(Color color, int alpha) {+ this(color.getRed(), color.getGreen(), color.getBlue(), alpha);+ }+++ /**+ * Constructor for the AlphaColor object+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public AlphaColor(InStream in) throws IOException {+ super(in);+ alpha = in.readUI8();+ }+++ /**+ * Description of the Method+ *+ *@param out Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void write(OutStream out) throws IOException {+ writeRGB(out);+ out.writeUI8(alpha);+ }+++ /**+ * Description of the Method+ *+ *@param out Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void writeWithAlpha(OutStream out) throws IOException {+ write(out);+ }+++ /**+ * Description of the Method+ *+ *@param color Description of the Parameter+ *@return Description of the Return Value+ */+ public boolean equals(Object color) {+ return super.equals(color) && (alpha == ((AlphaColor)color).getAlpha());+ }++ public int hashCode() {+ return super.hashCode();+ }+++ /**+ * Description of the Method+ *+ *@return Description of the Return Value+ */+ public String toString() {+ return "RGBA(" + red + "," + green + "," + blue + "," + alpha + ")";+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/AlphaTransform.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/AlphaTransform.javanew file mode 100644index 000000000..5c918c679--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/AlphaTransform.java@@ -0,0 +1,193 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class AlphaTransform extends ColorTransform {+ /**+ * Gets the multAlpha attribute of the AlphaTransform object+ *+ *@return The multAlpha value+ */+ public double getMultAlpha() {+ return multAlpha;+ }+++ /**+ * Gets the addAlpha attribute of the AlphaTransform object+ *+ *@return The addAlpha value+ */+ public int getAddAlpha() {+ return addAlpha;+ }+++ /**+ * Sets the multAlpha attribute of the AlphaTransform object+ *+ *@param multAlpha The new multAlpha value+ */+ public void setMultAlpha(double multAlpha) {+ this.multAlpha = multAlpha;+ }+++ /**+ * Sets the addAlpha attribute of the AlphaTransform object+ *+ *@param addAlpha The new addAlpha value+ */+ public void setAddAlpha(int addAlpha) {+ this.addAlpha = addAlpha;+ }+++ /**+ * An identity transform+ */+ public AlphaTransform() { }+++ /**+ * Copy another transform+ *+ *@param copy Description of the Parameter+ */+ public AlphaTransform(ColorTransform copy) {+ if (copy == null) {+ return;+ }+ this.addRed = copy.addRed;+ this.addGreen = copy.addGreen;+ this.addBlue = copy.addBlue;+ this.addAlpha = copy.addAlpha;++ this.multRed = copy.multRed;+ this.multGreen = copy.multGreen;+ this.multBlue = copy.multBlue;+ this.multAlpha = copy.multAlpha;+ }+++ /**+ * Constructor for the AlphaTransform object+ *+ *@param multRed Description of the Parameter+ *@param multGreen Description of the Parameter+ *@param multBlue Description of the Parameter+ *@param multAlpha Description of the Parameter+ *@param addRed Description of the Parameter+ *@param addGreen Description of the Parameter+ *@param addBlue Description of the Parameter+ *@param addAlpha Description of the Parameter+ */+ public AlphaTransform(double multRed, double multGreen, double multBlue,+ double multAlpha,+ int addRed, int addGreen, int addBlue,+ int addAlpha) {+ super(multRed, multGreen, multBlue, addRed, addGreen, addBlue);+ this.multAlpha = multAlpha;+ this.addAlpha = addAlpha;+ }+++ /**+ * Constructor for the AlphaTransform object+ *+ *@param addRed Description of the Parameter+ *@param addGreen Description of the Parameter+ *@param addBlue Description of the Parameter+ *@param addAlpha Description of the Parameter+ */+ public AlphaTransform(int addRed, int addGreen, int addBlue, int addAlpha) {+ super(addRed, addGreen, addBlue);+ this.addAlpha = addAlpha;+ }+++ /**+ * Constructor for the AlphaTransform object+ *+ *@param multRed Description of the Parameter+ *@param multGreen Description of the Parameter+ *@param multBlue Description of the Parameter+ *@param multAplha Description of the Parameter+ */+ public AlphaTransform(double multRed, double multGreen, double multBlue,+ double multAlpha) {+ super(multRed, multGreen, multBlue);+ this.multAlpha = multAlpha;+ }+++ /**+ * Constructor for the AlphaTransform object+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public AlphaTransform(InStream in) throws IOException {+ in.synchBits();++ //--Add and mult are reversed+ boolean hasAddTerms = (in.readUBits(1) == 1);+ boolean hasMultTerms = (in.readUBits(1) == 1);++ int numBits = (int) in.readUBits(4);++ if (hasMultTerms) {+ multRed = ((double) in.readSBits(numBits)) / 256.0;+ multGreen = ((double) in.readSBits(numBits)) / 256.0;+ multBlue = ((double) in.readSBits(numBits)) / 256.0;+ multAlpha = ((double) in.readSBits(numBits)) / 256.0;+ }++ if (hasAddTerms) {+ addRed = in.readSBits(numBits);+ addGreen = in.readSBits(numBits);+ addBlue = in.readSBits(numBits);+ addAlpha = in.readSBits(numBits);+ }+ }+++ /**+ * Description of the Method+ *+ *@param out Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void write(OutStream out) throws IOException {+ writeWithAlpha(out);+ }+++ /**+ * Description of the Method+ *+ *@param out Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void writeWithoutAlpha(OutStream out) throws IOException {+ super.write(out);+ }+++ /**+ * Description of the Method+ *+ *@return Description of the Return Value+ */+ public String toString() {+ return " cxform(+rgba,*rgba)=(" + addRed + "," + addGreen + "," + addBlue+ + "," + addAlpha + "," + multRed + "," + multGreen + "," ++ multBlue + "," + multAlpha + ")";+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Base64.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Base64.javanew file mode 100644index 000000000..5ec780add--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Base64.java@@ -0,0 +1,315 @@+package pt.tumba.parser.swf;++import java.io.ByteArrayInputStream;+import java.io.ByteArrayOutputStream;+import java.io.IOException;+import java.io.InputStream;+import java.io.InputStreamReader;+import java.io.OutputStream;+import java.io.OutputStreamWriter;+import java.io.Reader;+import java.io.StringReader;+import java.io.StringWriter;+import java.io.Writer;+import java.util.Hashtable;++/**+ * Base64 encoding/decoding utilities+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class Base64 {++ private static final Base64 _theInstance = new Base64();++ private Base64() {+ }++ public static Base64 getInstance() {+ return _theInstance;+ }+++ /**+ * Description of the Field+ */+ public final static char[] charset =+ {+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',+ 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',+ 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',+ 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',+ 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',+ 'w', 'x', 'y', 'z', '0', '1', '2', '3',+ '4', '5', '6', '7', '8', '9', '+', '/'+ };++ /**+ * Description of the Field+ */+ public final static char paddingChar = '=';++ /**+ * Description of the Field+ */+ protected static Hashtable charLookup = new Hashtable();++ static {+ //initialize the hashtable++ for (int i = 0; i < charset.length; i++) {+ charLookup.put(new Character(charset[i]),+ new Integer(i));+ }+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@param out Description of the Parameter+ *@exception Exception Description of the Exception+ */+ public static void decode(Reader in, OutputStream out)+ throws Exception {+ char[] chars = new char[4];+ int[] sixbit = new int[4];++ //--Process the input stream in 4-character chunks+ while (true) {+ int numread = 0;++ while (numread < 4) {+ int read = in.read();+ if (read < 0) {+ break;+ }+ //end of input++ char aChar = (char) read;++ if (Character.isWhitespace(aChar)) {+ continue;+ }+ //skip w/s++ chars[numread++] = aChar;+ }++ if (numread == 0) {+ return;+ }+ //end of input++ if (numread != 4) {+ throw new Exception("Incomplete character quartet at end of Base64 input");+ }++ //--Convert chars to six-bit values+ for (int i = 0; i < 4; i++) {+ Integer value = (Integer) charLookup.get(new Character(chars[i]));++ if (value == null) {+ if (chars[i] != '=' || i < 2) {+ throw new Exception("Invalid char ("+ + chars[i] + ") in Base64 data");+ }++ sixbit[i] = -1;+ } else {+ sixbit[i] = value.intValue();+ }+ }++ //--Write first 6 bits and top 2 bits from second value+ out.write((sixbit[0] << 2) + (sixbit[1] >> 4));+ //System.out.println( (sixbit[0] << 2) + (sixbit[1] >> 4) );++ //--Get bottom four bits of second value+ int val = (sixbit[1] & 0xf) << 4;++ if (sixbit[2] >= 0) {+ //third value is valid++ //--Add top four bits of third value+ val += sixbit[2] >> 2;++ out.write(val);+ //System.out.println( val );++ //--Get bottom two bits of third value+ val = (sixbit[2] & 0x3) << 6;++ if (sixbit[3] >= 0) {+ //fourth value is valid++ val += sixbit[3];++ out.write(val);+ //System.out.println( val );+ }+ }+ }+ }+++ /**+ * Description of the Method+ *+ *@param base64 Description of the Parameter+ *@return Description of the Return Value+ *@exception Exception Description of the Exception+ */+ public static byte[] decode(String base64)+ throws Exception {+ //if base64 is invalid++ ByteArrayOutputStream out = new ByteArrayOutputStream();+ StringReader in = new StringReader(base64);++ decode(in, out);++ in.close();+ out.flush();+ out.close();++ return out.toByteArray();+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@param out Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public static void encode(InputStream in, Writer out)+ throws IOException {+ int column = 0;++ //--Process 3 bytes in each loop - writing 4 base64 chars to the output+ while (true) {+ int byte1 = in.read();+ int byte2 = in.read();+ int byte3 = in.read();++ if (byte1 < 0) {+ return;+ }+ //end-of-data++ //--Wrap output at column 72+ if (column >= 72) {+ column = 0;+ out.write('\n');+ }++ out.write(charset[byte1 >> 2]);+ //write top 6 bits of byte 1++ int index = (byte1 & 0x3) << 4;+ //get bottom two bits of byte 1++ if (byte2 < 0) {+ //no more data++ out.write(charset[index]);+ out.write(paddingChar);+ out.write(paddingChar);+ return;+ }++ index += byte2 >> 4;+ //add the top 4 bits of byte 2+ out.write(charset[index]);++ index = (byte2 & 0xf) << 2;+ //get bottom 4 bits of byte 2++ if (byte3 < 0) {+ //more more data++ out.write(charset[index]);+ out.write(paddingChar);+ return;+ }++ index += byte3 >> 6;+ //add top 2 bits of byte 3+ out.write(charset[index]);++ out.write(charset[byte3 & 0x3f]);+ //write bottom 6 bits of byte 3++ //--Advance column counter+ column += 4;+ }+ }+++ /**+ * Description of the Method+ *+ *@param data Description of the Parameter+ *@return Description of the Return Value+ */+ public static String encode(byte[] data) {+ try {+ return encode(data, 0, data.length);+ } catch (ArrayIndexOutOfBoundsException aiobe) {+ return aiobe.toString();+ }+ }+++ /**+ * Description of the Method+ *+ *@param data Description of the Parameter+ *@param start Description of the Parameter+ *@param length Description of the Parameter+ *@return Description of the Return+ * Value+ *@exception ArrayIndexOutOfBoundsException Description of the Exception+ */+ public static String encode(byte[] data, int start, int length)+ throws ArrayIndexOutOfBoundsException {+ StringWriter out = new StringWriter();+ ByteArrayInputStream in = new ByteArrayInputStream(data, start, length);++ try {+ encode(in, out);+ in.close();+ out.flush();+ out.close();+ } catch (IOException ioe) {+ return ioe.toString();+ }++ return out.toString();+ }+++ /**+ * If args.length > 0 then encode binary on stdin to base64 on stdout, else+ * decode base64 on stdin to binary on stdout+ *+ *@param args The command line arguments+ *@exception Exception Description of the Exception+ */+ public static void main(String[] args) throws Exception {+ if (args.length > 0) {+ OutputStreamWriter out = new OutputStreamWriter(System.out);+ encode(System.in, out);+ out.flush();+ return;+ }++ decode(new InputStreamReader(System.in), System.out);+ System.out.flush();+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ButtonRecord.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ButtonRecord.javanew file mode 100644index 000000000..75d8f0a13--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ButtonRecord.java@@ -0,0 +1,260 @@+package pt.tumba.parser.swf;++import java.io.IOException;+import java.util.Iterator;+import java.util.List;+import java.util.Vector;++/**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class ButtonRecord {+ /**+ * Description of the Field+ */+ public final static int BUTTON_HITTEST = 0x08;+ /**+ * Description of the Field+ */+ public final static int BUTTON_DOWN = 0x04;+ /**+ * Description of the Field+ */+ public final static int BUTTON_OVER = 0x02;+ /**+ * Description of the Field+ */+ public final static int BUTTON_UP = 0x01;++ /**+ * Description of the Field+ */+ protected int flags;+ /**+ * Description of the Field+ */+ protected int id;+ /**+ * Description of the Field+ */+ protected int layer;+ /**+ * Description of the Field+ */+ protected Matrix matrix;+++ /**+ * Gets the charId attribute of the ButtonRecord object+ *+ *@return The charId value+ */+ public int getCharId() {+ return id;+ }+++ /**+ * Gets the layer attribute of the ButtonRecord object+ *+ *@return The layer value+ */+ public int getLayer() {+ return layer;+ }+++ /**+ * Gets the matrix attribute of the ButtonRecord object+ *+ *@return The matrix value+ */+ public Matrix getMatrix() {+ return matrix;+ }+++ /**+ * Gets the flags attribute of the ButtonRecord object+ *+ *@return The flags value+ */+ public int getFlags() {+ return flags;+ }+++ /**+ * Gets the hitTest attribute of the ButtonRecord object+ *+ *@return The hitTest value+ */+ public boolean isHitTest() {+ return ((flags & BUTTON_HITTEST) != 0);+ }+++ /**+ * Gets the down attribute of the ButtonRecord object+ *+ *@return The down value+ */+ public boolean isDown() {+ return ((flags & BUTTON_DOWN) != 0);+ }+++ /**+ * Gets the over attribute of the ButtonRecord object+ *+ *@return The over value+ */+ public boolean isOver() {+ return ((flags & BUTTON_OVER) != 0);+ }+++ /**+ * Gets the up attribute of the ButtonRecord object+ *+ *@return The up value+ */+ public boolean isUp() {+ return ((flags & BUTTON_UP) != 0);+ }+++ /**+ * Sets the charId attribute of the ButtonRecord object+ *+ *@param id The new charId value+ */+ public void setCharId(int id) {+ this.id = id;+ }+++ /**+ * Sets the layer attribute of the ButtonRecord object+ *+ *@param layer The new layer value+ */+ public void setLayer(int layer) {+ this.layer = layer;+ }+++ /**+ * Sets the matrix attribute of the ButtonRecord object+ *+ *@param matrix The new matrix value+ */+ public void setMatrix(Matrix matrix) {+ this.matrix = matrix;+ }+++ /**+ * Sets the flags attribute of the ButtonRecord object+ *+ *@param flags The new flags value+ */+ public void setFlags(int flags) {+ this.flags = flags;+ }+++ /**+ * Read a button record array+ *+ *@param in Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public static List read(InStream in) throws IOException {+ Vector records = new Vector();++ int firstByte = 0;+ while ((firstByte = in.readUI8()) != 0) {+ records.addElement(new ButtonRecord(in, firstByte));+ }++ return records;+ }+++ /**+ * Write a button record array+ *+ *@param out Description of the Parameter+ *@param records Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public static void write(OutStream out, List records) throws IOException {+ for (Iterator enumerator = records.iterator(); enumerator.hasNext(); ) {+ ButtonRecord rec = (ButtonRecord) enumerator.next();+ rec.write(out);+ }++ out.writeUI8(0);+ }+++ /**+ * Constructor for the ButtonRecord object+ *+ *@param id Description of the Parameter+ *@param layer Description of the Parameter+ *@param matrix Description of the Parameter+ *@param flags Description of the Parameter+ */+ public ButtonRecord(int id, int layer, Matrix matrix, int flags) {+ this.id = id;+ this.layer = layer;+ this.matrix = matrix;+ this.flags = flags;+ }+++ /**+ * Constructor for the ButtonRecord object+ *+ *@param in Description of the Parameter+ *@param firstByte Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected ButtonRecord(InStream in, int firstByte) throws IOException {+ flags = firstByte;+ id = in.readUI16();+ layer = in.readUI16();+ matrix = new Matrix(in);+ }+++ /**+ * Description of the Method+ *+ *@param out Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void write(OutStream out) throws IOException {+ out.writeUI8(flags);+ out.writeUI16(id);+ out.writeUI16(layer);+ matrix.write(out);+ }+++ /**+ * Description of the Method+ *+ *@return Description of the Return Value+ */+ public String toString() {+ return "layer=" + layer + " id=" + id ++ " flags=" + Integer.toBinaryString(flags) + " " + matrix;+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ButtonRecord2.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ButtonRecord2.javanew file mode 100644index 000000000..6a2134b14--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ButtonRecord2.java@@ -0,0 +1,129 @@+package pt.tumba.parser.swf;++import java.io.IOException;+import java.util.Iterator;+import java.util.List;+import java.util.Vector;++/**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class ButtonRecord2 extends ButtonRecord {+ /**+ * Description of the Field+ */+ protected AlphaTransform transform;+++ /**+ * Gets the transform attribute of the ButtonRecord2 object+ *+ *@return The transform value+ */+ public AlphaTransform getTransform() {+ return transform;+ }+++ /**+ * Sets the transform attribute of the ButtonRecord2 object+ *+ *@param transform The new transform value+ */+ public void setTransform(AlphaTransform transform) {+ this.transform = transform;+ }+++ /**+ * Read a button record array+ *+ *@param in Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public static List read(InStream in) throws IOException {+ Vector records = new Vector();++ int firstByte = 0;+ while ((firstByte = in.readUI8()) != 0) {+ records.addElement(new ButtonRecord2(in, firstByte));+ }++ return records;+ }+++ /**+ * Write a button record array+ *+ *@param out Description of the Parameter+ *@param records Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public static void write(OutStream out, List records) throws IOException {+ for (Iterator enumerator = records.iterator(); enumerator.hasNext(); ) {+ ButtonRecord2 rec = (ButtonRecord2) enumerator.next();+ rec.write(out);+ }++ out.writeUI8(0);+ }+++ /**+ * Constructor for the ButtonRecord2 object+ *+ *@param id Description of the Parameter+ *@param layer Description of the Parameter+ *@param matrix Description of the Parameter+ *@param transform Description of the Parameter+ *@param flags Description of the Parameter+ */+ public ButtonRecord2(int id,+ int layer,+ Matrix matrix,+ AlphaTransform transform,+ int flags) {+ super(id, layer, matrix, flags);+ this.transform = transform;+ }+++ /**+ * Constructor for the ButtonRecord2 object+ *+ *@param in Description of the Parameter+ *@param firstByte Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected ButtonRecord2(InStream in, int firstByte) throws IOException {+ super(in, firstByte);+ transform = new AlphaTransform(in);+ }+++ /**+ * Description of the Method+ *+ *@param out Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void write(OutStream out) throws IOException {+ super.write(out);+ transform.write(out);+ }+++ /**+ * Description of the Method+ *+ *@return Description of the Return Value+ */+ public String toString() {+ return super.toString() + " " + transform;+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Color.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Color.javanew file mode 100644index 000000000..58a607fac--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Color.java@@ -0,0 +1,176 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * An RGB Color without alpha+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class Color {+ /**+ * Description of the Field+ */+ protected int red;+ /**+ * Description of the Field+ */+ protected int green;+ /**+ * Description of the Field+ */+ protected int blue;+++ /**+ * Gets the red attribute of the Color object+ *+ *@return The red value+ */+ public int getRed() {+ return red;+ }+++ /**+ * Gets the green attribute of the Color object+ *+ *@return The green value+ */+ public int getGreen() {+ return green;+ }+++ /**+ * Gets the blue attribute of the Color object+ *+ *@return The blue value+ */+ public int getBlue() {+ return blue;+ }+++ /**+ * Sets the red attribute of the Color object+ *+ *@param red The new red value+ */+ public void setRed(int red) {+ this.red = red;+ }+++ /**+ * Sets the green attribute of the Color object+ *+ *@param green The new green value+ */+ public void setGreen(int green) {+ this.green = green;+ }+++ /**+ * Sets the blue attribute of the Color object+ *+ *@param blue The new blue value+ */+ public void setBlue(int blue) {+ this.blue = blue;+ }+++ /**+ * Constructor for the Color object+ *+ *@param red Description of the Parameter+ *@param green Description of the Parameter+ *@param blue Description of the Parameter+ */+ public Color(int red, int green, int blue) {+ this.red = red;+ this.green = green;+ this.blue = blue;+ }+++ /**+ * Constructor for the Color object+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public Color(InStream in) throws IOException {+ red = in.readUI8();+ green = in.readUI8();+ blue = in.readUI8();+ }+++ /**+ * Description of the Method+ *+ *@param out Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void write(OutStream out) throws IOException {+ writeRGB(out);+ }+++ /**+ * Description of the Method+ *+ *@param color Description of the Parameter+ *@return Description of the Return Value+ */+ public boolean equals(Object color) {+ return (red == ((Color)color).getRed())+ && (green == ((Color)color).getGreen())+ && (blue == ((Color)color).getBlue());+ }++ public int hashCode () {+ return super.hashCode();+ }++++ /**+ * Description of the Method+ *+ *@param out Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void writeRGB(OutStream out) throws IOException {+ out.writeUI8(red);+ out.writeUI8(green);+ out.writeUI8(blue);+ }+++ /**+ * Description of the Method+ *+ *@param out Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void writeWithAlpha(OutStream out) throws IOException {+ writeRGB(out);+ out.writeUI8(0xff);+ //fully opaque alpha+ }+++ /**+ * Description of the Method+ *+ *@return Description of the Return Value+ */+ public String toString() {+ return "RGB(" + red + "," + green + "," + blue + ")";+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ColorTransform.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ColorTransform.javanew file mode 100644index 000000000..2d9e7dae4--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ColorTransform.java@@ -0,0 +1,442 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class ColorTransform {+ /**+ * Description of the Field+ */+ protected double multRed = 1.0;+ /**+ * Description of the Field+ */+ protected double multGreen = 1.0;+ /**+ * Description of the Field+ */+ protected double multBlue = 1.0;++ /**+ * Description of the Field+ */+ protected int addRed = 0;+ /**+ * Description of the Field+ */+ protected int addGreen = 0;+ /**+ * Description of the Field+ */+ protected int addBlue = 0;++ /**+ * Description of the Field+ */+ protected double multAlpha = 1.0;+ //used by AlphaTransform+ /**+ * Description of the Field+ */+ protected int addAlpha = 0;+++ //used by AlphaTransform++ /**+ * Gets the multRed attribute of the ColorTransform object+ *+ *@return The multRed value+ */+ public double getMultRed() {+ return multRed;+ }+++ /**+ * Gets the multGreen attribute of the ColorTransform object+ *+ *@return The multGreen value+ */+ public double getMultGreen() {+ return multGreen;+ }+++ /**+ * Gets the multBlue attribute of the ColorTransform object+ *+ *@return The multBlue value+ */+ public double getMultBlue() {+ return multBlue;+ }+++ /**+ * Gets the addRed attribute of the ColorTransform object+ *+ *@return The addRed value+ */+ public int getAddRed() {+ return addRed;+ }+++ /**+ * Gets the addGreen attribute of the ColorTransform object+ *+ *@return The addGreen value+ */+ public int getAddGreen() {+ return addGreen;+ }+++ /**+ * Gets the addBlue attribute of the ColorTransform object+ *+ *@return The addBlue value+ */+ public int getAddBlue() {+ return addBlue;+ }+++ /**+ * Sets the multRed attribute of the ColorTransform object+ *+ *@param multRed The new multRed value+ */+ public void setMultRed(double multRed) {+ this.multRed = multRed;+ }+++ /**+ * Sets the multGreen attribute of the ColorTransform object+ *+ *@param multGreen The new multGreen value+ */+ public void setMultGreen(double multGreen) {+ this.multGreen = multGreen;+ }+++ /**+ * Sets the multBlue attribute of the ColorTransform object+ *+ *@param multBlue The new multBlue value+ */+ public void setMultBlue(double multBlue) {+ this.multBlue = multBlue;+ }+++ /**+ * Sets the addRed attribute of the ColorTransform object+ *+ *@param addRed The new addRed value+ */+ public void setAddRed(int addRed) {+ this.addRed = addRed;+ }+++ /**+ * Sets the addGreen attribute of the ColorTransform object+ *+ *@param addGreen The new addGreen value+ */+ public void setAddGreen(int addGreen) {+ this.addGreen = addGreen;+ }+++ /**+ * Sets the addBlue attribute of the ColorTransform object+ *+ *@param addBlue The new addBlue value+ */+ public void setAddBlue(int addBlue) {+ this.addBlue = addBlue;+ }+++ /**+ * An identity transform+ */+ public ColorTransform() { }+++ /**+ * Constructor for the ColorTransform object+ *+ *@param multRed Description of the Parameter+ *@param multGreen Description of the Parameter+ *@param multBlue Description of the Parameter+ *@param addRed Description of the Parameter+ *@param addGreen Description of the Parameter+ *@param addBlue Description of the Parameter+ */+ public ColorTransform(double multRed, double multGreen, double multBlue,+ int addRed, int addGreen, int addBlue) {+ this.multRed = multRed;+ this.multGreen = multGreen;+ this.multBlue = multBlue;+ this.addRed = addRed;+ this.addGreen = addGreen;+ this.addBlue = addBlue;+ }+++ /**+ * Constructor for the ColorTransform object+ *+ *@param addRed Description of the Parameter+ *@param addGreen Description of the Parameter+ *@param addBlue Description of the Parameter+ */+ public ColorTransform(int addRed, int addGreen, int addBlue) {+ this.addRed = addRed;+ this.addGreen = addGreen;+ this.addBlue = addBlue;+ }+++ /**+ * Constructor for the ColorTransform object+ *+ *@param multRed Description of the Parameter+ *@param multGreen Description of the Parameter+ *@param multBlue Description of the Parameter+ */+ public ColorTransform(double multRed, double multGreen, double multBlue) {+ this.multRed = multRed;+ this.multGreen = multGreen;+ this.multBlue = multBlue;+ }+++ /**+ * Constructor for the ColorTransform object+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public ColorTransform(InStream in) throws IOException {+ in.synchBits();++ //--Add and mult are reversed+ boolean hasAddTerms = (in.readUBits(1) == 1);+ boolean hasMultTerms = (in.readUBits(1) == 1);++ int numBits = (int) in.readUBits(4);++ if (hasMultTerms) {+ multRed = ((double) in.readSBits(numBits)) / 256.0;+ multGreen = ((double) in.readSBits(numBits)) / 256.0;+ multBlue = ((double) in.readSBits(numBits)) / 256.0;+ }++ if (hasAddTerms) {+ addRed = in.readSBits(numBits);+ addGreen = in.readSBits(numBits);+ addBlue = in.readSBits(numBits);+ }+ }+++ /**+ * Description of the Method+ *+ *@param out Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void write(OutStream out) throws IOException {+ out.flushBits();++ boolean hasAddTerms = (addRed != 0)+ || (addGreen != 0)+ || (addBlue != 0);++ boolean hasMultTerms = (multRed != 1.0)+ || (multGreen != 1.0)+ || (multBlue != 1.0);++ int intMultRed = (int) (multRed * 256.0);+ int intMultGreen = (int) (multGreen * 256.0);+ int intMultBlue = (int) (multBlue * 256.0);++ //--Figure out the bit sizes+ int numBits = 1;++ if (hasAddTerms) {+ int redBits = OutStream.determineSignedBitSize(addRed);+ int greenBits = OutStream.determineSignedBitSize(addGreen);+ int blueBits = OutStream.determineSignedBitSize(addBlue);++ if (numBits < redBits) {+ numBits = redBits;+ }+ if (numBits < greenBits) {+ numBits = greenBits;+ }+ if (numBits < blueBits) {+ numBits = blueBits;+ }+ }++ if (hasMultTerms) {+ int redBits = OutStream.determineSignedBitSize(intMultRed);+ int greenBits = OutStream.determineSignedBitSize(intMultGreen);+ int blueBits = OutStream.determineSignedBitSize(intMultBlue);++ if (numBits < redBits) {+ numBits = redBits;+ }+ if (numBits < greenBits) {+ numBits = greenBits;+ }+ if (numBits < blueBits) {+ numBits = blueBits;+ }+ }++ //--Add and mult are reversed+ out.writeUBits(1, hasAddTerms ? 1L : 0L);+ out.writeUBits(1, hasMultTerms ? 1L : 0L);+ out.writeUBits(4, numBits);++ if (hasMultTerms) {+ out.writeSBits(numBits, intMultRed);+ out.writeSBits(numBits, intMultGreen);+ out.writeSBits(numBits, intMultBlue);+ }++ if (hasAddTerms) {+ out.writeSBits(numBits, addRed);+ out.writeSBits(numBits, addGreen);+ out.writeSBits(numBits, addBlue);+ }++ out.flushBits();+ }+++ /**+ * Description of the Method+ *+ *@param out Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void writeWithoutAlpha(OutStream out) throws IOException {+ write(out);+ }+++ /**+ * Description of the Method+ *+ *@param out Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void writeWithAlpha(OutStream out) throws IOException {+ out.flushBits();++ boolean hasAddTerms = (addRed != 0)+ || (addGreen != 0)+ || (addBlue != 0)+ || (addAlpha != 0);++ boolean hasMultTerms = (multRed != 1.0)+ || (multGreen != 1.0)+ || (multBlue != 1.0)+ || (multAlpha != 1.0);++ int intMultRed = (int) (multRed * 256.0);+ int intMultGreen = (int) (multGreen * 256.0);+ int intMultBlue = (int) (multBlue * 256.0);+ int intMultAlpha = (int) (multAlpha * 256.0);++ //--Figure out the bit sizes+ int numBits = 1;++ if (hasAddTerms) {+ int redBits = OutStream.determineSignedBitSize(addRed);+ int greenBits = OutStream.determineSignedBitSize(addGreen);+ int blueBits = OutStream.determineSignedBitSize(addBlue);+ int alphaBits = OutStream.determineSignedBitSize(addAlpha);++ if (numBits < redBits) {+ numBits = redBits;+ }+ if (numBits < greenBits) {+ numBits = greenBits;+ }+ if (numBits < blueBits) {+ numBits = blueBits;+ }+ if (numBits < alphaBits) {+ numBits = alphaBits;+ }+ }++ if (hasMultTerms) {+ int redBits = OutStream.determineSignedBitSize(intMultRed);+ int greenBits = OutStream.determineSignedBitSize(intMultGreen);+ int blueBits = OutStream.determineSignedBitSize(intMultBlue);+ int alphaBits = OutStream.determineSignedBitSize(intMultAlpha);++ if (numBits < redBits) {+ numBits = redBits;+ }+ if (numBits < greenBits) {+ numBits = greenBits;+ }+ if (numBits < blueBits) {+ numBits = blueBits;+ }+ if (numBits < alphaBits) {+ numBits = alphaBits;+ }+ }++ //--Add and mult are reversed+ out.writeUBits(1, hasAddTerms ? 1L : 0L);+ out.writeUBits(1, hasMultTerms ? 1L : 0L);+ out.writeUBits(4, numBits);++ if (hasMultTerms) {+ out.writeSBits(numBits, intMultRed);+ out.writeSBits(numBits, intMultGreen);+ out.writeSBits(numBits, intMultBlue);+ out.writeSBits(numBits, intMultAlpha);+ }++ if (hasAddTerms) {+ out.writeSBits(numBits, addRed);+ out.writeSBits(numBits, addGreen);+ out.writeSBits(numBits, addBlue);+ out.writeSBits(numBits, addAlpha);+ }++ out.flushBits();+ }+++ /**+ * Description of the Method+ *+ *@return Description of the Return Value+ */+ public String toString() {+ return " cxform(+rgb,*rgb)=(" + addRed + "," + addGreen + "," + addBlue+ + "," + multRed + "," + multGreen + "," + multBlue + ")";+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ExportedSymbol.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ExportedSymbol.javanew file mode 100644index 000000000..ae854649e--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ExportedSymbol.java@@ -0,0 +1,51 @@+package pt.tumba.parser.swf;+++/**+ * Information about a symbol exported from the movie+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class ExportedSymbol {+ /**+ * Description of the Field+ */+ protected Symbol symbol;+ /**+ * Description of the Field+ */+ protected String exportName;+++ /**+ * Gets the symbol attribute of the ExportedSymbol object+ *+ *@return The symbol value+ */+ public Symbol getSymbol() {+ return symbol;+ }+++ /**+ * Gets the exportName attribute of the ExportedSymbol object+ *+ *@return The exportName value+ */+ public String getExportName() {+ return exportName;+ }+++ /**+ * Constructor for the ExportedSymbol object+ *+ *@param s Description of the Parameter+ *@param name Description of the Parameter+ */+ protected ExportedSymbol(Symbol s, String name) {+ symbol = s;+ exportName = name;+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/FillStyle.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/FillStyle.javanew file mode 100644index 000000000..03c73dcbe--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/FillStyle.java@@ -0,0 +1,240 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class FillStyle implements Style {+ /**+ * Description of the Field+ */+ protected int fillType;+ /**+ * Description of the Field+ */+ protected Color color;+ /**+ * Description of the Field+ */+ protected Matrix matrix;+ /**+ * Description of the Field+ */+ protected int[] ratios;+ //for gradient fill+ /**+ * Description of the Field+ */+ protected Color[] colors;+ //for gradient fill+ /**+ * Description of the Field+ */+ protected int bitmapId;+++ /**+ * Gets the type attribute of the FillStyle object+ *+ *@return The type value+ */+ public int getType() {+ return fillType;+ }+++ /**+ * Gets the solidColor attribute of the FillStyle object+ *+ *@return The solidColor value+ */+ public Color getSolidColor() {+ return color;+ }+++ /**+ * Gets the matrix attribute of the FillStyle object+ *+ *@return The matrix value+ */+ public Matrix getMatrix() {+ return matrix;+ }+++ /**+ * Gets the imageId attribute of the FillStyle object+ *+ *@return The imageId value+ */+ public int getImageId() {+ return bitmapId;+ }+++ /**+ * Gets the gradientRatios attribute of the FillStyle object+ *+ *@return The gradientRatios value+ */+ public int[] getGradientRatios() {+ return ratios;+ }+++ /**+ * Gets the gradientColors attribute of the FillStyle object+ *+ *@return The gradientColors value+ */+ public Color[] getGradientColors() {+ return colors;+ }+++ /**+ * Solid color fill (alpha depends on the TagDefineShapeX tag used)+ *+ *@param solidColor Description of the Parameter+ */+ public FillStyle(Color solidColor) {+ fillType = SWFConstants.FILL_SOLID;+ color = solidColor;+ }+++ /**+ * Linear/Radial Gradient Fill+ *+ *@param matrix Description of the Parameter+ *@param ratios Description of the Parameter+ *@param colors Description of the Parameter+ *@param radial Description of the Parameter+ */+ public FillStyle(Matrix matrix, int[] ratios,+ Color[] colors, boolean radial) {+ this.matrix = matrix;+ this.ratios = ratios;+ this.colors = colors;++ fillType = radial ? SWFConstants.FILL_RADIAL_GRADIENT :+ SWFConstants.FILL_LINEAR_GRADIENT;+ }+++ /**+ * Bitmap fill+ *+ *@param bitmapId Description of the Parameter+ *@param matrix Description of the Parameter+ *@param clipped Description of the Parameter+ */+ public FillStyle(int bitmapId, Matrix matrix, boolean clipped) {+ this.matrix = matrix;+ this.bitmapId = bitmapId;++ fillType = clipped ? SWFConstants.FILL_CLIPPED_BITMAP :+ SWFConstants.FILL_TILED_BITMAP;+ }+++ /**+ * Description of the Method+ *+ *@param out Description of the Parameter+ *@param hasAlpha Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void write(OutStream out, boolean hasAlpha) throws IOException {+ out.writeUI8(fillType);++ if (fillType == SWFConstants.FILL_SOLID) {+ if (hasAlpha) {+ color.writeWithAlpha(out);+ } else {+ color.writeRGB(out);+ }+ } else if (fillType == SWFConstants.FILL_LINEAR_GRADIENT+ || fillType == SWFConstants.FILL_RADIAL_GRADIENT) {+ matrix.write(out);++ int numRatios = ratios.length;++ out.writeUI8(numRatios);++ for (int i = 0; i < numRatios; i++) {+ if (colors[i] == null) {+ continue;+ }++ out.writeUI8(ratios[i]);++ if (hasAlpha) {+ colors[i].writeWithAlpha(out);+ } else {+ colors[i].writeRGB(out);+ }+ }+ } else if (fillType == SWFConstants.FILL_TILED_BITMAP+ || fillType == SWFConstants.FILL_CLIPPED_BITMAP) {+ out.writeUI16(bitmapId);+ matrix.write(out);+ }+ }+++ /**+ * Description of the Method+ *+ *@param out Description of the Parameter+ *@param startStyle Description of the Parameter+ *@param endStyle Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public static void writeMorphFillStyle(OutStream out,+ FillStyle startStyle,+ FillStyle endStyle)+ throws IOException {+ int fillType = startStyle.fillType;++ out.writeUI8(fillType);++ if (fillType == SWFConstants.FILL_SOLID) {+ startStyle.color.writeWithAlpha(out);+ endStyle.color.writeWithAlpha(out);+ } else if (fillType == SWFConstants.FILL_LINEAR_GRADIENT+ || fillType == SWFConstants.FILL_RADIAL_GRADIENT) {+ startStyle.matrix.write(out);+ endStyle.matrix.write(out);++ int numRatios = startStyle.ratios.length;+ out.writeUI8(startStyle.ratios.length);++ for (int i = 0; i < numRatios; i++) {+ if (startStyle.colors[i] == null ||+ endStyle.colors[i] == null) {+ continue;+ }++ out.writeUI8(startStyle.ratios[i]);+ startStyle.colors[i].writeWithAlpha(out);++ out.writeUI8(endStyle.ratios[i]);+ endStyle.colors[i].writeWithAlpha(out);+ }+ } else if (fillType == SWFConstants.FILL_TILED_BITMAP+ || fillType == SWFConstants.FILL_CLIPPED_BITMAP) {+ int bitmapId = startStyle.bitmapId;++ out.writeUI16(bitmapId);++ startStyle.matrix.write(out);+ endStyle.matrix.write(out);+ }+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Font.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Font.javanew file mode 100644index 000000000..e048128a6--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Font.java@@ -0,0 +1,646 @@+package pt.tumba.parser.swf;++import java.io.IOException;+import java.util.ArrayList;+import java.util.HashMap;+import java.util.Iterator;+import java.util.List;+import java.util.Map;++/**+ * A Font Symbol. The Font references a FontDefinition object from which it+ * takes the glyph definitions it needs.+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class Font extends Symbol {+ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public class NoGlyphException extends Exception {+ /**+ * Description of the Field+ */+ public int code;+++ /**+ * Constructor for the NoGlyphException object+ *+ *@param code Description of the Parameter+ */+ public NoGlyphException(int code) {+ super("The font does not have a glyph definition for code " + code);+ this.code = code;+ }+ }+++ /**+ * A set of contiguous characters in one font.+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public class Chars {+ /**+ * Description of the Field+ */+ protected String chars;+ /**+ * Description of the Field+ */+ protected double size;+ /**+ * Description of the Field+ */+ protected int[] indices;+ /**+ * Description of the Field+ */+ protected int[] advances;++ /**+ * Description of the Field+ */+ protected double totalAdvance;+ //total advance+ /**+ * Description of the Field+ */+ protected double ascent;+ /**+ * Description of the Field+ */+ protected double descent;+ /**+ * Description of the Field+ */+ protected double leftMargin;+ /**+ * Description of the Field+ */+ protected double rightMargin;+++ /**+ * Description of the Method+ *+ *@return Description of the Return Value+ */+ public String toString() {+ return chars;+ }+++ /**+ * Gets the font attribute of the Chars object+ *+ *@return The font value+ */+ public Font getFont() {+ return Font.this;+ }+++ /**+ * Gets the size attribute of the Chars object+ *+ *@return The size value+ */+ public double getSize() {+ return size;+ }+++ /**+ * Gets the totalAdvance attribute of the Chars object+ *+ *@return The totalAdvance value+ */+ public double getTotalAdvance() {+ return totalAdvance;+ }+++ /**+ * Gets the ascent attribute of the Chars object+ *+ *@return The ascent value+ */+ public double getAscent() {+ return ascent;+ }+++ /**+ * Gets the descent attribute of the Chars object+ *+ *@return The descent value+ */+ public double getDescent() {+ return descent;+ }+++ /**+ * The left margin is the difference between the origin of the first+ * glyph and the left edge of its geometry+ *+ *@return The leftMargin value+ */+ public double getLeftMargin() {+ return leftMargin;+ }+++ /**+ * The right margin is the different between the total advance and the+ * right edge of the geometry of the last glyph+ *+ *@return The rightMargin value+ */+ public double getRightMargin() {+ return rightMargin;+ }+++ /**+ *@param chars the characters to display (displayable+ * chars only - i.e. no newlines, tabs etc..)+ *@param size point-size - only relevant if font is+ * not null+ *@exception NoGlyphException Description of the Exception+ */+ protected Chars(String chars, double size) throws NoGlyphException {+ this.chars = chars;+ this.size = size;+ init();+ }+++ /**+ * Description of the Method+ *+ *@exception NoGlyphException Description of the Exception+ */+ protected final void init() throws NoGlyphException {+ //--Figure out the indices and advances+ char[] codes = chars.toCharArray();+ indices = new int[codes.length];+ advances = new int[codes.length];++ double maxAscent = 0.0;+ double maxDescent = 0.0;++ double scale = size * SWFConstants.TWIPS / 1024.0;++ for (int i = 0; i < codes.length; i++) {+ int code = (int) codes[i];++ int[] index = new int[1];+ FontDefinition.Glyph glyph = getGlyph(code, index);++ indices[i] = index[0];++ if (glyph != null) {+ Shape shape = glyph.getShape();++ double[] outline = shape.getBoundingRectangle();+ double x1 = outline[0] * scale;+ double y1 = outline[1] * scale;+ double x2 = outline[2] * scale;+ double y2 = outline[3] * scale;++ if (maxAscent < -y1) {+ maxAscent = -y1;+ }+ if (maxDescent < y2) {+ maxDescent = y2;+ }++ double advance = glyph.getAdvance() * scale;+ if (advance == 0) {+ advance = x2 - x1;+ }++ //Kerning adjustment+ if (i < codes.length - 1) {+ advance += (fontDef.getKerningOffset(code, (int) codes[i + 1]) * scale);+ }++ totalAdvance += advance;++ advances[i] = (int) (advance * SWFConstants.TWIPS);++ if (i == 0) {+ leftMargin = -y1;+ }+ if (i == codes.length - 1) {+ rightMargin = x2 - advance;+ }+ }+ }++ ascent = fontDef.getAscent() * scale;+ if (ascent == 0.0) {+ ascent = maxAscent;+ }++ descent = fontDef.getDescent() * scale;+ if (descent == 0.0) {+ descent = maxDescent;+ }+ }+ }+++ /**+ * Description of the Field+ */+ protected Object font1Key = new Object();+ //used in movie defined symbols lookup+ /**+ * Description of the Field+ */+ protected Object font2Key = new Object();+ //used in movie defined symbols lookup++ /**+ * Description of the Field+ */+ protected FontDefinition fontDef;+ /**+ * Description of the Field+ */+ protected Map glyphs = new HashMap();+ //glyphs used by this font+ /**+ * Description of the Field+ */+ protected Map indices = new HashMap();+ //glyph indices+ /**+ * Description of the Field+ */+ protected List glyphList = new ArrayList();+++ /**+ * Gets the definition attribute of the Font object+ *+ *@return The definition value+ */+ public FontDefinition getDefinition() {+ return fontDef;+ }+++ /**+ * Constructor for the Font object+ *+ *@param fontDef Description of the Parameter+ */+ public Font(FontDefinition fontDef) {+ this.fontDef = fontDef;+ }+++ /**+ * Gets the glyphList attribute of the Font object+ *+ *@return The glyphList value+ */+ public List getGlyphList() {+ return glyphList;+ }+++ /**+ * Load the glyphs for the characters in the given string from the+ * FontDefinition into this font.+ *+ *@param chars Description of the Parameter+ *@exception NoGlyphException+ */+ public void loadGlyphs(String chars) throws NoGlyphException {+ char[] chs = chars.toCharArray();+ for (int i = 0; i < chs.length; i++) {+ getGlyph(chs[i], null);+ }+ }+++ /**+ * Load all glyphs from the font definition+ */+ public void loadAllGlyphs() {+ List list = fontDef.getGlyphList();++ for (Iterator it = list.iterator(); it.hasNext(); ) {+ FontDefinition.Glyph g = (FontDefinition.Glyph) it.next();++ addGlyph(g);+ }+ }+++ /**+ * Get the Chars instance for the given string at the given font size+ *+ *@param chars Description of the Parameter+ *@param fontSize Description of the Parameter+ *@return Description of the Return Value+ *@exception NoGlyphException Description of the Exception+ */+ public Chars chars(String chars, double fontSize)+ throws NoGlyphException {+ return new Chars(chars, fontSize);+ }+++ /**+ * Gets the glyph attribute of the Font object+ *+ *@param code Description of the Parameter+ *@param index Description of the Parameter+ *@return The glyph value+ *@exception NoGlyphException Description of the Exception+ */+ protected FontDefinition.Glyph getGlyph(int code, int[] index2)+ throws NoGlyphException {+ int index[] = index2;+ Integer codeI = new Integer(code);+ FontDefinition.Glyph g = (FontDefinition.Glyph) glyphs.get(codeI);++ if (g != null) {+ if (index != null) {+ Integer idx = (Integer) indices.get(codeI);+ index[0] = idx.intValue();+ }++ return g;+ }++ g = fontDef.getGlyph(code);++ if (g == null) {+ throw new NoGlyphException(code);+ }++ int idx = addGlyph(g);+ if (index != null) {+ index[0] = idx;+ }++ return g;+ }+++ /**+ * Add a glyph and return the index+ *+ *@param glyph The feature to be added to the Glyph attribute+ *@return Description of the Return Value+ */+ public int addGlyph(FontDefinition.Glyph glyph) {+ int idx = glyphs.size();++ if (glyph.getCode() > 0) {+ Integer codeI = new Integer(glyph.getCode());+ indices.put(codeI, new Integer(idx));+ glyphs.put(codeI, glyph);+ }++ glyphList.add(glyph);++ return idx;+ }+++ /**+ * Set the code for the glyph at the given index+ *+ *@param index The new code value+ *@param code The new code value+ */+ public void setCode(int index, int code) {+ if (index >= glyphList.size()) {+ return;+ }++ FontDefinition.Glyph g = (FontDefinition.Glyph) glyphList.get(index);+ g.setCode(code);++ Integer codeI = new Integer(code);+ indices.put(codeI, new Integer(index));+ glyphs.put(codeI, g);+ }+++ /**+ * Description of the Method+ *+ *@param textFont Description of the Parameter+ *@param movie Description of the Parameter+ *@param tagwriter Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ protected int define(boolean textFont, Movie movie, SWFTagTypes tagwriter)+ throws IOException {+ Integer integerId = textFont ?+ (Integer) movie.definedSymbols.get(font1Key) :+ (Integer) movie.definedSymbols.get(font2Key);++ if (integerId == null) {+ if (textFont) {+ integerId = new Integer(defineFont1(movie, tagwriter));+ movie.definedSymbols.put(font1Key, integerId);+ } else {+ integerId = new Integer(defineFont2(movie, tagwriter));+ movie.definedSymbols.put(font2Key, integerId);+ }+ }++ id = integerId.intValue();+ return id;+ }+++ /**+ * Description of the Method+ *+ *@param movie Description of the Parameter+ *@param tagwriter Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ protected int defineFont1(Movie movie, SWFTagTypes tagwriter)+ throws IOException {+ int id = getNextId(movie);++ SWFVectors vecs = tagwriter.tagDefineFont(id, glyphList.size());++ for (Iterator it = glyphList.iterator(); it.hasNext(); ) {+ FontDefinition.Glyph g = (FontDefinition.Glyph) it.next();++ Shape s = g.getShape();++ s.writeGlyph(vecs);+ }++ if (fontDef.getName() != null) {+ int flags = 0;++ if (fontDef.isUnicode()) {+ flags |= SWFConstants.FONT_UNICODE;+ }+ if (fontDef.isShiftJIS()) {+ flags |= SWFConstants.FONT_SHIFTJIS;+ }+ if (fontDef.isAnsi()) {+ flags |= SWFConstants.FONT_ANSI;+ }+ if (fontDef.isItalic()) {+ flags |= SWFConstants.FONT_ITALIC;+ }+ if (fontDef.isBold()) {+ flags |= SWFConstants.FONT_BOLD;+ }++ tagwriter.tagDefineFontInfo(id, fontDef.getName(), flags, getCodes());+ }++ return id;+ }+++ /**+ * Description of the Method+ *+ *@param movie Description of the Parameter+ *@param tagwriter Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ protected int defineFont2(Movie movie, SWFTagTypes tagwriter)+ throws IOException {+ int id = getNextId(movie);++ int glyphCount = glyphList.size();+ int[] codes = new int[glyphCount];+ Rect[] bounds = new Rect[glyphCount];+ int[] advances = new int[glyphCount];++ //--Gather glyph info+ int i = 0;+ for (Iterator it = glyphList.iterator(); it.hasNext(); ) {+ FontDefinition.Glyph g = (FontDefinition.Glyph) it.next();++ codes[i] = g.getCode();+ advances[i] = (int) (g.getAdvance() * SWFConstants.TWIPS);++ double[] bound = g.getShape().getBoundingRectangle();++ bounds[i] = new Rect((int) (bound[0] * SWFConstants.TWIPS),+ (int) (bound[1] * SWFConstants.TWIPS),+ (int) (bound[2] * SWFConstants.TWIPS),+ (int) (bound[3] * SWFConstants.TWIPS));++ i++;+ }++ //--Gather kerning info+ List kerns = fontDef.getKerningPairList();+ int kernCount = kerns.size();+ int[] kern1 = new int[kernCount];+ int[] kern2 = new int[kernCount];+ int[] kernOff = new int[kernCount];++ i = 0;+ for (Iterator it = kerns.iterator(); it.hasNext(); ) {+ FontDefinition.KerningPair pair = (FontDefinition.KerningPair) it.next();++ kern1[i] = pair.getCode1();+ kern2[i] = pair.getCode2();+ kernOff[i] = (int) (pair.getAdjustment() * SWFConstants.TWIPS);++ i++;+ }++ int flags = 0;+ if (fontDef.hasMetrics()) {+ flags |= SWFConstants.FONT2_HAS_LAYOUT;+ }+ if (fontDef.isShiftJIS()) {+ flags |= SWFConstants.FONT2_SHIFTJIS;+ }+ if (fontDef.isUnicode()) {+ flags |= SWFConstants.FONT2_UNICODE;+ }+ if (fontDef.isAnsi()) {+ flags |= SWFConstants.FONT2_ANSI;+ }+ if (fontDef.isItalic()) {+ flags |= SWFConstants.FONT2_ITALIC;+ }+ if (fontDef.isBold()) {+ flags |= SWFConstants.FONT2_BOLD;+ }++ SWFVectors vecs = tagwriter.tagDefineFont2(+ id, flags, fontDef.getName(), glyphCount,+ (int) (fontDef.getAscent() * SWFConstants.TWIPS),+ (int) (fontDef.getDescent() * SWFConstants.TWIPS),+ (int) (fontDef.getLeading() * SWFConstants.TWIPS),+ codes, advances, bounds, kern1, kern2, kernOff);++ for (Iterator it = glyphList.iterator(); it.hasNext(); ) {+ FontDefinition.Glyph g = (FontDefinition.Glyph) it.next();++ Shape s = g.getShape();++ s.writeGlyph(vecs);+ }++ return id;+ }+++ /**+ * Get the codes of the current set of glyphs+ *+ *@return The codes value+ */+ protected int[] getCodes() {+ int[] codes = new int[glyphList.size()];++ for (int i = 0; i < codes.length; i++) {+ FontDefinition.Glyph g = (FontDefinition.Glyph) glyphList.get(i);+ codes[i] = g.getCode();+ }++ return codes;+ }+++ /**+ * Description of the Method+ *+ *@param movie Description of the Parameter+ *@param timelineWriter Description of the Parameter+ *@param definitionwriter Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ protected int defineSymbol(Movie movie,+ SWFTagTypes timelineWriter,+ SWFTagTypes definitionwriter) throws IOException {+ return id;+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/FontDefinition.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/FontDefinition.javanew file mode 100644index 000000000..72b2ed93c--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/FontDefinition.java@@ -0,0 +1,551 @@+package pt.tumba.parser.swf;++import java.util.ArrayList;+import java.util.HashMap;+import java.util.Iterator;+import java.util.List;+import java.util.Map;++/**+ * A Font Definition that can referenced by Font symbols. If read in from an+ * existing Flash movie the font definition may only contain a subset of the+ * glyphs in the font. To use a system font set the hasMetrics flag to false.+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class FontDefinition {+ /**+ * A Glyph within the font.+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public static class Glyph {+ /**+ * Description of the Field+ */+ protected int code;+ /**+ * Description of the Field+ */+ protected double advance;+ /**+ * Description of the Field+ */+ protected Shape shape;+++ /**+ * Gets the shape attribute of the Glyph object+ *+ *@return The shape value+ */+ public Shape getShape() {+ return shape;+ }+++ /**+ * Gets the code attribute of the Glyph object+ *+ *@return The code value+ */+ public int getCode() {+ return code;+ }+++ /**+ * Gets the advance attribute of the Glyph object+ *+ *@return The advance value+ */+ public double getAdvance() {+ return advance;+ }+++ /**+ * Sets the shape attribute of the Glyph object+ *+ *@param shape The new shape value+ */+ public void setShape(Shape shape) {+ this.shape = shape;+ }+++ /**+ * Sets the code attribute of the Glyph object+ *+ *@param code The new code value+ */+ public void setCode(int code) {+ this.code = code;+ }+++ /**+ * Sets the advance attribute of the Glyph object+ *+ *@param advance The new advance value+ */+ public void setAdvance(double advance) {+ this.advance = advance;+ }+++ /**+ * Constructor for the Glyph object+ *+ *@param shape Description of the Parameter+ *@param advance Description of the Parameter+ *@param code Description of the Parameter+ */+ public Glyph(Shape shape, double advance, int code) {+ this.shape = shape;+ this.advance = advance;+ this.code = code;+ }+ }+++ /**+ * A Kerning Pair is an adjustment to the advance between two particular+ * glyphs.+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public static class KerningPair {+ /**+ * Description of the Field+ */+ protected int code1, code2;+ /**+ * Description of the Field+ */+ protected double adjustment;+++ /**+ * Gets the code1 attribute of the KerningPair object+ *+ *@return The code1 value+ */+ public int getCode1() {+ return code1;+ }+++ /**+ * Gets the code2 attribute of the KerningPair object+ *+ *@return The code2 value+ */+ public int getCode2() {+ return code2;+ }+++ /**+ * Gets the adjustment attribute of the KerningPair object+ *+ *@return The adjustment value+ */+ public double getAdjustment() {+ return adjustment;+ }+++ /**+ * Sets the code1 attribute of the KerningPair object+ *+ *@param code The new code1 value+ */+ public void setCode1(int code) {+ code1 = code;+ }+++ /**+ * Sets the code2 attribute of the KerningPair object+ *+ *@param code The new code2 value+ */+ public void setCode2(int code) {+ code2 = code;+ }+++ /**+ * Sets the adjustment attribute of the KerningPair object+ *+ *@param offset The new adjustment value+ */+ public void setAdjustment(double offset) {+ adjustment = offset;+ }+++ /**+ * Constructor for the KerningPair object+ *+ *@param code1 Description of the Parameter+ *@param code2 Description of the Parameter+ *@param adjustment Description of the Parameter+ */+ public KerningPair(int code1, int code2, double adjustment) {+ this.code1 = code1;+ this.code2 = code2;+ this.adjustment = adjustment;+ }+ }+++ /**+ * Description of the Field+ */+ protected String name;+ /**+ * Description of the Field+ */+ protected double ascent;+ /**+ * Description of the Field+ */+ protected double descent;+ /**+ * Description of the Field+ */+ protected double leading;++ /**+ * Description of the Field+ */+ protected boolean isUnicode;+ /**+ * Description of the Field+ */+ protected boolean isShiftJIS;+ /**+ * Description of the Field+ */+ protected boolean isAnsi;+ /**+ * Description of the Field+ */+ protected boolean isItalic;+ /**+ * Description of the Field+ */+ protected boolean isBold;+ /**+ * Description of the Field+ */+ protected boolean hasMetrics;++ /**+ * Description of the Field+ */+ protected List glyphs = new ArrayList();+ /**+ * Description of the Field+ */+ protected List kerning = new ArrayList();++ /**+ * Description of the Field+ */+ protected Map glyphLookup;+ /**+ * Description of the Field+ */+ protected Map kernLookup;+++ /**+ * Gets the name attribute of the FontDefinition object+ *+ *@return The name value+ */+ public String getName() {+ return name;+ }+++ /**+ * Gets the ascent attribute of the FontDefinition object+ *+ *@return The ascent value+ */+ public double getAscent() {+ return ascent;+ }+++ /**+ * Gets the descent attribute of the FontDefinition object+ *+ *@return The descent value+ */+ public double getDescent() {+ return descent;+ }+++ /**+ * Gets the leading attribute of the FontDefinition object+ *+ *@return The leading value+ */+ public double getLeading() {+ return leading;+ }+++ /**+ * Gets the unicode attribute of the FontDefinition object+ *+ *@return The unicode value+ */+ public boolean isUnicode() {+ return isUnicode;+ }+++ /**+ * Gets the shiftJIS attribute of the FontDefinition object+ *+ *@return The shiftJIS value+ */+ public boolean isShiftJIS() {+ return isShiftJIS;+ }+++ /**+ * Gets the ansi attribute of the FontDefinition object+ *+ *@return The ansi value+ */+ public boolean isAnsi() {+ return isAnsi;+ }+++ /**+ * Gets the italic attribute of the FontDefinition object+ *+ *@return The italic value+ */+ public boolean isItalic() {+ return isItalic;+ }+++ /**+ * Gets the bold attribute of the FontDefinition object+ *+ *@return The bold value+ */+ public boolean isBold() {+ return isBold;+ }+++ /**+ * Description of the Method+ *+ *@return Description of the Return Value+ */+ public boolean hasMetrics() {+ return hasMetrics;+ }+++ /**+ * Get the List of Glyph objects+ *+ *@return The glyphList value+ */+ public List getGlyphList() {+ return glyphs;+ }+++ /**+ * Get the List of KerningPair objects+ *+ *@return The kerningPairList value+ */+ public List getKerningPairList() {+ return kerning;+ }+++ /**+ * Sets the name attribute of the FontDefinition object+ *+ *@param name The new name value+ */+ public void setName(String name) {+ this.name = name;+ }+++ /**+ * Sets the ascent attribute of the FontDefinition object+ *+ *@param ascent The new ascent value+ */+ public void setAscent(double ascent) {+ this.ascent = ascent;+ }+++ /**+ * Sets the descent attribute of the FontDefinition object+ *+ *@param descent The new descent value+ */+ public void setDescent(double descent) {+ this.descent = descent;+ }+++ /**+ * Sets the leading attribute of the FontDefinition object+ *+ *@param leading The new leading value+ */+ public void setLeading(double leading) {+ this.leading = leading;+ }+++ /**+ * Sets the fontFlags attribute of the FontDefinition object+ *+ *@param isUnicode The new fontFlags value+ *@param isShiftJIS The new fontFlags value+ *@param isAnsi The new fontFlags value+ *@param isItalic The new fontFlags value+ *@param isBold The new fontFlags value+ *@param hasMetrics The new fontFlags value+ */+ public void setFontFlags(boolean isUnicode, boolean isShiftJIS, boolean isAnsi,+ boolean isItalic, boolean isBold, boolean hasMetrics) {+ this.isUnicode = isUnicode;+ this.isShiftJIS = isShiftJIS;+ this.isAnsi = isAnsi;+ this.isItalic = isItalic;+ this.isBold = isBold;+ this.hasMetrics = hasMetrics;+ }+++ /**+ * Constructor for the FontDefinition object+ */+ public FontDefinition() { }+++ /**+ * Constructor for the FontDefinition object+ *+ *@param name Description of the Parameter+ *@param ascent Description of the Parameter+ *@param descent Description of the Parameter+ *@param leading Description of the Parameter+ *@param isUnicode Description of the Parameter+ *@param isShiftJIS Description of the Parameter+ *@param isAnsi Description of the Parameter+ *@param isItalic Description of the Parameter+ *@param isBold Description of the Parameter+ *@param hasMetrics Description of the Parameter+ */+ public FontDefinition(String name, double ascent, double descent, double leading,+ boolean isUnicode, boolean isShiftJIS, boolean isAnsi,+ boolean isItalic, boolean isBold, boolean hasMetrics) {+ this.name = name;+ this.ascent = ascent;+ this.descent = descent;+ this.leading = leading;++ this.isUnicode = isUnicode;+ this.isShiftJIS = isShiftJIS;+ this.isAnsi = isAnsi;+ this.isItalic = isItalic;+ this.isBold = isBold;+ this.hasMetrics = hasMetrics;+ }+++ /**+ * Look up a glyph by code+ *+ *@param code Description of the Parameter+ *@return null if the code has no glyph+ */+ public Glyph getGlyph(int code) {+ if (glyphLookup == null) {+ glyphLookup = new HashMap();++ for (Iterator it = glyphs.iterator(); it.hasNext(); ) {+ Glyph g = (Glyph) it.next();++ glyphLookup.put(new Integer(g.code), g);+ }+ }++ Glyph g = (Glyph) glyphLookup.get(new Integer(code));++ return g;+ }+++ /**+ * Get the kerning adjustment required between the two given codes+ *+ *@param code1 Description of the Parameter+ *@param code2 Description of the Parameter+ *@return The kerningOffset value+ */+ public double getKerningOffset(int code1, int code2) {+ if (kernLookup == null) {+ kernLookup = new HashMap();++ for (Iterator it = kerning.iterator(); it.hasNext(); ) {+ KerningPair pair = (KerningPair) it.next();+ Integer i1 = new Integer(pair.code1);+ Integer i2 = new Integer(pair.code2);++ HashMap kerns = (HashMap) kernLookup.get(i1);++ if (kerns == null) {+ kerns = new HashMap();+ kernLookup.put(i1, kerns);+ }++ kerns.put(i2, pair);+ }+ }++ Integer i1 = new Integer(code1);+ Integer i2 = new Integer(code2);++ HashMap kerns = (HashMap) kernLookup.get(i1);+ if (kerns == null) {+ return 0.0;+ }++ KerningPair pair = (KerningPair) kerns.get(i2);+ if (pair == null) {+ return 0.0;+ }++ return pair.adjustment;+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Frame.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Frame.javanew file mode 100644index 000000000..60a02d1d5--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Frame.java@@ -0,0 +1,461 @@+package pt.tumba.parser.swf;++import java.io.IOException;+import java.util.Iterator;+import java.util.List;+import java.util.Vector;++/**+ * A Movie or Movie Clip frame+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class Frame {+ /**+ * Description of the Field+ */+ protected int frameNumber;+ /**+ * Description of the Field+ */+ protected String label;+ /**+ * Description of the Field+ */+ protected List placements = new Vector();+ /**+ * Description of the Field+ */+ protected boolean stop;+ /**+ * Description of the Field+ */+ protected TimeLine timeline;+ /**+ * Description of the Field+ */+ protected Actions actions;++ /**+ * Constructor for the Frame object+ *+ *@param number Description of the Parameter+ *@param timeline Description of the Parameter+ */+ protected Frame(int number, TimeLine timeline) {+ frameNumber = number;+ this.timeline = timeline;+ }++ /**+ * Get the frame actions+ *+ *@return The actions value+ */+ public Actions getActions() {+ return actions;+ }++ /**+ * Set the frame actions (or null them out)+ *+ *@param actions The new actions value+ */+ public void setActions(Actions actions) {+ this.actions = actions;+ }++ /**+ * Reset the frame actions (if any) and return the new empty Actions object+ *+ *@param flashVersion Description of the Parameter+ *@return Description of the Return Value+ */+ public Actions actions(int flashVersion) {+ actions = new Actions(0, flashVersion);+ return actions;+ }++ /**+ * Get the frame number+ *+ *@return The frameNumber value+ */+ public int getFrameNumber() {+ return frameNumber;+ }++ /**+ * Get the placements in this frame+ *+ *@return The placements value+ */+ public Placement[] getPlacements() {+ Placement[] p = new Placement[placements.size()];+ placements.toArray(p);+ return p;+ }++ /**+ * Get the frame label+ *+ *@return null if the frame has no label+ */+ public String getLabel() {+ return label;+ }++ /**+ * Set the frame label - set to null to clear any label+ *+ *@param label The new label value+ */+ public void setLabel(String label) {+ this.label = label;+ }++ /**+ * Set the stop flag - if true then the movie will stop at this frame. This+ * can be set on the last frame to prevent the movie looping.+ */+ public void stop() {+ this.stop = true;+ }++ /**+ * Place a symbol at the given coordinates at the next available depth.+ *+ *@param symbol Description of the Parameter+ *@param x Description of the Parameter+ *@param y Description of the Parameter+ *@return Description of the Return Value+ */+ public Instance placeSymbol(Symbol symbol, int x, int y) {+ return placeSymbol(symbol, new Transform(x, y), null, -1, -1);+ }++ /**+ * Place a symbol at the next available depth with the given matrix+ * transform and color transform.+ *+ *@param matrix may be null to place the symbol at (0,0)+ *@param cxform may be null if no color transform is required+ *@param symbol Description of the Parameter+ *@return Description of the Return Value+ */+ public Instance placeSymbol(+ Symbol symbol,+ Transform matrix,+ AlphaTransform cxform) {+ return placeSymbol(symbol, matrix, cxform, -1, -1);+ }++ /**+ * Place a symbol at the next available depth with the given properties.+ *+ *@param matrix may be null to place the symbol at (0,0)+ *@param cxform may be null if no color transform is required+ *@param ratio only for a MorphShape - the morph ratio from 0 to+ * 65535, should be -1 for a non-MorphShape+ *@param clipDepth the top depth that will be clipped by the symbol,+ * should be -1 if this is not a clipping symbol+ *@param symbol Description of the Parameter+ *@return Description of the Return Value+ */+ public Instance placeSymbol(+ Symbol symbol,+ Transform matrix2,+ AlphaTransform cxform,+ int ratio,+ int clipDepth) {+ Transform matrix = matrix2;+ int depth = timeline.getAvailableDepth();+ Instance inst = new Instance(symbol, depth);+ timeline.setAvailableDepth(depth + 1);++ if (matrix == null) {+ matrix = new Transform();+ }++ Placement placement =+ new Placement(+ inst,+ matrix,+ cxform,+ null,+ ratio,+ clipDepth,+ frameNumber,+ false,+ false,+ null);++ placements.add(placement);+ return inst;+ }++ /**+ * Replace the symbol at the given depth with the new symbol+ *+ *@param matrix may be null to place the symbol at (0,0)+ *@param cxform may be null if no color transform is required+ *@param ratio only for a MorphShape - the morph ratio from 0 to+ * 65535, should be -1 for a non-MorphShape+ *@param clipDepth the top depth that will be clipped by the symbol,+ * should be -1 if this is not a clipping symbol+ *@param symbol Description of the Parameter+ *@param depth Description of the Parameter+ *@return Description of the Return Value+ */+ public Instance replaceSymbol(+ Symbol symbol,+ int depth,+ Transform matrix2,+ AlphaTransform cxform,+ int ratio,+ int clipDepth) {+ Transform matrix = matrix2;+ Instance inst = new Instance(symbol, depth);++ if (matrix == null) {+ matrix = new Transform();+ }++ Placement placement =+ new Placement(+ inst,+ matrix,+ cxform,+ null,+ ratio,+ clipDepth,+ frameNumber,+ false,+ true,+ null);++ placements.add(placement);+ return inst;+ }++ /**+ * Place a Movie Clip at the next available depth with the given+ * properties.+ *+ *@param matrix may be null to place the symbol at (0,0)+ *@param cxform may be null if no color transform is required+ *@param name the instance name of a MovieClip - should be null if+ * this is not a MovieClip+ *@param symbol Description of the Parameter+ *@param clipActions Description of the Parameter+ *@return Description of the Return Value+ */+ public Instance placeMovieClip(+ Symbol symbol,+ Transform matrix2,+ AlphaTransform cxform,+ String name,+ Actions[] clipActions) {+ Transform matrix = matrix2;+ int depth = timeline.getAvailableDepth();+ Instance inst = new Instance(symbol, depth);+ timeline.setAvailableDepth(depth + 1);++ if (matrix == null) {+ matrix = new Transform();+ }++ Placement placement =+ new Placement(+ inst,+ matrix,+ cxform,+ name,+ -1,+ -1,+ frameNumber,+ false,+ false,+ clipActions);++ placements.add(placement);+ return inst;+ }++ /**+ * Replace the Symbol at the given depth with the new MovieClip+ *+ *@param matrix may be null to place the symbol at (0,0)+ *@param cxform may be null if no color transform is required+ *@param name the instance name of a MovieClip - should be null if+ * this is not a MovieClip+ *@param symbol Description of the Parameter+ *@param depth Description of the Parameter+ *@param clipActions Description of the Parameter+ *@return Description of the Return Value+ */+ public Instance replaceMovieClip(+ Symbol symbol,+ int depth,+ Transform matrix2,+ AlphaTransform cxform,+ String name,+ Actions[] clipActions) {+ Transform matrix = matrix2;+ Instance inst = new Instance(symbol, depth);++ if (matrix == null) {+ matrix = new Transform();+ }++ Placement placement =+ new Placement(+ inst,+ matrix,+ cxform,+ name,+ -1,+ -1,+ frameNumber,+ false,+ true,+ clipActions);++ placements.add(placement);+ return inst;+ }++ /**+ * Remove the symbol instance from the stage+ *+ *@param instance Description of the Parameter+ */+ public void remove(Instance instance) {+ placements.add(new Placement(instance, frameNumber));+ }++ /**+ * Alter the symbol instance by moving it to the new coordinates. Only one+ * alteration may be made to an Instance in any given frame.+ *+ *@param instance Description of the Parameter+ *@param x Description of the Parameter+ *@param y Description of the Parameter+ */+ public void alter(Instance instance, int x, int y) {+ alter(instance, new Transform(x, y), null, -1);+ }++ /**+ * Alter the symbol instance by applying the given transform and/or color+ * transform. Only one alteration may be made to an Instance in any given+ * frame.+ *+ *@param matrix may be null if no positional change is to be made.+ *@param cxform may be null if no color change is required.+ *@param instance Description of the Parameter+ */+ public void alter(+ Instance instance,+ Transform matrix,+ AlphaTransform cxform) {+ alter(instance, matrix, cxform, -1);+ }++ /**+ * Alter the symbol instance by applying the given properties. Only one+ * alteration may be made to an Instance in any given frame.+ *+ *@param matrix may be null if no positional change is to be made.+ *@param cxform may be null if no color change is required.+ *@param ratio only for a MorphShape - the morph ratio from 0 to 65535,+ * should be -1 for a non-MorphShape+ *@param instance Description of the Parameter+ */+ public void alter(+ Instance instance,+ Transform matrix,+ AlphaTransform cxform,+ int ratio) {+ Placement placement =+ new Placement(+ instance,+ matrix,+ cxform,+ null,+ ratio,+ -1,+ frameNumber,+ true,+ false,+ null);++ placements.add(placement);+ }++ /**+ * Description of the Method+ *+ *@param movie Description of the Parameter+ *@param timelineWriter Description of the Parameter+ *@param definitionWriter Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void flushDefinitions(+ Movie movie,+ SWFTagTypes timelineWriter,+ SWFTagTypes definitionWriter)+ throws IOException {+ for (Iterator enumerator = placements.iterator();+ enumerator.hasNext();+ ) {+ Placement placement = (Placement) enumerator.next();++ placement.flushDefinitions(movie, timelineWriter, definitionWriter);+ }+ }++ /**+ * Write the frame+ *+ *@param movie Description of the Parameter+ *@param movieTagWriter Description of the Parameter+ *@param timelineTagWriter Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void write(+ Movie movie,+ SWFTagTypes movieTagWriter,+ SWFTagTypes timelineTagWriter)+ throws IOException {+ if (actions != null) {+ SWFActions acts = timelineTagWriter.tagDoAction();+ acts.start(0);+ acts.blob(actions.bytes);+ acts.done();+ }++ if (stop) {+ SWFActions actions = timelineTagWriter.tagDoAction();++ actions.start(0);+ actions.stop();+ actions.end();+ actions.done();+ }++ for (Iterator enumumerator = placements.iterator();+ enumumerator.hasNext();+ ) {+ Placement placement = (Placement) enumumerator.next();++ placement.write(movie, movieTagWriter, timelineTagWriter);+ }++ if (label != null) {+ timelineTagWriter.tagFrameLabel(label);+ }+ timelineTagWriter.tagShowFrame();+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ImportedSymbol.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ImportedSymbol.javanew file mode 100644index 000000000..92adb607d--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ImportedSymbol.java@@ -0,0 +1,72 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * A Symbol that is to be imported (within the Player) from another Flash+ * movie. The import/export feature only works with Flash version 5 and up.+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class ImportedSymbol extends Symbol {+ /**+ * Description of the Field+ */+ protected String name;+ /**+ * Description of the Field+ */+ protected String libName;+++ /**+ * Constructor for the ImportedSymbol object+ *+ *@param id Description of the Parameter+ *@param name Description of the Parameter+ *@param libName Description of the Parameter+ */+ protected ImportedSymbol(int id, String name, String libName) {+ super(id);+ this.name = name;+ this.libName = libName;+ }+++ /**+ * The import name of the symbol+ *+ *@return The name value+ */+ public String getName() {+ return name;+ }+++ /**+ * The library name (another Flash movie)+ *+ *@return The libraryName value+ */+ public String getLibraryName() {+ return libName;+ }+++ /**+ * Description of the Method+ *+ *@param movie Description of the Parameter+ *@param timelineWriter Description of the Parameter+ *@param definitionwriter Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ protected int defineSymbol(Movie movie,+ SWFTagTypes timelineWriter,+ SWFTagTypes definitionwriter)+ throws IOException {+ return getNextId(movie);+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/InStream.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/InStream.javanew file mode 100644index 000000000..8513f80f6--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/InStream.java@@ -0,0 +1,485 @@+package pt.tumba.parser.swf;++import java.io.ByteArrayInputStream;+import java.io.ByteArrayOutputStream;+import java.io.DataInputStream;+import java.io.IOException;+import java.io.InputStream;+import java.util.Enumeration;+import java.util.Vector;++/**+ * Input Stream Wrapper+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class InStream {+ /**+ * Description of the Field+ */+ protected InputStream in;+ /**+ * Description of the Field+ */+ protected long bytesRead = 0L;++ //--Bit buffer..+ /**+ * Description of the Field+ */+ protected int bitBuf;+ /**+ * Description of the Field+ */+ protected int bitPos;++ /**+ * Constructor for the InStream object+ *+ *@param in Description of the Parameter+ */+ public InStream(InputStream in) {+ this.in = in;+ bitBuf = 0;+ bitPos = 0;+ }++ /**+ * Constructor for the InStream object+ *+ *@param bytes Description of the Parameter+ */+ public InStream(byte[] bytes) {+ this(new ByteArrayInputStream(bytes));+ }++ /**+ * Read a string from the input stream+ *+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public byte[] readStringBytes() throws IOException {+ synchBits();++ Vector chars = new Vector();+ byte[] aChar = new byte[1];+ int num = 0;++ while ((num = in.read(aChar)) == 1) {+ bytesRead++;++ if (aChar[0] == 0) {+ //end of string++ byte[] string = new byte[chars.size()];++ int i = 0;+ for (Enumeration enumerator = chars.elements();+ enumerator.hasMoreElements();+ ) {+ string[i++] = ((Byte) enumerator.nextElement()).byteValue();+ }++ return string;+ }++ chars.addElement(new Byte(aChar[0]));+ }++ throw new IOException("Unterminated string - reached end of input before null char");+ }++ /**+ * Read a null terminated string using the default character encoding+ *+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public String readString() throws IOException {+ return new String(readStringBytes());+ }++ /**+ * Read all remaining bytes from the stream+ *+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public byte[] read() throws IOException {+ ByteArrayOutputStream bout = new ByteArrayOutputStream();++ int b = 0;+ while ((b = in.read()) >= 0) {+ bout.write(b);+ }++ return bout.toByteArray();+ }++ /**+ * Read bytes from the input stream+ *+ *@param length Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public byte[] read(int length) throws IOException {+ byte[] data = new byte[length];++ if (length > 0) {+ int read = 0;++ while (read < length) {+ int count = in.read(data, read, length - read);+ if (count < 0) {+ bytesRead += read;+ throw new IOException("Unexpected end of input while reading a specified number of bytes");+ }++ read += count;+ }++ bytesRead += read;+ }++ return data;+ }++ /**+ * Reset the bit buffer+ */+ public void synchBits() {+ bitBuf = 0;+ bitPos = 0;+ }++ /**+ * Gets the bytesRead attribute of the InStream object+ *+ *@return The bytesRead value+ */+ public long getBytesRead() {+ return bytesRead;+ }++ /**+ * Sets the bytesRead attribute of the InStream object+ *+ *@param read The new bytesRead value+ */+ public void setBytesRead(long read) {+ bytesRead = read;+ }++ /**+ * Skip a number of bytes from the input stream+ *+ *@param length Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void skipBytes(long length) throws IOException {+ long skipped = 0;++ while (skipped < length) {+ int val = in.read();++ if (val < 0) {+ throw new IOException("Unexpected end of input");+ }++ skipped++;+ }++ bytesRead += length;+ }++ /**+ * Read an unsigned value from the given number of bits+ *+ *@param numBits Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public long readUBits(int numBits) throws IOException {+ if (numBits == 0) {+ return 0;+ }++ int bitsLeft = numBits;+ long result = 0;++ if (bitPos == 0) {+ //no value in the buffer - read a byte++ bitBuf = in.read();+ bitPos = 8;++ bytesRead++;+ }++ while (true) {+ int shift = bitsLeft - bitPos;+ if (shift > 0) {+ // Consume the entire buffer+ result |= bitBuf << shift;+ bitsLeft -= bitPos;++ // Get the next byte from the input stream+ bitBuf = in.read();+ bitPos = 8;++ bytesRead++;+ } else {+ // Consume a portion of the buffer+ result |= bitBuf >> -shift;+ bitPos -= bitsLeft;+ bitBuf &= 0xff >> (8 - bitPos);+ // mask off the consumed bits++ return result;+ }+ }+ }++ /**+ * Read an unsigned 8 bit value+ *+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public int readUI8() throws IOException {+ synchBits();++ int ui8 = in.read();+ if (ui8 < 0) {+ throw new IOException("Unexpected end of input");+ }++ bytesRead++;++ return ui8;+ }++ /**+ * Read an unsigned 16 bit value+ *+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public int readUI16() throws IOException {+ synchBits();++ int ui16 = in.read();+ if (ui16 < 0) {+ throw new IOException("Unexpected end of input");+ }++ int val = in.read();+ if (val < 0) {+ throw new IOException("Unexpected end of input");+ }++ ui16 += val << 8;++ bytesRead += 2;++ return ui16;+ }++ /**+ * Read a signed 16 bit value+ *+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public short readSI16() throws IOException {+ synchBits();++ int lowerByte = in.read();+ if (lowerByte < 0) {+ throw new IOException("Unexpected end of input");+ }++ byte[] aByte = new byte[1];+ int count = in.read(aByte);+ if (count < 1) {+ throw new IOException("Unexpected end of input");+ }++ bytesRead += 2;++ return (short) ((aByte[0] * 256) + lowerByte);+ }++ /**+ * Read an unsigned 32 bit value+ *+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public long readUI32() throws IOException {+ synchBits();++ long ui32 = in.read();+ if (ui32 < 0) {+ throw new IOException("Unexpected end of input");+ }++ long val = in.read();+ if (val < 0) {+ throw new IOException("Unexpected end of input");+ }++ ui32 += val << 8;++ val = in.read();+ if (val < 0) {+ throw new IOException("Unexpected end of input");+ }++ ui32 += val << 16;++ val = in.read();+ if (val < 0) {+ throw new IOException("Unexpected end of input");+ }++ ui32 += val << 24;++ bytesRead += 4;++ return ui32;+ }++ /**+ * Read a signed value from the given number of bits+ *+ *@param numBits Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public int readSBits(int numBits) throws IOException {+ // Get the number as an unsigned value.+ long uBits = readUBits(numBits);++ // Is the number negative?+ if ((uBits & (1L << (numBits - 1))) != 0) {+ // Yes. Extend the sign.+ uBits |= -1L << numBits;+ }++ return (int) uBits;+ }++ /**+ * Read a 32 bit signed number+ *+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public int readSI32() throws IOException {+ synchBits();++ int b0 = in.read();+ if (b0 < 0) {+ throw new IOException("Unexpected end of input");+ }++ int b1 = in.read();+ if (b1 < 0) {+ throw new IOException("Unexpected end of input");+ }++ int b2 = in.read();+ if (b2 < 0) {+ throw new IOException("Unexpected end of input");+ }++ byte[] aByte = new byte[1];+ int count = in.read(aByte);+ if (count < 1) {+ throw new IOException("Unexpected end of input");+ }++ bytesRead += 4;++ return (int)+ ((aByte[0] * 256 * 256 * 256) + (b2 * 256 * 256) + (b1 * 256) + b0);+ }++ /**+ * Read a 32 bit floating point number+ *+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public float readFloat() throws IOException {+ return Float.intBitsToFloat(readSI32());+ }++ /**+ * Read a 64 bit floating point number+ *+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public double readDouble() throws IOException {+ byte[] bytes = read(8);++ byte[] bytes2 = new byte[8];++ bytes2[0] = bytes[3];+ bytes2[1] = bytes[2];+ bytes2[2] = bytes[1];+ bytes2[3] = bytes[0];+ bytes2[4] = bytes[7];+ bytes2[5] = bytes[6];+ bytes2[6] = bytes[5];+ bytes2[7] = bytes[4];++ ByteArrayInputStream bin = new ByteArrayInputStream(bytes2);++ return new DataInputStream(bin).readDouble();+ }++ /**+ * Util to convert an unsigned byte to an unsigned int+ *+ *@param b Description of the Parameter+ *@return Description of the Return Value+ */+ public static int ubyteToInt(byte b2) {+ boolean highbit = b2 < 0;+ byte b = (byte)(b2 & 0x7f);++ int i = (int) b;++ if (highbit) {+ i += 128;+ }++ return i;+ }++ /**+ * Util to convert 2 bytes to a signed value+ *+ *@param lo Description of the Parameter+ *@param hi Description of the Parameter+ *@return Description of the Return Value+ */+ public static int bytesToSigned(byte lo, byte hi) {+ int low = ubyteToInt(lo);+ int high = ubyteToInt(hi);++ int value = (high << 8) + low;++ if (value > 0x7fff) {+ value -= 65536;+ }++ return value;+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Instance.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Instance.javanew file mode 100644index 000000000..0dfb3828f--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Instance.java@@ -0,0 +1,50 @@+package pt.tumba.parser.swf;++/**+ * An instance of a Symbol that has been placed on the stage.+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class Instance {+ /**+ * Description of the Field+ */+ protected Symbol symbol;+ /**+ * Description of the Field+ */+ protected int depth;+++ /**+ * Constructor for the Instance object+ *+ *@param symbol Description of the Parameter+ *@param depth Description of the Parameter+ */+ protected Instance(Symbol symbol, int depth) {+ this.symbol = symbol;+ this.depth = depth;+ }+++ /**+ * Gets the depth attribute of the Instance object+ *+ *@return The depth value+ */+ public int getDepth() {+ return depth;+ }+++ /**+ * Gets the symbol attribute of the Instance object+ *+ *@return The symbol value+ */+ public Symbol getSymbol() {+ return symbol;+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/LineStyle.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/LineStyle.javanew file mode 100644index 000000000..7ac870251--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/LineStyle.java@@ -0,0 +1,90 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class LineStyle implements Style {+ /**+ * Description of the Field+ */+ protected int width;+ /**+ * Description of the Field+ */+ protected Color color;+++ /**+ * Gets the width attribute of the LineStyle object+ *+ *@return The width value+ */+ public int getWidth() {+ return width;+ }+++ /**+ * Gets the color attribute of the LineStyle object+ *+ *@return The color value+ */+ public Color getColor() {+ return color;+ }+++ /**+ * Constructor for the LineStyle object+ *+ *@param width Description of the Parameter+ *@param color Description of the Parameter+ */+ public LineStyle(int width, Color color) {+ this.width = width;+ this.color = color;+ }+++ /**+ * Description of the Method+ *+ *@param out Description of the Parameter+ *@param hasAlpha Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void write(OutStream out, boolean hasAlpha) throws IOException {+ out.writeUI16(width);++ if (hasAlpha) {+ color.writeWithAlpha(out);+ } else {+ color.writeRGB(out);+ }+ }+++ /**+ * Description of the Method+ *+ *@param out Description of the Parameter+ *@param startStyle Description of the Parameter+ *@param endStyle Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public static void writeMorphLineStyle(OutStream out,+ LineStyle startStyle,+ LineStyle endStyle)+ throws IOException {+ out.writeUI16(startStyle.width);+ out.writeUI16(endStyle.width);++ startStyle.color.writeWithAlpha(out);+ endStyle.color.writeWithAlpha(out);+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Matrix.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Matrix.javanew file mode 100644index 000000000..82d0a4321--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Matrix.java@@ -0,0 +1,327 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class Matrix {+ /**+ * Description of the Field+ */+ protected double scaleX = 1.0;+ /**+ * Description of the Field+ */+ protected double scaleY = 1.0;++ /**+ * Description of the Field+ */+ protected double skew0 = 0.0;+ /**+ * Description of the Field+ */+ protected double skew1 = 0.0;++ /**+ * Description of the Field+ */+ protected double translateX = 0.0;+ /**+ * Description of the Field+ */+ protected double translateY = 0.0;+++ /**+ * Gets the scaleX attribute of the Matrix object+ *+ *@return The scaleX value+ */+ public double getScaleX() {+ return scaleX;+ }+++ /**+ * Gets the scaleY attribute of the Matrix object+ *+ *@return The scaleY value+ */+ public double getScaleY() {+ return scaleY;+ }+++ /**+ * Gets the skew0 attribute of the Matrix object+ *+ *@return The skew0 value+ */+ public double getSkew0() {+ return skew0;+ }+++ /**+ * Gets the skew1 attribute of the Matrix object+ *+ *@return The skew1 value+ */+ public double getSkew1() {+ return skew1;+ }+++ /**+ * Gets the translateX attribute of the Matrix object+ *+ *@return The translateX value+ */+ public double getTranslateX() {+ return translateX;+ }+++ /**+ * Gets the translateY attribute of the Matrix object+ *+ *@return The translateY value+ */+ public double getTranslateY() {+ return translateY;+ }+++ /**+ * Sets the scaleX attribute of the Matrix object+ *+ *@param scaleX The new scaleX value+ */+ public void setScaleX(double scaleX) {+ this.scaleX = scaleX;+ }+++ /**+ * Sets the scaleY attribute of the Matrix object+ *+ *@param scaleY The new scaleY value+ */+ public void setScaleY(double scaleY) {+ this.scaleY = scaleY;+ }+++ /**+ * Sets the skew0 attribute of the Matrix object+ *+ *@param skew0 The new skew0 value+ */+ public void setSkew0(double skew0) {+ this.skew0 = skew0;+ }+++ /**+ * Sets the skew1 attribute of the Matrix object+ *+ *@param skew1 The new skew1 value+ */+ public void setSkew1(double skew1) {+ this.skew1 = skew1;+ }+++ /**+ * Sets the translateX attribute of the Matrix object+ *+ *@param translateX The new translateX value+ */+ public void setTranslateX(double translateX) {+ this.translateX = translateX;+ }+++ /**+ * Sets the translateY attribute of the Matrix object+ *+ *@param translateY The new translateY value+ */+ public void setTranslateY(double translateY) {+ this.translateY = translateY;+ }+++ /**+ * An identity matrix+ */+ public Matrix() {+ this(1.0, 1.0, 0.0, 0.0, 0, 0);+ }+++ /**+ * Constructor for the Matrix object+ *+ *@param translateX Description of the Parameter+ *@param translateY Description of the Parameter+ */+ public Matrix(double translateX, double translateY) {+ this(1.0, 1.0, 0.0, 0.0, translateX, translateY);+ }+++ /**+ * Copy another matrix+ *+ *@param copy Description of the Parameter+ */+ public Matrix(Matrix copy) {+ if (copy == null) {+ return;+ }+ scaleX = copy.scaleX;+ scaleY = copy.scaleY;+ skew0 = copy.skew0;+ skew1 = copy.skew1;+ translateX = copy.translateX;+ translateY = copy.translateY;+ }+++ /**+ * Constructor for the Matrix object+ *+ *@param scaleX Description of the Parameter+ *@param scaleY Description of the Parameter+ *@param skew0 Description of the Parameter+ *@param skew1 Description of the Parameter+ *@param translateX Description of the Parameter+ *@param translateY Description of the Parameter+ */+ public Matrix(double scaleX, double scaleY,+ double skew0, double skew1,+ double translateX, double translateY) {+ this.scaleX = scaleX;+ this.scaleY = scaleY;+ this.skew0 = skew0;+ this.skew1 = skew1;+ this.translateX = translateX;+ this.translateY = translateY;+ }+++ /**+ * Constructor for the Matrix object+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public Matrix(InStream in) throws IOException {+ in.synchBits();++ if (in.readUBits(1) == 1) {+ //has scale values++ int scaleBits = (int) in.readUBits(5);+ scaleX = ((double) in.readSBits(scaleBits)) / 65536.0;+ scaleY = ((double) in.readSBits(scaleBits)) / 65536.0;+ }++ if (in.readUBits(1) == 1) {+ //has rotate/skew values++ int skewBits = (int) in.readUBits(5);+ skew0 = ((double) in.readSBits(skewBits)) / 65536.0;+ skew1 = ((double) in.readSBits(skewBits)) / 65536.0;+ }++ int translateBits = (int) in.readUBits(5);+ translateX = in.readSBits(translateBits);+ translateY = in.readSBits(translateBits);+ }+++ /**+ * Description of the Method+ *+ *@param out Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void write(OutStream out) throws IOException {+ out.flushBits();++ if (scaleX != 1.0 || scaleY != 1.0) {+ //if non-default values++ int intScaleX = (int) (scaleX * 65536.0);+ int intScaleY = (int) (scaleY * 65536.0);++ int scaleBits = OutStream.determineSignedBitSize(intScaleX);+ int scaleBits2 = OutStream.determineSignedBitSize(intScaleY);+ if (scaleBits < scaleBits2) {+ scaleBits = scaleBits2;+ }++ out.writeUBits(1, 1);+ out.writeUBits(5, scaleBits);+ out.writeSBits(scaleBits, intScaleX);+ out.writeSBits(scaleBits, intScaleY);+ } else {+ out.writeUBits(1, 0);+ }++ if (skew0 != 0.0 || skew1 != 0.0) {+ //if non-default values++ int intSkew0 = (int) (skew0 * 65536.0);+ int intSkew1 = (int) (skew1 * 65536.0);++ int skewBits = OutStream.determineSignedBitSize(intSkew0);+ int skewBits2 = OutStream.determineSignedBitSize(intSkew1);+ if (skewBits < skewBits2) {+ skewBits = skewBits2;+ }++ out.writeUBits(1, 1);+ out.writeUBits(5, skewBits);+ out.writeSBits(skewBits, intSkew0);+ out.writeSBits(skewBits, intSkew1);+ } else {+ out.writeUBits(1, 0);+ }++ if (translateX == 0 && translateY == 0) {+ out.writeUBits(5, 0);+ } else {+ int translateBits = OutStream.determineSignedBitSize((int) translateX);+ int translateBits2 = OutStream.determineSignedBitSize((int) translateY);+ if (translateBits < translateBits2) {+ translateBits = translateBits2;+ }++ out.writeUBits(5, translateBits);+ out.writeSBits(translateBits, (int) translateX);+ out.writeSBits(translateBits, (int) translateY);+ }++ out.flushBits();+ }+++ /**+ * Description of the Method+ *+ *@return Description of the Return Value+ */+ public String toString() {+ return " Matrix(sx,sy,s0,s1,tx,ty)=(" ++ scaleX + "," + scaleY + "," + skew0 + "," + skew1 + "," ++ translateX + "," + translateY + ")";+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Movie.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Movie.javanew file mode 100644index 000000000..39d207501--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Movie.java@@ -0,0 +1,537 @@+package pt.tumba.parser.swf;++import java.io.IOException;+import java.io.OutputStream;+import java.util.ArrayList;+import java.util.HashMap;+import java.util.Iterator;+import java.util.List;+import java.util.Map;+import java.util.SortedMap;+import java.util.TreeMap;+import java.util.Vector;++/**+ * A Flash Movie+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class Movie implements TimeLine {+ /**+ * Description of the Field+ */+ protected int width;+ /**+ * Description of the Field+ */+ protected int height;+ /**+ * Description of the Field+ */+ protected int frameRate;+ /**+ * Description of the Field+ */+ protected Color backColor;+ /**+ * Description of the Field+ */+ protected int version;+ /**+ * Description of the Field+ */+ protected boolean isProtected;++ /**+ * Description of the Field+ */+ protected Map importLibraries;+ /**+ * Description of the Field+ */+ protected List exportedSymbols;++ /**+ * Description of the Field+ */+ protected SortedMap frames = new TreeMap();+ /**+ * Description of the Field+ */+ protected int frameCount = 0;++ //--Table of characters defined so far in the movie - while writing out+ /**+ * Description of the Field+ */+ protected Map definedSymbols = new HashMap();++ /**+ * Description of the Field+ */+ protected int depth = 1;+ //the next available depth+ /**+ * Description of the Field+ */+ protected int maxId = 1;+++ //the next available symbol id++ /**+ * Create a movie with the default values - (550x400), 12 frames/sec, white+ * backcolor, Flash version 5.+ */+ public Movie() {+ width = 550;+ height = 400;+ frameRate = 12;+ version = 5;+ }+++ /**+ * Create a movie with the given properties+ *+ *@param width Description of the Parameter+ *@param height Description of the Parameter+ *@param frameRate Description of the Parameter+ *@param version Description of the Parameter+ *@param backColor Description of the Parameter+ */+ public Movie(int width, int height, int frameRate, int version, Color backColor) {+ this.width = width;+ this.height = height;+ this.frameRate = frameRate;+ this.version = version;+ this.backColor = backColor;+ }+++ /**+ * Gets the width attribute of the Movie object+ *+ *@return The width value+ */+ public int getWidth() {+ return width;+ }+++ /**+ * Gets the height attribute of the Movie object+ *+ *@return The height value+ */+ public int getHeight() {+ return height;+ }+++ /**+ * Gets the frameRate attribute of the Movie object+ *+ *@return The frameRate value+ */+ public int getFrameRate() {+ return frameRate;+ }+++ /**+ * Gets the version attribute of the Movie object+ *+ *@return The version value+ */+ public int getVersion() {+ return version;+ }+++ /**+ * Gets the backColor attribute of the Movie object+ *+ *@return The backColor value+ */+ public Color getBackColor() {+ return backColor;+ }+++ /**+ * Sets the width attribute of the Movie object+ *+ *@param width The new width value+ */+ public void setWidth(int width) {+ this.width = width;+ }+++ /**+ * Sets the height attribute of the Movie object+ *+ *@param height The new height value+ */+ public void setHeight(int height) {+ this.height = height;+ }+++ /**+ * Sets the frameRate attribute of the Movie object+ *+ *@param rate The new frameRate value+ */+ public void setFrameRate(int rate) {+ this.frameRate = rate;+ }+++ /**+ * Sets the version attribute of the Movie object+ *+ *@param version The new version value+ */+ public void setVersion(int version) {+ this.version = version;+ }+++ /**+ * Sets the backColor attribute of the Movie object+ *+ *@param color The new backColor value+ */+ public void setBackColor(Color color) {+ this.backColor = color;+ }+++ /**+ * Return the protection flag. If true then the movie cannot be imported+ * into the Flash Author. The existence of tools such as JavaSWF makes this+ * kind of protection almost worthless.+ *+ *@return The protected value+ */+ public boolean isProtected() {+ return isProtected;+ }+++ /**+ * Description of the Method+ *+ *@param isProtected Description of the Parameter+ */+ public void protect(boolean isProtected) {+ this.isProtected = isProtected;+ }+++ /**+ * Get the current number of frames in the timeline.+ *+ *@return The frameCount value+ */+ public int getFrameCount() {+ return frameCount;+ }+++ /**+ * Get the Frame object for the given frame number - or create one if none+ * exists. If the frame number is larger than the current frame count then+ * the frame count is increased.+ *+ *@param frameNumber must be 1 or larger+ *@return The frame value+ */+ public Frame getFrame(int frameNumber) {+ if (frameNumber < 1) {+ return null;+ }++ Integer num = new Integer(frameNumber);+ Frame frame = (Frame) frames.get(num);++ if (frame == null) {+ frame = new Frame(frameNumber, this);+ frames.put(num, frame);+ if (frameNumber > frameCount) {+ frameCount = frameNumber;+ }+ }++ return frame;+ }+++ /**+ * Append a frame to the end of the timeline+ *+ *@return Description of the Return Value+ */+ public Frame appendFrame() {+ frameCount++;+ Frame frame = new Frame(frameCount, this);+ frames.put(new Integer(frameCount), frame);+ return frame;+ }+++ /**+ * Get the next available depth in the timeline+ *+ *@return The availableDepth value+ */+ public int getAvailableDepth() {+ return depth;+ }+++ /**+ * Set the next available depth in the timeline+ *+ *@param depth must be >= 1+ */+ public void setAvailableDepth(int depth) {+ if (depth < 1) {+ return;+ }+ this.depth = depth;+ }+++ /**+ * Import symbols from another movie (Flash 5 only)+ *+ *@param libraryName Description of the Parameter+ *@param symbolNames Description of the Parameter+ *@return Symbols representing the imports+ */+ public ImportedSymbol[] importSymbols(String libraryName, String[] symbolNames) {+ if (importLibraries == null) {+ importLibraries = new HashMap();+ }++ ArrayList imports = (ArrayList) importLibraries.get(libraryName);+ if (imports == null) {+ imports = new ArrayList();+ importLibraries.put(libraryName, imports);+ }++ ImportedSymbol[] symbols = new ImportedSymbol[symbolNames.length];++ for (int i = 0; i < symbolNames.length; i++) {+ ImportedSymbol imp = new ImportedSymbol(0, symbolNames[i], libraryName);+ symbols[i] = imp;+ imports.add(imp);+ }++ return symbols;+ }+++ /**+ * Clear all the defined library imports+ */+ public void clearImports() {+ if (importLibraries != null) {+ importLibraries.clear();+ }+ }+++ /**+ * Access the imported symbols.+ *+ *@return an empty array if there are no imports+ */+ public ImportedSymbol[] getImportedSymbols() {+ if (importLibraries == null) {+ return new ImportedSymbol[0];+ }++ Vector imports = new Vector();++ for (Iterator iter = importLibraries.values().iterator(); iter.hasNext(); ) {+ List list = (List) iter.next();++ for (Iterator i2 = list.iterator(); i2.hasNext(); ) {+ imports.add(i2.next());+ }+ }++ ImportedSymbol[] imps = new ImportedSymbol[imports.size()];+ imports.copyInto(imps);++ return imps;+ }+++ /**+ * Export a number of symbols with the given names so that other movies can+ * import and use them. Flash version 5 only.+ *+ *@param exportNames Description of the Parameter+ *@param symbols Description of the Parameter+ */+ public void exportSymbols(String[] exportNames, Symbol[] symbols) {+ if (exportedSymbols == null) {+ exportedSymbols = new Vector();+ }++ for (int i = 0; i < exportNames.length && i < symbols.length; i++) {+ exportedSymbols.add(new ExportedSymbol(symbols[i], exportNames[i]));+ }+ }+++ /**+ * Get the symbols exported from the movie+ *+ *@return an empty array if there are no exports+ */+ public ExportedSymbol[] getExportedSymbols() {+ if (exportedSymbols == null) {+ return new ExportedSymbol[0];+ }+ ExportedSymbol[] exports = new ExportedSymbol[exportedSymbols.size()];+ exportedSymbols.toArray(exports);+ return exports;+ }+++ /**+ * Clear all the symbol exports+ */+ public void clearExports() {+ if (exportedSymbols != null) {+ exportedSymbols.clear();+ }+ }+++ /**+ * Write the movie in SWF format.+ *+ *@param tagwriter Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void write(SWFTagTypes tagwriter) throws IOException {+ //--Reset state+ definedSymbols.clear();+ maxId = 1;++ tagwriter.header(version,+ -1,+ //force length calculation+ width * SWFConstants.TWIPS,+ height * SWFConstants.TWIPS,+ frameRate,+ -1);+ //force frame calculation++ //default backColor is white+ if (backColor == null) {+ backColor = new Color(255, 255, 255);+ }++ tagwriter.tagSetBackgroundColor(backColor);++ if (isProtected) {+ tagwriter.tagProtect(null);+ }++ //--Process Imports+ if (importLibraries != null && !importLibraries.isEmpty()) {+ for (Iterator keys = importLibraries.keySet().iterator(); keys.hasNext(); ) {+ String libName = (String) keys.next();+ List imports = (List) importLibraries.get(libName);++ String[] names = new String[imports.size()];+ int[] ids = new int[imports.size()];++ int i = 0;+ for (Iterator it = imports.iterator(); it.hasNext(); ) {+ ImportedSymbol imp = (ImportedSymbol) it.next();++ names[i] = imp.getName();+ ids[i] = imp.define(this, tagwriter, tagwriter);++ i++;+ }++ tagwriter.tagImport(libName, names, ids);+ }+ }++ //--Process Exports+ if (exportedSymbols != null && !exportedSymbols.isEmpty()) {+ String[] names = new String[exportedSymbols.size()];+ int[] ids = new int[exportedSymbols.size()];++ int i = 0;+ for (Iterator it = exportedSymbols.iterator(); it.hasNext(); ) {+ ExportedSymbol exp = (ExportedSymbol) it.next();++ names[i] = exp.getExportName();+ ids[i] = exp.getSymbol().define(this, tagwriter, tagwriter);++ i++;+ }++ tagwriter.tagExport(names, ids);+ }++ int lastFrame = 0;+ for (Iterator iter = frames.values().iterator(); iter.hasNext(); ) {+ Frame frame = (Frame) iter.next();++ int number = frame.getFrameNumber();++ //write any intermediate empty frames+ while (number > lastFrame + 1) {+ tagwriter.tagShowFrame();+ lastFrame++;+ }++ frame.write(this, tagwriter, tagwriter);++ lastFrame = number;+ }++ //end of time line+ tagwriter.tagEnd();+ }+++ /**+ * Write the movie in SWF format to the given file.+ *+ *@param filename Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void write(String filename) throws IOException {+ SWFWriter swfwriter = new SWFWriter(filename);+ TagWriter tagwriter = new TagWriter(swfwriter);+ write(tagwriter);+ }+++ /**+ * Write the movie in SWF format to the given output stream.+ *+ *@param out Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void write(OutputStream out) throws IOException {+ SWFWriter swfwriter = new SWFWriter(out);+ TagWriter tagwriter = new TagWriter(swfwriter);+ write(tagwriter);+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/OutStream.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/OutStream.javanew file mode 100644index 000000000..0700fcc75--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/OutStream.java@@ -0,0 +1,566 @@+package pt.tumba.parser.swf;++import java.io.ByteArrayOutputStream;+import java.io.DataOutputStream;+import java.io.IOException;+import java.io.OutputStream;++/**+ * Output Stream Wrapper+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class OutStream {+ /**+ * Description of the Field+ */+ protected OutputStream out;+ /**+ * Description of the Field+ */+ protected long bytesWritten = 0L;++ //--Bit buffer..+ /**+ * Description of the Field+ */+ protected int bitBuf;+ /**+ * Description of the Field+ */+ protected int bitPos;+++ /**+ * Constructor for the OutStream object+ *+ *@param out Description of the Parameter+ */+ public OutStream(OutputStream out) {+ this.out = out;+ bitBuf = 0;+ bitPos = 0;+ }+++ /**+ * Gets the bytesWritten attribute of the OutStream object+ *+ *@return The bytesWritten value+ */+ public long getBytesWritten() {+ return bytesWritten;+ }+++ /**+ * Sets the bytesWritten attribute of the OutStream object+ *+ *@param written The new bytesWritten value+ */+ public void setBytesWritten(long written) {+ bytesWritten = written;+ }+++ /**+ * Write a signed value to the output stream in the given number of bits.+ * The value must actually fit in that number of bits or it will be garbled+ *+ *@param numBits Description of the Parameter+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void writeSBits(int numBits, int value) throws IOException {+ //--Mask out any sign bit+ long lval = value & 0x7FFFFFFF;++ if (value < 0) {+ //add the sign bit++ lval |= 1L << (numBits - 1);+ }++ //--Write the bits as if unsigned+ writeUBits(numBits, lval);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void flush() throws IOException {+ flushBits();+ out.flush();+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void close() throws IOException {+ out.close();+ }+++ /**+ * Flush the bit buffer to the output stream and reset values+ *+ *@exception IOException Description of the Exception+ */+ public void flushBits() throws IOException {+ if (bitPos == 0) {+ return;+ }+ //nothing to flush++ out.write(bitBuf);+ bitBuf = 0;+ bitPos = 0;++ bytesWritten++;+ }+++ /**+ * Write an unsigned value to the output stream in the given number of bits+ *+ *@param numBits Description of the Parameter+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void writeUBits(int numBits, long value) throws IOException {+ if (numBits == 0) {+ return;+ }++ if (bitPos == 0) {+ bitPos = 8;+ }+ //bitBuf was empty++ int bitNum = numBits;++ while (bitNum > 0) {+ //write all bits++ while (bitPos > 0 && bitNum > 0) {+ //write into all position of the bit buffer++ if (getBit(bitNum, value)) {+ bitBuf = setBit(bitPos, bitBuf);+ }++ bitNum--;+ bitPos--;+ }++ if (bitPos == 0) {+ //bit buffer is full - write it++ writeUI8(bitBuf);+ bitBuf = 0;+ if (bitNum > 0) {+ bitPos = 8;+ }+ //prepare for more bits+ }+ }+ }+++ /**+ * Get the given bit (where lowest bit is numbered 1)+ *+ *@param bitNum Description of the Parameter+ *@param value Description of the Parameter+ *@return The bit value+ */+ public static boolean getBit(int bitNum, long value) {+ return (value & (1L << (bitNum - 1))) != 0;+ }+++ /**+ * Set the given bit (where lowest bit is numbered 1)+ *+ *@param bitNum The new bit value+ *@param value The new bit value+ *@return Description of the Return Value+ */+ public static int setBit(int bitNum, int value) {+ return value | (1 << (bitNum - 1));+ }+++ /**+ * Write the given bytes to the output stream+ *+ *@param bytes Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void write(byte[] bytes) throws IOException {+ flushBits();++ if (bytes != null && bytes.length > 0) {+ out.write(bytes);+ bytesWritten += bytes.length;+ }+ }+++ /**+ * Write the given bytes to the output stream+ *+ *@param bytes Description of the Parameter+ *@param start Description of the Parameter+ *@param length Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void write(byte[] bytes, int start, int length) throws IOException {+ flushBits();++ if (bytes != null && length > 0) {+ out.write(bytes, start, length);+ bytesWritten += length;+ }+ }+++ /**+ * Write an 8 bit unsigned value to the out stream+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void writeUI8(int value) throws IOException {+ flushBits();++ out.write(value);++ bytesWritten++;+ }+++ /**+ * Write a 16 bit unsigned value to the out stream+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void writeUI16(int value) throws IOException {+ flushBits();++ out.write(value & 0xff);+ out.write(value >> 8);++ bytesWritten += 2;+ }+++ /**+ * Write a 16 bit signed value to the out stream+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void writeSI16(short value) throws IOException {+ flushBits();++ out.write(value & 0xff);+ out.write(value >> 8);++ bytesWritten += 2;+ }+++ /**+ * Write a 32 bit unsigned value to the out stream+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void writeUI32(long value) throws IOException {+ flushBits();++ out.write((int) (value & 0xff));+ out.write((int) (value >> 8));+ out.write((int) (value >> 16));+ out.write((int) (value >> 24));++ bytesWritten += 4;+ }+++ /**+ * Write a string to the output stream using the default encoding and add+ * terminating null+ *+ *@param s Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void writeString(String s2) throws IOException {+ String s = s2;+ if (s == null) {+ s = "";+ }+ writeString(s.getBytes());+ }+++ /**+ * Write a string to the output stream and add terminating null+ *+ *@param string Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void writeString(byte[] string) throws IOException {+ flushBits();++ if (string != null) {+ out.write(string);+ }+ out.write(0);+ //terminate string++ bytesWritten += string.length + 1;+ }+++ /**+ * Calculate the byte length of a string as it would be written to the+ * output stream+ *+ *@param string Description of the Parameter+ *@return The stringLength value+ */+ public static int getStringLength(byte[] string) {+ if (string == null) {+ return 1;+ }+ return string.length + 1;+ //to include the terminating null+ }+++ /**+ * Calculate the byte length of a string as it would be written to the+ * output stream using the default character encoding+ *+ *@param string Description of the Parameter+ *@return The stringLength value+ */+ public static int getStringLength(String string) {+ if (string == null) {+ return 1;+ }+ byte[] bytes = string.getBytes();++ return bytes.length + 1;+ //to include the terminating null+ }+++ /**+ * Reset the bit buffer+ */+ protected void initBits() {+ bitBuf = 0;+ bitPos = 0;+ }+++ /**+ * Determine the minimum number of bits required to hold the given signed+ * value+ *+ *@param value Description of the Parameter+ *@return Description of the Return Value+ */+ public static int determineSignedBitSize(int value) {+ if (value >= 0) {+ return determineUnsignedBitSize(value) + 1;+ }++ //--This is probably a really bad way of doing this...+ int topBit = 31;+ long mask = 0x40000000L;++ while (topBit > 0) {+ if ((value & mask) == 0) {+ break;+ }++ mask >>= 1;+ topBit--;+ }++ if (topBit == 0) {+ return 2;+ }+ //must have been -1++ //HACK: Flash represents -16 as 110000 rather than 10000 etc..+ int val2 = value & ((1 << topBit) - 1);+ if (val2 == 0) {+ topBit++;+ }++ return topBit + 1;+ }+++ /**+ * Determine the minimum number of bits required to hold the given unsigned+ * value (may be zero)+ *+ *@param value Description of the Parameter+ *@return Description of the Return Value+ */+ public static int determineUnsignedBitSize(long value) {+ //--This is probably a really bad way of doing this...+ int topBit = 32;+ long mask = 0x80000000L;++ while (topBit > 0) {+ if ((value & mask) != 0) {+ return topBit;+ }++ mask >>= 1;+ topBit--;+ }++ return 0;+ }+++ /**+ * Write a float value+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void writeFloat(float value) throws IOException {+ writeSI32(Float.floatToIntBits(value));+ }+++ /**+ * Write a double value+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void writeDouble(double value) throws IOException {+ ByteArrayOutputStream baos = new ByteArrayOutputStream();+ DataOutputStream dout = new DataOutputStream(baos);++ dout.writeDouble(value);++ dout.flush();++ byte[] bytes = baos.toByteArray();+ byte[] bytes2 = new byte[8];++ bytes2[0] = bytes[3];+ bytes2[1] = bytes[2];+ bytes2[2] = bytes[1];+ bytes2[3] = bytes[0];+ bytes2[4] = bytes[7];+ bytes2[5] = bytes[6];+ bytes2[6] = bytes[5];+ bytes2[7] = bytes[4];++ write(bytes2);+ }+++ /**+ * Write a 32 bit signed value+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void writeSI32(int value) throws IOException {+ flushBits();++ out.write(value & 0xff);+ out.write(value >> 8);+ out.write(value >> 16);+ out.write(value >> 24);++ bytesWritten += 4;+ }+++ /**+ * Util to convert a signed int to 2 bytes+ *+ *@param value Description of the Parameter+ *@return Description of the Return Value+ */+ public static byte[] sintTo2Bytes(int value) {+ return new byte[]+ {+ uintToByte(value & 0xff),+ uintToByte(value >> 8)+ };+ }+++ /**+ * Util to convert an unsigned int to 2 bytes+ *+ *@param value Description of the Parameter+ *@return Description of the Return Value+ */+ public static byte[] uintTo2Bytes(int value) {+ return new byte[]+ {+ uintToByte(value & 0xff),+ uintToByte(value >> 8)+ };+ }+++ /**+ * Util to convert an unsigned int to 4 bytes+ *+ *@param value Description of the Parameter+ *@return Description of the Return Value+ */+ public static byte[] uintTo4Bytes(int value) {+ return new byte[]+ {+ uintToByte(value & 0xff),+ uintToByte(value >> 8),+ uintToByte(value >> 16),+ uintToByte(value >> 24)+ };+ }+++ /**+ * Util to convert an unsigned int to an unsigned byte+ *+ *@param value Description of the Parameter+ *@return Description of the Return Value+ */+ public static byte uintToByte(int value2) {+ int value = value2;+ int lowbit = value & 1;+ value >>= 1;++ byte b = (byte) value;+ b <<= 1;+ b |= (byte) lowbit;++ return b;+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Placement.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Placement.javanew file mode 100644index 000000000..2617f7efc--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Placement.java@@ -0,0 +1,309 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * A Placement holds the transformation and other values relating to the+ * "placement" of a Symbol Instance within a particular frame.+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class Placement {+ /**+ * Description of the Field+ */+ protected boolean isAlteration;+ /**+ * Description of the Field+ */+ protected boolean isReplacement;+ /**+ * Description of the Field+ */+ protected int frameNumber;+ /**+ * Description of the Field+ */+ protected Instance instance;+ /**+ * Description of the Field+ */+ protected Transform matrix;+ /**+ * Description of the Field+ */+ protected AlphaTransform cxform;+ /**+ * Description of the Field+ */+ protected String name;+ /**+ * Description of the Field+ */+ protected int ratio = -1;+ /**+ * Description of the Field+ */+ protected int clipDepth = -1;+ /**+ * Description of the Field+ */+ protected boolean isRemove = false;+ /**+ * Description of the Field+ */+ protected Actions[] clipActions;+++ /**+ * Return true if the placement is replacing the symbol at a given depth+ * with a new symbol+ *+ *@return The replacement value+ */+ public boolean isReplacement() {+ return isReplacement;+ }+++ /**+ * Return true if this placement is an alteration to an Instance that was+ * placed in a previous frame.+ *+ *@return The alteration value+ */+ public boolean isAlteration() {+ return isAlteration;+ }+++ /**+ * Get the number of the frame within which this placement takes place+ *+ *@return The frameNumber value+ */+ public int getFrameNumber() {+ return frameNumber;+ }+++ /**+ * Get the Symbol Instance represented by this Placement+ *+ *@return The instance value+ */+ public Instance getInstance() {+ return instance;+ }+++ /**+ * The transform may be null+ *+ *@return The transform value+ */+ public Transform getTransform() {+ return matrix;+ }+++ /**+ * The color transform may be null+ *+ *@return The colorTransform value+ */+ public AlphaTransform getColorTransform() {+ return cxform;+ }+++ /**+ * The name only relates to MovieClip instances and may be null. The name+ * is only present on the first Placement of an Instance.+ *+ *@return The name value+ */+ public String getName() {+ return name;+ }+++ /**+ * The ratio only relates to Morph Shapes and will be -1 otherwise. The+ * ratio is from zero to 65535 and denotes the degree of the morph from the+ * initial shape to the final shape.+ *+ *@return The ratio value+ */+ public int getRatio() {+ return ratio;+ }+++ /**+ * The clip depth defines the range of depths which will be clipped by this+ * symbol. All symbols placed at depths from depth+1 to clipDepth+ * (inclusive) will be clipped. If this symbol is not a clipping symbol+ * then the clip depth will be -1. The clip depth is only present on the+ * first Placement of an Instance.+ *+ *@return The clipDepth value+ */+ public int getClipDepth() {+ return clipDepth;+ }+++ /**+ * If true then this Placement denotes the removal of the Instance from the+ * stage.+ *+ *@return The remove value+ */+ public boolean isRemove() {+ return isRemove;+ }+++ /**+ * Get the actions for a movie clip+ *+ *@return The clipActions value+ */+ public Actions[] getClipActions() {+ return clipActions;+ }+++ /**+ * Set the actions for a movie clip+ *+ *@param clipActions The new clipActions value+ */+ public void setClipActions(Actions[] clipActions) {+ this.clipActions = clipActions;+ }+++ /**+ * Constructor for the Placement object+ *+ *@param instance Description of the Parameter+ *@param frameNumber Description of the Parameter+ */+ protected Placement(Instance instance, int frameNumber) {+ this.instance = instance;+ this.frameNumber = frameNumber;+ this.isRemove = true;+ }+++ /**+ * Constructor for the Placement object+ *+ *@param instance Description of the Parameter+ *@param matrix Description of the Parameter+ *@param cxform Description of the Parameter+ *@param name Description of the Parameter+ *@param ratio Description of the Parameter+ *@param clipDepth Description of the Parameter+ *@param frameNumber Description of the Parameter+ *@param alteration Description of the Parameter+ *@param replacement Description of the Parameter+ *@param clipActions Description of the Parameter+ */+ protected Placement(Instance instance, Transform matrix, AlphaTransform cxform,+ String name, int ratio, int clipDepth, int frameNumber,+ boolean alteration, boolean replacement, Actions[] clipActions) {+ this.instance = instance;+ this.frameNumber = frameNumber;+ this.matrix = matrix;+ this.cxform = cxform;+ this.name = name;+ this.ratio = ratio;+ this.clipDepth = clipDepth;+ this.isRemove = false;+ this.isAlteration = alteration;+ this.isReplacement = replacement;+ this.clipActions = clipActions;+ }+++ /**+ * Description of the Method+ *+ *@param movie Description of the Parameter+ *@param timelineWriter Description of the Parameter+ *@param definitionWriter Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void flushDefinitions(Movie movie,+ SWFTagTypes timelineWriter,+ SWFTagTypes definitionWriter)+ throws IOException {+ if ((!isAlteration) && !isRemove) {+ //--Make sure that the symbol is defined+ Symbol symbol = instance.getSymbol();++ symbol.define(movie, timelineWriter, definitionWriter);+ }+ }+++ /**+ * Description of the Method+ *+ *@param movie Description of the Parameter+ *@param movieTagWriter Description of the Parameter+ *@param timelineTagWriter Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void write(Movie movie,+ SWFTagTypes movieTagWriter,+ SWFTagTypes timelineTagWriter)+ throws IOException {+ int depth = instance.getDepth();+ if (depth < 0) {+ return;+ }++ if (isRemove) {+ //--Remove the instance+ timelineTagWriter.tagRemoveObject2(depth);+ return;+ }++ //--Check whether the Instance has been placed+ if (!isAlteration) {+ //--Make sure that the symbol is defined+ Symbol symbol = instance.getSymbol();+ int id = symbol.define(movie, timelineTagWriter, movieTagWriter);++ int flags = 0;++ if (clipActions != null && clipActions.length > 0) {+ for (int i = 0; i < clipActions.length; i++) {+ flags |= clipActions[i].getConditions();+ }+ }++ SWFActions acts = timelineTagWriter.tagPlaceObject2(+ isReplacement, clipDepth, depth, id,+ matrix, cxform, ratio, name, flags);++ if (clipActions != null && clipActions.length > 0) {+ for (int i = 0; i < clipActions.length; i++) {+ acts.start(clipActions[i].getConditions());+ acts.blob(clipActions[i].bytes);+ }++ acts.done();+ }+ } else {+ //--Instance is placed - this is just a move+ timelineTagWriter.tagPlaceObject2(true, clipDepth, depth, -1,+ matrix, cxform, ratio, null, 0);+ }+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Rect.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Rect.javanew file mode 100644index 000000000..ccaa57e3a--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Rect.java@@ -0,0 +1,234 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * A SWF Rectangle structure+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class Rect {+ /**+ * Description of the Field+ */+ protected int bitSize = -1;+ /**+ * Description of the Field+ */+ protected int minX;+ /**+ * Description of the Field+ */+ protected int minY;+ /**+ * Description of the Field+ */+ protected int maxX;+ /**+ * Description of the Field+ */+ protected int maxY;+++ /**+ * Gets the minX attribute of the Rect object+ *+ *@return The minX value+ */+ public int getMinX() {+ return minX;+ }+++ /**+ * Gets the minY attribute of the Rect object+ *+ *@return The minY value+ */+ public int getMinY() {+ return minY;+ }+++ /**+ * Gets the maxX attribute of the Rect object+ *+ *@return The maxX value+ */+ public int getMaxX() {+ return maxX;+ }+++ /**+ * Gets the maxY attribute of the Rect object+ *+ *@return The maxY value+ */+ public int getMaxY() {+ return maxY;+ }+++ /**+ * Sets the minX attribute of the Rect object+ *+ *@param minX The new minX value+ */+ public void setMinX(int minX) {+ this.minX = minX;+ bitSize = -1;+ }+++ /**+ * Sets the minY attribute of the Rect object+ *+ *@param minY The new minY value+ */+ public void setMinY(int minY) {+ this.minY = minY;+ bitSize = -1;+ }+++ /**+ * Sets the maxX attribute of the Rect object+ *+ *@param maxX The new maxX value+ */+ public void setMaxX(int maxX) {+ this.maxX = maxX;+ bitSize = -1;+ }+++ /**+ * Sets the maxY attribute of the Rect object+ *+ *@param maxY The new maxY value+ */+ public void setMaxY(int maxY) {+ this.maxY = maxY;+ bitSize = -1;+ }+++ /**+ * Constructor for the Rect object+ *+ *@param minX Description of the Parameter+ *@param minY Description of the Parameter+ *@param maxX Description of the Parameter+ *@param maxY Description of the Parameter+ */+ public Rect(int minX, int minY, int maxX, int maxY) {+ this.minX = minX;+ this.minY = minY;+ this.maxX = maxX;+ this.maxY = maxY;+ }+++ /**+ * Constructor for the Rect object+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public Rect(InStream in) throws IOException {+ in.synchBits();+ bitSize = (int) in.readUBits(5);+ minX = (int) in.readSBits(bitSize);+ maxX = (int) in.readSBits(bitSize);+ minY = (int) in.readSBits(bitSize);+ maxY = (int) in.readSBits(bitSize);+ }+++ /**+ * Constructor for the Rect object+ */+ public Rect() {+ this(0, 0, 11000, 8000);+ //default size+ }+++ /**+ * Calculate the minimum bit size based on the current values+ *+ *@return The bitSize value+ */+ protected int getBitSize() {+ if (bitSize == -1) {+ //bitsize not defined++ int bsMinX = OutStream.determineSignedBitSize(minX);+ int bsMaxX = OutStream.determineSignedBitSize(maxX);+ int bsMinY = OutStream.determineSignedBitSize(minY);+ int bsMaxY = OutStream.determineSignedBitSize(maxY);++ bitSize = bsMinY;+ if (bitSize < bsMaxX) {+ bitSize = bsMaxX;+ }+ if (bitSize < bsMinX) {+ bitSize = bsMinX;+ }+ if (bitSize < bsMaxY) {+ bitSize = bsMaxY;+ }+ }++ return bitSize;+ }+++ /**+ * Gets the length attribute of the Rect object+ *+ *@return The length value+ */+ public long getLength() {+ int bits = 5 + (getBitSize() * 4);+ int bytes = bits / 8;++ if (bytes * 8 < bits) {+ bytes++;+ }++ return bytes;+ }+++ /**+ * Write the rect contents to the output stream+ *+ *@param out Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void write(OutStream out) throws IOException {+ out.flushBits();++ out.writeUBits(5, getBitSize());+ out.writeSBits(bitSize, minX);+ out.writeSBits(bitSize, maxX);+ out.writeSBits(bitSize, minY);+ out.writeSBits(bitSize, maxY);++ out.flushBits();+ }+++ /**+ * Description of the Method+ *+ *@return Description of the Return Value+ */+ public String toString() {+ return "Rect bitsize=" + bitSize ++ " (" + minX + "," + minY + ")-(" + maxX + "," + maxY + ")";+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWF2HTML.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWF2HTML.javanew file mode 100644index 000000000..9823516b2--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWF2HTML.java@@ -0,0 +1,320 @@+package pt.tumba.parser.swf;++import java.io.ByteArrayInputStream;+import java.io.File;+import java.io.FileInputStream;+import java.io.IOException;+import java.io.InputStream;+import java.io.PrintWriter;+import java.io.StringWriter;+import java.net.HttpURLConnection;+import java.net.URL;+import java.util.HashMap;+import java.util.Map;++import pt.tumba.parser.DocFilter;++/**+ * Description of the Class+ *+ *@author bmartins+ *@created 22 de Agosto de 2002+ */+public class SWF2HTML extends SWFTagTypesImpl implements DocFilter {++ private int sizeCount = 0;+++ /**+ * Description of the Method+ *+ *@return Description of the Return Value+ */+ public int originalSize() {+ return sizeCount;+ }+++ /**+ * Description of the Field+ */+ protected Map fontCodes = new HashMap();++ /**+ * Description of the Field+ */+ protected PrintWriter output;++ //private HTMLParser aux;+++ /**+ * Constructor for the SWF2HTML object+ */+ public SWF2HTML() {+ super(null);+ }+++ /**+ * SWFTagTypes interface Save the Text Font character code info+ *+ *@param fontId Description of the Parameter+ *@param fontName Description of the Parameter+ *@param flags Description of the Parameter+ *@param codes Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineFontInfo(int fontId, String fontName, int flags, int[] codes)+ throws IOException {+ fontCodes.put(new Integer(fontId), codes);+ }+++ /**+ * SWFTagTypes interface Save the character code info+ *+ *@param id Description of the Parameter+ *@param flags Description of the Parameter+ *@param name Description of the Parameter+ *@param numGlyphs Description of the Parameter+ *@param ascent Description of the Parameter+ *@param descent Description of the Parameter+ *@param leading Description of the Parameter+ *@param codes Description of the Parameter+ *@param advances Description of the Parameter+ *@param bounds Description of the Parameter+ *@param kernCodes1 Description of the Parameter+ *@param kernCodes2 Description of the Parameter+ *@param kernAdjustments Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFVectors tagDefineFont2(int id, int flags, String name, int numGlyphs,+ int ascent, int descent, int leading,+ int[] codes, int[] advances, Rect[] bounds,+ int[] kernCodes1, int[] kernCodes2,+ int[] kernAdjustments) throws IOException {+ fontCodes.put(new Integer(id), (codes != null) ? codes : new int[0]);++ return null;+ }+++ /**+ * SWFTagTypes interface Dump any initial text in the field+ *+ *@param fieldId Description of the Parameter+ *@param fieldName Description of the Parameter+ *@param initialText Description of the Parameter+ *@param boundary Description of the Parameter+ *@param flags Description of the Parameter+ *@param textColor Description of the Parameter+ *@param alignment Description of the Parameter+ *@param fontId Description of the Parameter+ *@param fontSize Description of the Parameter+ *@param charLimit Description of the Parameter+ *@param leftMargin Description of the Parameter+ *@param rightMargin Description of the Parameter+ *@param indentation Description of the Parameter+ *@param lineSpacing Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineTextField(int fieldId, String fieldName,+ String initialText, Rect boundary, int flags,+ AlphaColor textColor, int alignment, int fontId, int fontSize,+ int charLimit, int leftMargin, int rightMargin, int indentation,+ int lineSpacing)+ throws IOException {+ if (initialText != null) {+ output.println(initialText);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param bounds Description of the Parameter+ *@param matrix Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFText tagDefineText(int id, Rect bounds, Matrix matrix)+ throws IOException {+ return new TextDumper();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param bounds Description of the Parameter+ *@param matrix Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFText tagDefineText2(int id, Rect bounds, Matrix matrix) throws IOException {+ return new TextDumper();+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public class TextDumper implements SWFText {+ /**+ * Description of the Field+ */+ protected Integer fontId;+ /**+ * Description of the Field+ */+ protected boolean firstY = true;+++ /**+ * Description of the Method+ *+ *@param fontId Description of the Parameter+ *@param textHeight Description of the Parameter+ */+ public void font(int fontId, int textHeight) {+ this.fontId = new Integer(fontId);+ }+++ /**+ * Sets the y attribute of the TextDumper object+ *+ *@param y The new y value+ */+ public void setY(int y) {+ if (firstY) {+ firstY = false;+ } else {+ output.println();+ }+ //Change in Y - dump a new line+ }+++ /**+ * Description of the Method+ *+ *@param glyphIndices Description of the Parameter+ *@param glyphAdvances Description of the Parameter+ */+ public void text(int[] glyphIndices, int[] glyphAdvances) {+ int[] codes = (int[]) fontCodes.get(fontId);+ if (codes == null) {+ return;+ }+ //--Translate the glyph indices to character codes+ char[] chars = new char[glyphIndices.length];+ for (int i = 0; i < chars.length; i++) {+ int index = glyphIndices[i];+ if (index >= codes.length) {+ //System Font ?+ chars[i] = (char) index;+ } else {+ chars[i] = (char) (codes[index]);+ }+ }++ output.print(chars);+ }+++ /**+ * Description of the Method+ *+ *@param color Description of the Parameter+ */+ public void color(Color color) { }+++ /**+ * Sets the x attribute of the TextDumper object+ *+ *@param x The new x value+ */+ public void setX(int x) { }+++ /**+ * Description of the Method+ */+ public void done() {+ output.println();+ }+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@return Description of the Return Value+ *@exception Exception Description of the Exception+ */+ public String convertSWFToHTML(File in) throws Exception {+ return convertSWFToHTML(new FileInputStream(in));+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@return Description of the Return Value+ *@exception Exception Description of the Exception+ */+ public String convertSWFToHTML(URL in) throws Exception {+ HttpURLConnection conn = (HttpURLConnection) in.openConnection();+ conn.setAllowUserInteraction(false);+ conn.setRequestProperty("User-agent", "www.tumba.pt");+ conn.setInstanceFollowRedirects(true);+ conn.connect();+ return convertSWFToHTML(conn.getInputStream());+ }+++ /**+ * Arguments are: 0. Name of input SWF+ *+ *@param in Description of the Parameter+ *@return Description of the Return Value+ *@exception Exception Description of the Exception+ */+ public String convertSWFToHTML(InputStream in) throws Exception {+ StringWriter out1 = new StringWriter();+ output = new PrintWriter(out1);+ output.println("<html><body>");+ TagParser parser = new TagParser(this);+ SWFReader reader = new SWFReader(parser, in);+ reader.readFile();+ in.close();+ output.println("</body></html>");+ sizeCount = reader.size;+ return out1.toString();+ }+++ /**+ * Description of the Method+ *+ *@param b2 Description of the Parameter+ *@return Description of the Return Value+ *@exception Exception Description of the Exception+ */+ public String convertSWFToHTML(byte[] b2) throws Exception {+ return convertSWFToHTML(new ByteArrayInputStream(b2));+ }++}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFActionCodes.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFActionCodes.javanew file mode 100644index 000000000..35fc9c9a6--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFActionCodes.java@@ -0,0 +1,631 @@+package pt.tumba.parser.swf;+++/**+ * Action Codes and associated constants+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public interface SWFActionCodes {+ /**+ * Description of the Field+ */+ public final static int NEXT_FRAME = 0x04;+ //F3 ***+ /**+ * Description of the Field+ */+ public final static int PREVIOUS_FRAME = 0x05;+ //F3 ***+ /**+ * Description of the Field+ */+ public final static int PLAY = 0x06;+ //F3 ***+ /**+ * Description of the Field+ */+ public final static int STOP = 0x07;+ //F3 ***+ /**+ * Description of the Field+ */+ public final static int TOGGLE_QUALITY = 0x08;+ //F3 ***+ /**+ * Description of the Field+ */+ public final static int STOP_SOUNDS = 0x09;+ //F3 ***+ /**+ * Description of the Field+ */+ public final static int ADD = 0x0a;+ //F4+ /**+ * Description of the Field+ */+ public final static int SUBTRACT = 0x0b;+ //F4+ /**+ * Description of the Field+ */+ public final static int MULTIPLY = 0x0c;+ //F4+ /**+ * Description of the Field+ */+ public final static int DIVIDE = 0x0d;+ //F4+ /**+ * Description of the Field+ */+ public final static int EQUALS = 0x0e;+ //F4+ /**+ * Description of the Field+ */+ public final static int LESS = 0x0f;+ //F4+ /**+ * Description of the Field+ */+ public final static int AND = 0x10;+ //F4+ /**+ * Description of the Field+ */+ public final static int OR = 0x11;+ //F4+ /**+ * Description of the Field+ */+ public final static int NOT = 0x12;+ //F4+ /**+ * Description of the Field+ */+ public final static int STRING_EQUALS = 0x13;+ //F4+ /**+ * Description of the Field+ */+ public final static int STRING_LENGTH = 0x14;+ //F4+ /**+ * Description of the Field+ */+ public final static int STRING_EXTRACT = 0x15;+ //F4++ /**+ * Description of the Field+ */+ public final static int POP = 0x17;+ //F4+ /**+ * Description of the Field+ */+ public final static int TO_INTEGER = 0x18;+ //F4++ /**+ * Description of the Field+ */+ public final static int GET_VARIABLE = 0x1c;+ //F4+ /**+ * Description of the Field+ */+ public final static int SET_VARIABLE = 0x1d;+ //F4++ /**+ * Description of the Field+ */+ public final static int SET_TARGET_2 = 0x20;+ //F4+ /**+ * Description of the Field+ */+ public final static int STRING_ADD = 0x21;+ //F4+ /**+ * Description of the Field+ */+ public final static int GET_PROPERTY = 0x22;+ //F4+ /**+ * Description of the Field+ */+ public final static int SET_PROPERTY = 0x23;+ //F4+ /**+ * Description of the Field+ */+ public final static int CLONE_SPRITE = 0x24;+ //F4+ /**+ * Description of the Field+ */+ public final static int REMOVE_SPRITE = 0x25;+ //F4+ /**+ * Description of the Field+ */+ public final static int TRACE = 0x26;+ //F4+ /**+ * Description of the Field+ */+ public final static int START_DRAG = 0x27;+ //F4+ /**+ * Description of the Field+ */+ public final static int END_DRAG = 0x28;+ //F4+ /**+ * Description of the Field+ */+ public final static int STRING_LESS = 0x29;+ //F4++ /**+ * Description of the Field+ */+ public final static int RANDOM_NUMBER = 0x30;+ //F4+ /**+ * Description of the Field+ */+ public final static int MB_STRING_LENGTH = 0x31;+ //F4+ /**+ * Description of the Field+ */+ public final static int CHAR_TO_ASCII = 0x32;+ //F4+ /**+ * Description of the Field+ */+ public final static int ASCII_TO_CHAR = 0x33;+ //F4+ /**+ * Description of the Field+ */+ public final static int GET_TIME = 0x34;+ //F4+ /**+ * Description of the Field+ */+ public final static int MB_STRING_EXTRACT = 0x35;+ //F4+ /**+ * Description of the Field+ */+ public final static int MB_CHAR_TO_ASCII = 0x36;+ //F4+ /**+ * Description of the Field+ */+ public final static int MB_ASCII_TO_CHAR = 0x37;+ //F4++ /**+ * Description of the Field+ */+ public final static int DEL_VAR = 0x3a;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int DEL_THREAD_VARS = 0x3b;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int DEFINE_LOCAL_VAL = 0x3c;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int CALL_FUNCTION = 0x3d;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int RETURN = 0x3e;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int MODULO = 0x3f;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int NEW_OBJECT = 0x40;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int DEFINE_LOCAL = 0x41;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int INIT_ARRAY = 0x42;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int INIT_OBJECT = 0x43;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int TYPEOF = 0x44;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int GET_TARGET_PATH = 0x45;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int ENUMERATE = 0x46;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int TYPED_ADD = 0x47;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int TYPED_LESS_THAN = 0x48;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int TYPED_EQUALS = 0x49;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int CONVERT_TO_NUMBER = 0x4a;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int CONVERT_TO_STRING = 0x4b;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int DUPLICATE = 0x4c;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int SWAP = 0x4d;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int GET_MEMBER = 0x4e;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int SET_MEMBER = 0x4f;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int INCREMENT = 0x50;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int DECREMENT = 0x51;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int CALL_METHOD = 0x52;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int CALL_NEW_METHOD = 0x53;+ //F5 ---++ /**+ * Description of the Field+ */+ public final static int BIT_AND = 0x60;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int BIT_OR = 0x61;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int BIT_XOR = 0x62;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int SHIFT_LEFT = 0x63;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int SHIFT_RIGHT = 0x64;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int SHIFT_UNSIGNED = 0x65;+ //F5 ---++ /**+ * Description of the Field+ */+ public final static int GOTO_FRAME = 0x81;+ //F3 ***++ /**+ * Description of the Field+ */+ public final static int GET_URL = 0x83;+ //F3 ***++ /**+ * Description of the Field+ */+ public final static int REGISTER = 0x87;+ //F5 ---+ /**+ * Description of the Field+ */+ public final static int LOOKUP_TABLE = 0x88;+ //F5 ---++ /**+ * Description of the Field+ */+ public final static int WAIT_FOR_FRAME = 0x8a;+ //F3 ***+ /**+ * Description of the Field+ */+ public final static int SET_TARGET = 0x8b;+ //F3 ***+ /**+ * Description of the Field+ */+ public final static int GOTO_LABEL = 0x8c;+ //F3 ***+ /**+ * Description of the Field+ */+ public final static int WAIT_FOR_FRAME_2 = 0x8d;+ //F4++ /**+ * Description of the Field+ */+ public final static int WITH = 0x94;+ //F5 ---++ /**+ * Description of the Field+ */+ public final static int PUSH = 0x96;+ //F4++ /**+ * Description of the Field+ */+ public final static int JUMP = 0x99;+ //F4+ /**+ * Description of the Field+ */+ public final static int GET_URL_2 = 0x9a;+ //F4+ /**+ * Description of the Field+ */+ public final static int DEFINE_FUNCTION = 0x9b;+ //F5 ---++ /**+ * Description of the Field+ */+ public final static int IF = 0x9d;+ //F4+ /**+ * Description of the Field+ */+ public final static int CALL = 0x9e;+ //F4+ /**+ * Description of the Field+ */+ public final static int GOTO_FRAME_2 = 0x9f;+ //F4++ //--Property Constants+ /**+ * Description of the Field+ */+ public final static int PROP_X = 0;+ /**+ * Description of the Field+ */+ public final static int PROP_Y = 1;+ /**+ * Description of the Field+ */+ public final static int PROP_XSCALE = 2;+ /**+ * Description of the Field+ */+ public final static int PROP_YSCALE = 3;+ /**+ * Description of the Field+ */+ public final static int PROP_CURRENTFRAME = 4;+ /**+ * Description of the Field+ */+ public final static int PROP_TOTALFRAMES = 5;+ /**+ * Description of the Field+ */+ public final static int PROP_ALPHA = 6;+ /**+ * Description of the Field+ */+ public final static int PROP_VISIBLE = 7;+ /**+ * Description of the Field+ */+ public final static int PROP_WIDTH = 8;+ /**+ * Description of the Field+ */+ public final static int PROP_HEIGHT = 9;+ /**+ * Description of the Field+ */+ public final static int PROP_ROTATION = 10;+ /**+ * Description of the Field+ */+ public final static int PROP_TARGET = 11;+ /**+ * Description of the Field+ */+ public final static int PROP_FRAMESLOADED = 12;+ /**+ * Description of the Field+ */+ public final static int PROP_NAME = 13;+ /**+ * Description of the Field+ */+ public final static int PROP_DROPTARGET = 14;+ /**+ * Description of the Field+ */+ public final static int PROP_URL = 15;+ /**+ * Description of the Field+ */+ public final static int PROP_HIGHQUALITY = 16;+ /**+ * Description of the Field+ */+ public final static int PROP_FOCUSRECT = 17;+ /**+ * Description of the Field+ */+ public final static int PROP_SOUNDBUFTIME = 18;+ /**+ * Description of the Field+ */+ public final static int PROP_QUALITY = 19;+ //flash 5 only+ /**+ * Description of the Field+ */+ public final static int PROP_XMOUSE = 20;+ //flash 5 only+ /**+ * Description of the Field+ */+ public final static int PROP_YMOUSE = 21;+ //flash 5 only++ //--TypeOf Strings (from the ActionScript typeof() operator)+ /**+ * Description of the Field+ */+ public final static String TYPEOF_NUMBER = "number";+ /**+ * Description of the Field+ */+ public final static String TYPEOF_BOOLEAN = "boolean";+ /**+ * Description of the Field+ */+ public final static String TYPEOF_STRING = "string";+ /**+ * Description of the Field+ */+ public final static String TYPEOF_OBJECT = "object";+ /**+ * Description of the Field+ */+ public final static String TYPEOF_MOVIECLIP = "movieclip";+ /**+ * Description of the Field+ */+ public final static String TYPEOF_NULL = "null";+ /**+ * Description of the Field+ */+ public final static String TYPEOF_UNDEFINED = "undefined";+ /**+ * Description of the Field+ */+ public final static String TYPEOF_FUNCTION = "function";++ //--Types for Flash 5 push action+ /**+ * Description of the Field+ */+ public final static int PUSHTYPE_STRING = 0;+ /**+ * Description of the Field+ */+ public final static int PUSHTYPE_FLOAT = 1;+ /**+ * Description of the Field+ */+ public final static int PUSHTYPE_NULL = 2;+ /**+ * Description of the Field+ */+ public final static int PUSHTYPE_03 = 3;+ //unknown+ /**+ * Description of the Field+ */+ public final static int PUSHTYPE_REGISTER = 4;+ /**+ * Description of the Field+ */+ public final static int PUSHTYPE_BOOLEAN = 5;+ /**+ * Description of the Field+ */+ public final static int PUSHTYPE_DOUBLE = 6;+ /**+ * Description of the Field+ */+ public final static int PUSHTYPE_INTEGER = 7;+ /**+ * Description of the Field+ */+ public final static int PUSHTYPE_LOOKUP = 8;+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFActions.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFActions.javanew file mode 100644index 000000000..220b0cf21--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFActions.java@@ -0,0 +1,912 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * Interface for passing Action Codes Lifecycle is - 1. start(..) is called+ * with any condition flags (e.g. event codes) for the action array 2. action+ * methods are called 3. end() is called to terminate array 4. 1..3 is repeated+ * for any subsequent condition blocks 5. done() is called to terminate all+ * action passing+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public interface SWFActions {+ /**+ * Start of actions+ *+ *@param flags Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void start(int flags) throws IOException;+++ /**+ * End of all action blocks+ *+ *@exception IOException Description of the Exception+ */+ public void done() throws IOException;+++ /**+ * End of actions+ *+ *@exception IOException Description of the Exception+ */+ public void end() throws IOException;+++ /**+ * Pass through a blob of actions+ *+ *@param blob Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void blob(byte[] blob) throws IOException;+++ /**+ * Unrecognized action code+ *+ *@param data may be null+ *@param code Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void unknown(int code, byte[] data) throws IOException;+++ /**+ * Target label for a jump - this method call immediately precedes the+ * target action.+ *+ *@param label Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void jumpLabel(String label) throws IOException;+++ /**+ * Comment Text - useful for debugging purposes+ *+ *@param comment Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void comment(String comment) throws IOException;+++ //--Flash 3 Actions:+ /**+ * Description of the Method+ *+ *@param frameNumber Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void gotoFrame(int frameNumber) throws IOException;+++ /**+ * Description of the Method+ *+ *@param label Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void gotoFrame(String label) throws IOException;+++ /**+ * Gets the uRL attribute of the SWFActions object+ *+ *@param url Description of the Parameter+ *@param target Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void getURL(String url, String target) throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void nextFrame() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void prevFrame() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void play() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void stop() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void toggleQuality() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void stopSounds() throws IOException;+++ /**+ * Description of the Method+ *+ *@param frameNumber Description of the Parameter+ *@param jumpLabel Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void waitForFrame(int frameNumber, String jumpLabel) throws IOException;+++ /**+ * Sets the target attribute of the SWFActions object+ *+ *@param target The new target value+ *@exception IOException Description of the Exception+ */+ public void setTarget(String target) throws IOException;+++ //--Flash 4 Actions:+ /**+ * Description of the Method+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(String value) throws IOException;+++ /**+ * Description of the Method+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(float value) throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void pop() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void add() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void substract() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void multiply() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void divide() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void equals() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void lessThan() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void and() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void or() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void not() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void stringEquals() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void stringLength() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void concat() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void substring() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void stringLessThan() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void stringLengthMB() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void substringMB() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void toInteger() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void charToAscii() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void asciiToChar() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void charMBToAscii() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void asciiToCharMB() throws IOException;+++ /**+ * Description of the Method+ *+ *@param jumpLabel Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void jump(String jumpLabel) throws IOException;+++ /**+ * Description of the Method+ *+ *@param jumpLabel Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void ifJump(String jumpLabel) throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void call() throws IOException;+++ /**+ * Gets the variable attribute of the SWFActions object+ *+ *@exception IOException Description of the Exception+ */+ public void getVariable() throws IOException;+++ /**+ * Sets the variable attribute of the SWFActions object+ *+ *@exception IOException Description of the Exception+ */+ public void setVariable() throws IOException;+++ //----------------------------------------------------------+ /**+ * Description of the Field+ */+ public final static int GET_URL_SEND_VARS_NONE = 0;+ //don't send variables+ /**+ * Description of the Field+ */+ public final static int GET_URL_SEND_VARS_GET = 1;+ //send vars using GET+ /**+ * Description of the Field+ */+ public final static int GET_URL_SEND_VARS_POST = 2;+ //send vars using POST++ /**+ * Description of the Field+ */+ public final static int GET_URL_MODE_LOAD_MOVIE_INTO_LEVEL = 0;+ /**+ * Description of the Field+ */+ public final static int GET_URL_MODE_LOAD_MOVIE_INTO_SPRITE = 1;+ /**+ * Description of the Field+ */+ public final static int GET_URL_MODE_LOAD_VARS_INTO_LEVEL = 3;+ /**+ * Description of the Field+ */+ public final static int GET_URL_MODE_LOAD_VARS_INTO_SPRITE = 4;+++ /**+ * Gets the uRL attribute of the SWFActions object+ *+ *@param sendVars Description of the Parameter+ *@param loadMode Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void getURL(int sendVars, int loadMode) throws IOException;+++ //----------------------------------------------------------++ /**+ * Description of the Method+ *+ *@param play Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void gotoFrame(boolean play) throws IOException;+++ /**+ * Sets the target attribute of the SWFActions object+ *+ *@exception IOException Description of the Exception+ */+ public void setTarget() throws IOException;+++ /**+ * Gets the property attribute of the SWFActions object+ *+ *@exception IOException Description of the Exception+ */+ public void getProperty() throws IOException;+++ /**+ * Sets the property attribute of the SWFActions object+ *+ *@exception IOException Description of the Exception+ */+ public void setProperty() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void cloneSprite() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void removeSprite() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void startDrag() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void endDrag() throws IOException;+++ /**+ * Description of the Method+ *+ *@param jumpLabel Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void waitForFrame(String jumpLabel) throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void trace() throws IOException;+++ /**+ * Gets the time attribute of the SWFActions object+ *+ *@exception IOException Description of the Exception+ */+ public void getTime() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void randomNumber() throws IOException;+++ //--Flash 5 Actions+ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void callFunction() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void callMethod() throws IOException;+++ /**+ * Description of the Method+ *+ *@param values Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void lookupTable(String[] values) throws IOException;+++ //startFunction(..) is terminated by matching endBlock()+ /**+ * Description of the Method+ *+ *@param name Description of the Parameter+ *@param paramNames Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void startFunction(String name, String[] paramNames) throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void endBlock() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void defineLocalValue() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void defineLocal() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void deleteProperty() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void deleteThreadVars() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void enumerate() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void typedEquals() throws IOException;+++ /**+ * Gets the member attribute of the SWFActions object+ *+ *@exception IOException Description of the Exception+ */+ public void getMember() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void initArray() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void initObject() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void newMethod() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void newObject() throws IOException;+++ /**+ * Sets the member attribute of the SWFActions object+ *+ *@exception IOException Description of the Exception+ */+ public void setMember() throws IOException;+++ /**+ * Gets the targetPath attribute of the SWFActions object+ *+ *@exception IOException Description of the Exception+ */+ public void getTargetPath() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void startWith() throws IOException;+++ //terminated by matching endBlock()++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void convertToNumber() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void convertToString() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void typeOf() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void typedAdd() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void typedLessThan() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void modulo() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void bitAnd() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void bitOr() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void bitXor() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void shiftLeft() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void shiftRight() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void shiftRightUnsigned() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void decrement() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void increment() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void duplicate() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void returnValue() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void swap() throws IOException;+++ /**+ * Description of the Method+ *+ *@param registerNumber Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void storeInRegister(int registerNumber) throws IOException;+++ /**+ * Description of the Method+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(double value) throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void pushNull() throws IOException;+++ /**+ * Description of the Method+ *+ *@param registerNumber Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void pushRegister(int registerNumber) throws IOException;+++ /**+ * Description of the Method+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(boolean value) throws IOException;+++ /**+ * Description of the Method+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(int value) throws IOException;+++ /**+ * Description of the Method+ *+ *@param dictionaryIndex Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void lookup(int dictionaryIndex) throws IOException;+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFConstants.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFConstants.javanew file mode 100644index 000000000..d35837d47--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFConstants.java@@ -0,0 +1,513 @@+package pt.tumba.parser.swf;+++/**+ * Various SWF Constant Values+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public interface SWFConstants {+ /**+ * Description of the Field+ */+ public final static int TWIPS = 20;+ //number of TWIPS per pixel++ /**+ * Description of the Field+ */+ public final static int TAG_END = 0;+ /**+ * Description of the Field+ */+ public final static int TAG_SHOWFRAME = 1;+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINESHAPE = 2;+ /**+ * Description of the Field+ */+ public final static int TAG_FREECHARACTER = 3;+ /**+ * Description of the Field+ */+ public final static int TAG_PLACEOBJECT = 4;+ /**+ * Description of the Field+ */+ public final static int TAG_REMOVEOBJECT = 5;+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINEBITS = 6;+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINEBUTTON = 7;+ /**+ * Description of the Field+ */+ public final static int TAG_JPEGTABLES = 8;+ /**+ * Description of the Field+ */+ public final static int TAG_SETBACKGROUNDCOLOR = 9;+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINEFONT = 10;+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINETEXT = 11;+ /**+ * Description of the Field+ */+ public final static int TAG_DOACTION = 12;+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINEFONTINFO = 13;+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINESOUND = 14;+ /**+ * Description of the Field+ */+ public final static int TAG_STARTSOUND = 15;+ //???+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINEBUTTONSOUND = 17;+ /**+ * Description of the Field+ */+ public final static int TAG_SOUNDSTREAMHEAD = 18;+ /**+ * Description of the Field+ */+ public final static int TAG_SOUNDSTREAMBLOCK = 19;+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINEBITSLOSSLESS = 20;+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINEBITSJPEG2 = 21;+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINESHAPE2 = 22;+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINEBUTTONCXFORM = 23;+ /**+ * Description of the Field+ */+ public final static int TAG_PROTECT = 24;+ //???+ /**+ * Description of the Field+ */+ public final static int TAG_PLACEOBJECT2 = 26;+ //???+ /**+ * Description of the Field+ */+ public final static int TAG_REMOVEOBJECT2 = 28;+ //???+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINESHAPE3 = 32;+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINETEXT2 = 33;+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINEBUTTON2 = 34;+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINEBITSJPEG3 = 35;+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINEBITSLOSSLESS2 = 36;+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINETEXTFIELD = 37;+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINEQUICKTIMEMOVIE = 38;+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINESPRITE = 39;+ /**+ * Description of the Field+ */+ public final static int TAG_NAMECHARACTER = 40;+ /**+ * Description of the Field+ */+ public final static int TAG_SERIALNUMBER = 41;+ /**+ * Description of the Field+ */+ public final static int TAG_GENERATOR_TEXT = 42;+ /**+ * Description of the Field+ */+ public final static int TAG_FRAMELABEL = 43;+ //???+ /**+ * Description of the Field+ */+ public final static int TAG_SOUNDSTREAMHEAD2 = 45;+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINEMORPHSHAPE = 46;+ //???+ /**+ * Description of the Field+ */+ public final static int TAG_DEFINEFONT2 = 48;+ /**+ * Description of the Field+ */+ public final static int TAG_TEMPLATECOMMAND = 49;+ //???+ /**+ * Description of the Field+ */+ public final static int TAG_FLASHGENERATOR = 51;+ /**+ * Description of the Field+ */+ public final static int TAG_GEN_EXTERNAL_FONT = 52;+ //???+ //???+ //???+ /**+ * Description of the Field+ */+ public final static int TAG_EXPORT = 56;+ /**+ * Description of the Field+ */+ public final static int TAG_IMPORT = 57;+ /**+ * Description of the Field+ */+ public final static int TAG_ENABLEDEBUG = 58;++ //--Fill Types+ /**+ * Description of the Field+ */+ public final static int FILL_SOLID = 0x00;+ /**+ * Description of the Field+ */+ public final static int FILL_LINEAR_GRADIENT = 0x10;+ /**+ * Description of the Field+ */+ public final static int FILL_RADIAL_GRADIENT = 0x12;+ /**+ * Description of the Field+ */+ public final static int FILL_TILED_BITMAP = 0x40;+ /**+ * Description of the Field+ */+ public final static int FILL_CLIPPED_BITMAP = 0x41;++ //--Clip Action Conditions+ /**+ * Description of the Field+ */+ public final static int CLIP_ACTION_ON_LOAD = 0x01;+ /**+ * Description of the Field+ */+ public final static int CLIP_ACTION_ENTER_FRAME = 0x02;+ /**+ * Description of the Field+ */+ public final static int CLIP_ACTION_UNLOAD = 0x04;+ /**+ * Description of the Field+ */+ public final static int CLIP_ACTION_MOUSE_MOVE = 0x08;+ /**+ * Description of the Field+ */+ public final static int CLIP_ACTION_MOUSE_DOWN = 0x10;+ /**+ * Description of the Field+ */+ public final static int CLIP_ACTION_MOUSE_UP = 0x20;+ /**+ * Description of the Field+ */+ public final static int CLIP_ACTION_KEY_DOWN = 0x40;+ /**+ * Description of the Field+ */+ public final static int CLIP_ACTION_KEY_UP = 0x80;+ /**+ * Description of the Field+ */+ public final static int CLIP_ACTION_DATA = 0x100;++ //--Font Info flags+ /**+ * Description of the Field+ */+ public final static int FONT_UNICODE = 0x20;+ /**+ * Description of the Field+ */+ public final static int FONT_SHIFTJIS = 0x10;+ /**+ * Description of the Field+ */+ public final static int FONT_ANSI = 0x08;+ /**+ * Description of the Field+ */+ public final static int FONT_ITALIC = 0x04;+ /**+ * Description of the Field+ */+ public final static int FONT_BOLD = 0x02;+ /**+ * Description of the Field+ */+ public final static int FONT_WIDECHARS = 0x01;++ //--DefineFont2 flags+ /**+ * Description of the Field+ */+ public final static int FONT2_HAS_LAYOUT = 0x80;+ /**+ * Description of the Field+ */+ public final static int FONT2_SHIFTJIS = 0x40;+ /**+ * Description of the Field+ */+ public final static int FONT2_UNICODE = 0x20;+ /**+ * Description of the Field+ */+ public final static int FONT2_ANSI = 0x10;+ /**+ * Description of the Field+ */+ public final static int FONT2_32OFFSETS = 0x08;+ /**+ * Description of the Field+ */+ public final static int FONT2_WIDECHARS = 0x04;+ /**+ * Description of the Field+ */+ public final static int FONT2_ITALIC = 0x02;+ /**+ * Description of the Field+ */+ public final static int FONT2_BOLD = 0x01;++ //--Text Field flags+ /**+ * Description of the Field+ */+ public final static int TEXTFIELD_HAS_LAYOUT = 0x2000;+ //author always sets this+ /**+ * Description of the Field+ */+ public final static int TEXTFIELD_NO_SELECTION = 0x1000;+ /**+ * Description of the Field+ */+ public final static int TEXTFIELD_DRAW_BORDER = 0x0800;+ /**+ * Description of the Field+ */+ public final static int TEXTFIELD_HTML = 0x0200;+ /**+ * Description of the Field+ */+ public final static int TEXTFIELD_FONT_GLYPHS = 0x0100;+ /**+ * Description of the Field+ */+ public final static int TEXTFIELD_HAS_TEXT = 0x0080;+ /**+ * Description of the Field+ */+ public final static int TEXTFIELD_WORD_WRAP = 0x0040;+ /**+ * Description of the Field+ */+ public final static int TEXTFIELD_IS_MULTILINE = 0x0020;+ /**+ * Description of the Field+ */+ public final static int TEXTFIELD_IS_PASSWORD = 0x0010;+ /**+ * Description of the Field+ */+ public final static int TEXTFIELD_DISABLE_EDIT = 0x0008;+ /**+ * Description of the Field+ */+ public final static int TEXTFIELD_HAS_TEXT_COLOR = 0x0004;+ //author always sets this+ /**+ * Description of the Field+ */+ public final static int TEXTFIELD_LIMIT_CHARS = 0x0002;+ /**+ * Description of the Field+ */+ public final static int TEXTFIELD_HAS_FONT = 0x0001;+ //author always sets this++ //--Text Field alignment+ /**+ * Description of the Field+ */+ public final static int TEXTFIELD_ALIGN_LEFT = 0;+ /**+ * Description of the Field+ */+ public final static int TEXTFIELD_ALIGN_RIGHT = 1;+ /**+ * Description of the Field+ */+ public final static int TEXTFIELD_ALIGN_CENTER = 2;+ /**+ * Description of the Field+ */+ public final static int TEXTFIELD_ALIGN_JUSTIFY = 3;++ //--Used by TagDefineText(2)..+ /**+ * Description of the Field+ */+ public final static int TEXT_HAS_FONT = 0x08;+ /**+ * Description of the Field+ */+ public final static int TEXT_HAS_COLOR = 0x04;+ /**+ * Description of the Field+ */+ public final static int TEXT_HAS_YOFFSET = 0x02;+ /**+ * Description of the Field+ */+ public final static int TEXT_HAS_XOFFSET = 0x01;++ //--Action Conditions for DefineButton2..+ /**+ * Description of the Field+ */+ public final static int BUTTON2_OVERDOWN2IDLE = 0x100;+ /**+ * Description of the Field+ */+ public final static int BUTTON2_IDLE2OVERDOWN = 0x080;+ /**+ * Description of the Field+ */+ public final static int BUTTON2_OUTDOWN2IDLE = 0x040;+ /**+ * Description of the Field+ */+ public final static int BUTTON2_OUTDOWN2OVERDOWN = 0x020;+ /**+ * Description of the Field+ */+ public final static int BUTTON2_OVERDOWN2OUTDOWN = 0x010;+ /**+ * Description of the Field+ */+ public final static int BUTTON2_OVERDOWN2OVERUP = 0x008;+ /**+ * Description of the Field+ */+ public final static int BUTTON2_OVERUP2OVERDOWN = 0x004;+ /**+ * Description of the Field+ */+ public final static int BUTTON2_OVERUP2IDLE = 0x002;+ /**+ * Description of the Field+ */+ public final static int BUTTON2_IDLE2OVERUP = 0x001;++ //--Formats for DefineBitsLossless..+ /**+ * Description of the Field+ */+ public final static int BITMAP_FORMAT_8_BIT = 3;+ /**+ * Description of the Field+ */+ public final static int BITMAP_FORMAT_16_BIT = 4;+ /**+ * Description of the Field+ */+ public final static int BITMAP_FORMAT_32_BIT = 5;++ //--Sound Constants..+ /**+ * Description of the Field+ */+ public final static int SOUND_FORMAT_RAW = 0;+ /**+ * Description of the Field+ */+ public final static int SOUND_FORMAT_ADPCM = 1;+ /**+ * Description of the Field+ */+ public final static int SOUND_FORMAT_MP3 = 2;++ /**+ * Description of the Field+ */+ public final static int SOUND_FREQ_5_5KHZ = 0;+ //5.5 kHz+ /**+ * Description of the Field+ */+ public final static int SOUND_FREQ_11KHZ = 1;+ /**+ * Description of the Field+ */+ public final static int SOUND_FREQ_22KHZ = 2;+ /**+ * Description of the Field+ */+ public final static int SOUND_FREQ_44KHZ = 3;++}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFHeader.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFHeader.javanew file mode 100644index 000000000..768777c49--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFHeader.java@@ -0,0 +1,27 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * Interface for passing a SWF file header+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public interface SWFHeader {+ /**+ * SWF File header.+ *+ *@param length -1 if the length is unknown and must be inferred+ *@param frameCount -1 if the framecount is unknown and must be+ * inferred+ *@param version Description of the Parameter+ *@param twipsWidth Description of the Parameter+ *@param twipsHeight Description of the Parameter+ *@param frameRate Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void header(int version, long length,+ int twipsWidth, int twipsHeight,+ int frameRate, int frameCount) throws IOException;+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFReader.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFReader.javanew file mode 100644index 000000000..918f81e47--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFReader.java@@ -0,0 +1,164 @@+package pt.tumba.parser.swf;++import java.io.ByteArrayInputStream;+import java.io.ByteArrayOutputStream;+import java.io.IOException;+import java.io.InputStream;++/**+ * Reads a SWF input stream and drives the SWFConsumer interface.+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class SWFReader {+ /**+ * Description of the Field+ */+ protected SWFTags consumer;+ /**+ * Description of the Field+ */+ protected InStream in;+ /**+ * Description of the Field+ */+ protected InputStream inputstream;++ /**+ * Description of the Field+ */+ public int size;+++ /**+ * Constructor for the SWFReader object+ *+ *@param consumer Description of the Parameter+ *@param inputstream Description of the Parameter+ */+ public SWFReader(SWFTags consumer, InputStream inputstream) {+ ByteArrayOutputStream out = new ByteArrayOutputStream();+ int aux;+ this.size = 0;+ try {+ while ((aux = inputstream.read()) != -1) {+ size++;+ out.write((char) aux);+ }+ } catch (Exception e) {aux=-1;}+ this.consumer = consumer;+ this.inputstream = new ByteArrayInputStream(out.toByteArray());+ this.in = new InStream(this.inputstream);+ }+++ /**+ * Constructor for the SWFReader object+ *+ *@param consumer Description of the Parameter+ *@param instream Description of the Parameter+ */+ public SWFReader(SWFTags consumer, InStream instream) {+ // ByteArrayOutputStream out = new ByteArrayOutputStream();+ /*+ * int aux;+ * this.size = 0;+ * while ( (aux=inputstream.read())!=-1 ) {+ * size++;+ * out.write((char)aux);+ * }+ */+ this.consumer = consumer;+ this.in = instream;+ this.size = (int) (this.in.bytesRead);+ }+++ /**+ * Drive the consumer by reading a SWF File - including the header and all+ * tags+ *+ *@exception IOException Description of the Exception+ */+ public void readFile() throws IOException {+ readHeader();+ readTags();+ }+++ /**+ * Drive the consumer by reading SWF tags only+ *+ *@exception IOException Description of the Exception+ */+ public void readTags() throws IOException {+ while (readOneTag() != SWFConstants.TAG_END) {+ ;+ }+ }+++ /**+ * Drive the consumer by reading one tag+ *+ *@return the tag type+ *@exception IOException Description of the Exception+ */+ public int readOneTag() throws IOException {+ int header = in.readUI16();++ int type = header >> 6;+ //only want the top 10 bits+ int length = header & 0x3F;+ //only want the bottom 6 bits+ boolean longTag = (length == 0x3F);++ if (longTag) {+ length = (int) in.readUI32();+ }++ byte[] contents = in.read(length);++ consumer.tag(type, longTag, contents);++ return type;+ }+++ /**+ * Only read the SWF file header+ *+ *@exception IOException Description of the Exception+ */+ public void readHeader() throws IOException {+ //--Verify File Signature+ //if ((in.readUI8() != 0x46) || (in.readUI8() != 0x57) || (in.readUI8() != 0x53)) {+// throw new IOException("Invalid SWF File Signature");+ //}++ int version = in.readUI8();+ long length = in.readUI32();+ Rect frameSize = new Rect(in);+ int frameRate = in.readUI16() >> 8;+ int frameCount = in.readUI16();++ consumer.header(version, length,+ frameSize.getMaxX(), frameSize.getMaxY(),+ frameRate, frameCount);+ }+++ /**+ * The main program for the SWFReader class+ *+ *@param args The command line arguments+ *@exception IOException Description of the Exception+ */+ public static void main(String[] args) throws IOException {+ SWFWriter writer = new SWFWriter(System.out);+ SWFReader reader = new SWFReader(writer, System.in);+ reader.readFile();+ System.out.flush();+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFSaxParser.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFSaxParser.javanew file mode 100644index 000000000..c35cb062a--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFSaxParser.java@@ -0,0 +1,3267 @@+package pt.tumba.parser.swf;++import java.io.ByteArrayOutputStream;+import java.io.FileInputStream;+import java.io.FileOutputStream;+import java.io.IOException;+import java.io.InputStream;+import java.io.OutputStream;+import java.util.Iterator;+import java.util.List;+import java.util.Vector;++import org.xml.sax.ContentHandler;+import org.xml.sax.ErrorHandler;+import org.xml.sax.InputSource;+import org.xml.sax.SAXException;++/**+ * A SAX2 parser (XMLReader) that implements the SWFTagTypes interface and+ * produces an XML representation of the Flash movie.+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class SWFSaxParser extends SaxParserBase+ implements SWFTagTypes, SWFShape, SWFActions, SWFText {+ /**+ * The namespace for the SWF XML vocabulary+ */+ public final static String NAMESPACE = "http://www.anotherbigidea.com/javaswf2";++ /**+ * Description of the Field+ */+ protected String frameLabel;+ /**+ * Description of the Field+ */+ protected boolean definingSprite;+ /**+ * Description of the Field+ */+ protected int actionsType = 0;+ //1=frame,2=clip,3=button++ /**+ * Description of the Field+ */+ protected int glyphCount = 0;+ /**+ * Description of the Field+ */+ protected Rect[] glyphRects;+ /**+ * Description of the Field+ */+ protected int[] glyphAdvances;+ /**+ * Description of the Field+ */+ protected int[] glyphCodes;++ /**+ * Description of the Field+ */+ protected Rect morphEndRect;+ /**+ * Description of the Field+ */+ protected boolean morph;+++ /**+ * Constructor for the SWFSaxParser object+ */+ public SWFSaxParser() {+ super(NAMESPACE);+ }+++ /**+ * Constructor for the SWFSaxParser object+ *+ *@param contenthandler Description of the Parameter+ *@param errorhandler Description of the Parameter+ */+ public SWFSaxParser(ContentHandler contenthandler, ErrorHandler errorhandler) {+ this();+ this.setContentHandler(contenthandler);+ this.setErrorHandler(errorhandler);+ }+++ /**+ * Reads the input as a SWF file byte stream+ *+ *@param input Description of the Parameter+ *@exception IOException Description of the Exception+ *@exception SAXException Description of the Exception+ */+ public void parse(InputSource input) throws IOException, SAXException {+ InputStream istream = input.getByteStream();+ parse(istream);+ }+++ /**+ * Reads the systemId as a filename+ *+ *@param systemId Description of the Parameter+ *@exception IOException Description of the Exception+ *@exception SAXException Description of the Exception+ */+ public void parse(String systemId) throws IOException, SAXException {+ FileInputStream istream = new FileInputStream(systemId);+ parse(istream);+ }+++ /**+ * Description of the Method+ *+ *@param istream Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parse(InputStream istream) throws IOException {+ TagParser parser = new TagParser(this);+ SWFReader reader = new SWFReader(parser, istream);+ reader.readFile();++ istream.close();+ }+++ /**+ * SWFTags interface+ *+ *@param tagType Description of the Parameter+ *@param longTag Description of the Parameter+ *@param contents Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tag(int tagType, boolean longTag, byte[] contents)+ throws IOException {+ start("tag", new String[]+ {+ "type", Integer.toString(tagType)+ });++ text(Base64.encode(contents));++ end();+ }+++ /**+ * SWFHeader interface.+ *+ *@param version Description of the Parameter+ *@param length Description of the Parameter+ *@param twipsWidth Description of the Parameter+ *@param twipsHeight Description of the Parameter+ *@param frameRate Description of the Parameter+ *@param frameCount Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void header(int version, long length,+ int twipsWidth, int twipsHeight,+ int frameRate, int frameCount) throws IOException {+ startDoc();+ start("movie", new String[]+ {+ "version", Integer.toString(version),+ "width", Integer.toString(twipsWidth / SWFConstants.TWIPS),+ "height", Integer.toString(twipsHeight / SWFConstants.TWIPS),+ "rate", Integer.toString(frameRate)+ });+ }+++ /**+ * SWFTagTypes interface+ *+ *@exception IOException Description of the Exception+ */+ public void tagEnd() throws IOException {+ end();+ //movie or sprite++ if (!definingSprite) {+ endDoc();+ } else {+ definingSprite = false;+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@exception IOException Description of the Exception+ */+ public void tagShowFrame() throws IOException {+ element("frame", (frameLabel == null) ?+ null :+ new String[]{"label", frameLabel});++ frameLabel = null;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param format Description of the Parameter+ *@param frequency Description of the Parameter+ *@param bits16 Description of the Parameter+ *@param stereo Description of the Parameter+ *@param sampleCount Description of the Parameter+ *@param soundData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineSound(int id, int format, int frequency,+ boolean bits16, boolean stereo,+ int sampleCount, byte[] soundData)+ throws IOException {+ String sndFormat = null;+ switch (format) {+ case SWFConstants.SOUND_FORMAT_RAW:+ sndFormat = "raw";+ break;+ case SWFConstants.SOUND_FORMAT_ADPCM:+ sndFormat = "adpcm";+ break;+ case SWFConstants.SOUND_FORMAT_MP3:+ sndFormat = "mp3";+ break;+ default:+ break;+ }++ String freq = null;+ switch (frequency) {+ case SWFConstants.SOUND_FREQ_5_5KHZ:+ freq = "5.5";+ break;+ case SWFConstants.SOUND_FREQ_11KHZ:+ freq = "11";+ break;+ case SWFConstants.SOUND_FREQ_22KHZ:+ freq = "22";+ break;+ case SWFConstants.SOUND_FREQ_44KHZ:+ freq = "44";+ break;+ default:+ break;+ }++ start("sound", new String[]+ {+ "id", Integer.toString(id),+ "format", sndFormat,+ "rate", freq,+ "bits", (bits16 ? "16" : "8"),+ "stereo", (stereo ? "yes" : "no"),+ "sample-count", Integer.toString(sampleCount)+ });+ text(Base64.encode(soundData));+ end();+ }+++ /**+ * Description of the Method+ *+ *@param info Description of the Parameter+ *@param event Description of the Parameter+ *@param id Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void soundInfo(SoundInfo info, String event, int id) throws IOException {+ int loopCount = info.getLoopCount();+ int inpoint = info.getInPoint();+ int outpoint = info.getOutPoint();++ String loop = (loopCount > 1) ? Integer.toString(loopCount) : null;+ String inpnt = (inpoint >= 0) ? Integer.toString(inpoint) : null;+ String outpnt = (outpoint >= 0) ? Integer.toString(outpoint) : null;++ start("sound-info", new String[]+ {+ "event", event,+ "sound-id", Integer.toString(id),+ "single-instance", (info.isNoMultiplePlay() ? "yes" : "no"),+ "stop-playing", (info.isStopPlaying() ? "yes" : "no"),+ "loop-count", loop,+ "fade-in", inpnt,+ "fade-out", outpnt+ });++ SoundInfo.EnvelopePoint[] envelope = info.getEnvelope();+ if (envelope != null && envelope.length > 0) {+ for (int i = 0; i < envelope.length; i++) {+ element("envelope-point", new String[]+ {+ "position", Integer.toString(envelope[i].mark44),+ "level-0", Integer.toString(envelope[i].level0),+ "level-1", Integer.toString(envelope[i].level1)+ });+ }+ }++ end();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param buttonId Description of the Parameter+ *@param rollOverSoundId Description of the Parameter+ *@param rollOverSoundInfo Description of the Parameter+ *@param rollOutSoundId Description of the Parameter+ *@param rollOutSoundInfo Description of the Parameter+ *@param pressSoundId Description of the Parameter+ *@param pressSoundInfo Description of the Parameter+ *@param releaseSoundId Description of the Parameter+ *@param releaseSoundInfo Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineButtonSound(int buttonId,+ int rollOverSoundId, SoundInfo rollOverSoundInfo,+ int rollOutSoundId, SoundInfo rollOutSoundInfo,+ int pressSoundId, SoundInfo pressSoundInfo,+ int releaseSoundId, SoundInfo releaseSoundInfo)+ throws IOException {+ start("button-sound", new String[]{"id", Integer.toString(buttonId)});++ if (rollOverSoundId != 0) {+ soundInfo(rollOverSoundInfo, "roll-over", rollOverSoundId);+ }++ if (rollOutSoundId != 0) {+ soundInfo(rollOutSoundInfo, "roll-out", rollOutSoundId);+ }++ if (pressSoundId != 0) {+ soundInfo(pressSoundInfo, "press", pressSoundId);+ }++ if (releaseSoundId != 0) {+ soundInfo(releaseSoundInfo, "release", releaseSoundId);+ }+ end();+ //button-sound+ }+++ /**+ * SWFTagTypes interface+ *+ *@param soundId Description of the Parameter+ *@param info Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagStartSound(int soundId, SoundInfo info) throws IOException {+ start("start-sound", null);+ soundInfo(info, null, soundId);+ end();+ }+++ /**+ * Description of the Method+ *+ *@param type Description of the Parameter+ *@param playbackFrequency Description of the Parameter+ *@param playback16bit Description of the Parameter+ *@param playbackStereo Description of the Parameter+ *@param streamFormat Description of the Parameter+ *@param streamFrequency Description of the Parameter+ *@param stream16bit Description of the Parameter+ *@param streamStereo Description of the Parameter+ *@param averageSampleCount Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void soundStreamHead(String type,+ int playbackFrequency, boolean playback16bit, boolean playbackStereo,+ int streamFormat, int streamFrequency, boolean stream16bit, boolean streamStereo,+ int averageSampleCount) throws IOException {+ String sndFormat = null;+ switch (streamFormat) {+ case SWFConstants.SOUND_FORMAT_RAW:+ sndFormat = "raw";+ break;+ case SWFConstants.SOUND_FORMAT_ADPCM:+ sndFormat = "adpcm";+ break;+ case SWFConstants.SOUND_FORMAT_MP3:+ sndFormat = "mp3";+ break;+ default:+ break;+ }++ String playfreq = null;+ switch (playbackFrequency) {+ case SWFConstants.SOUND_FREQ_5_5KHZ:+ playfreq = "5.5";+ break;+ case SWFConstants.SOUND_FREQ_11KHZ:+ playfreq = "11";+ break;+ case SWFConstants.SOUND_FREQ_22KHZ:+ playfreq = "22";+ break;+ case SWFConstants.SOUND_FREQ_44KHZ:+ playfreq = "44";+ break;+ default:+ break;+ }++ String streamfreq = null;+ switch (streamFrequency) {+ case SWFConstants.SOUND_FREQ_5_5KHZ:+ streamfreq = "5.5";+ break;+ case SWFConstants.SOUND_FREQ_11KHZ:+ streamfreq = "11";+ break;+ case SWFConstants.SOUND_FREQ_22KHZ:+ streamfreq = "22";+ break;+ case SWFConstants.SOUND_FREQ_44KHZ:+ streamfreq = "44";+ break;+ default:+ break;+ }++ element("sound-stream-header", new String[]+ {+ "type", type,+ "play-rate", playfreq,+ "play-bits", (playback16bit ? "16" : "8"),+ "play-stereo", (playbackStereo ? "yes" : "no"),+ "stream-format", sndFormat,+ "stream-rate", streamfreq,+ "stream-bits", (stream16bit ? "16" : "8"),+ "stream-stereo", (streamStereo ? "yes" : "no"),+ "average-sample-count", Integer.toString(averageSampleCount)+ });+ }+++ /**+ * SWFTagTypes interface+ *+ *@param playbackFrequency Description of the Parameter+ *@param playback16bit Description of the Parameter+ *@param playbackStereo Description of the Parameter+ *@param streamFormat Description of the Parameter+ *@param streamFrequency Description of the Parameter+ *@param stream16bit Description of the Parameter+ *@param streamStereo Description of the Parameter+ *@param averageSampleCount Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagSoundStreamHead(+ int playbackFrequency, boolean playback16bit, boolean playbackStereo,+ int streamFormat, int streamFrequency, boolean stream16bit, boolean streamStereo,+ int averageSampleCount) throws IOException {+ soundStreamHead("1",+ playbackFrequency, playback16bit, playbackStereo,+ streamFormat, streamFrequency, stream16bit, streamStereo,+ averageSampleCount);+ }+++ /**+ * SWFTagTypes interface+ *+ *@param playbackFrequency Description of the Parameter+ *@param playback16bit Description of the Parameter+ *@param playbackStereo Description of the Parameter+ *@param streamFormat Description of the Parameter+ *@param streamFrequency Description of the Parameter+ *@param stream16bit Description of the Parameter+ *@param streamStereo Description of the Parameter+ *@param averageSampleCount Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagSoundStreamHead2(+ int playbackFrequency, boolean playback16bit, boolean playbackStereo,+ int streamFormat, int streamFrequency, boolean stream16bit, boolean streamStereo,+ int averageSampleCount) throws IOException {+ soundStreamHead("2",+ playbackFrequency, playback16bit, playbackStereo,+ streamFormat, streamFrequency, stream16bit, streamStereo,+ averageSampleCount);+ }+++ /**+ * SWFTagTypes interface+ *+ *@param soundData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagSoundStreamBlock(byte[] soundData) throws IOException {+ start("sound-stream-block", null);+ text(Base64.encode(soundData));+ end();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param serialNumber Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagSerialNumber(String serialNumber) throws IOException {+ start("serial-number", null);+ text(serialNumber);+ end();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagGenerator(byte[] data) throws IOException {+ start("generator", null);+ text(Base64.encode(data));+ end();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagGeneratorText(byte[] data) throws IOException {+ start("generator-text", null);+ text(Base64.encode(data));+ end();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagGeneratorCommand(byte[] data) throws IOException {+ start("generator-command", null);+ text(Base64.encode(data));+ end();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagGeneratorFont(byte[] data) throws IOException {+ start("generator-font", null);+ text(Base64.encode(data));+ end();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagNameCharacter(byte[] data) throws IOException {+ start("generator-name-character", null);+ text(Base64.encode(data));+ end();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param imageData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBits(int id, byte[] imageData) throws IOException {+ start("jpeg", new String[]+ {+ "id", Integer.toString(id),+ "common-header", "yes"+ });+ start("image", null);+ text(Base64.encode(imageData));+ end();+ end();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param jpegEncodingData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagJPEGTables(byte[] jpegEncodingData) throws IOException {+ start("jpeg-header", null);+ text(Base64.encode(jpegEncodingData));+ end();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param imageData Description of the Parameter+ *@param alphaData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsJPEG3(int id, byte[] imageData, byte[] alphaData) throws IOException {+ start("jpeg", new String[]+ {+ "id", Integer.toString(id)+ });++ start("image", null);+ text(Base64.encode(imageData));+ end();++ start("alpha", null);+ text(Base64.encode(alphaData));+ end();++ end();+ }+++ /**+ * SWFTagTypes interface+ *+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFActions tagDoAction() throws IOException {+ actionsType = 1;+ //frame actions+ return this;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param outline Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFShape tagDefineShape(int id, Rect outline) throws IOException {+ start("shape", new String[]+ {+ "id", Integer.toString(id),+ "has-alpha", "no",+ "min-x", Double.toString(((double) outline.getMinX()) / SWFConstants.TWIPS),+ "min-y", Double.toString(((double) outline.getMinY()) / SWFConstants.TWIPS),+ "max-x", Double.toString(((double) outline.getMaxX()) / SWFConstants.TWIPS),+ "max-y", Double.toString(((double) outline.getMaxY()) / SWFConstants.TWIPS)+ });++ return this;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param outline Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFShape tagDefineShape2(int id, Rect outline) throws IOException {+ start("shape", new String[]+ {+ "id", Integer.toString(id),+ "has-alpha", "no",+ "min-x", Double.toString(((double) outline.getMinX()) / SWFConstants.TWIPS),+ "min-y", Double.toString(((double) outline.getMinY()) / SWFConstants.TWIPS),+ "max-x", Double.toString(((double) outline.getMaxX()) / SWFConstants.TWIPS),+ "max-y", Double.toString(((double) outline.getMaxY()) / SWFConstants.TWIPS)+ });++ return this;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param outline Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFShape tagDefineShape3(int id, Rect outline) throws IOException {+ start("shape", new String[]+ {+ "id", Integer.toString(id),+ "has-alpha", "yes",+ "min-x", Double.toString(((double) outline.getMinX()) / SWFConstants.TWIPS),+ "min-y", Double.toString(((double) outline.getMinY()) / SWFConstants.TWIPS),+ "max-x", Double.toString(((double) outline.getMaxX()) / SWFConstants.TWIPS),+ "max-y", Double.toString(((double) outline.getMaxY()) / SWFConstants.TWIPS)+ });++ return this;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param charId Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagFreeCharacter(int charId) throws IOException {+ element("release", new String[]{"id", Integer.toString(charId)});+ }+++ /**+ * SWFTagTypes interface+ *+ *@param charId Description of the Parameter+ *@param depth Description of the Parameter+ *@param matrix Description of the Parameter+ *@param cxform Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagPlaceObject(int charId, int depth,+ Matrix matrix, AlphaTransform cxform)+ throws IOException {+ start("place", new String[]+ {+ "id", Integer.toString(charId),+ "depth", Integer.toString(depth)+ });++ if (matrix != null) {+ writeMatrix(matrix);+ }+ if (cxform != null) {+ writeCXForm(cxform);+ }++ end();+ //place+ }+++ /**+ * SWFTagTypes interface+ *+ *@param isMove Description of the Parameter+ *@param clipDepth Description of the Parameter+ *@param depth Description of the Parameter+ *@param charId Description of the Parameter+ *@param matrix Description of the Parameter+ *@param cxform Description of the Parameter+ *@param ratio Description of the Parameter+ *@param name Description of the Parameter+ *@param clipActionFlags Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFActions tagPlaceObject2(boolean isMove,+ int clipDepth,+ int depth,+ int charId,+ Matrix matrix,+ AlphaTransform cxform,+ int ratio,+ String name,+ int clipActionFlags)+ throws IOException {+ Vector attrs = new Vector();++ if (charId > 0) {+ attrs.add("id");+ attrs.add(Integer.toString(charId));+ }++ if (isMove) {+ attrs.add("alter");+ attrs.add("yes");+ }++ if (clipDepth > 0) {+ attrs.add("clip-depth");+ attrs.add(Integer.toString(clipDepth));+ }++ if (ratio >= 0) {+ attrs.add("ratio");+ attrs.add(Integer.toString(ratio));+ }++ attrs.add("depth");+ attrs.add(Integer.toString(depth));++ if (name != null && name.length() > 0) {+ attrs.add("name");+ attrs.add(name);+ }++ String[] attributes = new String[attrs.size()];+ attrs.copyInto(attributes);++ start("place", attributes);++ if (matrix != null) {+ writeMatrix(matrix);+ }+ if (cxform != null) {+ writeCXForm(cxform);+ }++ if (clipActionFlags == 0) {+ end();+ //place+ return null;+ }++ actionsType = 2;+ //clip actions+ return this;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param charId Description of the Parameter+ *@param depth Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagRemoveObject(int charId, int depth) throws IOException {+ element("remove", new String[]{"depth", Integer.toString(depth)});+ }+++ /**+ * SWFTagTypes interface+ *+ *@param depth Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagRemoveObject2(int depth) throws IOException {+ element("remove", new String[]{"depth", Integer.toString(depth)});+ }+++ /**+ * SWFTagTypes interface+ *+ *@param color Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagSetBackgroundColor(Color color) throws IOException {+ element("background-color", new String[]+ {+ "red", Integer.toString(color.getRed()),+ "green", Integer.toString(color.getGreen()),+ "blue", Integer.toString(color.getBlue())+ });+ }+++ /**+ * SWFTagTypes interface+ *+ *@param label Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagFrameLabel(String label) throws IOException {+ frameLabel = label;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFTagTypes tagDefineSprite(int id) throws IOException {+ start("sprite", new String[]{"id", Integer.toString(id)});+ definingSprite = true;+ return this;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param password Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagProtect(byte[] password) throws IOException {+ element("protect", (password == null || password.length == 0) ?+ null :+ new String[]+ {+ "password", Base64.encode(password)+ });+ }+++ /**+ * SWFTagTypes interface+ *+ *@param password Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagEnableDebug(byte[] password) throws IOException {+ element("enable-debug", (password == null || password.length == 0) ?+ null :+ new String[]+ {+ "password", Base64.encode(password)+ });+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param numGlyphs Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFVectors tagDefineFont(int id, int numGlyphs) throws IOException {+ start("text-font", new String[]{"id", Integer.toString(id)});+ glyphCount = numGlyphs;+ start("glyph", null);+ return this;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param fontId Description of the Parameter+ *@param fontName Description of the Parameter+ *@param flags Description of the Parameter+ *@param codes Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineFontInfo(int fontId, String fontName, int flags, int[] codes)+ throws IOException {+ StringBuffer buff = new StringBuffer();++ if ((flags & SWFConstants.FONT_UNICODE) != 0) {+ buff.append("unicode");+ }+ if ((flags & SWFConstants.FONT_SHIFTJIS) != 0) {+ buff.append(" shiftjis");+ }+ if ((flags & SWFConstants.FONT_ANSI) != 0) {+ buff.append(" ansi");+ }+ if ((flags & SWFConstants.FONT_ITALIC) != 0) {+ buff.append(" italic");+ }+ if ((flags & SWFConstants.FONT_BOLD) != 0) {+ buff.append(" bold");+ }++ start("font-info", new String[]+ {+ "id", Integer.toString(fontId),+ "name", fontName,+ "flags", buff.toString().trim()+ });++ for (int i = 0; i < codes.length; i++) {+ element("code", new String[]{"code", Integer.toString(codes[i])});+ }++ end();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param flags Description of the Parameter+ *@param name Description of the Parameter+ *@param numGlyphs Description of the Parameter+ *@param ascent Description of the Parameter+ *@param descent Description of the Parameter+ *@param leading Description of the Parameter+ *@param codes Description of the Parameter+ *@param advances Description of the Parameter+ *@param bounds Description of the Parameter+ *@param kernCodes1 Description of the Parameter+ *@param kernCodes2 Description of the Parameter+ *@param kernAdjustments Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFVectors tagDefineFont2(int id, int flags, String name, int numGlyphs,+ int ascent, int descent, int leading,+ int[] codes, int[] advances, Rect[] bounds,+ int[] kernCodes1, int[] kernCodes2,+ int[] kernAdjustments) throws IOException {+ StringBuffer buff = new StringBuffer();++ if ((flags & SWFConstants.FONT2_UNICODE) != 0) {+ buff.append("unicode");+ }+ if ((flags & SWFConstants.FONT2_SHIFTJIS) != 0) {+ buff.append(" shiftjis");+ }+ if ((flags & SWFConstants.FONT2_ANSI) != 0) {+ buff.append(" ansi");+ }+ if ((flags & SWFConstants.FONT2_ITALIC) != 0) {+ buff.append(" italic");+ }+ if ((flags & SWFConstants.FONT2_BOLD) != 0) {+ buff.append(" bold");+ }++ start("edit-font", new String[]+ {+ "id", Integer.toString(id),+ "flags", buff.toString().trim(),+ "name", name,+ "ascent", Double.toString(((double) ascent) / SWFConstants.TWIPS),+ "descent", Double.toString(((double) descent) / SWFConstants.TWIPS),+ "leading", Double.toString(((double) leading) / SWFConstants.TWIPS)+ });++ if (kernCodes1 != null && kernCodes1.length > 0) {+ start("kerning-info", null);++ for (int i = 0; i < kernCodes1.length; i++) {+ element("kerning", new String[]+ {+ "code-1", Integer.toString(kernCodes1[i]),+ "code-2", Integer.toString(kernCodes2[i]),+ "offset", Double.toString(((double) kernAdjustments[i]) / SWFConstants.TWIPS)+ });+ }++ end();+ }++ if (numGlyphs == 0) {+ end();+ return null;+ }++ glyphAdvances = advances;+ glyphRects = bounds;+ glyphCodes = codes;+ glyphCount = numGlyphs;++ Rect bound = bounds[0];+ int advance = 0;+ if (advances != null && advances.length >= 1) {+ advance = advances[0];+ }++ start("glyph", new String[]+ {+ "code", Integer.toString(glyphCodes[0]),+ "advance", Double.toString(((double) advance) / SWFConstants.TWIPS),+ "min-x", Double.toString(((double) bound.getMinX()) / SWFConstants.TWIPS),+ "min-y", Double.toString(((double) bound.getMinY()) / SWFConstants.TWIPS),+ "max-x", Double.toString(((double) bound.getMaxX()) / SWFConstants.TWIPS),+ "max-y", Double.toString(((double) bound.getMaxY()) / SWFConstants.TWIPS)+ });++ return this;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param fieldId Description of the Parameter+ *@param fieldName Description of the Parameter+ *@param initialText Description of the Parameter+ *@param boundary Description of the Parameter+ *@param flags Description of the Parameter+ *@param textColor Description of the Parameter+ *@param alignment Description of the Parameter+ *@param fontId Description of the Parameter+ *@param fontSize Description of the Parameter+ *@param charLimit Description of the Parameter+ *@param leftMargin Description of the Parameter+ *@param rightMargin Description of the Parameter+ *@param indentation Description of the Parameter+ *@param lineSpacing Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineTextField(int fieldId, String fieldName,+ String initialText, Rect boundary, int flags,+ AlphaColor textColor, int alignment, int fontId, int fontSize,+ int charLimit, int leftMargin, int rightMargin, int indentation,+ int lineSpacing)+ throws IOException {+ String align = null;+ if (alignment == SWFConstants.TEXTFIELD_ALIGN_CENTER) {+ align = "center";+ } else if (alignment == SWFConstants.TEXTFIELD_ALIGN_JUSTIFY) {+ align = "justify";+ } else if (alignment == SWFConstants.TEXTFIELD_ALIGN_LEFT) {+ align = "left";+ } else if (alignment == SWFConstants.TEXTFIELD_ALIGN_RIGHT) {+ align = "right";+ }++ start("edit-field", new String[]+ {+ "id", Integer.toString(fieldId),+ "font", Integer.toString(fontId),+ "size", Double.toString(((double) fontSize) / SWFConstants.TWIPS),+ "limit", (charLimit > 0) ? Integer.toString(charLimit) : null,+ "left-margin", Double.toString(((double) leftMargin) / SWFConstants.TWIPS),+ "right-margin", Double.toString(((double) rightMargin) / SWFConstants.TWIPS),+ "indentation", Double.toString(((double) indentation) / SWFConstants.TWIPS),+ "linespacing", Double.toString(((double) lineSpacing) / SWFConstants.TWIPS),+ "name", fieldName,+ "text", initialText,+ "align", align,+ "min-x", Double.toString(((double) boundary.getMinX()) / SWFConstants.TWIPS),+ "min-y", Double.toString(((double) boundary.getMinY()) / SWFConstants.TWIPS),+ "max-x", Double.toString(((double) boundary.getMaxX()) / SWFConstants.TWIPS),+ "max-y", Double.toString(((double) boundary.getMaxY()) / SWFConstants.TWIPS),+ "selectable", ((flags & SWFConstants.TEXTFIELD_NO_SELECTION) != 0) ? "no" : "yes",+ "border", ((flags & SWFConstants.TEXTFIELD_DRAW_BORDER) != 0) ? "yes" : "no",+ "html", ((flags & SWFConstants.TEXTFIELD_HTML) != 0) ? "yes" : "no",+ "system-font", ((flags & SWFConstants.TEXTFIELD_FONT_GLYPHS) != 0) ? "no" : "yes",+ "wordwrap", ((flags & SWFConstants.TEXTFIELD_WORD_WRAP) != 0) ? "yes" : "no",+ "multiline", ((flags & SWFConstants.TEXTFIELD_IS_MULTILINE) != 0) ? "yes" : "no",+ "password", ((flags & SWFConstants.TEXTFIELD_IS_PASSWORD) != 0) ? "yes" : "no",+ "read-only", ((flags & SWFConstants.TEXTFIELD_DISABLE_EDIT) != 0) ? "yes" : "no"+ });++ writeColor(textColor);++ end();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param bounds Description of the Parameter+ *@param matrix Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFText tagDefineText(int id, Rect bounds, Matrix matrix)+ throws IOException {+ return defineText(id, bounds, matrix, false);+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param bounds Description of the Parameter+ *@param matrix Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFText tagDefineText2(int id, Rect bounds, Matrix matrix) throws IOException {+ return defineText(id, bounds, matrix, true);+ }+++ /**+ * Description of the Method+ *+ *@param id Description of the Parameter+ *@param bounds Description of the Parameter+ *@param matrix Description of the Parameter+ *@param hasAlpha Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ protected SWFText defineText(int id, Rect bounds, Matrix matrix, boolean hasAlpha)+ throws IOException {+ start("text", new String[]+ {+ "has-alpha", hasAlpha ? "yes" : "no",+ "id", Integer.toString(id),+ "min-x", Double.toString(((double) bounds.getMinX()) / SWFConstants.TWIPS),+ "min-y", Double.toString(((double) bounds.getMinY()) / SWFConstants.TWIPS),+ "max-x", Double.toString(((double) bounds.getMaxX()) / SWFConstants.TWIPS),+ "max-y", Double.toString(((double) bounds.getMaxY()) / SWFConstants.TWIPS)+ });++ writeMatrix(matrix);++ return this;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param buttonRecords Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFActions tagDefineButton(int id, List buttonRecords)+ throws IOException {+ start("button", new String[]+ {+ "id", Integer.toString(id),+ "menu", "no"+ });++ for (Iterator e = buttonRecords.iterator(); e.hasNext(); ) {+ ButtonRecord rec = (ButtonRecord) e.next();++ StringBuffer buff = new StringBuffer();+ if (rec.isHitTest()) {+ buff.append("hit");+ }+ if (rec.isOver()) {+ buff.append(" over");+ }+ if (rec.isUp()) {+ buff.append(" up");+ }+ if (rec.isDown()) {+ buff.append(" down");+ }++ start("layer", new String[]+ {+ "id", Integer.toString(rec.getCharId()),+ "depth", Integer.toString(rec.getLayer()),+ "for", buff.toString().trim()+ });++ Matrix matrix = rec.getMatrix();++ if (matrix != null) {+ writeMatrix(matrix);+ }++ end();+ }++ this.actionsType = 3;+ return this;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param buttonId Description of the Parameter+ *@param transform Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagButtonCXForm(int buttonId, ColorTransform transform)+ throws IOException {+ start("button-cxform", new String[]{"id", Integer.toString(buttonId)});+ writeCXForm(transform);+ end();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param trackAsMenu Description of the Parameter+ *@param buttonRecord2s Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFActions tagDefineButton2(int id,+ boolean trackAsMenu,+ List buttonRecord2s)+ throws IOException {+ start("button", new String[]+ {+ "id", Integer.toString(id),+ "menu", trackAsMenu ? "yes" : "no"+ });++ for (Iterator e = buttonRecord2s.iterator(); e.hasNext(); ) {+ ButtonRecord2 rec = (ButtonRecord2) e.next();++ StringBuffer buff = new StringBuffer();+ if (rec.isHitTest()) {+ buff.append("hit");+ }+ if (rec.isOver()) {+ buff.append(" over");+ }+ if (rec.isUp()) {+ buff.append(" up");+ }+ if (rec.isDown()) {+ buff.append(" down");+ }++ start("layer", new String[]+ {+ "id", Integer.toString(rec.getCharId()),+ "depth", Integer.toString(rec.getLayer()),+ "for", buff.toString().trim()+ });++ Matrix matrix = rec.getMatrix();+ AlphaTransform cxform = rec.getTransform();++ if (matrix != null) {+ writeMatrix(matrix);+ }+ if (cxform != null) {+ writeCXForm(cxform);+ }++ end();+ }++ this.actionsType = 3;+ return this;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param names Description of the Parameter+ *@param ids Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagExport(String[] names, int[] ids) throws IOException {+ start("export", null);++ for (int i = 0; i < names.length; i++) {+ element("symbol", new String[]+ {+ "name", names[i],+ "id", Integer.toString(ids[i])+ });+ }++ end();+ //export+ }+++ /**+ * SWFTagTypes interface+ *+ *@param movieName Description of the Parameter+ *@param names Description of the Parameter+ *@param ids Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagImport(String movieName, String[] names, int[] ids)+ throws IOException {+ start("import", new String[]{"movie", movieName});++ for (int i = 0; i < names.length; i++) {+ element("symbol", new String[]+ {+ "name", names[i],+ "id", Integer.toString(ids[i])+ });+ }++ end();+ //export+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param filename Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineQuickTimeMovie(int id, String filename) throws IOException {+ element("quicktime-movie", new String[]+ {+ "id", Integer.toString(id),+ "name", filename+ });+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsJPEG2(int id, byte[] data) throws IOException {+ start("jpeg", new String[]{"id", Integer.toString(id)});++ start("image", null);+ text(Base64.encode(data));+ end();++ end();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param jpegImage Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsJPEG2(int id, InputStream jpegImage) throws IOException {+ ByteArrayOutputStream bout = new ByteArrayOutputStream();+ OutStream out = new OutStream(bout);++ //--Write stream terminator/header+ out.writeUI8(0xff);+ out.writeUI8(0xd9);+ out.writeUI8(0xff);+ out.writeUI8(0xd8);++ int read = 0;+ byte[] bytes = new byte[10000];++ while ((read = jpegImage.read(bytes)) >= 0) {+ out.write(bytes, 0, read);+ }++ jpegImage.close();++ tagDefineBitsJPEG2(id, bout.toByteArray());+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param startBounds Description of the Parameter+ *@param endBounds Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFShape tagDefineMorphShape(int id, Rect startBounds, Rect endBounds)+ throws IOException {+ start("morph", new String[]+ {+ "id", Integer.toString(id)+ });++ start("shape", new String[]+ {+ "min-x", Double.toString(((double) startBounds.getMinX()) / SWFConstants.TWIPS),+ "min-y", Double.toString(((double) startBounds.getMinY()) / SWFConstants.TWIPS),+ "max-x", Double.toString(((double) startBounds.getMaxX()) / SWFConstants.TWIPS),+ "max-y", Double.toString(((double) startBounds.getMaxY()) / SWFConstants.TWIPS)+ });++ morphEndRect = endBounds;+ morph = true;+ return this;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param format Description of the Parameter+ *@param width Description of the Parameter+ *@param height Description of the Parameter+ *@param colors Description of the Parameter+ *@param imageData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsLossless(int id, int format, int width, int height,+ Color[] colors, byte[] imageData)+ throws IOException {+ defineBitsLossless(id, format, width, height, colors, imageData, false);+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param format Description of the Parameter+ *@param width Description of the Parameter+ *@param height Description of the Parameter+ *@param colors Description of the Parameter+ *@param imageData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsLossless2(int id, int format, int width, int height,+ Color[] colors, byte[] imageData)+ throws IOException {+ defineBitsLossless(id, format, width, height, colors, imageData, true);+ }+++ /**+ * Description of the Method+ *+ *@param id Description of the Parameter+ *@param format Description of the Parameter+ *@param width Description of the Parameter+ *@param height Description of the Parameter+ *@param colors Description of the Parameter+ *@param imageData Description of the Parameter+ *@param hasAlpha Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void defineBitsLossless(int id, int format, int width, int height,+ Color[] colors, byte[] imageData,+ boolean hasAlpha)+ throws IOException {+ String bits = null;+ if (format == SWFConstants.BITMAP_FORMAT_8_BIT) {+ bits = "8";+ } else if (format == SWFConstants.BITMAP_FORMAT_16_BIT) {+ bits = "16";+ } else {+ bits = "32";+ }++ start("bitmap", new String[]+ {+ "id", Integer.toString(id),+ "width", Integer.toString(width),+ "height", Integer.toString(height),+ "has-alpha", hasAlpha ? "yes" : "no",+ "bits", bits+ });++ if (colors != null && colors.length > 0) {+ start("colors", null);++ for (int i = 0; i < colors.length; i++) {+ writeColor(colors[i]);+ }++ end();+ }++ start("pixels", null);+ text(Base64.encode(imageData));+ end();+ end();+ }+++ /**+ * SWFVectors interface SWFActions interface SWFText interface+ *+ *@exception IOException Description of the Exception+ */+ public void done() throws IOException {+ //--do not terminate an action block here (it's done in end())+ if (actionsType == 1) {+ actionsType = 0;+ return;+ }++ actionsType = 0;+ end();++ if (morph) {+ if (morphEndRect != null) {+ start("shape", new String[]+ {+ "min-x", Double.toString(((double) morphEndRect.getMinX()) / SWFConstants.TWIPS),+ "min-y", Double.toString(((double) morphEndRect.getMinY()) / SWFConstants.TWIPS),+ "max-x", Double.toString(((double) morphEndRect.getMaxX()) / SWFConstants.TWIPS),+ "max-y", Double.toString(((double) morphEndRect.getMaxY()) / SWFConstants.TWIPS)+ });++ morphEndRect = null;+ } else {+ end();+ morph = false;+ }++ return;+ }++ if (glyphCount > 0) {+ if (glyphCount == 1) {+ //end of glyphs++ glyphCount = 0;+ glyphRects = null;+ glyphAdvances = null;+ glyphCodes = null;+ end();+ //font+ } else {+ if (glyphRects == null) {+ start("glyph", null);+ } else {+ int idx = glyphRects.length - glyphCount + 1;+ Rect bound = glyphRects[idx];+ int advance = 0;+ if (glyphAdvances != null && glyphAdvances.length >= 1) {+ advance = glyphAdvances[idx];+ }++ start("glyph", new String[]+ {+ "code", Integer.toString(glyphCodes[idx]),+ "advance", Double.toString(((double) advance) / SWFConstants.TWIPS),+ "min-x", Double.toString(((double) bound.getMinX()) / SWFConstants.TWIPS),+ "min-y", Double.toString(((double) bound.getMinY()) / SWFConstants.TWIPS),+ "max-x", Double.toString(((double) bound.getMaxX()) / SWFConstants.TWIPS),+ "max-y", Double.toString(((double) bound.getMaxY()) / SWFConstants.TWIPS)+ });+ }+ }++ glyphCount--;+ }+ }+++ /**+ * SWFVectors interface+ *+ *@param dx Description of the Parameter+ *@param dy Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void line(int dx, int dy) throws IOException {+ element("line", new String[]+ {+ "dx", Double.toString(((double) dx) / SWFConstants.TWIPS),+ "dy", Double.toString(((double) dy) / SWFConstants.TWIPS)+ });+ }+++ /**+ * SWFVectors interface+ *+ *@param cx Description of the Parameter+ *@param cy Description of the Parameter+ *@param dx Description of the Parameter+ *@param dy Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void curve(int cx, int cy, int dx, int dy) throws IOException {+ element("curve", new String[]+ {+ "cx", Double.toString(((double) cx) / SWFConstants.TWIPS),+ "cy", Double.toString(((double) cy) / SWFConstants.TWIPS),+ "dx", Double.toString(((double) dx) / SWFConstants.TWIPS),+ "dy", Double.toString(((double) dy) / SWFConstants.TWIPS)+ });+ }+++ /**+ * SWFVectors interface+ *+ *@param x Description of the Parameter+ *@param y Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void move(int x, int y) throws IOException {+ element("move", new String[]+ {+ "x", Double.toString(((double) x) / SWFConstants.TWIPS),+ "y", Double.toString(((double) y) / SWFConstants.TWIPS)+ });+ }+++ /**+ * SWFShape interface+ *+ *@param styleIndex The new fillStyle0 value+ *@exception IOException Description of the Exception+ */+ public void setFillStyle0(int styleIndex) throws IOException {+ if (glyphCount > 0) {+ element("anticlockwise", null);+ return;+ }++ element("set-primary-fill", new String[]+ {+ "index", Integer.toString(styleIndex)+ });+ }+++ /**+ * SWFShape interface+ *+ *@param styleIndex The new fillStyle1 value+ *@exception IOException Description of the Exception+ */+ public void setFillStyle1(int styleIndex) throws IOException {+ if (glyphCount > 0) {+ return;+ }++ element("set-secondary-fill", new String[]+ {+ "index", Integer.toString(styleIndex)+ });+ }+++ /**+ * SWFShape interface+ *+ *@param styleIndex The new lineStyle value+ *@exception IOException Description of the Exception+ */+ public void setLineStyle(int styleIndex) throws IOException {+ if (glyphCount > 0) {+ return;+ }++ element("set-line-style", new String[]+ {+ "index", Integer.toString(styleIndex)+ });+ }+++ /**+ * SWFShape interface+ *+ *@param color Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void defineFillStyle(Color color) throws IOException {+ start("color-fill", null);+ writeColor(color);+ end();+ }+++ /**+ * SWFShape interface+ *+ *@param matrix Description of the Parameter+ *@param ratios Description of the Parameter+ *@param colors Description of the Parameter+ *@param radial Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void defineFillStyle(Matrix matrix, int[] ratios,+ Color[] colors, boolean radial)+ throws IOException {+ start("gradient-fill", new String[]{"radial", radial ? "yes" : "no"});+ writeMatrix(matrix);++ start("gradient", null);+ for (int i = 0; i < ratios.length; i++) {+ start("step", new String[]{"ratio", Integer.toString(ratios[i])});+ writeColor(colors[i]);+ end();+ //step+ }+ end();+ //gradient+ end();+ //gradient-fill+ }+++ /**+ * SWFShape interface+ *+ *@param bitmapId Description of the Parameter+ *@param matrix Description of the Parameter+ *@param clipped Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void defineFillStyle(int bitmapId, Matrix matrix, boolean clipped)+ throws IOException {+ start("image-fill", new String[]+ {+ "clipped", clipped ? "yes" : "no",+ "image-id", Integer.toString(bitmapId)+ });++ writeMatrix(matrix);++ end();+ //image-fill+ }+++ /**+ * SWFShape interface+ *+ *@param width Description of the Parameter+ *@param color Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void defineLineStyle(int width, Color color) throws IOException {+ start("line-style", new String[]+ {+ "width", Double.toString(((double) width) / SWFConstants.TWIPS)+ });++ writeColor(color);++ end();+ //line-style+ }+++ /**+ * Description of the Method+ *+ *@param matrix Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void writeMatrix(Matrix matrix) throws IOException {+ element("matrix", new String[]+ {+ "skew0", Double.toString(matrix.getSkew0()),+ "skew1", Double.toString(matrix.getSkew1()),+ "scale-x", Double.toString(matrix.getScaleX()),+ "scale-y", Double.toString(matrix.getScaleY()),+ "x", Double.toString(matrix.getTranslateX() / SWFConstants.TWIPS),+ "y", Double.toString(matrix.getTranslateY() / SWFConstants.TWIPS)+ });+ }+++ /**+ * Description of the Method+ *+ *@param color Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void writeColor(Color color) throws IOException {+ if (color instanceof AlphaColor) {+ AlphaColor acolor = (AlphaColor) color;++ element("color", new String[]+ {+ "red", Integer.toString(acolor.getRed()),+ "green", Integer.toString(acolor.getGreen()),+ "blue", Integer.toString(acolor.getBlue()),+ "alpha", Integer.toString(acolor.getAlpha())+ });+ } else {+ element("color", new String[]+ {+ "red", Integer.toString(color.getRed()),+ "green", Integer.toString(color.getGreen()),+ "blue", Integer.toString(color.getBlue())+ });+ }+ }+++ /**+ * Description of the Method+ *+ *@param cxform Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void writeCXForm(ColorTransform cxform) throws IOException {+ Vector attrs = new Vector();++ int addRed = cxform.getAddRed();+ int addGreen = cxform.getAddGreen();+ int addBlue = cxform.getAddBlue();+ double multRed = cxform.getMultRed();+ double multGreen = cxform.getMultGreen();+ double multBlue = cxform.getMultBlue();++ if (addRed != 0) {+ attrs.add("add-red");+ attrs.add(Integer.toString(addRed));+ }++ if (addGreen != 0) {+ attrs.add("add-green");+ attrs.add(Integer.toString(addGreen));+ }++ if (addBlue != 0) {+ attrs.add("add-blue");+ attrs.add(Integer.toString(addBlue));+ }++ if (multRed != 1.0) {+ attrs.add("mult-red");+ attrs.add(Double.toString(multRed));+ }++ if (multGreen != 1.0) {+ attrs.add("mult-green");+ attrs.add(Double.toString(multGreen));+ }++ if (multBlue != 1.0) {+ attrs.add("mult-blue");+ attrs.add(Double.toString(multBlue));+ }++ if (cxform instanceof AlphaTransform) {+ AlphaTransform axform = (AlphaTransform) cxform;++ int addAlpha = axform.getAddAlpha();+ double multAlpha = axform.getMultAlpha();++ if (addAlpha != 0) {+ attrs.add("add-alpha");+ attrs.add(Integer.toString(addAlpha));+ }++ if (multAlpha != 1.0) {+ attrs.add("mult-alpha");+ attrs.add(Double.toString(multAlpha));+ }+ }++ String[] attributes = new String[attrs.size()];+ attrs.copyInto(attributes);++ element("color-transform", attributes);+ }+++ /**+ * SWFActions interface+ *+ *@param flags Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void start(int flags2) throws IOException {+ String[] attrs = null;+ int flags = flags2;+ if (actionsType == 2) {+ //clip++ StringBuffer conds = new StringBuffer();++ if ((flags & SWFConstants.CLIP_ACTION_ON_LOAD) > 0) {+ conds.append("load");+ }+ if ((flags & SWFConstants.CLIP_ACTION_ENTER_FRAME) > 0) {+ conds.append(" enter-frame");+ }+ if ((flags & SWFConstants.CLIP_ACTION_UNLOAD) > 0) {+ conds.append(" unload");+ }+ if ((flags & SWFConstants.CLIP_ACTION_MOUSE_MOVE) > 0) {+ conds.append(" mouse-move");+ }+ if ((flags & SWFConstants.CLIP_ACTION_MOUSE_DOWN) > 0) {+ conds.append(" mouse-down");+ }+ if ((flags & SWFConstants.CLIP_ACTION_MOUSE_UP) > 0) {+ conds.append(" mouse-up");+ }+ if ((flags & SWFConstants.CLIP_ACTION_KEY_DOWN) > 0) {+ conds.append(" key-down");+ }+ if ((flags & SWFConstants.CLIP_ACTION_KEY_UP) > 0) {+ conds.append(" key-up");+ }+ if ((flags & SWFConstants.CLIP_ACTION_DATA) > 0) {+ conds.append(" data");+ }++ String conditions = conds.toString().trim();+ attrs = new String[]{"conditions", conditions};+ } else if (actionsType == 3) {+ //button++ StringBuffer conds = new StringBuffer();++ if (flags == 0) {+ flags = SWFConstants.BUTTON2_OVERDOWN2OVERUP;+ }++ if ((flags & SWFConstants.BUTTON2_OVERDOWN2IDLE) > 0) {+ conds.append("menu-drag-out");+ }+ if ((flags & SWFConstants.BUTTON2_IDLE2OVERDOWN) > 0) {+ conds.append(" menu-drag-over");+ }+ if ((flags & SWFConstants.BUTTON2_OUTDOWN2IDLE) > 0) {+ conds.append(" release-outside");+ }+ if ((flags & SWFConstants.BUTTON2_OUTDOWN2OVERDOWN) > 0) {+ conds.append(" drag-over");+ }+ if ((flags & SWFConstants.BUTTON2_OVERDOWN2OUTDOWN) > 0) {+ conds.append(" drag-out");+ }+ if ((flags & SWFConstants.BUTTON2_OVERDOWN2OVERUP) > 0) {+ conds.append(" release");+ }+ if ((flags & SWFConstants.BUTTON2_OVERUP2OVERDOWN) > 0) {+ conds.append(" press");+ }+ if ((flags & SWFConstants.BUTTON2_OVERUP2IDLE) > 0) {+ conds.append(" roll-out");+ }+ if ((flags & SWFConstants.BUTTON2_IDLE2OVERUP) > 0) {+ conds.append(" roll-over");+ }++ String conditions = conds.toString().trim();++ if ((flags & 0xfe00) > 0) {+ //has a key press condition++ int charcode = (flags & 0xfe00) >> 9;++ attrs = new String[]+ {+ "conditions", conditions,+ "char-code", Integer.toString(charcode)+ };+ } else {+ attrs = new String[]{"conditions", conditions};+ }+ }++ start("actions", attrs);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void end() throws IOException {+ super.end();+ }+++ /**+ * SWFActions interface+ *+ *@param blob Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void blob(byte[] blob) throws IOException {+ //not used+ }+++ /**+ * SWFActions interface+ *+ *@param code Description of the Parameter+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void unknown(int code, byte[] data) throws IOException {+ start("unknown", new String[]{"code", Integer.toString(code)});+ text(Base64.encode(data));+ end();+ }+++ /**+ * SWFActions interface+ *+ *@param label Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void jumpLabel(String label) throws IOException {+ element("jump-label", new String[]{"label", label});+ }+++ /**+ * SWFActions interface+ *+ *@param comment Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void comment(String comment) throws IOException {+ start("comment", null);+ text(comment);+ end();+ }+++ /**+ * SWFActions interface+ *+ *@param frameNumber Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void gotoFrame(int frameNumber) throws IOException {+ element("goto-frame", new String[]{"number",+ Integer.toString(frameNumber)});+ }+++ /**+ * SWFActions interface+ *+ *@param label Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void gotoFrame(String label) throws IOException {+ element("goto-frame", new String[]{"label", label});+ }+++ /**+ * SWFActions interface+ *+ *@param url Description of the Parameter+ *@param target Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void getURL(String url, String target) throws IOException {+ element("get-url", new String[]+ {+ "url", url,+ "target", target+ });+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void nextFrame() throws IOException {+ element("next-frame", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void prevFrame() throws IOException {+ element("prev-frame", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void play() throws IOException {+ element("play", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void stop() throws IOException {+ element("stop", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void toggleQuality() throws IOException {+ element("toggle-quality", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void stopSounds() throws IOException {+ element("stop-sounds", null);+ }+++ /**+ * SWFActions interface+ *+ *@param frameNumber Description of the Parameter+ *@param jumpLabel Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void waitForFrame(int frameNumber, String jumpLabel) throws IOException {+ element("wait-for-frame", new String[]+ {+ "number", Integer.toString(frameNumber),+ "jump-label", jumpLabel+ });+ }+++ /**+ * SWFActions interface+ *+ *@param target The new target value+ *@exception IOException Description of the Exception+ */+ public void setTarget(String target) throws IOException {+ element("set-target", new String[]{"target", target});+ }+++ /**+ * SWFActions interface+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(String value) throws IOException {+ element("push", new String[]{"string", value});+ }+++ /**+ * SWFActions interface+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(float value) throws IOException {+ element("push", new String[]{"float", Float.toString(value)});+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void pop() throws IOException {+ element("pop", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void add() throws IOException {+ element("add", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void substract() throws IOException {+ element("subtract", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void multiply() throws IOException {+ element("multiply", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void divide() throws IOException {+ element("divide", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void equals() throws IOException {+ element("equals", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void lessThan() throws IOException {+ element("less-than", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void and() throws IOException {+ element("and", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void or() throws IOException {+ element("or", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void not() throws IOException {+ element("not", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void stringEquals() throws IOException {+ element("string-equals", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void stringLength() throws IOException {+ element("string-length", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void concat() throws IOException {+ element("concat", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void substring() throws IOException {+ element("substring", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void stringLessThan() throws IOException {+ element("string-less-than", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void stringLengthMB() throws IOException {+ element("mutlibyte-string-length", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void substringMB() throws IOException {+ element("multibyte-substring", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void toInteger() throws IOException {+ element("to-integer", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void charToAscii() throws IOException {+ element("char-to-ascii", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void asciiToChar() throws IOException {+ element("ascii-to-char", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void charMBToAscii() throws IOException {+ element("mutlibyte-char-to-ascii", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void asciiToCharMB() throws IOException {+ element("ascii-to-multibyte-char", null);+ }+++ /**+ * SWFActions interface+ *+ *@param jumpLabel Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void jump(String jumpLabel) throws IOException {+ element("jump", new String[]{"jump-label", jumpLabel});+ }+++ /**+ * SWFActions interface+ *+ *@param jumpLabel Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void ifJump(String jumpLabel) throws IOException {+ element("if", new String[]{"jump-label", jumpLabel});+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void call() throws IOException {+ element("call", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void getVariable() throws IOException {+ element("get-variable", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void setVariable() throws IOException {+ element("set-variable", null);+ }+++ /**+ * SWFActions interface+ *+ *@param sendVars Description of the Parameter+ *@param loadMode Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void getURL(int sendVars, int loadMode) throws IOException {+ String method = "none";+ if (sendVars == GET_URL_SEND_VARS_GET) {+ method = "get";+ } else if (sendVars == GET_URL_SEND_VARS_POST) {+ method = "post";+ }++ String mode = null;+ String target = null;++ if (loadMode == GET_URL_MODE_LOAD_MOVIE_INTO_SPRITE) {+ mode = "yes";+ target = "target-sprite";+ } else if (loadMode == GET_URL_MODE_LOAD_VARS_INTO_LEVEL) {+ mode = "level";+ target = "load-vars-into";+ } else if (loadMode == GET_URL_MODE_LOAD_VARS_INTO_SPRITE) {+ mode = "sprite";+ target = "load-vars-into";+ }++ element("get-url", new String[]+ {+ "send-vars", method,+ target, mode+ });+ }+++ /**+ * SWFActions interface+ *+ *@param play Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void gotoFrame(boolean play) throws IOException {+ element("goto-frame", new String[]{"play", play ? "yes" : "no"});+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void setTarget() throws IOException {+ element("set-target", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void getProperty() throws IOException {+ element("get-property", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void setProperty() throws IOException {+ element("set-property", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void cloneSprite() throws IOException {+ element("clone-sprite", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void removeSprite() throws IOException {+ element("remove-sprite", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void startDrag() throws IOException {+ element("start-drag", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void endDrag() throws IOException {+ element("end-drag", null);+ }+++ /**+ * SWFActions interface+ *+ *@param jumpLabel Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void waitForFrame(String jumpLabel) throws IOException {+ element("wait-for-frame", new String[]+ {+ "jump-label", jumpLabel+ });+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void trace() throws IOException {+ element("trace", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void getTime() throws IOException {+ element("get-time", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void randomNumber() throws IOException {+ element("random-number", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void callFunction() throws IOException {+ element("call-function", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void callMethod() throws IOException {+ element("call-method", null);+ }+++ /**+ * SWFActions interface+ *+ *@param values Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void lookupTable(String[] values) throws IOException {+ start("lookup-table", null);++ for (int i = 0; i < values.length; i++) {+ start("value", null);+ text(values[i]);+ end();+ }++ end();+ }+++ /**+ * SWFActions interface+ *+ *@param name Description of the Parameter+ *@param paramNames Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void startFunction(String name, String[] paramNames) throws IOException {+ StringBuffer parms = new StringBuffer();++ for (int i = 0; i < paramNames.length; i++) {+ parms.append(" ");+ parms.append(paramNames[i]);+ }++ start("function", new String[]+ {+ "name", name,+ "params", parms.toString().trim()+ });+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void endBlock() throws IOException {+ end();+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void defineLocalValue() throws IOException {+ element("define-local-value", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void defineLocal() throws IOException {+ element("define-local", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void deleteProperty() throws IOException {+ element("delete-property", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void deleteThreadVars() throws IOException {+ element("delete-thread-vars", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void enumerate() throws IOException {+ element("enumerate", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void typedEquals() throws IOException {+ element("typed-equals", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void getMember() throws IOException {+ element("get-member", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void initArray() throws IOException {+ element("init-array", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void initObject() throws IOException {+ element("init-object", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void newMethod() throws IOException {+ element("new-method", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void newObject() throws IOException {+ element("new-object", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void setMember() throws IOException {+ element("set-member", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void getTargetPath() throws IOException {+ element("get-target-path", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void startWith() throws IOException {+ start("with", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void convertToNumber() throws IOException {+ element("to-number", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void convertToString() throws IOException {+ element("to-string", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void typeOf() throws IOException {+ element("type-of", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void typedAdd() throws IOException {+ element("typed-add", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void typedLessThan() throws IOException {+ element("typed-less-than", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void modulo() throws IOException {+ element("modulo", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void bitAnd() throws IOException {+ element("bit-and", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void bitOr() throws IOException {+ element("bit-or", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void bitXor() throws IOException {+ element("bit-xor", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void shiftLeft() throws IOException {+ element("shift-left", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void shiftRight() throws IOException {+ element("shift-right", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void shiftRightUnsigned() throws IOException {+ element("shift-right-unsigned", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void decrement() throws IOException {+ element("decrement", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void increment() throws IOException {+ element("increment", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void duplicate() throws IOException {+ element("duplicate", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void returnValue() throws IOException {+ element("return", null);+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void swap() throws IOException {+ element("swap", null);+ }+++ /**+ * SWFActions interface+ *+ *@param registerNumber Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void storeInRegister(int registerNumber) throws IOException {+ element("store", new String[]{"register", Integer.toString(registerNumber)});+ }+++ /**+ * SWFActions interface+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(double value) throws IOException {+ element("push", new String[]{"double", Double.toString(value)});+ }+++ /**+ * SWFActions interface+ *+ *@exception IOException Description of the Exception+ */+ public void pushNull() throws IOException {+ element("push", null);+ }+++ /**+ * SWFActions interface+ *+ *@param registerNumber Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void pushRegister(int registerNumber) throws IOException {+ element("push", new String[]{"register", Integer.toString(registerNumber)});+ }+++ /**+ * SWFActions interface+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(boolean value) throws IOException {+ element("push", new String[]{"boolean", "" + value});+ }+++ /**+ * SWFActions interface+ *+ *@param value Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void push(int value) throws IOException {+ element("push", new String[]{"int", Integer.toString(value)});+ }+++ /**+ * SWFActions interface+ *+ *@param dictionaryIndex Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void lookup(int dictionaryIndex) throws IOException {+ element("push", new String[]{"lookup", Integer.toString(dictionaryIndex)});+ }+++ /**+ * SWFText interface+ *+ *@param fontId Description of the Parameter+ *@param textHeight Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void font(int fontId, int textHeight) throws IOException {+ element("set-font", new String[]+ {+ "id", Integer.toString(fontId),+ "size", Double.toString(((double) textHeight) / SWFConstants.TWIPS)+ });+ }+++ /**+ * SWFText interface+ *+ *@param color Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void color(Color color) throws IOException {+ writeColor(color);+ }+++ /**+ * SWFText interface+ *+ *@param x The new x value+ *@exception IOException Description of the Exception+ */+ public void setX(int x) throws IOException {+ element("set-x", new String[]+ {+ "x", Double.toString(((double) x) / SWFConstants.TWIPS)+ });+ }+++ /**+ * SWFText interface+ *+ *@param y The new y value+ *@exception IOException Description of the Exception+ */+ public void setY(int y) throws IOException {+ element("set-y", new String[]+ {+ "y", Double.toString(((double) y) / SWFConstants.TWIPS)+ });+ }+++ /**+ * SWFText interface+ *+ *@param glyphIndices Description of the Parameter+ *@param glyphAdvances Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void text(int[] glyphIndices, int[] glyphAdvances) throws IOException {+ for (int i = 0; i < glyphIndices.length; i++) {+ element("char", new String[]+ {+ "glyph-index", Integer.toString(glyphIndices[i]),+ "advance", Double.toString(((double) glyphAdvances[i]) / SWFConstants.TWIPS)+ });+ }+ }+++ /**+ * Read a SWF file (args[0]) and write XML out (args[1])+ *+ *@param args The command line arguments+ *@exception Exception Description of the Exception+ */+ public static void main(String[] args) throws Exception {+ OutputStream out = new FileOutputStream(args[1]);+ XMLWriter writer = new XMLWriter(out);+ SWFSaxParser parser = new SWFSaxParser(writer, writer);++ parser.parse(args[0]);++ out.close();+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFShape.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFShape.javanew file mode 100644index 000000000..61aa7e40d--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFShape.java@@ -0,0 +1,84 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * Interface for passing shape style information in addition to the basic+ * vectors.+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public interface SWFShape extends SWFVectors {+ /**+ * Sets the fillStyle0 attribute of the SWFShape object+ *+ *@param styleIndex The new fillStyle0 value+ *@exception IOException Description of the Exception+ */+ public void setFillStyle0(int styleIndex) throws IOException;+++ /**+ * Sets the fillStyle1 attribute of the SWFShape object+ *+ *@param styleIndex The new fillStyle1 value+ *@exception IOException Description of the Exception+ */+ public void setFillStyle1(int styleIndex) throws IOException;+++ /**+ * Sets the lineStyle attribute of the SWFShape object+ *+ *@param styleIndex The new lineStyle value+ *@exception IOException Description of the Exception+ */+ public void setLineStyle(int styleIndex) throws IOException;+++ /**+ * Solid color fill+ *+ *@param color Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void defineFillStyle(Color color) throws IOException;+++ /**+ * Gradient fill - linear or radial.+ *+ *@param colors may have null elements - these (and the+ * corresponding ratio) should be ignored+ *@param matrix Description of the Parameter+ *@param ratios Description of the Parameter+ *@param radial Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void defineFillStyle(Matrix matrix, int[] ratios,+ Color[] colors, boolean radial)+ throws IOException;+++ /**+ * Bitmap fill - tiled or clipped+ *+ *@param bitmapId Description of the Parameter+ *@param matrix Description of the Parameter+ *@param clipped Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void defineFillStyle(int bitmapId, Matrix matrix, boolean clipped)+ throws IOException;+++ /**+ * Description of the Method+ *+ *@param width Description of the Parameter+ *@param color Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void defineLineStyle(int width, Color color) throws IOException;+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFSpriteTagTypes.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFSpriteTagTypes.javanew file mode 100644index 000000000..09ca775e0--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFSpriteTagTypes.java@@ -0,0 +1,163 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * Interface for passing SWF tag types that can be used in a movie or a sprite+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public interface SWFSpriteTagTypes extends SWFTags {+ /**+ * Start/stop playing a sound+ *+ *@param soundId Description of the Parameter+ *@param info Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagStartSound(int soundId, SoundInfo info) throws IOException;+++ /**+ * Only allows ADPCM encoding.+ *+ *@param streamFormat must be SWFConstants.SOUND_FORMAT_ADPCM+ *@param playbackFrequency one of the SWFConstants.SOUND_FREQ_* constants+ *@param streamFrequency one of the SWFConstants.SOUND_FREQ_* constants+ *@param playback16bit Description of the Parameter+ *@param playbackStereo Description of the Parameter+ *@param stream16bit Description of the Parameter+ *@param streamStereo Description of the Parameter+ *@param averageSampleCount Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagSoundStreamHead(+ int playbackFrequency, boolean playback16bit, boolean playbackStereo,+ int streamFormat, int streamFrequency, boolean stream16bit, boolean streamStereo,+ int averageSampleCount) throws IOException;+++ /**+ * Allows any encoding.+ *+ *@param streamFormat one of the SWFConstants.SOUND_FORMAT_*+ * constants+ *@param playbackFrequency one of the SWFConstants.SOUND_FREQ_* constants+ *@param streamFrequency one of the SWFConstants.SOUND_FREQ_* constants+ *@param playback16bit Description of the Parameter+ *@param playbackStereo Description of the Parameter+ *@param stream16bit Description of the Parameter+ *@param streamStereo Description of the Parameter+ *@param averageSampleCount Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagSoundStreamHead2(+ int playbackFrequency, boolean playback16bit, boolean playbackStereo,+ int streamFormat, int streamFrequency, boolean stream16bit, boolean streamStereo,+ int averageSampleCount) throws IOException;+++ /**+ *@param soundData format-dependent sound data+ *@exception IOException Description of the Exception+ */+ public void tagSoundStreamBlock(byte[] soundData) throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void tagEnd() throws IOException;+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void tagShowFrame() throws IOException;+++ /**+ *@return SWFActions to receive actions - or null to skip+ * the data+ *@exception IOException Description of the Exception+ */+ public SWFActions tagDoAction() throws IOException;+++ /**+ * Description of the Method+ *+ *@param charId Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagFreeCharacter(int charId) throws IOException;+++ /**+ *@param cxform may be null+ *@param charId Description of the Parameter+ *@param depth Description of the Parameter+ *@param matrix Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagPlaceObject(int charId, int depth, Matrix matrix, AlphaTransform cxform) throws IOException;+++ /**+ * Description of the Method+ *+ *@param charId Description of the Parameter+ *@param depth Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagRemoveObject(int charId, int depth) throws IOException;+++ /**+ *@param clipDepth < 1 if not relevant+ *@param charId < 1 if not relevant+ *@param name of sprite instance - null if not relevant+ *@param ratio < 0 if not relevant+ *@param matrix null if not relevant+ *@param cxform null if not relevant+ *@param clipActionFlags == 0 if there are no clip actions - otherwise+ * this is the OR of the condition flags on all the clip action blocks+ *@param isMove Description of the Parameter+ *@param depth Description of the Parameter+ *@return null if there are no clip actions or they are+ * irrelevant+ *@exception IOException Description of the Exception+ */+ public SWFActions tagPlaceObject2(boolean isMove,+ int clipDepth,+ int depth,+ int charId,+ Matrix matrix,+ AlphaTransform cxform,+ int ratio,+ String name,+ int clipActionFlags) throws IOException;+++ /**+ * Description of the Method+ *+ *@param depth Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagRemoveObject2(int depth) throws IOException;+++ /**+ * Description of the Method+ *+ *@param label Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagFrameLabel(String label) throws IOException;+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTagTypes.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTagTypes.javanew file mode 100644index 000000000..ff6afb7eb--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTagTypes.java@@ -0,0 +1,428 @@+package pt.tumba.parser.swf;++import java.io.IOException;+import java.io.InputStream;+import java.util.List;++/**+ * Interface for passing SWF tag types.+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public interface SWFTagTypes extends SWFSpriteTagTypes {++ /**+ *@param format one of the SWFConstants.SOUND_FORMAT_* constants+ *@param frequency one of the SWFConstants.SOUND_FREQ_* constants+ *@param soundData format-dependent sound data+ *@param id Description of the Parameter+ *@param bits16 Description of the Parameter+ *@param stereo Description of the Parameter+ *@param sampleCount Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineSound(int id, int format, int frequency,+ boolean bits16, boolean stereo,+ int sampleCount, byte[] soundData) throws IOException;+++ /**+ * Define the sound for a button+ *+ *@param buttonId Description of the Parameter+ *@param rollOverSoundId Description of the Parameter+ *@param rollOverSoundInfo Description of the Parameter+ *@param rollOutSoundId Description of the Parameter+ *@param rollOutSoundInfo Description of the Parameter+ *@param pressSoundId Description of the Parameter+ *@param pressSoundInfo Description of the Parameter+ *@param releaseSoundId Description of the Parameter+ *@param releaseSoundInfo Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineButtonSound(int buttonId,+ int rollOverSoundId, SoundInfo rollOverSoundInfo,+ int rollOutSoundId, SoundInfo rollOutSoundInfo,+ int pressSoundId, SoundInfo pressSoundInfo,+ int releaseSoundId, SoundInfo releaseSoundInfo)+ throws IOException;+++ /**+ *@param id Description of the Parameter+ *@param outline Description of the Parameter+ *@return SWFShape to receive shape info - or null to skip+ * the data+ *@exception IOException Description of the Exception+ */+ public SWFShape tagDefineShape(int id, Rect outline) throws IOException;+++ /**+ *@param id Description of the Parameter+ *@param outline Description of the Parameter+ *@return SWFShape to receive shape info - or null to skip+ * the data+ *@exception IOException Description of the Exception+ */+ public SWFShape tagDefineShape2(int id, Rect outline) throws IOException;+++ /**+ *@param id Description of the Parameter+ *@param outline Description of the Parameter+ *@return SWFShape to receive shape info - or null to skip+ * the data+ *@exception IOException Description of the Exception+ */+ public SWFShape tagDefineShape3(int id, Rect outline) throws IOException;+++ /**+ *@param buttonRecords contains ButtonRecord objects+ *@param id Description of the Parameter+ *@return SWFActions object (may be null) to receive button+ * actions - there is only one action array (with no conditions).+ *@exception IOException Description of the Exception+ *@see com.anotherbigidea.flash.structs.ButtonRecord+ */+ public SWFActions tagDefineButton(int id, List buttonRecords)+ throws IOException;+++ /**+ * Description of the Method+ *+ *@param buttonId Description of the Parameter+ *@param transform Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagButtonCXForm(int buttonId, ColorTransform transform) throws IOException;+++ /**+ *@param buttonRecord2s contains ButtonRecord2 objects+ *@param id Description of the Parameter+ *@param trackAsMenu Description of the Parameter+ *@return SWFActions object (may be null) to receive button+ * actions - there may be multiple action arrays - each one is+ * conditional, using the BUTTON2_* condition flags defined in+ * SWFConstants.java+ *@exception IOException Description of the Exception+ *@see com.anotherbigidea.flash.structs.ButtonRecord2+ */+ public SWFActions tagDefineButton2(int id,+ boolean trackAsMenu,+ List buttonRecord2s)+ throws IOException;+++ /**+ * Description of the Method+ *+ *@param color Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagSetBackgroundColor(Color color) throws IOException;+++ /**+ * The SWFVectors object returned will be called numGlyphs times to pass+ * the vector information for each glyph (each glyph is terminated by+ * calling SWFVectors.done() )+ *+ *@param id Description of the Parameter+ *@param numGlyphs Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFVectors tagDefineFont(int id, int numGlyphs) throws IOException;+++ /**+ *@param id Description of the Parameter+ *@param bounds Description of the Parameter+ *@param matrix Description of the Parameter+ *@return SWFText object to receive the text style and+ * glyph information - this may be null if the info is not required+ *@exception IOException Description of the Exception+ */+ public SWFText tagDefineText(int id, Rect bounds, Matrix matrix) throws IOException;+++ /**+ * Allows alpha colors+ *+ *@param id Description of the Parameter+ *@param bounds Description of the Parameter+ *@param matrix Description of the Parameter+ *@return SWFText object to receive the text style and+ * glyph information - this may be null if the info is not required+ *@exception IOException Description of the Exception+ */+ public SWFText tagDefineText2(int id, Rect bounds, Matrix matrix) throws IOException;+++ /**+ *@param flags see FONT_* constants in SWFConstants.java+ *@param fontId Description of the Parameter+ *@param fontName Description of the Parameter+ *@param codes Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineFontInfo(int fontId, String fontName,+ int flags, int[] codes) throws IOException;+++ /**+ *@param data must contain the header data - use the+ * InputStream version when using an external JPEG+ *@param id Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsJPEG2(int id, byte[] data) throws IOException;+++ /**+ *@param jpegImage must be a baseline JPEG (not a progressive JPEG)+ *@param id Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsJPEG2(int id, InputStream jpegImage) throws IOException;+++ /**+ * JPEG image data only - header/encoding data is in tagJPEGTables tag+ *+ *@param id Description of the Parameter+ *@param imageData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBits(int id, byte[] imageData) throws IOException;+++ /**+ * Only one tag per SWF - holds common JPEG encoding data+ *+ *@param jpegEncodingData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagJPEGTables(byte[] jpegEncodingData) throws IOException;+++ /**+ * JPEG image and encoding data with alpha channel bitmap+ *+ *@param alphaData is zlib compressed+ *@param id Description of the Parameter+ *@param imageData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsJPEG3(int id, byte[] imageData, byte[] alphaData) throws IOException;+++ /**+ *@param format one of the SWFConstants.BITMAP_FORMAT_n_BIT+ * constants+ *@param id Description of the Parameter+ *@param width Description of the Parameter+ *@param height Description of the Parameter+ *@param colors Description of the Parameter+ *@param imageData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsLossless(int id, int format, int width, int height,+ Color[] colors, byte[] imageData)+ throws IOException;+++ /**+ *@param format one of the SWFConstants.BITMAP_FORMAT_n_BIT+ * constants+ *@param id Description of the Parameter+ *@param width Description of the Parameter+ *@param height Description of the Parameter+ *@param colors Description of the Parameter+ *@param imageData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsLossless2(int id, int format, int width, int height,+ Color[] colors, byte[] imageData)+ throws IOException;+++ /**+ *@param password may be null+ *@exception IOException Description of the Exception+ */+ public void tagProtect(byte[] password) throws IOException;+++ /**+ *@param flags see TEXTFIELD_* constants in SWFConstants.java+ *@param fieldId Description of the Parameter+ *@param fieldName Description of the Parameter+ *@param initialText Description of the Parameter+ *@param boundary Description of the Parameter+ *@param textColor Description of the Parameter+ *@param alignment Description of the Parameter+ *@param fontId Description of the Parameter+ *@param fontSize Description of the Parameter+ *@param charLimit Description of the Parameter+ *@param leftMargin Description of the Parameter+ *@param rightMargin Description of the Parameter+ *@param indentation Description of the Parameter+ *@param lineSpacing Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineTextField(int fieldId, String fieldName,+ String initialText, Rect boundary, int flags,+ AlphaColor textColor, int alignment, int fontId, int fontSize,+ int charLimit, int leftMargin, int rightMargin, int indentation,+ int lineSpacing)+ throws IOException;+++ /**+ * Description of the Method+ *+ *@param id Description of the Parameter+ *@param filename Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineQuickTimeMovie(int id, String filename) throws IOException;+++ /**+ * Description of the Method+ *+ *@param id Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFTagTypes tagDefineSprite(int id) throws IOException;+++ /**+ * Description of the Method+ *+ *@param id Description of the Parameter+ *@param startBounds Description of the Parameter+ *@param endBounds Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFShape tagDefineMorphShape(int id, Rect startBounds, Rect endBounds)+ throws IOException;+++ /**+ * Description of the Method+ *+ *@param id Description of the Parameter+ *@param flags Description of the Parameter+ *@param name Description of the Parameter+ *@param numGlyphs Description of the Parameter+ *@param ascent Description of the Parameter+ *@param descent Description of the Parameter+ *@param leading Description of the Parameter+ *@param codes Description of the Parameter+ *@param advances Description of the Parameter+ *@param bounds Description of the Parameter+ *@param kernCodes1 Description of the Parameter+ *@param kernCodes2 Description of the Parameter+ *@param kernAdjustments Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFVectors tagDefineFont2(int id, int flags, String name, int numGlyphs,+ int ascent, int descent, int leading,+ int[] codes, int[] advances, Rect[] bounds,+ int[] kernCodes1, int[] kernCodes2,+ int[] kernAdjustments) throws IOException;+++ /**+ * Description of the Method+ *+ *@param names Description of the Parameter+ *@param ids Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagExport(String[] names, int[] ids) throws IOException;+++ /**+ * Description of the Method+ *+ *@param movieName Description of the Parameter+ *@param names Description of the Parameter+ *@param ids Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagImport(String movieName, String[] names, int[] ids) throws IOException;+++ /**+ * Description of the Method+ *+ *@param password Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagEnableDebug(byte[] password) throws IOException;+++ /**+ * In files produced by Generator...+ *+ *@param serialNumber Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagSerialNumber(String serialNumber) throws IOException;+++ /**+ * In Generator templates. Data is not parsed.+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagGenerator(byte[] data) throws IOException;+++ /**+ * In Generator templates. Data is not parsed.+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagGeneratorText(byte[] data) throws IOException;+++ /**+ * In Generator templates. Data is not parsed.+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagGeneratorCommand(byte[] data) throws IOException;+++ /**+ * In Generator templates. Data is not parsed.+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagNameCharacter(byte[] data) throws IOException;+++ /**+ * In Generator templates. Data is not parsed.+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagGeneratorFont(byte[] data) throws IOException;+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTagTypesImpl.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTagTypesImpl.javanew file mode 100644index 000000000..8ca7cb816--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTagTypesImpl.java@@ -0,0 +1,884 @@+package pt.tumba.parser.swf;++import java.io.IOException;+import java.io.InputStream;+import java.util.List;++/**+ * A pass-through implementation of the SWFTagTypes interface - useful as a+ * base class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class SWFTagTypesImpl implements SWFTagTypes {+ /**+ * Description of the Field+ */+ protected SWFTagTypes tags;+++ /**+ *@param tags may be null+ */+ public SWFTagTypesImpl(SWFTagTypes tags) {+ this.tags = tags;+ }+++ /**+ * SWFTags interface+ *+ *@param tagType Description of the Parameter+ *@param longTag Description of the Parameter+ *@param contents Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tag(int tagType, boolean longTag, byte[] contents)+ throws IOException {+ if (tags != null) {+ tags.tag(tagType, longTag, contents);+ }+ }+++ /**+ * SWFHeader interface. Sets movie length to -1 to force a recalculation+ * since the length cannot be guaranteed to be the same as the original.+ *+ *@param version Description of the Parameter+ *@param length Description of the Parameter+ *@param twipsWidth Description of the Parameter+ *@param twipsHeight Description of the Parameter+ *@param frameRate Description of the Parameter+ *@param frameCount Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void header(int version, long length,+ int twipsWidth, int twipsHeight,+ int frameRate, int frameCount) throws IOException {+ if (tags != null) {+ tags.header(version, length, twipsWidth, twipsHeight,+ frameRate, frameCount);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@exception IOException Description of the Exception+ */+ public void tagEnd() throws IOException {+ if (tags != null) {+ tags.tagEnd();+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param format Description of the Parameter+ *@param frequency Description of the Parameter+ *@param bits16 Description of the Parameter+ *@param stereo Description of the Parameter+ *@param sampleCount Description of the Parameter+ *@param soundData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineSound(int id, int format, int frequency,+ boolean bits16, boolean stereo,+ int sampleCount, byte[] soundData)+ throws IOException {+ if (tags != null) {+ tags.tagDefineSound(id, format, frequency,+ bits16, stereo, sampleCount, soundData);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param buttonId Description of the Parameter+ *@param rollOverSoundId Description of the Parameter+ *@param rollOverSoundInfo Description of the Parameter+ *@param rollOutSoundId Description of the Parameter+ *@param rollOutSoundInfo Description of the Parameter+ *@param pressSoundId Description of the Parameter+ *@param pressSoundInfo Description of the Parameter+ *@param releaseSoundId Description of the Parameter+ *@param releaseSoundInfo Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineButtonSound(int buttonId,+ int rollOverSoundId, SoundInfo rollOverSoundInfo,+ int rollOutSoundId, SoundInfo rollOutSoundInfo,+ int pressSoundId, SoundInfo pressSoundInfo,+ int releaseSoundId, SoundInfo releaseSoundInfo)+ throws IOException {+ if (tags != null) {+ tags.tagDefineButtonSound(buttonId,+ rollOverSoundId, rollOverSoundInfo,+ rollOutSoundId, rollOutSoundInfo,+ pressSoundId, pressSoundInfo,+ releaseSoundId, releaseSoundInfo);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param soundId Description of the Parameter+ *@param info Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagStartSound(int soundId, SoundInfo info) throws IOException {+ if (tags != null) {+ tags.tagStartSound(soundId, info);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param playbackFrequency Description of the Parameter+ *@param playback16bit Description of the Parameter+ *@param playbackStereo Description of the Parameter+ *@param streamFormat Description of the Parameter+ *@param streamFrequency Description of the Parameter+ *@param stream16bit Description of the Parameter+ *@param streamStereo Description of the Parameter+ *@param averageSampleCount Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagSoundStreamHead(+ int playbackFrequency, boolean playback16bit, boolean playbackStereo,+ int streamFormat, int streamFrequency, boolean stream16bit, boolean streamStereo,+ int averageSampleCount) throws IOException {+ if (tags != null) {+ tags.tagSoundStreamHead(+ playbackFrequency, playback16bit, playbackStereo,+ streamFormat, streamFrequency, stream16bit, streamStereo,+ averageSampleCount);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param playbackFrequency Description of the Parameter+ *@param playback16bit Description of the Parameter+ *@param playbackStereo Description of the Parameter+ *@param streamFormat Description of the Parameter+ *@param streamFrequency Description of the Parameter+ *@param stream16bit Description of the Parameter+ *@param streamStereo Description of the Parameter+ *@param averageSampleCount Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagSoundStreamHead2(+ int playbackFrequency, boolean playback16bit, boolean playbackStereo,+ int streamFormat, int streamFrequency, boolean stream16bit, boolean streamStereo,+ int averageSampleCount) throws IOException {+ if (tags != null) {+ tags.tagSoundStreamHead2(+ playbackFrequency, playback16bit, playbackStereo,+ streamFormat, streamFrequency, stream16bit, streamStereo,+ averageSampleCount);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param soundData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagSoundStreamBlock(byte[] soundData) throws IOException {+ if (tags != null) {+ tags.tagSoundStreamBlock(soundData);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param serialNumber Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagSerialNumber(String serialNumber) throws IOException {+ if (tags != null) {+ tags.tagSerialNumber(serialNumber);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagGenerator(byte[] data) throws IOException {+ if (tags != null) {+ tags.tagGenerator(data);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagGeneratorText(byte[] data) throws IOException {+ if (tags != null) {+ tags.tagGeneratorText(data);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagGeneratorFont(byte[] data) throws IOException {+ if (tags != null) {+ tags.tagGeneratorFont(data);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagGeneratorCommand(byte[] data) throws IOException {+ if (tags != null) {+ tags.tagGeneratorCommand(data);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagNameCharacter(byte[] data) throws IOException {+ if (tags != null) {+ tags.tagNameCharacter(data);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param imageData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBits(int id, byte[] imageData) throws IOException {+ if (tags != null) {+ tags.tagDefineBits(id, imageData);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param jpegEncodingData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagJPEGTables(byte[] jpegEncodingData) throws IOException {+ if (tags != null) {+ tags.tagJPEGTables(jpegEncodingData);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param imageData Description of the Parameter+ *@param alphaData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsJPEG3(int id, byte[] imageData, byte[] alphaData)+ throws IOException {+ if (tags != null) {+ tags.tagDefineBitsJPEG3(id, imageData, alphaData);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@exception IOException Description of the Exception+ */+ public void tagShowFrame() throws IOException {+ if (tags != null) {+ tags.tagShowFrame();+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFActions tagDoAction() throws IOException {+ if (tags != null) {+ return tags.tagDoAction();+ }+ return null;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param outline Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFShape tagDefineShape(int id, Rect outline) throws IOException {+ if (tags != null) {+ return tags.tagDefineShape(id, outline);+ }+ return null;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param outline Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFShape tagDefineShape2(int id, Rect outline) throws IOException {+ if (tags != null) {+ return tags.tagDefineShape2(id, outline);+ }+ return null;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param outline Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFShape tagDefineShape3(int id, Rect outline) throws IOException {+ if (tags != null) {+ return tags.tagDefineShape3(id, outline);+ }+ return null;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param charId Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagFreeCharacter(int charId) throws IOException {+ if (tags != null) {+ tags.tagFreeCharacter(charId);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param charId Description of the Parameter+ *@param depth Description of the Parameter+ *@param matrix Description of the Parameter+ *@param cxform Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagPlaceObject(int charId, int depth,+ Matrix matrix, AlphaTransform cxform)+ throws IOException {+ if (tags != null) {+ tags.tagPlaceObject(charId, depth, matrix, cxform);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param isMove Description of the Parameter+ *@param clipDepth Description of the Parameter+ *@param depth Description of the Parameter+ *@param charId Description of the Parameter+ *@param matrix Description of the Parameter+ *@param cxform Description of the Parameter+ *@param ratio Description of the Parameter+ *@param name Description of the Parameter+ *@param clipActionFlags Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFActions tagPlaceObject2(boolean isMove,+ int clipDepth,+ int depth,+ int charId,+ Matrix matrix,+ AlphaTransform cxform,+ int ratio,+ String name,+ int clipActionFlags)+ throws IOException {+ if (tags != null) {+ return tags.tagPlaceObject2(isMove, clipDepth, depth,+ charId, matrix, cxform, ratio,+ name, clipActionFlags);+ }+ return null;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param charId Description of the Parameter+ *@param depth Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagRemoveObject(int charId, int depth) throws IOException {+ if (tags != null) {+ tags.tagRemoveObject(charId, depth);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param depth Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagRemoveObject2(int depth) throws IOException {+ if (tags != null) {+ tags.tagRemoveObject2(depth);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param color Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagSetBackgroundColor(Color color) throws IOException {+ if (tags != null) {+ tags.tagSetBackgroundColor(color);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param label Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagFrameLabel(String label) throws IOException {+ if (tags != null) {+ tags.tagFrameLabel(label);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFTagTypes tagDefineSprite(int id) throws IOException {+ if (tags != null) {+ return tags.tagDefineSprite(id);+ }+ return null;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param password Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagProtect(byte[] password) throws IOException {+ if (tags != null) {+ tags.tagProtect(password);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param password Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagEnableDebug(byte[] password) throws IOException {+ if (tags != null) {+ tags.tagEnableDebug(password);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param numGlyphs Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFVectors tagDefineFont(int id, int numGlyphs) throws IOException {+ if (tags != null) {+ return tags.tagDefineFont(id, numGlyphs);+ }+ return null;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param fontId Description of the Parameter+ *@param fontName Description of the Parameter+ *@param flags Description of the Parameter+ *@param codes Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineFontInfo(int fontId, String fontName, int flags, int[] codes)+ throws IOException {+ if (tags != null) {+ tags.tagDefineFontInfo(fontId, fontName, flags, codes);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param flags Description of the Parameter+ *@param name Description of the Parameter+ *@param numGlyphs Description of the Parameter+ *@param ascent Description of the Parameter+ *@param descent Description of the Parameter+ *@param leading Description of the Parameter+ *@param codes Description of the Parameter+ *@param advances Description of the Parameter+ *@param bounds Description of the Parameter+ *@param kernCodes1 Description of the Parameter+ *@param kernCodes2 Description of the Parameter+ *@param kernAdjustments Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFVectors tagDefineFont2(int id, int flags, String name, int numGlyphs,+ int ascent, int descent, int leading,+ int[] codes, int[] advances, Rect[] bounds,+ int[] kernCodes1, int[] kernCodes2,+ int[] kernAdjustments) throws IOException {+ if (tags != null) {+ return tags.tagDefineFont2(id, flags, name, numGlyphs,+ ascent, descent, leading, codes, advances,+ bounds, kernCodes1, kernCodes2, kernAdjustments);+ }+ return null;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param fieldId Description of the Parameter+ *@param fieldName Description of the Parameter+ *@param initialText Description of the Parameter+ *@param boundary Description of the Parameter+ *@param flags Description of the Parameter+ *@param textColor Description of the Parameter+ *@param alignment Description of the Parameter+ *@param fontId Description of the Parameter+ *@param fontSize Description of the Parameter+ *@param charLimit Description of the Parameter+ *@param leftMargin Description of the Parameter+ *@param rightMargin Description of the Parameter+ *@param indentation Description of the Parameter+ *@param lineSpacing Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineTextField(int fieldId, String fieldName,+ String initialText, Rect boundary, int flags,+ AlphaColor textColor, int alignment, int fontId, int fontSize,+ int charLimit, int leftMargin, int rightMargin, int indentation,+ int lineSpacing)+ throws IOException {+ if (tags != null) {+ tags.tagDefineTextField(fieldId, fieldName, initialText,+ boundary, flags, textColor, alignment, fontId,+ fontSize, charLimit, leftMargin, rightMargin,+ indentation, lineSpacing);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param bounds Description of the Parameter+ *@param matrix Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFText tagDefineText(int id, Rect bounds, Matrix matrix)+ throws IOException {+ if (tags != null) {+ return tags.tagDefineText(id, bounds, matrix);+ }++ return null;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param bounds Description of the Parameter+ *@param matrix Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFText tagDefineText2(int id, Rect bounds, Matrix matrix) throws IOException {+ if (tags != null) {+ return tags.tagDefineText2(id, bounds, matrix);+ }+ return null;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param buttonRecords Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFActions tagDefineButton(int id, List buttonRecords)+ throws IOException {+ if (tags != null) {+ return tags.tagDefineButton(id, buttonRecords);+ }+ return null;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param buttonId Description of the Parameter+ *@param transform Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagButtonCXForm(int buttonId, ColorTransform transform)+ throws IOException {+ if (tags != null) {+ tags.tagButtonCXForm(buttonId, transform);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param trackAsMenu Description of the Parameter+ *@param buttonRecord2s Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFActions tagDefineButton2(int id,+ boolean trackAsMenu,+ List buttonRecord2s)+ throws IOException {+ if (tags != null) {+ return tags.tagDefineButton2(id, trackAsMenu,+ buttonRecord2s);+ }+ return null;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param names Description of the Parameter+ *@param ids Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagExport(String[] names, int[] ids) throws IOException {+ if (tags != null) {+ tags.tagExport(names, ids);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param movieName Description of the Parameter+ *@param names Description of the Parameter+ *@param ids Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagImport(String movieName, String[] names, int[] ids)+ throws IOException {+ if (tags != null) {+ tags.tagImport(movieName, names, ids);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param filename Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineQuickTimeMovie(int id, String filename) throws IOException {+ if (tags != null) {+ tags.tagDefineQuickTimeMovie(id, filename);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsJPEG2(int id, byte[] data) throws IOException {+ if (tags != null) {+ tags.tagDefineBitsJPEG2(id, data);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param jpegImage Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsJPEG2(int id, InputStream jpegImage) throws IOException {+ if (tags != null) {+ tags.tagDefineBitsJPEG2(id, jpegImage);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param startBounds Description of the Parameter+ *@param endBounds Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFShape tagDefineMorphShape(int id, Rect startBounds, Rect endBounds)+ throws IOException {+ if (tags != null) {+ return tags.tagDefineMorphShape(id, startBounds, endBounds);+ }+ return null;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param format Description of the Parameter+ *@param width Description of the Parameter+ *@param height Description of the Parameter+ *@param colors Description of the Parameter+ *@param imageData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsLossless(int id, int format, int width, int height,+ Color[] colors, byte[] imageData)+ throws IOException {+ if (tags != null) {+ tags.tagDefineBitsLossless(id, format, width, height,+ colors, imageData);+ }+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param format Description of the Parameter+ *@param width Description of the Parameter+ *@param height Description of the Parameter+ *@param colors Description of the Parameter+ *@param imageData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsLossless2(int id, int format, int width, int height,+ Color[] colors, byte[] imageData)+ throws IOException {+ if (tags != null) {+ tags.tagDefineBitsLossless2(id, format, width, height,+ colors, imageData);+ }+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTags.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTags.javanew file mode 100644index 000000000..e4d33a285--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTags.java@@ -0,0 +1,25 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * Interface for passing SWF Header and Generic Tags.+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public interface SWFTags extends SWFHeader {+ /**+ * A SWF tag.+ *+ *@param tagType a type of zero (TAG_END) denotes the end of the+ * tags+ *@param longTag true if the tag header is forced into the long+ * form+ *@param contents may be null+ *@exception IOException Description of the Exception+ */+ public void tag(int tagType, boolean longTag, byte[] contents)+ throws IOException;++}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFText.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFText.javanew file mode 100644index 000000000..91a617599--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFText.java@@ -0,0 +1,65 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * Interface for passing static text+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public interface SWFText {+ /**+ * Description of the Method+ *+ *@param fontId Description of the Parameter+ *@param textHeight Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void font(int fontId, int textHeight) throws IOException;+++ /**+ * Color is AlphaColor for DefineText2+ *+ *@param color Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void color(Color color) throws IOException;+++ /**+ * Sets the x attribute of the SWFText object+ *+ *@param x The new x value+ *@exception IOException Description of the Exception+ */+ public void setX(int x) throws IOException;+++ /**+ * Sets the y attribute of the SWFText object+ *+ *@param y The new y value+ *@exception IOException Description of the Exception+ */+ public void setY(int y) throws IOException;+++ /**+ * Description of the Method+ *+ *@param glyphIndices Description of the Parameter+ *@param glyphAdvances Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void text(int[] glyphIndices, int[] glyphAdvances) throws IOException;+++ /**+ * Called at end of all text+ *+ *@exception IOException Description of the Exception+ */+ public void done() throws IOException;+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFVectors.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFVectors.javanew file mode 100644index 000000000..e19f93c1c--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFVectors.java@@ -0,0 +1,50 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * Interface for passing basic shape information without styles.+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public interface SWFVectors {+ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void done() throws IOException;+++ /**+ * Description of the Method+ *+ *@param dx Description of the Parameter+ *@param dy Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void line(int dx, int dy) throws IOException;+++ /**+ * Description of the Method+ *+ *@param cx Description of the Parameter+ *@param cy Description of the Parameter+ *@param dx Description of the Parameter+ *@param dy Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void curve(int cx, int cy, int dx, int dy) throws IOException;+++ /**+ * Description of the Method+ *+ *@param x Description of the Parameter+ *@param y Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void move(int x, int y) throws IOException;+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFWriter.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFWriter.javanew file mode 100644index 000000000..3223045b8--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFWriter.java@@ -0,0 +1,239 @@+package pt.tumba.parser.swf;++import java.io.ByteArrayOutputStream;+import java.io.FileNotFoundException;+import java.io.FileOutputStream;+import java.io.IOException;+import java.io.OutputStream;+import java.io.RandomAccessFile;++/**+ * Implements the SWFTags interface and writes a SWF file to the output stream+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class SWFWriter implements SWFTags {+ /**+ * Description of the Field+ */+ protected OutStream out;+ /**+ * Description of the Field+ */+ protected OutputStream outputstream;+ /**+ * Description of the Field+ */+ protected ByteArrayOutputStream byteout;+ /**+ * Description of the Field+ */+ protected String filename;++ //--deferred header values+ /**+ * Description of the Field+ */+ protected int frameCount;+ /**+ * Description of the Field+ */+ protected int version;+ /**+ * Description of the Field+ */+ protected Rect frameSize;+ /**+ * Description of the Field+ */+ protected int height;+ /**+ * Description of the Field+ */+ protected int rate;+++ /**+ * Constructor for the SWFWriter object+ *+ *@param filename Description of the Parameter+ *@exception FileNotFoundException Description of the Exception+ */+ public SWFWriter(String filename) throws FileNotFoundException {+ this(new FileOutputStream(filename));+ this.filename = filename;+ }+++ /**+ * Constructor for the SWFWriter object+ *+ *@param outputstream Description of the Parameter+ */+ public SWFWriter(OutputStream outputstream) {+ this.outputstream = outputstream;+ out = new OutStream(outputstream);+ }+++ /**+ * Constructor for the SWFWriter object+ *+ *@param outstream Description of the Parameter+ */+ public SWFWriter(OutStream outstream) {+ out = outstream;+ }+++ /**+ * Interface SWFTags+ *+ *@param version Description of the Parameter+ *@param length Description of the Parameter+ *@param twipsWidth Description of the Parameter+ *@param twipsHeight Description of the Parameter+ *@param frameRate Description of the Parameter+ *@param frameCount Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void header(int version, long length2,+ int twipsWidth, int twipsHeight,+ int frameRate, int frameCount2) throws IOException {+ int frameCount = frameCount2;+ long length = length2;+ frameSize = new Rect(0, 0, twipsWidth, twipsHeight);++ //--Unknown values+ if (length < 0 || frameCount < 0) {+ //--defer the header+ this.version = version;+ this.rate = frameRate;+ this.frameCount = 0;++ if (filename != null) {+ //write the header later++ length = 0;+ frameCount = 0;+ } else {+ //write to a byte array first++ //--set up a byte array for the output+ if (byteout == null) {+ byteout = new ByteArrayOutputStream(20000);+ out = new OutStream(byteout);+ }++ return;+ }+ }++ writeHeader(version, length, frameRate, frameCount);+ }+++ /**+ * Interface SWFTags+ *+ *@param tagType Description of the Parameter+ *@param longTag Description of the Parameter+ *@param contents Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tag(int tagType, boolean longTag2,+ byte[] contents) throws IOException {+ boolean longTag = longTag2;+ //System.out.println( "OUT Tag " + tagType + " " + longTag + " " + ( (contents==null) ? 0 : contents.length) );+ //System.out.println();++ int length = (contents != null) ? contents.length : 0;+ longTag = (length > 62) || longTag;++ int hdr = (tagType << 6) + (longTag ? 0x3f : length);++ out.writeUI16(hdr);++ if (longTag) {+ out.writeUI32(length);+ }++ if (contents != null) {+ out.write(contents);+ }++ if (tagType == SWFConstants.TAG_SHOWFRAME) {+ frameCount++;+ }+ if (tagType == SWFConstants.TAG_END) {+ finish();+ }+ }+++ /**+ * Description of the Method+ *+ *@param version Description of the Parameter+ *@param length Description of the Parameter+ *@param frameRate Description of the Parameter+ *@param frameCount Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void writeHeader(int version, long length,+ int frameRate, int frameCount) throws IOException {+ //--Write File Signature+ out.write(new byte[]{0x46, 0x57, 0x53});++ out.writeUI8(version);+ out.writeUI32(length);+ frameSize.write(out);+ out.writeUI16(frameRate << 8);+ out.writeUI16(frameCount);+ }+++ /**+ * Finish writing+ *+ *@exception IOException Description of the Exception+ */+ protected void finish() throws IOException {+ out.flush();++ //--Close the output file, calculate length and framecount and then+ // rewrite the header.+ if (filename != null) {+ outputstream.close();++ RandomAccessFile raf = new RandomAccessFile(filename, "rw");+ int length = (int) raf.length();++ byteout = new ByteArrayOutputStream();+ out = new OutStream(byteout);++ writeHeader(version, length, rate, frameCount);+ out.flush();++ raf.write(byteout.toByteArray());+ raf.close();++ return;+ }++ //--Writing to a byte array - need to recalculate lengths+ if (byteout != null) {+ byte[] bytes = byteout.toByteArray();++ long length = 12L + frameSize.getLength() + bytes.length;++ out = new OutStream(outputstream);++ writeHeader(version, length, rate, frameCount);++ out.write(bytes);+ out.flush();+ }+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SaxHandlerBase.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SaxHandlerBase.javanew file mode 100644index 000000000..5cf8f65dd--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SaxHandlerBase.java@@ -0,0 +1,505 @@+package pt.tumba.parser.swf;++import java.util.ArrayList;+import java.util.HashMap;+import java.util.Iterator;+import java.util.List;+import java.util.Map;++import org.xml.sax.Attributes;+import org.xml.sax.SAXException;+import org.xml.sax.helpers.AttributesImpl;+import org.xml.sax.helpers.DefaultHandler;++/**+ * Base class for SAX2 Content Handlers+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public abstract class SaxHandlerBase extends DefaultHandler {+ /**+ * Description of the Field+ */+ protected Map elementTypes = new HashMap();+ /**+ * Description of the Field+ */+ protected SaxHandlerBase.ElementType elemType;+ /**+ * Description of the Field+ */+ protected List elems = new ArrayList();++ /**+ * Description of the Field+ */+ protected boolean gatherMode = false;+ /**+ * Description of the Field+ */+ protected List gatherBuffer;+ /**+ * Description of the Field+ */+ protected SaxHandlerBase.GatheringElementType gatheringElement;+++ //--Start gathering elements/chars for later dispatch+ /**+ * Description of the Method+ *+ *@param elem Description of the Parameter+ */+ public void startGatherMode(SaxHandlerBase.GatheringElementType elem) {+ gatheringElement = elem;+ gatherBuffer = new ArrayList();+ gatherMode = true;+ }+++ //--stop gathering and dispatch the gathered elements+ /**+ * Description of the Method+ *+ *@exception Exception Description of the Exception+ */+ public void endGatherMode() throws Exception {+ gatherMode = false;+ gatheringElement = null;++ //--replay the elements+ for (Iterator it = gatherBuffer.iterator(); it.hasNext(); ) {+ Object[] elem = (Object[]) it.next();++ SaxHandlerBase.ElementType type = (SaxHandlerBase.ElementType) elem[0];+ if (type == null) {+ continue;+ }++ if (elem[1] == null) {+ //element end++ type.endElement();+ } else if (elem[1] instanceof String) {+ String charstring = (String) elem[1];+ char[] chars = charstring.toCharArray();+ type.characters(chars, 0, chars.length);+ } else {+ Attributes atts = (Attributes) elem[1];+ type.startElement(atts);+ }+ }++ gatherBuffer = null;+ }+++ //--dispatch all the gathered elements that match the name+ /**+ * Description of the Method+ *+ *@param elemName Description of the Parameter+ *@exception Exception Description of the Exception+ */+ public void dispatchAllMatchingGatheredElements(String elemName) throws Exception {+ SaxHandlerBase.ElementType dispelem =+ (SaxHandlerBase.ElementType) elementTypes.get(elemName);++ if (dispelem == null) {+ return;+ }+ boolean found = false;++ for (Iterator it = gatherBuffer.iterator(); it.hasNext(); ) {+ Object[] elem = (Object[]) it.next();++ SaxHandlerBase.ElementType type = (SaxHandlerBase.ElementType) elem[0];+ if (type == null) {+ continue;+ }++ if (type == dispelem) {+ found = true;+ }++ if (found) {+ it.remove();++ if (elem[1] == null) {+ //element end++ type.endElement();+ if (type == dispelem) {+ found = false;+ }+ //done dispatching this element+ } else if (elem[1] instanceof String) {+ String charstring = (String) elem[1];+ char[] chars = charstring.toCharArray();+ type.characters(chars, 0, chars.length);+ } else {+ Attributes atts = (Attributes) elem[1];+ type.startElement(atts);+ }+ }+ }+ }+++ //--dispatch the first gathered element that matches the name+ /**+ * Description of the Method+ *+ *@param elemName Description of the Parameter+ *@exception Exception Description of the Exception+ */+ public void dispatchGatheredElement(String elemName) throws Exception {+ SaxHandlerBase.ElementType dispelem =+ (SaxHandlerBase.ElementType) elementTypes.get(elemName);++ if (dispelem == null) {+ return;+ }+ boolean found = false;++ for (Iterator it = gatherBuffer.iterator(); it.hasNext(); ) {+ Object[] elem = (Object[]) it.next();++ SaxHandlerBase.ElementType type = (SaxHandlerBase.ElementType) elem[0];+ if (type == null) {+ continue;+ }++ if (type == dispelem) {+ found = true;+ }++ if (found) {+ it.remove();++ if (elem[1] == null) {+ //element end++ type.endElement();+ if (type == dispelem) {+ return;+ }+ //done dispatching+ } else if (elem[1] instanceof String) {+ String charstring = (String) elem[1];+ char[] chars = charstring.toCharArray();+ type.characters(chars, 0, chars.length);+ } else {+ Attributes atts = (Attributes) elem[1];+ type.startElement(atts);+ }+ }+ }+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public static class ElementType {+ /**+ * Description of the Method+ *+ *@param atts Description of the Parameter+ *@exception Exception Description of the Exception+ */+ public void startElement(Attributes atts) throws Exception { }+++ /**+ * Description of the Method+ *+ *@exception Exception Description of the Exception+ */+ public void endElement() throws Exception { }+++ /**+ * Description of the Method+ *+ *@param ch Description of the Parameter+ *@param start Description of the Parameter+ *@param length Description of the Parameter+ *@exception Exception Description of the Exception+ */+ public void characters(char[] ch, int start, int length)+ throws Exception { }+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public static class ContentElementType extends SaxHandlerBase.ElementType {+ /**+ * Description of the Field+ */+ protected Attributes attrs;+ /**+ * Description of the Field+ */+ protected StringBuffer buff;+++ /**+ * Description of the Method+ *+ *@param atts Description of the Parameter+ *@exception Exception Description of the Exception+ */+ public void startElement(Attributes atts) throws Exception {+ attrs = new AttributesImpl(atts);+ buff = new StringBuffer();+ }+++ /**+ * Description of the Method+ *+ *@param ch Description of the Parameter+ *@param start Description of the Parameter+ *@param length Description of the Parameter+ *@exception Exception Description of the Exception+ */+ public void characters(char[] ch, int start, int length)+ throws Exception {+ buff.append(ch, start, length);+ }+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public static class GatheringElementType extends SaxHandlerBase.ContentElementType {+ /**+ * Description of the Method+ *+ *@param atts Description of the Parameter+ *@exception Exception Description of the Exception+ */+ public void startElement(Attributes atts) throws Exception {+ super.startElement(atts);+ }+++ /**+ * Description of the Method+ *+ *@param localName Description of the Parameter+ *@param atts Description of the Parameter+ *@return Description of the Return Value+ */+ public boolean gatherElement(String localName, Attributes atts) {+ return true;+ }+ }+++ /**+ * Description of the Method+ *+ *@param namespaceURI Description of the Parameter+ *@param localName Description of the Parameter+ *@param qName Description of the Parameter+ *@param atts Description of the Parameter+ *@exception SAXException Description of the Exception+ */+ public void startElement(String namespaceURI, String localName,+ String qName, Attributes atts)+ throws SAXException {+ try {+ elemType = (SaxHandlerBase.ElementType) elementTypes.get(localName);++ if (gatherMode) {+ //gather the element for later processing++ if (gatheringElement.gatherElement(localName, atts)) {+ gatherBuffer.add(new Object[]{elemType, new AttributesImpl(atts)});+ }+ } else {+ if (elemType == null) {+ return;+ }+ elemType.startElement(atts);+ }++ elems.add(elemType);+ } catch (SAXException saxex) {+ throw saxex;+ } catch (Exception ex) {+ //ex.printStackTrace();+ throw new SAXException(ex);+ }+ }+++ /**+ * Description of the Method+ *+ *@param namespaceURI Description of the Parameter+ *@param localName Description of the Parameter+ *@param qName Description of the Parameter+ *@exception SAXException Description of the Exception+ */+ public void endElement(String namespaceURI, String localName, String qName)+ throws SAXException {+ try {+ elemType = (SaxHandlerBase.ElementType) elementTypes.get(localName);+ if (elemType == null) {+ return;+ }++ if (elemType == gatheringElement) {+ gatherMode = false;+ }++ if (gatherMode) {+ //gather the element for later processing++ gatherBuffer.add(new Object[]{elemType, null});+ } else {+ elemType.endElement();+ }++ if (!elems.isEmpty()) {+ elemType = (SaxHandlerBase.ElementType) elems.remove(elems.size() - 1);+ } else {+ elemType = null;+ }+ } catch (SAXException saxex) {+ throw saxex;+ } catch (Exception ex) {+ throw new SAXException(ex);+ }+ }+++ /**+ * Description of the Method+ *+ *@param ch Description of the Parameter+ *@param start Description of the Parameter+ *@param length Description of the Parameter+ *@exception SAXException Description of the Exception+ */+ public void characters(char[] ch, int start, int length) throws SAXException {+ try {+ if (elemType == null) {+ return;+ }++ if (gatherMode) {+ //gather the element for later processing++ gatherBuffer.add(new Object[]{elemType, new String(ch, start, length)});+ } else {+ elemType.characters(ch, start, length);+ }+ } catch (SAXException saxex) {+ throw saxex;+ } catch (Exception ex) {+ throw new SAXException(ex);+ }+ }+++ /**+ * Gets the attr attribute of the SaxHandlerBase class+ *+ *@param attrs Description of the Parameter+ *@param name Description of the Parameter+ *@param defaultValue Description of the Parameter+ *@return The attr value+ */+ public static String getAttr(Attributes attrs, String name, String defaultValue) {+ String value = attrs.getValue("", name);+ if (value == null) {+ return defaultValue;+ }+ return value;+ }+++ /**+ * Gets the attrInt attribute of the SaxHandlerBase class+ *+ *@param attrs Description of the Parameter+ *@param name Description of the Parameter+ *@param defaultValue Description of the Parameter+ *@return The attrInt value+ */+ public static int getAttrInt(Attributes attrs, String name, int defaultValue) {+ String value = attrs.getValue("", name);+ if (value == null) {+ return defaultValue;+ }++ try {+ return Integer.parseInt(value);+ } catch (NumberFormatException nfe) {+ return defaultValue;+ }+ }+++ /**+ * Gets the attrDouble attribute of the SaxHandlerBase class+ *+ *@param attrs Description of the Parameter+ *@param name Description of the Parameter+ *@param defaultValue Description of the Parameter+ *@return The attrDouble value+ */+ public static double getAttrDouble(Attributes attrs, String name, double defaultValue) {+ String value = attrs.getValue("", name);+ if (value == null) {+ return defaultValue;+ }++ try {+ return Double.parseDouble(value);+ } catch (NumberFormatException nfe) {+ return defaultValue;+ }+ }+++ /**+ * Gets the attrBool attribute of the SaxHandlerBase class+ *+ *@param attrs Description of the Parameter+ *@param name Description of the Parameter+ *@param defaultValue Description of the Parameter+ *@return The attrBool value+ */+ public static boolean getAttrBool(Attributes attrs, String name, boolean defaultValue) {+ String value = attrs.getValue("", name);+ if (value == null) {+ return defaultValue;+ }++ if (value.equalsIgnoreCase("yes")) {+ return true;+ }+ if (value.equalsIgnoreCase("true")) {+ return true;+ }+ return false;+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SaxParserBase.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SaxParserBase.javanew file mode 100644index 000000000..e009fe47a--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SaxParserBase.java@@ -0,0 +1,402 @@+package pt.tumba.parser.swf;++import java.io.IOException;+import java.util.ArrayList;+import java.util.List;++import org.xml.sax.ContentHandler;+import org.xml.sax.DTDHandler;+import org.xml.sax.EntityResolver;+import org.xml.sax.ErrorHandler;+import org.xml.sax.InputSource;+import org.xml.sax.SAXException;+import org.xml.sax.SAXNotRecognizedException;+import org.xml.sax.SAXNotSupportedException;+import org.xml.sax.XMLReader;+import org.xml.sax.helpers.AttributesImpl;++/**+ * Base class for SAX2 Parsers+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public abstract class SaxParserBase implements XMLReader {+ /**+ * Description of the Field+ */+ protected EntityResolver resolver;+ /**+ * Description of the Field+ */+ protected DTDHandler dtdhandler;+ /**+ * Description of the Field+ */+ protected ContentHandler contenthandler;+ /**+ * Description of the Field+ */+ protected ErrorHandler errorhandler;++ /**+ * Description of the Field+ */+ protected List elementStack = new ArrayList();++ /**+ * Description of the Field+ */+ protected String namespace;+++ /**+ * Gets the namespace attribute of the SaxParserBase object+ *+ *@return The namespace value+ */+ public String getNamespace() {+ return namespace;+ }+++ /**+ * Sets the namespace attribute of the SaxParserBase object+ *+ *@param namespace The new namespace value+ */+ public void setNamespace(String namespace) {+ this.namespace = namespace;+ }+++ /**+ * Constructor for the SaxParserBase object+ *+ *@param namespace Description of the Parameter+ */+ protected SaxParserBase(String namespace) {+ this.namespace = namespace;+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ protected void startDoc() throws IOException {+ if (contenthandler == null) {+ return;+ }++ try {+ contenthandler.startDocument();+ } catch (SAXException saxex) {+ throw new IOException(saxex.toString());+ }+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ protected void endDoc() throws IOException {+ if (contenthandler == null) {+ return;+ }++ try {+ contenthandler.endDocument();+ } catch (SAXException saxex) {+ throw new IOException(saxex.toString());+ }+ }+++ /**+ * Description of the Method+ *+ *@param text Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void text(String text) throws IOException {+ if (contenthandler == null) {+ return;+ }++ try {+ contenthandler.characters(text.toCharArray(), 0, text.length());+ } catch (SAXException saxex) {+ throw new IOException(saxex.toString());+ }+ }+++ /**+ * Description of the Method+ *+ *@param name Description of the Parameter+ *@param attributes Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void element(String name, String[] attributes)+ throws IOException {+ if (contenthandler == null) {+ return;+ }++ AttributesImpl attrs = new AttributesImpl();++ if (attributes != null) {+ int topIndex = attributes.length - 1;+ for (int i = 0; i < topIndex; i += 2) {+ String attName = attributes[i];+ String value = attributes[i + 1];++ if (attName != null && value != null) {+ attrs.addAttribute("", attName, attName, "CDATA", value);+ }+ }+ }++ try {+ contenthandler.startElement(namespace, name, name, attrs);+ contenthandler.endElement(namespace, name, name);+ } catch (SAXException saxex) {+ throw new IOException(saxex.toString());+ }+ }+++ /**+ * Description of the Method+ *+ *@param name Description of the Parameter+ *@param attributes Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void start(String name, String[] attributes)+ throws IOException {+ elementStack.add(name);+ if (contenthandler == null) {+ return;+ }++ AttributesImpl attrs = new AttributesImpl();++ if (attributes != null) {+ int topIndex = attributes.length - 1;+ for (int i = 0; i < topIndex; i += 2) {+ String attName = attributes[i];+ String value = attributes[i + 1];++ if (attName != null && value != null) {+ attrs.addAttribute("", attName, attName, "CDATA", value);+ }+ }+ }++ try {+ contenthandler.startElement(namespace, name, name, attrs);+ } catch (SAXException saxex) {+ throw new IOException(saxex.toString());+ }+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ protected void end() throws IOException {+ if (elementStack.isEmpty()) {+ return;+ }+ if (contenthandler == null) {+ return;+ }++ String name = (String) elementStack.remove(elementStack.size() - 1);++ try {+ contenthandler.endElement(namespace, name, name);+ } catch (SAXException saxex) {+ throw new IOException(saxex.toString());+ }+ }+++ //============ XMLReader interface follows: ================++ /**+ * Gets the feature attribute of the SaxParserBase object+ *+ *@param name Description of the Parameter+ *@return The feature value+ *@exception SAXNotRecognizedException Description of the Exception+ *@exception SAXNotSupportedException Description of the Exception+ */+ public boolean getFeature(String name)+ throws SAXNotRecognizedException, SAXNotSupportedException {+ if (name.equals("http://xml.org/sax/features/namespaces")) {+ return true;+ }++ if (name.equals("http://xml.org/sax/features/namespace-prefixes")) {+ return false;+ }++ throw new SAXNotRecognizedException(name);+ }+++ /**+ * Sets the feature attribute of the SaxParserBase object+ *+ *@param name The new feature value+ *@param value The new feature value+ *@exception SAXNotRecognizedException Description of the Exception+ *@exception SAXNotSupportedException Description of the Exception+ */+ public void setFeature(String name, boolean value)+ throws SAXNotRecognizedException, SAXNotSupportedException {+ if (name.equals("http://xml.org/sax/features/namespaces")+ || name.equals("http://xml.org/sax/features/namespace-prefixes")) {+ return;+ }++ throw new SAXNotRecognizedException(name);+ }+++ /**+ * Gets the property attribute of the SaxParserBase object+ *+ *@param name Description of the Parameter+ *@return The property value+ *@exception SAXNotRecognizedException Description of the Exception+ *@exception SAXNotSupportedException Description of the Exception+ */+ public Object getProperty(String name)+ throws SAXNotRecognizedException, SAXNotSupportedException {+ throw new SAXNotRecognizedException(name);+ }+++ /**+ * Sets the property attribute of the SaxParserBase object+ *+ *@param name The new property value+ *@param value The new property value+ *@exception SAXNotRecognizedException Description of the Exception+ *@exception SAXNotSupportedException Description of the Exception+ */+ public void setProperty(String name, Object value)+ throws SAXNotRecognizedException, SAXNotSupportedException {+ throw new SAXNotRecognizedException(name);+ }+++ /**+ * Sets the entityResolver attribute of the SaxParserBase object+ *+ *@param resolver The new entityResolver value+ */+ public void setEntityResolver(EntityResolver resolver) {+ this.resolver = resolver;+ }+++ /**+ * Gets the entityResolver attribute of the SaxParserBase object+ *+ *@return The entityResolver value+ */+ public EntityResolver getEntityResolver() {+ return resolver;+ }+++ /**+ * Sets the dTDHandler attribute of the SaxParserBase object+ *+ *@param handler The new dTDHandler value+ */+ public void setDTDHandler(DTDHandler handler) {+ this.dtdhandler = handler;+ }+++ /**+ * Gets the dTDHandler attribute of the SaxParserBase object+ *+ *@return The dTDHandler value+ */+ public DTDHandler getDTDHandler() {+ return dtdhandler;+ }+++ /**+ * Sets the contentHandler attribute of the SaxParserBase object+ *+ *@param handler The new contentHandler value+ */+ public void setContentHandler(ContentHandler handler) {+ this.contenthandler = handler;+ }+++ /**+ * Gets the contentHandler attribute of the SaxParserBase object+ *+ *@return The contentHandler value+ */+ public ContentHandler getContentHandler() {+ return contenthandler;+ }+++ /**+ * Sets the errorHandler attribute of the SaxParserBase object+ *+ *@param handler The new errorHandler value+ */+ public void setErrorHandler(ErrorHandler handler) {+ this.errorhandler = handler;+ }+++ /**+ * Gets the errorHandler attribute of the SaxParserBase object+ *+ *@return The errorHandler value+ */+ public ErrorHandler getErrorHandler() {+ return errorhandler;+ }+++ /**+ * Description of the Method+ *+ *@param input Description of the Parameter+ *@exception IOException Description of the Exception+ *@exception SAXException Description of the Exception+ */+ public abstract void parse(InputSource input) throws IOException, SAXException;+++ /**+ * Description of the Method+ *+ *@param systemId Description of the Parameter+ *@exception IOException Description of the Exception+ *@exception SAXException Description of the Exception+ */+ public abstract void parse(String systemId) throws IOException, SAXException;+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Shape.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Shape.javanew file mode 100644index 000000000..3447caeb8--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Shape.java@@ -0,0 +1,1151 @@+package pt.tumba.parser.swf;++import java.io.IOException;+import java.util.ArrayList;+import java.util.Iterator;+import java.util.List;++/**+ * A Shape Symbol+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class Shape extends Symbol {+ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public abstract static class Element {+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public abstract static class Style extends Shape.Element {+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public abstract static class FillStyle extends Shape.Style {+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public static class ColorFill extends Shape.FillStyle {+ /**+ * Description of the Field+ */+ protected Color color;+++ /**+ *@return may be Color or AlphaColor+ */+ public Color getColor() {+ return color;+ }+++ /**+ * Sets the color attribute of the ColorFill object+ *+ *@param color The new color value+ */+ public void setColor(Color color) {+ this.color = color;+ }+++ /**+ * Constructor for the ColorFill object+ *+ *@param color Description of the Parameter+ */+ public ColorFill(Color color) {+ this.color = color;+ }+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public static class ImageFill extends Shape.FillStyle {+ /**+ * Description of the Field+ */+ protected Symbol image;+ /**+ * Description of the Field+ */+ protected Transform matrix;+ /**+ * Description of the Field+ */+ protected boolean clipped;+++ /**+ * Gets the image attribute of the ImageFill object+ *+ *@return The image value+ */+ public Symbol getImage() {+ return image;+ }+++ /**+ * Gets the transform attribute of the ImageFill object+ *+ *@return The transform value+ */+ public Transform getTransform() {+ return matrix;+ }+++ /**+ * Gets the clipped attribute of the ImageFill object+ *+ *@return The clipped value+ */+ public boolean isClipped() {+ return clipped;+ }+++ /**+ * Sets the image attribute of the ImageFill object+ *+ *@param image The new image value+ */+ public void setImage(Symbol image) {+ this.image = image;+ }+++ /**+ * Sets the transform attribute of the ImageFill object+ *+ *@param matrix The new transform value+ */+ public void setTransform(Transform matrix) {+ this.matrix = matrix;+ }+++ /**+ * Sets the clipped attribute of the ImageFill object+ *+ *@param isClipped The new clipped value+ */+ public void setClipped(boolean isClipped) {+ clipped = isClipped;+ }+++ /**+ * Constructor for the ImageFill object+ *+ *@param image Description of the Parameter+ *@param matrix Description of the Parameter+ *@param isClipped Description of the Parameter+ */+ public ImageFill(Symbol image, Transform matrix, boolean isClipped) {+ this.image = image;+ this.matrix = matrix;+ this.clipped = isClipped;+ }+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public static class GradientFill extends Shape.FillStyle {+ /**+ * Description of the Field+ */+ protected Color[] colors;+ /**+ * Description of the Field+ */+ protected int[] ratios;+ /**+ * Description of the Field+ */+ protected Transform matrix;+ /**+ * Description of the Field+ */+ protected boolean radial;+++ /**+ * Gets the colors attribute of the GradientFill object+ *+ *@return The colors value+ */+ public Color[] getColors() {+ return colors;+ }+++ /**+ * Gets the transform attribute of the GradientFill object+ *+ *@return The transform value+ */+ public Transform getTransform() {+ return matrix;+ }+++ /**+ * Gets the ratios attribute of the GradientFill object+ *+ *@return The ratios value+ */+ public int[] getRatios() {+ return ratios;+ }+++ /**+ * Gets the radial attribute of the GradientFill object+ *+ *@return The radial value+ */+ public boolean isRadial() {+ return radial;+ }+++ /**+ * Sets the colors attribute of the GradientFill object+ *+ *@param colors The new colors value+ */+ public void setColors(Color[] colors) {+ this.colors = colors;+ }+++ /**+ * Sets the ratios attribute of the GradientFill object+ *+ *@param ratios The new ratios value+ */+ public void setRatios(int[] ratios) {+ this.ratios = ratios;+ }+++ /**+ * Sets the transform attribute of the GradientFill object+ *+ *@param matrix The new transform value+ */+ public void setTransform(Transform matrix) {+ this.matrix = matrix;+ }+++ /**+ * Sets the radial attribute of the GradientFill object+ *+ *@param isRadial The new radial value+ */+ public void setRadial(boolean isRadial) {+ this.radial = isRadial;+ }+++ /**+ * Constructor for the GradientFill object+ *+ *@param colors Description of the Parameter+ *@param ratios Description of the Parameter+ *@param matrix Description of the Parameter+ *@param isRadial Description of the Parameter+ */+ public GradientFill(Color[] colors, int[] ratios,+ Transform matrix, boolean isRadial) {+ this.colors = colors;+ this.matrix = matrix;+ this.radial = isRadial;+ this.ratios = ratios;+ }+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public static class LineStyle extends Shape.Style {+ /**+ * Description of the Field+ */+ protected double width;+ /**+ * Description of the Field+ */+ protected Color color;+++ /**+ * Gets the width attribute of the LineStyle object+ *+ *@return The width value+ */+ public double getWidth() {+ return width;+ }+++ /**+ * Gets the color attribute of the LineStyle object+ *+ *@return The color value+ */+ public Color getColor() {+ return color;+ }+++ /**+ * Sets the width attribute of the LineStyle object+ *+ *@param width The new width value+ */+ public void setWidth(double width) {+ this.width = width;+ }+++ /**+ * Sets the color attribute of the LineStyle object+ *+ *@param color The new color value+ */+ public void setColor(Color color) {+ this.color = color;+ }+++ /**+ * Constructor for the LineStyle object+ *+ *@param width Description of the Parameter+ *@param color Description of the Parameter+ */+ public LineStyle(double width, Color color) {+ this.width = width;+ this.color = color;+ }+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public abstract static class SetStyle extends Shape.Element {+ /**+ * Description of the Field+ */+ protected int index;+++ /**+ * Gets the styleIndex attribute of the SetStyle object+ *+ *@return The styleIndex value+ */+ public int getStyleIndex() {+ return index;+ }+++ /**+ * Sets the styleIndex attribute of the SetStyle object+ *+ *@param index The new styleIndex value+ */+ public void setStyleIndex(int index) {+ this.index = index;+ }+++ /**+ * Constructor for the SetStyle object+ *+ *@param index Description of the Parameter+ */+ protected SetStyle(int index) {+ this.index = index;+ }+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public abstract static class SetFillStyle extends Shape.SetStyle {+ /**+ * Constructor for the SetFillStyle object+ *+ *@param index Description of the Parameter+ */+ protected SetFillStyle(int index) {+ super(index);+ }+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public static class SetLeftFillStyle extends Shape.SetFillStyle {+ /**+ * Constructor for the SetLeftFillStyle object+ *+ *@param index Description of the Parameter+ */+ public SetLeftFillStyle(int index) {+ super(index);+ }+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public static class SetRightFillStyle extends Shape.SetFillStyle {+ /**+ * Constructor for the SetRightFillStyle object+ *+ *@param index Description of the Parameter+ */+ public SetRightFillStyle(int index) {+ super(index);+ }+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public static class SetLineStyle extends Shape.SetStyle {+ /**+ * Constructor for the SetLineStyle object+ *+ *@param index Description of the Parameter+ */+ public SetLineStyle(int index) {+ super(index);+ }+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public abstract static class Vector extends Shape.Element {+ /**+ * Description of the Field+ */+ protected double x, y;+++ /**+ * Gets the x attribute of the Vector object+ *+ *@return The x value+ */+ public double getX() {+ return x;+ }+++ /**+ * Gets the y attribute of the Vector object+ *+ *@return The y value+ */+ public double getY() {+ return y;+ }+++ /**+ * Sets the x attribute of the Vector object+ *+ *@param x The new x value+ */+ public void setX(double x) {+ this.x = x;+ }+++ /**+ * Sets the y attribute of the Vector object+ *+ *@param y The new y value+ */+ public void setY(double y) {+ this.y = y;+ }+++ /**+ * Constructor for the Vector object+ *+ *@param x Description of the Parameter+ *@param y Description of the Parameter+ */+ protected Vector(double x, double y) {+ this.x = x;+ this.y = y;+ }+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public static class Move extends Shape.Vector {+ /**+ * Constructor for the Move object+ *+ *@param x Description of the Parameter+ *@param y Description of the Parameter+ */+ public Move(double x, double y) {+ super(x, y);+ }+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public static class Line extends Shape.Vector {+ /**+ * Constructor for the Line object+ *+ *@param x Description of the Parameter+ *@param y Description of the Parameter+ */+ public Line(double x, double y) {+ super(x, y);+ }+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public static class Curve extends Shape.Vector {+ /**+ * Description of the Field+ */+ protected double cx, cy;+++ /**+ * Gets the controlX attribute of the Curve object+ *+ *@return The controlX value+ */+ public double getControlX() {+ return cx;+ }+++ /**+ * Gets the controlY attribute of the Curve object+ *+ *@return The controlY value+ */+ public double getControlY() {+ return cy;+ }+++ /**+ * Sets the controlX attribute of the Curve object+ *+ *@param cx The new controlX value+ */+ public void setControlX(double cx) {+ this.cx = cx;+ }+++ /**+ * Sets the controlY attribute of the Curve object+ *+ *@param cy The new controlY value+ */+ public void setControlY(double cy) {+ this.cy = cy;+ }+++ /**+ * Constructor for the Curve object+ *+ *@param x Description of the Parameter+ *@param y Description of the Parameter+ *@param controlX Description of the Parameter+ *@param controlY Description of the Parameter+ */+ public Curve(double x, double y, double controlX, double controlY) {+ super(x, y);+ this.cx = controlX;+ this.cy = controlY;+ }+ }+++ /**+ * Description of the Field+ */+ protected List elements = new ArrayList();+ /**+ * Description of the Field+ */+ protected double minX, maxX, minY, maxY;+ //bounding rectangle+ /**+ * Description of the Field+ */+ protected boolean hasAlpha = false;+ /**+ * Description of the Field+ */+ protected double maxLineWidth;+ /**+ * Description of the Field+ */+ protected double currx, curry;+++ /**+ * Constructor for the Shape object+ */+ public Shape() { }+++ /**+ * Get the bounding rectangle as a double[4] - (min-X,min-Y,max-X,max-Y)+ *+ *@return The boundingRectangle value+ */+ public double[] getBoundingRectangle() {+ return new double[]{minX, minY, maxX, maxY};+ }+++ /**+ * Set the bounding rectangle. This will be automatically calculated as the+ * geometry vectors are defined and this rectangle will be enlarged if it+ * does not contain all the vectors.+ *+ *@param minx The new boundingRectangle value+ *@param minY The new boundingRectangle value+ *@param maxX The new boundingRectangle value+ *@param maxY The new boundingRectangle value+ */+ public void setBoundingRectangle(double minX, double minY,+ double maxX, double maxY) {+ this.minX = minX;+ this.minY = minY;+ this.maxX = maxX;+ this.maxY = maxY;+ }+++ /**+ * Access the list of shape elements Each object is a subclass of+ * Shape.Element+ *+ *@return The shapeElements value+ */+ public List getShapeElements() {+ return elements;+ }+++ /**+ * Define a line style+ *+ *@param color if null then black is assumed+ *@param width Description of the Parameter+ */+ public void defineLineStyle(double width, Color color2) {+ Color color = color2;+ if (color == null) {+ color = new Color(0, 0, 0);+ }++ LineStyle style = new LineStyle(width, color);++ if (maxLineWidth < width) {+ maxLineWidth = width;+ }++ if (color instanceof AlphaColor) {+ hasAlpha = true;+ }++ elements.add(style);+ }+++ /**+ * Define a color fill+ *+ *@param color if null then white is assumed+ */+ public void defineFillStyle(Color color2) {+ Color color = color2;+ if (color == null) {+ color = new Color(255, 255, 255);+ }+ ColorFill fill = new ColorFill(color);++ if (color instanceof AlphaColor) {+ hasAlpha = true;+ }++ elements.add(fill);+ }+++ /**+ * Define an image fill+ *+ *@param image Description of the Parameter+ *@param matrix Description of the Parameter+ *@param clipped Description of the Parameter+ */+ public void defineFillStyle(Symbol image, Transform matrix, boolean clipped) {+ ImageFill fill = new ImageFill(image, matrix, clipped);++ elements.add(fill);+ }+++ /**+ * Define a gradient fill+ *+ *@param colors Description of the Parameter+ *@param ratios Description of the Parameter+ *@param matrix Description of the Parameter+ *@param radial Description of the Parameter+ */+ public void defineFillStyle(Color[] colors, int[] ratios,+ Transform matrix, boolean radial) {+ GradientFill fill = new GradientFill(colors, ratios, matrix, radial);++ elements.add(fill);++ for (int i = 0; i < colors.length; i++) {+ if (colors[i] == null) {+ continue;+ }+ if (colors[i] instanceof AlphaColor) {+ hasAlpha = true;+ }+ }+ }+++ /**+ * Set the left fill style+ *+ *@param index The new leftFillStyle value+ */+ public void setLeftFillStyle(int index) {+ SetLeftFillStyle fill = new SetLeftFillStyle(index);++ elements.add(fill);+ }+++ /**+ * Set the right fill style+ *+ *@param index The new rightFillStyle value+ */+ public void setRightFillStyle(int index) {+ SetRightFillStyle fill = new SetRightFillStyle(index);++ elements.add(fill);+ }+++ /**+ * Set the line style+ *+ *@param index The new lineStyle value+ */+ public void setLineStyle(int index) {+ SetLineStyle style = new SetLineStyle(index);++ elements.add(style);+ }+++ /**+ * Move the pen without drawing any line+ *+ *@param x Description of the Parameter+ *@param y Description of the Parameter+ */+ public void move(double x, double y) {+ Move move = new Move(x, y);++ if (x < minX) {+ minX = x;+ }+ if (y < minY) {+ minY = y;+ }+ if (x > maxX) {+ maxX = x;+ }+ if (y > maxY) {+ maxY = y;+ }++ elements.add(move);+ }+++ /**+ * Draw a line in the current line style (if any)+ *+ *@param x Description of the Parameter+ *@param y Description of the Parameter+ */+ public void line(double x, double y) {+ Line line = new Line(x, y);++ if (x < minX) {+ minX = x;+ }+ if (y < minY) {+ minY = y;+ }+ if (x > maxX) {+ maxX = x;+ }+ if (y > maxY) {+ maxY = y;+ }++ elements.add(line);+ }+++ /**+ * Draw a curve in the current line style (if any)+ *+ *@param x Description of the Parameter+ *@param y Description of the Parameter+ *@param controlX Description of the Parameter+ *@param controlY Description of the Parameter+ */+ public void curve(double x, double y, double controlX, double controlY) {+ Curve curve = new Curve(x, y, controlX, controlY);++ if (x < minX) {+ minX = x;+ }+ if (y < minY) {+ minY = y;+ }+ if (x > maxX) {+ maxX = x;+ }+ if (y > maxY) {+ maxY = y;+ }++ if (controlX < minX) {+ minX = controlX;+ }+ if (controlY < minY) {+ minY = controlY;+ }+ if (controlX > maxX) {+ maxX = controlX;+ }+ if (controlY > maxY) {+ maxY = controlY;+ }++ elements.add(curve);+ }+++ /**+ * Description of the Method+ *+ *@param movie Description of the Parameter+ *@param timelineWriter Description of the Parameter+ *@param definitionWriter Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ protected int defineSymbol(Movie movie,+ SWFTagTypes timelineWriter,+ SWFTagTypes definitionWriter)+ throws IOException {+ currx = 0.0;+ curry = 0.0;++ predefineImageFills(movie, timelineWriter, definitionWriter);++ int id = getNextId(movie);++ Rect outline = getRect();++ SWFShape shape = hasAlpha ?+ definitionWriter.tagDefineShape3(id, outline) :+ definitionWriter.tagDefineShape2(id, outline);++ writeShape(shape);++ return id;+ }+++ /**+ * Gets the rect attribute of the Shape object+ *+ *@return The rect value+ */+ protected Rect getRect() {+ double adjust = maxLineWidth / 2.0;++ Rect outline = new Rect((int) (minX * SWFConstants.TWIPS - adjust * SWFConstants.TWIPS),+ (int) (minY * SWFConstants.TWIPS - adjust * SWFConstants.TWIPS),+ (int) (maxX * SWFConstants.TWIPS + adjust * SWFConstants.TWIPS),+ (int) (maxY * SWFConstants.TWIPS + adjust * SWFConstants.TWIPS));++ return outline;+ }+++ /**+ * Description of the Method+ *+ *@param movie Description of the Parameter+ *@param timelineWriter Description of the Parameter+ *@param definitionWriter Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void predefineImageFills(Movie movie,+ SWFTagTypes timelineWriter,+ SWFTagTypes definitionWriter)+ throws IOException {+ //--Make sure any image fills are defined prior to the shape+ for (Iterator it = elements.iterator(); it.hasNext(); ) {+ Object el = it.next();++ if (el instanceof Shape.ImageFill) {+ Symbol image = ((Shape.ImageFill) el).getImage();++ if (image != null) {+ image.define(movie,+ timelineWriter,+ definitionWriter);+ }+ }+ }+ }+++ /**+ * Description of the Method+ *+ *@param shape Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void writeShape(SWFShape shape) throws IOException {+ for (Iterator it = elements.iterator(); it.hasNext(); ) {+ Object el = it.next();++ if (el instanceof Shape.ColorFill) {+ Shape.ColorFill fill = (Shape.ColorFill) el;+ shape.defineFillStyle(fill.getColor());+ } else if (el instanceof Shape.ImageFill) {+ Shape.ImageFill fill = (Shape.ImageFill) el;++ Symbol image = fill.getImage();+ int imgId = (image != null) ? image.getId() : 65535;++ shape.defineFillStyle(imgId, fill.getTransform(), fill.isClipped());+ } else if (el instanceof Shape.GradientFill) {+ Shape.GradientFill fill = (Shape.GradientFill) el;++ shape.defineFillStyle(fill.getTransform(),+ fill.getRatios(),+ fill.getColors(),+ fill.isRadial());+ } else if (el instanceof Shape.LineStyle) {+ Shape.LineStyle style = (Shape.LineStyle) el;++ shape.defineLineStyle((int) (style.getWidth() * SWFConstants.TWIPS),+ style.getColor());+ } else if (el instanceof Shape.SetLeftFillStyle) {+ Shape.SetLeftFillStyle style = (Shape.SetLeftFillStyle) el;+ shape.setFillStyle0(style.getStyleIndex());+ } else if (el instanceof Shape.SetRightFillStyle) {+ Shape.SetRightFillStyle style = (Shape.SetRightFillStyle) el;+ shape.setFillStyle1(style.getStyleIndex());+ } else if (el instanceof Shape.SetLineStyle) {+ Shape.SetLineStyle style = (Shape.SetLineStyle) el;+ shape.setLineStyle(style.getStyleIndex());+ } else {+ writeVector(shape, el);+ }+ }++ shape.done();+ }+++ /**+ * Description of the Method+ *+ *@param vecs Description of the Parameter+ *@param el Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void writeVector(SWFVectors vecs, Object el) throws IOException {+ if (el instanceof Shape.Move) {+ Shape.Move move = (Shape.Move) el;++ currx = move.getX() * SWFConstants.TWIPS;+ curry = move.getY() * SWFConstants.TWIPS;++ int x = (int) currx;+ int y = (int) curry;++ vecs.move(x, y);++ //System.out.println( "M: " + x + " " + y );+ } else if (el instanceof Shape.Line) {+ Shape.Line line = (Shape.Line) el;++ double xx = line.getX() * SWFConstants.TWIPS;+ double yy = line.getY() * SWFConstants.TWIPS;++ int dx = (int) (xx - currx);+ int dy = (int) (yy - curry);++ vecs.line(dx, dy);++ //System.out.println( "currx=" + currx + " curry=" + curry + " xx=" + xx + " yy=" + yy + " (xx - currx)=" + (xx - currx) + " (yy - curry)=" + (yy - curry) );+ //System.out.println( "L: " + dx + " " + dy );++ currx = xx;+ curry = yy;+ } else if (el instanceof Shape.Curve) {+ Shape.Curve curve = (Shape.Curve) el;++ double xx = curve.getX() * SWFConstants.TWIPS;+ double yy = curve.getY() * SWFConstants.TWIPS;+ double cxx = curve.getControlX() * SWFConstants.TWIPS;+ double cyy = curve.getControlY() * SWFConstants.TWIPS;++ int dx = (int) (xx - cxx);+ int dy = (int) (yy - cyy);+ int cx = (int) (cxx - currx);+ int cy = (int) (cyy - curry);++ vecs.curve(cx, cy, dx, dy);++ currx = xx;+ curry = yy;++ //System.out.println( "C: " + cx + " " + cy + " " + dx + " " + dy );+ }+ }+++ /**+ * Description of the Method+ *+ *@param vecs Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void writeGlyph(SWFVectors vecs) throws IOException {+ currx = 0.0;+ curry = 0.0;++ for (Iterator it = elements.iterator(); it.hasNext(); ) {+ writeVector(vecs, it.next());+ }++ vecs.done();+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SoundInfo.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SoundInfo.javanew file mode 100644index 000000000..a8814da6a--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SoundInfo.java@@ -0,0 +1,278 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * A Sound Information structure - defines playback style and envelope+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class SoundInfo {+ /**+ * A Point in a sound envelope+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ public static class EnvelopePoint {+ /**+ * Description of the Field+ */+ public int mark44;+ /**+ * Description of the Field+ */+ public int level0;+ /**+ * Description of the Field+ */+ public int level1;+++ /**+ * Constructor for the EnvelopePoint object+ *+ *@param mark44 Description of the Parameter+ *@param level0 Description of the Parameter+ *@param level1 Description of the Parameter+ */+ public EnvelopePoint(int mark44, int level0, int level1) {+ this.mark44 = mark44;+ this.level0 = level0;+ this.level1 = level1;+ }+ }+++ /**+ * Description of the Field+ */+ protected boolean noMultiplePlay;+ //only one instance can play at a time+ /**+ * Description of the Field+ */+ protected boolean stopPlaying;++ /**+ * Description of the Field+ */+ protected EnvelopePoint[] envelope;+ /**+ * Description of the Field+ */+ protected int inPoint;+ /**+ * Description of the Field+ */+ protected int outPoint;+ /**+ * Description of the Field+ */+ protected int loopCount;+++ /**+ *@param noMultiplePlay true = only play if not already playing+ *@param stopSound true = stop playing the sound+ *@param envelope may be null or empty for no envelope+ *@param inPoint -1 for no in-point+ *@param outPoint -1 for no out-point+ *@param loopCount >1 for a loop count+ */+ public SoundInfo(boolean noMultiplePlay, boolean stopSound,+ EnvelopePoint[] envelope,+ int inPoint, int outPoint, int loopCount) {+ this.noMultiplePlay = noMultiplePlay;+ this.stopPlaying = stopSound;+ this.envelope = envelope;+ this.inPoint = inPoint;+ this.outPoint = outPoint;+ this.loopCount = loopCount;+ }+++ /**+ * Gets the noMultiplePlay attribute of the SoundInfo object+ *+ *@return The noMultiplePlay value+ */+ public boolean isNoMultiplePlay() {+ return this.noMultiplePlay;+ }+++ /**+ * Gets the stopPlaying attribute of the SoundInfo object+ *+ *@return The stopPlaying value+ */+ public boolean isStopPlaying() {+ return this.stopPlaying;+ }+++ /**+ * Gets the envelope attribute of the SoundInfo object+ *+ *@return The envelope value+ */+ public EnvelopePoint[] getEnvelope() {+ return this.envelope;+ }+++ /**+ * Gets the inPoint attribute of the SoundInfo object+ *+ *@return The inPoint value+ */+ public int getInPoint() {+ return this.inPoint;+ }+++ /**+ * Gets the outPoint attribute of the SoundInfo object+ *+ *@return The outPoint value+ */+ public int getOutPoint() {+ return this.outPoint;+ }+++ /**+ * Gets the loopCount attribute of the SoundInfo object+ *+ *@return The loopCount value+ */+ public int getLoopCount() {+ return this.loopCount;+ }+++ /**+ * Constructor for the SoundInfo object+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public SoundInfo(InStream in) throws IOException {+ int flags = in.readUI8();++ noMultiplePlay = ((flags & 16) != 0);+ stopPlaying = ((flags & 32) != 0);+ boolean hasEnvelope = ((flags & 8) != 0);+ boolean hasLoops = ((flags & 4) != 0);+ boolean hasOutPoint = ((flags & 2) != 0);+ boolean hasInPoint = ((flags & 1) != 0);++ if (hasInPoint) {+ inPoint = (int) in.readUI32();+ } else {+ inPoint = -1;+ }++ if (hasOutPoint) {+ outPoint = (int) in.readUI32();+ } else {+ outPoint = -1;+ }++ if (hasLoops) {+ loopCount = in.readUI16();+ } else {+ loopCount = 1;+ }++ int envsize = 0;+ if (hasEnvelope) {+ envsize = in.readUI8();+ }++ envelope = new EnvelopePoint[envsize];++ for (int i = 0; i < envsize; i++) {+ envelope[i] = new EnvelopePoint((int) in.readUI32(),+ in.readUI16(),+ in.readUI16());+ }+ }+++ /**+ * Description of the Method+ *+ *@param out Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void write(OutStream out) throws IOException {+ int flags = 0;+ if (noMultiplePlay) {+ flags += 1;+ }+ if (stopPlaying) {+ flags += 2;+ }++ out.writeUBits(4, flags);++ boolean hasEnvelope = (envelope != null && envelope.length > 0);+ boolean hasLoops = (loopCount > 1);+ boolean hasOutPoint = (outPoint >= 0);+ boolean hasInPoint = (inPoint >= 0);++ flags = 0;+ if (hasEnvelope) {+ flags += 8;+ }+ if (hasLoops) {+ flags += 4;+ }+ if (hasOutPoint) {+ flags += 2;+ }+ if (hasInPoint) {+ flags += 1;+ }++ out.writeUBits(4, flags);++ if (hasInPoint) {+ out.writeUI32(inPoint);+ }+ if (hasOutPoint) {+ out.writeUI32(outPoint);+ }+ if (hasLoops) {+ out.writeUI16(loopCount);+ }++ if (hasEnvelope) {+ out.writeUI8(envelope.length);++ for (int i = 0; i < envelope.length; i++) {+ out.writeUI32(envelope[i].mark44);+ out.writeUI16(envelope[i].level0);+ out.writeUI16(envelope[i].level1);+ }+ }+ }+++ /**+ * Description of the Method+ *+ *@return Description of the Return Value+ */+ public String toString() {+ return "SoundInfo: no-multiplay=" + noMultiplePlay ++ " stop=" + stopPlaying ++ " envelope=" + ((envelope == null) ? "none" : ("" + envelope.length + " points")) ++ " in-point=" + inPoint ++ " out-point=" + outPoint ++ " loop-count=" + loopCount;+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Style.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Style.javanew file mode 100644index 000000000..74980b279--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Style.java@@ -0,0 +1,20 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * Common interface for Fill and Line Styles+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public interface Style {+ /**+ * Description of the Method+ *+ *@param out Description of the Parameter+ *@param hasAlpha Description of the Parameter+ *@exception IOException Description of the Exception+ */+ void write(OutStream out, boolean hasAlpha) throws IOException;+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Symbol.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Symbol.javanew file mode 100644index 000000000..56241c995--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Symbol.java@@ -0,0 +1,98 @@+package pt.tumba.parser.swf;++import java.io.IOException;++/**+ * Base class for all defined symbols+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public abstract class Symbol {+ /**+ * Description of the Field+ */+ protected int id = 0;+++ /**+ * Constructor for the Symbol object+ */+ protected Symbol() { }+++ /**+ * Constructor for the Symbol object+ *+ *@param id Description of the Parameter+ */+ protected Symbol(int id) {+ this.id = id;+ }+++ /**+ * Get the internal SWF id for the symbol. This will always be zero for a+ * Movie that was not loaded from an existing SWF until the Movie is+ * written out.+ *+ *@return The id value+ */+ public int getId() {+ return id;+ }+++ /**+ * Make sure that the Symbol is fully defined in the given Movie and return+ * the character id+ *+ *@param movie Description of the Parameter+ *@param timelineWriter Description of the Parameter+ *@param definitionWriter Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ protected int define(Movie movie,+ SWFTagTypes timelineWriter,+ SWFTagTypes definitionWriter)+ throws IOException {+ Integer integerId = (Integer) movie.definedSymbols.get(this);++ if (integerId == null) {+ integerId = new Integer(defineSymbol(movie,+ timelineWriter,+ definitionWriter));+ movie.definedSymbols.put(this, integerId);+ }++ id = integerId.intValue();+ return id;+ }+++ /**+ * Gets the nextId attribute of the Symbol object+ *+ *@param movie Description of the Parameter+ *@return The nextId value+ */+ protected int getNextId(Movie movie) {+ return movie.maxId++;+ }+++ /**+ * Override to provide symbol definition+ *+ *@param movie Description of the Parameter+ *@param timelineWriter Description of the Parameter+ *@param definitionwriter Description of the Parameter+ *@return the new symbol id+ *@exception IOException Description of the Exception+ */+ protected abstract int defineSymbol(Movie movie,+ SWFTagTypes timelineWriter,+ SWFTagTypes definitionwriter)+ throws IOException;+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TagParser.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TagParser.javanew file mode 100644index 000000000..f33a3e7bb--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TagParser.java@@ -0,0 +1,1423 @@+package pt.tumba.parser.swf;++import java.io.ByteArrayInputStream;+import java.io.FileInputStream;+import java.io.FileOutputStream;+import java.io.IOException;+import java.util.Enumeration;+import java.util.List;+import java.util.Vector;+import java.util.zip.InflaterInputStream;++/**+ * Parse Tags and drive a SWFTagTypes interface.+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class TagParser implements SWFTags, SWFConstants {+ /**+ * Description of the Field+ */+ protected SWFTagTypes tagtypes;+++ //protected byte[] contents; //for debugging++ /**+ * Constructor for the TagParser object+ *+ *@param tagtypes Description of the Parameter+ */+ public TagParser(SWFTagTypes tagtypes) {+ this.tagtypes = tagtypes;+ }+++ /**+ * Interface SWFTags+ *+ *@param version Description of the Parameter+ *@param length Description of the Parameter+ *@param twipsWidth Description of the Parameter+ *@param twipsHeight Description of the Parameter+ *@param frameRate Description of the Parameter+ *@param frameCount Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void header(int version, long length,+ int twipsWidth, int twipsHeight,+ int frameRate, int frameCount) throws IOException {+ tagtypes.header(version, length,+ twipsWidth, twipsHeight,+ frameRate, frameCount);+ }+++ /**+ * Interface SWFTags+ *+ *@param tagType Description of the Parameter+ *@param longTag Description of the Parameter+ *@param contents Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tag(int tagType, boolean longTag, byte[] contents)+ throws IOException {+ //this.contents = contents; //for debugging++ int length = (contents != null) ? contents.length : 0;++ InStream in = (length > 0) ? new InStream(contents) : null;++ switch (tagType) {+ case TAG_END:+ tagtypes.tagEnd();+ break;+ case TAG_SHOWFRAME:+ tagtypes.tagShowFrame();+ break;+ case TAG_DEFINESHAPE:+ case TAG_DEFINESHAPE2:+ case TAG_DEFINESHAPE3:+ parseDefineShape(tagType, in);+ break;+ case TAG_DOACTION:+ parseDoAction(in);+ break;+ case TAG_FREECHARACTER:+ tagtypes.tagFreeCharacter(in.readUI16());+ break;+ case TAG_PLACEOBJECT:+ parsePlaceObject(in, length);+ break;+ case TAG_PLACEOBJECT2:+ parsePlaceObject2(in);+ break;+ case TAG_REMOVEOBJECT:+ tagtypes.tagRemoveObject(in.readUI16(), in.readUI16());+ break;+ case TAG_REMOVEOBJECT2:+ tagtypes.tagRemoveObject2(in.readUI16());+ break;+ case TAG_SETBACKGROUNDCOLOR:+ tagtypes.tagSetBackgroundColor(new Color(in));+ break;+ case TAG_FRAMELABEL:+ tagtypes.tagFrameLabel(in.readString());+ break;+ case TAG_DEFINESPRITE:+ parseDefineSprite(in);+ break;+ case TAG_PROTECT:+ tagtypes.tagProtect((length > 0) ? in.read(length) : null);+ break;+ case TAG_ENABLEDEBUG:+ tagtypes.tagEnableDebug((length > 0) ? in.read(length) : null);+ break;+ case TAG_DEFINEFONT:+ parseDefineFont(in);+ break;+ case TAG_DEFINEFONTINFO:+ parseFontInfo(in, length);+ break;+ case TAG_DEFINEFONT2:+ parseDefineFont2(in);+ break;+ case TAG_DEFINETEXTFIELD:+ parseDefineTextField(in);+ break;+ case TAG_DEFINETEXT:+ case TAG_DEFINETEXT2:+ parseDefineText(tagType, in);+ break;+ case TAG_DEFINEBUTTON:+ parseDefineButton(in);+ break;+ case TAG_DEFINEBUTTON2:+ parseDefineButton2(in);+ break;+ case TAG_DEFINEBUTTONCXFORM:+ parseButtonCXForm(in);+ break;+ case TAG_EXPORT:+ parseExport(in);+ break;+ case TAG_IMPORT:+ parseImport(in);+ break;+ case TAG_DEFINEQUICKTIMEMOVIE:+ tagtypes.tagDefineQuickTimeMovie(in.readUI16(), in.readString());+ break;+ case TAG_DEFINEBITSJPEG2:+ parseDefineJPEG2(in, length);+ break;+ case TAG_DEFINEBITSLOSSLESS:+ parseDefineBitsLossless(in, length, false);+ break;+ case TAG_DEFINEBITSLOSSLESS2:+ parseDefineBitsLossless(in, length, true);+ break;+ case TAG_DEFINEMORPHSHAPE:+ parseMorphShape(in);+ break;+ case TAG_NAMECHARACTER:+ tagtypes.tagNameCharacter(contents);+ break;+ case TAG_GENERATOR_TEXT:+ tagtypes.tagGeneratorText(contents);+ break;+ case TAG_TEMPLATECOMMAND:+ tagtypes.tagGeneratorCommand(contents);+ break;+ case TAG_FLASHGENERATOR:+ tagtypes.tagGenerator(contents);+ break;+ case TAG_GEN_EXTERNAL_FONT:+ tagtypes.tagGeneratorFont(contents);+ break;+ case TAG_SERIALNUMBER:+ tagtypes.tagSerialNumber(in.readString());+ break;+ case TAG_DEFINESOUND:+ parseDefineSound(in);+ break;+ case TAG_STARTSOUND:+ parseStartSound(in);+ break;+ case TAG_DEFINEBUTTONSOUND:+ parseDefineButtonSound(in);+ break;+ case TAG_SOUNDSTREAMHEAD:+ parseSoundStreamHead(true, in);+ break;+ case TAG_SOUNDSTREAMHEAD2:+ parseSoundStreamHead(false, in);+ break;+ case TAG_SOUNDSTREAMBLOCK:+ parseSoundStreamBlock(in);+ break;+ case TAG_DEFINEBITS:+ parseDefineBits(in);+ break;+ case TAG_JPEGTABLES:+ parseDefineJPEGTables(in);+ break;+ case TAG_DEFINEBITSJPEG3:+ parseDefineBitsJPEG3(in);+ break;+ default:+ //--Unknown Tag Type+ tagtypes.tag(tagType, longTag, contents);+ break;+ }+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseDefineSound(InStream in) throws IOException {+ int id = in.readUI16();+ int format = (int) in.readUBits(4);+ int frequency = (int) in.readUBits(2);+ boolean bits16 = in.readUBits(1) != 0;+ boolean stereo = in.readUBits(1) != 0;+ int sampleCount = (int) in.readUI32();++ byte[] soundData = in.read();++ tagtypes.tagDefineSound(id, format, frequency, bits16, stereo,+ sampleCount, soundData);+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseStartSound(InStream in) throws IOException {+ int id = in.readUI16();+ SoundInfo info = new SoundInfo(in);++ tagtypes.tagStartSound(id, info);+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseDefineButtonSound(InStream in) throws IOException {+ int id = in.readUI16();++ int rollOverSoundId = in.readUI16();+ SoundInfo rollOverSoundInfo = (rollOverSoundId == 0) ? null : new SoundInfo(in);++ int rollOutSoundId = in.readUI16();+ SoundInfo rollOutSoundInfo = (rollOutSoundId == 0) ? null : new SoundInfo(in);++ int pressSoundId = in.readUI16();+ SoundInfo pressSoundInfo = (pressSoundId == 0) ? null : new SoundInfo(in);++ int releaseSoundId = in.readUI16();+ SoundInfo releaseSoundInfo = (releaseSoundId == 0) ? null : new SoundInfo(in);++ tagtypes.tagDefineButtonSound(id,+ rollOverSoundId, rollOverSoundInfo,+ rollOutSoundId, rollOutSoundInfo,+ pressSoundId, pressSoundInfo,+ releaseSoundId, releaseSoundInfo);++ }+++ /**+ * Description of the Method+ *+ *@param adpcmOnly Description of the Parameter+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseSoundStreamHead(boolean adpcmOnly, InStream in) throws IOException {+ //int reserved = (int) in.readUBits(4);+ int playbackFreq = (int) in.readUBits(2);+ boolean playback16bits = (in.readUBits(1) != 0);+ boolean playbackStereo = (in.readUBits(1) != 0);++ int format = (int) in.readUBits(4);+ int streamFreq = (int) in.readUBits(2);+ boolean stream16bits = (in.readUBits(1) != 0);+ boolean streamStereo = (in.readUBits(1) != 0);+ int avgSampleCount = (int) in.readUI16();++ //--MP3 Streams sometimes have an extra word here...+ //if( format == SWFConstants.SOUND_FORMAT_MP3 )+ //{+ // int unknown = in.readUI16();+ //}+ //--but other SDK's don't know about this so we can't assume it+ // will always be present in a SWF.++ if (adpcmOnly) {+ tagtypes.tagSoundStreamHead(playbackFreq, playback16bits, playbackStereo,+ format, streamFreq, stream16bits, streamStereo,+ avgSampleCount);+ } else {+ tagtypes.tagSoundStreamHead2(playbackFreq, playback16bits, playbackStereo,+ format, streamFreq, stream16bits, streamStereo,+ avgSampleCount);+ }+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseSoundStreamBlock(InStream in) throws IOException {+ tagtypes.tagSoundStreamBlock(in.read());+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseDefineBits(InStream in) throws IOException {+ tagtypes.tagDefineBits(in.readUI16(), in.read());+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseDefineJPEGTables(InStream in) throws IOException {+ tagtypes.tagJPEGTables(in.read());+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseDefineBitsJPEG3(InStream in) throws IOException {+ int id = in.readUI16();+ int size = (int) in.readUI32();++ byte[] imageData = in.read(size);+ byte[] alphaData = in.read();++ tagtypes.tagDefineBitsJPEG3(id, imageData, alphaData);+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseMorphShape(InStream in) throws IOException {+ int id = in.readUI16();++ Rect startBounds = new Rect(in);+ Rect endBounds = new Rect(in);++ //int edgeOffset = (int) in.readUI32();++ SWFShape shape = tagtypes.tagDefineMorphShape(id, startBounds, endBounds);++ if (shape == null) {+ return;+ }++ //--Read the Fill Styles+ int fillCount = in.readUI8();+ if (fillCount == 0xff) {+ fillCount = in.readUI16();+ }++ for (int i = 0; i < fillCount; i++) {+ parseMorphFillStyle(in, shape);+ }++ //--Read the Line Styles+ int lineCount = in.readUI8();+ if (lineCount == 0xff) {+ lineCount = in.readUI16();+ }++ for (int i = 0; i < lineCount; i++) {+ parseMorphLineStyle(in, shape);+ }++ //--read the start shape+ parseShape(in, shape, false, true);++ //--read the end shape+ parseShape(in, shape, false, true);+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@param shape Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseMorphLineStyle(InStream in, SWFShape shape) throws IOException {+ int startWidth = in.readUI16();+ int endWidth = in.readUI16();++ AlphaColor startColor = new AlphaColor(in);+ AlphaColor endColor = new AlphaColor(in);++ shape.defineLineStyle(startWidth, startColor);+ shape.defineLineStyle(endWidth, endColor);+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@param shape Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseMorphFillStyle(InStream in, SWFShape shape) throws IOException {+ int fillType = in.readUI8();++ if (fillType == FILL_SOLID) {+ AlphaColor startColor = new AlphaColor(in);+ AlphaColor endColor = new AlphaColor(in);++ shape.defineFillStyle(startColor);+ shape.defineFillStyle(endColor);+ } else if (fillType == FILL_LINEAR_GRADIENT+ || fillType == FILL_RADIAL_GRADIENT) {+ Matrix startMatrix = new Matrix(in);+ Matrix endMatrix = new Matrix(in);++ int numRatios = in.readUI8();++ int[] startRatios = new int[numRatios];+ AlphaColor[] startColors = new AlphaColor[numRatios];++ int[] endRatios = new int[numRatios];+ AlphaColor[] endColors = new AlphaColor[numRatios];++ for (int i = 0; i < numRatios; i++) {+ startRatios[i] = in.readUI8();+ startColors[i] = new AlphaColor(in);+ endRatios[i] = in.readUI8();+ endColors[i] = new AlphaColor(in);+ }++ shape.defineFillStyle(startMatrix, startRatios, startColors,+ fillType == FILL_RADIAL_GRADIENT);++ shape.defineFillStyle(endMatrix, endRatios, endColors,+ fillType == FILL_RADIAL_GRADIENT);+ } else if (fillType == FILL_TILED_BITMAP+ || fillType == FILL_CLIPPED_BITMAP) {+ int bitmapId = in.readUI16();+ Matrix startMatrix = new Matrix(in);+ Matrix endMatrix = new Matrix(in);++ shape.defineFillStyle(bitmapId, startMatrix,+ fillType == FILL_CLIPPED_BITMAP);++ shape.defineFillStyle(bitmapId, endMatrix,+ fillType == FILL_CLIPPED_BITMAP);+ }+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@param length Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseDefineJPEG2(InStream in, int length) throws IOException {+ int id = in.readUI16();++ //--read the image data+ byte[] image = in.read(length - 2);++ tagtypes.tagDefineBitsJPEG2(id, image);+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@param length Description of the Parameter+ *@param hasAlpha Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseDefineBitsLossless(InStream in, int length,+ boolean hasAlpha)+ throws IOException {+ int id = in.readUI16();+ int format = in.readUI8();+ int width = in.readUI16();+ int height = in.readUI16();++ int size = 0;++ switch (format) {+ case BITMAP_FORMAT_8_BIT:+ size = in.readUI8() + 1;+ break;+ case BITMAP_FORMAT_16_BIT:+ size = in.readUI16() + 1;+ break;+ case BITMAP_FORMAT_32_BIT:+ size = 0;+ break;+ default:+ throw new IOException("unknown bitmap format: " + format);+ }++ byte[] data = in.read(length - (int) in.getBytesRead());++ //--unzip the data+ ByteArrayInputStream bin = new ByteArrayInputStream(data);+ InflaterInputStream inflater = new InflaterInputStream(bin);+ InStream dataIn = new InStream(inflater);++ Color[] colors = hasAlpha ? new AlphaColor[size] : new Color[size];++ for (int i = 0; i < size; i++) {+ colors[i] = hasAlpha ? new AlphaColor(dataIn) : new Color(dataIn);+ }++ byte[] imageData = dataIn.read();++ if (hasAlpha) {+ tagtypes.tagDefineBitsLossless2(id, format, width, height,+ (AlphaColor[]) colors, imageData);+ } else {+ tagtypes.tagDefineBitsLossless(id, format, width, height, colors, imageData);+ }+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseExport(InStream in) throws IOException {+ int count = in.readUI16();++ String[] exportNames = new String[count];+ int[] exportIds = new int[count];++ for (int i = 0; i < count; i++) {+ exportIds[i] = in.readUI16();+ exportNames[i] = in.readString();+ }++ tagtypes.tagExport(exportNames, exportIds);+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseImport(InStream in) throws IOException {+ String movieName = in.readString();+ int count = in.readUI16();++ String[] importNames = new String[count];+ int[] importIds = new int[count];++ for (int i = 0; i < count; i++) {+ importIds[i] = in.readUI16();+ importNames[i] = in.readString();+ }++ tagtypes.tagImport(movieName, importNames, importIds);+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseDefineButton2(InStream in) throws IOException {+ int id = in.readUI16();++ boolean trackAsMenu = (in.readUI8() != 0);++ int actionOffset = in.readUI16();+ //skip first offset++ //--Read multiple button records+ List buttonRecords = ButtonRecord2.read(in);++ SWFActions actions = tagtypes.tagDefineButton2(id, trackAsMenu, buttonRecords);++ if (actions == null) {+ return;+ }++ //--Read multiple action records+ while (actionOffset != 0) {+ actionOffset = in.readUI16();++ //--Read the condition flags for this action array+ int actionConditions = in.readUI16();++ actions.start(actionConditions);++ ActionParser parser = new ActionParser(actions);+ parser.parse(in);+ }++ actions.done();+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseButtonCXForm(InStream in) throws IOException {+ int buttonId = in.readUI16();+ ColorTransform transform = new ColorTransform(in);++ tagtypes.tagButtonCXForm(buttonId, transform);+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseDefineButton(InStream in) throws IOException {+ int id = in.readUI16();+ List buttonRecords = ButtonRecord.read(in);++ SWFActions actions = tagtypes.tagDefineButton(id, buttonRecords);++ if (actions == null) {+ return;+ }++ actions.start(0);+ //no conditions+ ActionParser parser = new ActionParser(actions);+ parser.parse(in);+ actions.done();+ }+++ /**+ * Description of the Method+ *+ *@param type Description of the Parameter+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseDefineText(int type, InStream in) throws IOException {+ int id = in.readUI16();+ Rect bounds = new Rect(in);+ Matrix matrix = new Matrix(in);++ SWFText text = (type == TAG_DEFINETEXT) ?+ tagtypes.tagDefineText(id, bounds, matrix) :+ tagtypes.tagDefineText2(id, bounds, matrix);++ if (text == null) {+ return;+ }++ int glyphBits = in.readUI8();+ int advanceBits = in.readUI8();++ //--Read multiple text records+ int firstByte;++ while ((firstByte = in.readUI8()) != 0) {+ if ((firstByte & 0x80) == 0) {+ //Glyph Record++ //--Get number of glyph entries+ int glyphCount = firstByte & 0x7f;++ int[] glyphs = new int[glyphCount];+ int[] advances = new int[glyphCount];++ //--Read the glyph entries+ for (int i = 0; i < glyphCount; i++) {+ glyphs[i] = (int) in.readUBits(glyphBits);+ advances[i] = in.readSBits(advanceBits);+ }++ text.text(glyphs, advances);+ } else {+ //Style Record++ int flags = firstByte;++ int fontId = 0;++ if ((flags & TEXT_HAS_FONT) != 0) {+ fontId = in.readUI16();+ }++ if ((flags & TEXT_HAS_COLOR) != 0) {+ text.color((type == TAG_DEFINETEXT2) ?+ new AlphaColor(in) :+ new Color(in));+ }++ if ((flags & TEXT_HAS_XOFFSET) != 0) {+ text.setX(in.readSI16());+ }++ if ((flags & TEXT_HAS_YOFFSET) != 0) {+ //x & y are in reverse order from flag bits++ text.setY(in.readSI16());+ }++ if ((flags & TEXT_HAS_FONT) != 0) {+ int textHeight = in.readUI16();++ text.font(fontId, textHeight);+ }+ }+ }++ text.done();+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseDefineTextField(InStream in) throws IOException {+ int id = in.readUI16();++ Rect boundary = new Rect(in);++ int flags = in.readUI16();+ int fontId = in.readUI16();+ int fontSize = in.readUI16();+ AlphaColor textColor = new AlphaColor(in);++ int charLimit = ((flags & TEXTFIELD_LIMIT_CHARS) != 0) ? in.readUI16() : 0;++ int alignment = in.readUI8();+ int leftMargin = in.readUI16();+ int rightMargin = in.readUI16();+ int indentation = in.readUI16();+ int lineSpacing = in.readUI16();++ String fieldName = in.readString();+ String initialText = ((flags & TEXTFIELD_HAS_TEXT) != 0) ? in.readString() : null;++ tagtypes.tagDefineTextField(id, fieldName, initialText, boundary, flags,+ textColor, alignment, fontId, fontSize,+ charLimit, leftMargin, rightMargin,+ indentation, lineSpacing);+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseDefineFont2(InStream in) throws IOException {+ int id = in.readUI16();+ int flags = in.readUI8();+ int reservedFlags = in.readUI8(); // LANGUAGECODE, spec: SWF 5 or earlier: always 0; SWF 6 or later: language code++ int nameLength = in.readUI8();+ String name = new String(in.read(nameLength));++ int glyphCount = in.readUI16();+ Vector glyphs = new Vector();++ int[] offsets = new int[glyphCount + 1];+ boolean is32 = (flags & FONT2_32OFFSETS) != 0;+ for (int i = 0; i <= glyphCount; i++) {+ offsets[i] = is32 ? (int) in.readUI32() : in.readUI16();+ }++ for (int i = 1; i <= glyphCount; i++) {+ int glyphSize = offsets[i] - offsets[i - 1];+ byte[] glyphBytes = in.read(glyphSize);+ glyphs.addElement(glyphBytes);+ }++ boolean isWide = ((flags & FONT2_WIDECHARS) != 0) || (glyphCount > 256);++ int[] codes = new int[glyphCount];+ for (int i = 0; i < glyphCount; i++) {+ codes[i] = isWide ? in.readUI16() : in.readUI8();+ }++ int ascent = 0;+ int descent = 0;+ int leading = 0;+ int[] advances = null;+ Rect[] bounds = null;+ int[] kerningCodes1 = null;+ int[] kerningCodes2 = null;+ int[] kerningAdjustments = null;++ if ((flags & FONT2_HAS_LAYOUT) != 0) {+ ascent = in.readSI16();+ descent = in.readSI16();+ leading = in.readSI16();++ advances = new int[glyphCount];++ for (int i = 0; i < glyphCount; i++) {+ advances[i] = in.readSI16();+ }++ bounds = new Rect[glyphCount];++ for (int i = 0; i < glyphCount; i++) {+ bounds[i] = new Rect(in);+ }++ int kerningCount = in.readUI16();++ kerningCodes1 = new int[kerningCount];+ kerningCodes2 = new int[kerningCount];+ kerningAdjustments = new int[kerningCount];++ for (int i = 0; i < kerningCount; i++) {+ kerningCodes1[i] = isWide ? in.readUI16() : in.readUI8();+ kerningCodes2[i] = isWide ? in.readUI16() : in.readUI8();+ kerningAdjustments[i] = in.readSI16();+ }+ }++ SWFVectors vectors = tagtypes.tagDefineFont2(id, flags, name, glyphCount,+ ascent, descent, leading,+ codes, advances, bounds,+ kerningCodes1,+ kerningCodes2,+ kerningAdjustments);++ if (vectors == null) {+ return;+ }++ if (glyphs.isEmpty()) {+ vectors.done();+ } else {+ for (Enumeration enumerator = glyphs.elements(); enumerator.hasMoreElements(); ) {+ byte[] glyphBytes = (byte[]) enumerator.nextElement();++ InStream glyphIn = new InStream(glyphBytes);++ parseShape(glyphIn, vectors, false, false);+ }+ }+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@param length Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseFontInfo(InStream in, int length2) throws IOException {+ int fontId = in.readUI16();+ int length = length2;+ //--Read the font name+ int nameLength = in.readUI8();+ byte[] chars = in.read(nameLength);+ String fontName = new String(chars);++ //--Read the font flags+ int flags = in.readUI8();++ //--Adjust the body length+ length -= 4 + nameLength;++ //--Read the Glyph-to-code table+ boolean wide = (flags & FONT_WIDECHARS) != 0;++ int[] codes = new int[wide ? (length / 2) : length];++ for (int i = 0; i < codes.length; i++) {+ codes[i] = wide ? in.readUI16() : in.readUI8();+ }++ tagtypes.tagDefineFontInfo(fontId, fontName, flags, codes);+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseDefineFont(InStream in) throws IOException {+ int id = in.readUI16();+ int firstOffset = in.readUI16();+ int numGlyphs = firstOffset / 2;++ SWFVectors vectors = tagtypes.tagDefineFont(id, numGlyphs);++ if (vectors == null) {+ return;+ }++ //--Skip the offset table+ for (int i = 1; i < numGlyphs; i++) {+ in.readUI16();+ }++ for (int i = 0; i < numGlyphs; i++) {+ parseShape(in, vectors, false, false);+ }+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseDefineSprite(InStream in) throws IOException {+ int id = in.readUI16();+ //int frameCount = in.readUI16();++ SWFTagTypes sstt = tagtypes.tagDefineSprite(id);++ if (sstt == null) {+ return;+ }++ TagParser parser = new TagParser(sstt);+ SWFReader reader = new SWFReader(parser, in);+ reader.readTags();+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parsePlaceObject2(InStream in) throws IOException {+ boolean hasClipActions = in.readUBits(1) != 0;+ boolean isClipBracket = in.readUBits(1) != 0;+ boolean hasName = in.readUBits(1) != 0;+ boolean hasRatio = in.readUBits(1) != 0;+ boolean hasColorTransform = in.readUBits(1) != 0;+ boolean hasMatrix = in.readUBits(1) != 0;+ boolean hasCharacter = in.readUBits(1) != 0;+ boolean isMove = in.readUBits(1) != 0;++ int depth = in.readUI16();++ int charId = hasCharacter ? in.readUI16() : 0;+ Matrix matrix = hasMatrix ? new Matrix(in) : null;+ AlphaTransform cxform = hasColorTransform ? new AlphaTransform(in) : null;+ int ratio = hasRatio ? in.readUI16() : -1;+ int clipDepth = isClipBracket ? in.readUI16() : 0;+ String name = hasName ? in.readString() : null;++ int clipActionFlags = 0;++ if (hasClipActions) {+ in.readUI16();+ //unknown+ clipActionFlags = in.readUI16();+ //compound flags+ }++ SWFActions actions = tagtypes.tagPlaceObject2(+ isMove, clipDepth, depth, charId,+ matrix, cxform, ratio, name,+ clipActionFlags);++ if (hasClipActions && actions != null) {+ int flags = 0;++ while ((flags = in.readUI16()) != 0) {+ //int length = (int) in.readUI32();++ actions.start(flags);+ ActionParser parser = new ActionParser(actions);++ parser.parse(in);+ }++ actions.done();+ }+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@param length Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parsePlaceObject(InStream in, int length) throws IOException {+ tagtypes.tagPlaceObject(+ in.readUI16(),+ //char id+ in.readUI16(),+ //depth+ new Matrix(in),+ (in.getBytesRead() < length) ? new AlphaTransform(in) : null);+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseDoAction(InStream in) throws IOException {+ SWFActions actions = tagtypes.tagDoAction();++ if (actions == null) {+ return;+ }++ actions.start(0);+ //no conditions+ ActionParser parser = new ActionParser(actions);+ parser.parse(in);+ actions.done();+ }+++ /**+ * Description of the Method+ *+ *@param type Description of the Parameter+ *@param in Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseDefineShape(int type, InStream in) throws IOException {+ int id = in.readUI16();+ Rect rect = new Rect(in);++ SWFShape shape = null;++ switch (type) {+ case TAG_DEFINESHAPE:+ shape = tagtypes.tagDefineShape(id, rect);+ break;+ case TAG_DEFINESHAPE2:+ shape = tagtypes.tagDefineShape2(id, rect);+ break;+ case TAG_DEFINESHAPE3:+ shape = tagtypes.tagDefineShape3(id, rect);+ break;+ default:+ break;+ }++ if (shape == null) {+ return;+ }++ parseShape(in, shape,+ true+ /*+ * has style+ */+ ,+ type == TAG_DEFINESHAPE3+ /*+ * has alpha+ */+ );+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@param vectors Description of the Parameter+ *@param hasStyle Description of the Parameter+ *@param hasAlpha Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseShape(InStream in, SWFVectors vectors,+ boolean hasStyle, boolean hasAlpha)+ throws IOException {+ SWFShape shape = (vectors instanceof SWFShape) ?+ (SWFShape) vectors :+ null;++ in.synchBits();++ if (hasStyle) {+ parseStyles(in, shape, hasAlpha);+ }++ in.synchBits();++ int[] numFillBits = new int[]{(int) in.readUBits(4)};+ int[] numLineBits = new int[]{(int) in.readUBits(4)};++ //--Read the shape records+ while (true) {+ int type = (int) in.readUBits(1);++ if (type == 1) {+ // Edge shape-record++ boolean isCurved = in.readUBits(1) == 0L;++ if (isCurved) {+ //curve++ int numBits = ((int) in.readUBits(4)) + 2;++ int cx = in.readSBits(numBits);+ int cy = in.readSBits(numBits);+ int dx = in.readSBits(numBits);+ int dy = in.readSBits(numBits);++ vectors.curve(cx, cy, dx, dy);+ } else {+ //line++ int numBits = ((int) in.readUBits(4)) + 2;++ boolean generalLine = in.readUBits(1) == 1;++ int dx = 0;+ int dy = 0;++ if (generalLine) {+ dx = in.readSBits(numBits);+ dy = in.readSBits(numBits);+ } else {+ // a non-general line++ boolean vertLine = in.readUBits(1) == 1;++ if (vertLine) {+ dy = in.readSBits(numBits);+ } else {+ //horizontal line++ dx = in.readSBits(numBits);+ }+ }++ vectors.line(dx, dy);+ }+ } else {+ //End of records or Change Record++ int flags = (int) in.readUBits(5);++ if (flags == 0) {+ break;+ }+ //end of records++ parseChangeRecord(in, flags, vectors, shape, hasAlpha,+ numFillBits, numLineBits);+ }+ }++ vectors.done();+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@param flags Description of the Parameter+ *@param vectors Description of the Parameter+ *@param shape Description of the Parameter+ *@param hasAlpha Description of the Parameter+ *@param numFillBits Description of the Parameter+ *@param numLineBits Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseChangeRecord(InStream in, int flags, SWFVectors vectors,+ SWFShape shape, boolean hasAlpha,+ int[] numFillBits2, int[] numLineBits2)+ throws IOException {+ int numFillBits[] = numFillBits2;+ int numLineBits[] = numLineBits2;+ //System.out.println( "In Change --> " + Integer.toBinaryString( flags ));++ boolean hasNewStyles = (flags & 0x10) != 0;+ boolean hasLineStyle = (flags & 0x08) != 0;+ boolean hasFillStyle1 = (flags & 0x04) != 0;+ //note reverse order+ boolean hasFillStyle0 = (flags & 0x02) != 0;+ //note reverse order+ boolean hasMoveTo = (flags & 0x01) != 0;++ if (hasMoveTo) {+ int moveBits = (int) in.readUBits(5);+ int moveX = in.readSBits(moveBits);+ int moveY = in.readSBits(moveBits);++ //System.out.println( "X=" + moveX + ", Y=" + moveY );++ vectors.move(moveX, moveY);+ }++ if (hasFillStyle0) {+ int fillStyle0 = (int) in.readUBits(numFillBits[0]);++ //System.out.println( "fill0=" + fillStyle0 );++ if (shape != null) {+ shape.setFillStyle0(fillStyle0);+ }+ }++ if (hasFillStyle1) {+ int fillStyle1 = (int) in.readUBits(numFillBits[0]);++ //System.out.println( "fill1=" + fillStyle1 );++ if (shape != null) {+ shape.setFillStyle1(fillStyle1);+ }+ }++ if (hasLineStyle) {+ int lineStyle = (int) in.readUBits(numLineBits[0]);++ //System.out.println( "line=" + lineStyle );++ if (shape != null) {+ shape.setLineStyle(lineStyle);+ }+ }++ if (hasNewStyles) {+ parseStyles(in, shape, hasAlpha);++ numFillBits[0] = (int) in.readUBits(4);+ numLineBits[0] = (int) in.readUBits(4);+ }+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@param shape Description of the Parameter+ *@param hasAlpha Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void parseStyles(InStream in, SWFShape shape, boolean hasAlpha)+ throws IOException {+ int numFillStyles = in.readUI8();+ if (numFillStyles == 0xff) {+ //larger number format++ numFillStyles = in.readUI16();+ }++ for (int i = 0; i < numFillStyles; i++) {+ parseFillStyle(in, shape, hasAlpha);+ }++ int numLineStyles = in.readUI8();+ if (numLineStyles == 0xff) {+ //larger number format++ numLineStyles = in.readUI16();+ }++ for (int i = 0; i < numLineStyles; i++) {+ parseLineStyle(in, shape, hasAlpha);+ }+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@param shape Description of the Parameter+ *@param hasAlpha Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void parseLineStyle(InStream in, SWFShape shape, boolean hasAlpha)+ throws IOException {+ int width = in.readUI16();+ Color color = hasAlpha ? new AlphaColor(in) : new Color(in);++ if (shape != null) {+ shape.defineLineStyle(width, color);+ }+ }+++ /**+ * Description of the Method+ *+ *@param in Description of the Parameter+ *@param shape Description of the Parameter+ *@param hasAlpha Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void parseFillStyle(InStream in, SWFShape shape, boolean hasAlpha)+ throws IOException {+ int fillType = in.readUI8();++ if (fillType == FILL_SOLID) {+ Color color = hasAlpha ? new AlphaColor(in) : new Color(in);++ if (shape != null) {+ shape.defineFillStyle(color);+ }+ } else if (fillType == FILL_LINEAR_GRADIENT+ || fillType == FILL_RADIAL_GRADIENT) {+ Matrix matrix = new Matrix(in);++ int numRatios = in.readUI8();++ int[] ratios = new int[numRatios];+ Color[] colors = new Color[numRatios];++ for (int i = 0; i < numRatios; i++) {+ ratios[i] = in.readUI8();+ colors[i] = hasAlpha ? new AlphaColor(in) : new Color(in);+ }++ if (shape != null) {+ shape.defineFillStyle(matrix, ratios, colors,+ fillType == FILL_RADIAL_GRADIENT);+ }+ } else if (fillType == FILL_TILED_BITMAP+ || fillType == FILL_CLIPPED_BITMAP) {+ int bitmapId = in.readUI16();+ Matrix matrix = new Matrix(in);++ if (shape != null) {+ shape.defineFillStyle(bitmapId, matrix,+ fillType == FILL_CLIPPED_BITMAP);+ }+ }+ }+++ /**+ * The main program for the TagParser class+ *+ *@param args The command line arguments+ *@exception IOException Description of the Exception+ */+ public static void main(String[] args) throws IOException {+ FileInputStream in = new FileInputStream(args[0]);+ FileOutputStream out = new FileOutputStream(args[1]);++ SWFWriter writer = new SWFWriter(out);+ TagWriter tagwtr = new TagWriter(writer);++ TagParser parser = new TagParser(tagwtr);+ SWFReader reader = new SWFReader(parser, in);++ reader.readFile();+ out.flush();+ out.close();+ in.close();+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TagWriter.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TagWriter.javanew file mode 100644index 000000000..d4bfe14b6--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TagWriter.java@@ -0,0 +1,2586 @@+package pt.tumba.parser.swf;++import java.io.ByteArrayOutputStream;+import java.io.IOException;+import java.io.InputStream;+import java.util.Iterator;+import java.util.List;+import java.util.Vector;+import java.util.zip.DeflaterOutputStream;++/**+ * A writer that implements the SWFTagTypes interface and writes to a SWFTags+ * interface+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class TagWriter implements SWFTagTypes, SWFConstants {+ /**+ * Description of the Field+ */+ protected SWFTags tags;++ /**+ * Description of the Field+ */+ protected OutStream out;+ /**+ * Description of the Field+ */+ protected ByteArrayOutputStream bytes;+ /**+ * Description of the Field+ */+ protected int tagType;+ /**+ * Description of the Field+ */+ protected boolean longTag;+ /**+ * Description of the Field+ */+ protected int version;+++ /**+ * Constructor for the TagWriter object+ *+ *@param tags Description of the Parameter+ */+ public TagWriter(SWFTags tags) {+ this.tags = tags;+ }+++ /**+ * Gets the outStream attribute of the TagWriter object+ *+ *@return The outStream value+ */+ protected OutStream getOutStream() {+ return out;+ }+++ /**+ * Description of the Method+ *+ *@return Description of the Return Value+ */+ protected SWFActions factorySWFActions() {+ return new ActionWriter(this, version);+ }+++ /**+ * Description of the Method+ *+ *@param hasAlpha Description of the Parameter+ *@param hasStyle Description of the Parameter+ *@return Description of the Return Value+ */+ protected SWFShape factorySWFShape(boolean hasAlpha, boolean hasStyle) {+ return new SWFShapeImpl(this, hasAlpha, hasStyle);+ }+++ /**+ * Start a new tag context+ *+ *@param tagType Description of the Parameter+ *@param longTag Description of the Parameter+ */+ protected void startTag(int tagType, boolean longTag) {+ this.tagType = tagType;+ this.longTag = longTag;++ bytes = new ByteArrayOutputStream(10000);+ out = new OutStream(bytes);+ }+++ /**+ * Start a new definition tag context+ *+ *@param tagType Description of the Parameter+ *@param id Description of the Parameter+ *@param longTag Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void startTag(int tagType, int id, boolean longTag)+ throws IOException {+ startTag(tagType, longTag);+ out.writeUI16(id);+ }+++ /**+ * Finish the tag context and write the tag+ *+ *@exception IOException Description of the Exception+ */+ protected void completeTag() throws IOException {+ out.flush();+ byte[] contents = bytes.toByteArray();++ out = null;+ bytes = null;++ tags.tag(tagType, longTag, contents);+ }+++ /**+ * SWFTags interface+ *+ *@param tagType Description of the Parameter+ *@param longTag Description of the Parameter+ *@param contents Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tag(int tagType, boolean longTag, byte[] contents)+ throws IOException {+ tags.tag(tagType, longTag, contents);+ }+++ /**+ * SWFHeader interface. Sets movie length to -1 to force a recalculation+ * since the length cannot be guaranteed to be the same as the original.+ *+ *@param version Description of the Parameter+ *@param length Description of the Parameter+ *@param twipsWidth Description of the Parameter+ *@param twipsHeight Description of the Parameter+ *@param frameRate Description of the Parameter+ *@param frameCount Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void header(int version, long length,+ int twipsWidth, int twipsHeight,+ int frameRate, int frameCount) throws IOException {+ this.version = version;+ tags.header(version, -1, twipsWidth, twipsHeight, frameRate, frameCount);+ }+++ /**+ * SWFTagTypes interface+ *+ *@exception IOException Description of the Exception+ */+ public void tagEnd() throws IOException {+ tags.tag(TAG_END, false, null);+ }+++ /**+ * SWFTagTypes interface+ *+ *@exception IOException Description of the Exception+ */+ public void tagShowFrame() throws IOException {+ tags.tag(TAG_SHOWFRAME, false, null);+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param format Description of the Parameter+ *@param frequency Description of the Parameter+ *@param bits16 Description of the Parameter+ *@param stereo Description of the Parameter+ *@param sampleCount Description of the Parameter+ *@param soundData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineSound(int id, int format, int frequency,+ boolean bits16, boolean stereo,+ int sampleCount, byte[] soundData)+ throws IOException {+ startTag(TAG_DEFINESOUND, id, true);+ out.writeUBits(4, format);+ out.writeUBits(2, frequency);+ out.writeUBits(1, bits16 ? 1 : 0);+ out.writeUBits(1, stereo ? 1 : 0);+ out.writeUI32(sampleCount);+ out.write(soundData);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param buttonId Description of the Parameter+ *@param rollOverSoundId Description of the Parameter+ *@param rollOverSoundInfo Description of the Parameter+ *@param rollOutSoundId Description of the Parameter+ *@param rollOutSoundInfo Description of the Parameter+ *@param pressSoundId Description of the Parameter+ *@param pressSoundInfo Description of the Parameter+ *@param releaseSoundId Description of the Parameter+ *@param releaseSoundInfo Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineButtonSound(int buttonId,+ int rollOverSoundId, SoundInfo rollOverSoundInfo,+ int rollOutSoundId, SoundInfo rollOutSoundInfo,+ int pressSoundId, SoundInfo pressSoundInfo,+ int releaseSoundId, SoundInfo releaseSoundInfo)+ throws IOException {+ startTag(TAG_DEFINEBUTTONSOUND, buttonId, true);++ out.writeUI16(rollOverSoundId);+ if (rollOverSoundId != 0) {+ rollOverSoundInfo.write(out);+ }++ out.writeUI16(rollOutSoundId);+ if (rollOutSoundId != 0) {+ rollOutSoundInfo.write(out);+ }++ out.writeUI16(pressSoundId);+ if (pressSoundId != 0) {+ pressSoundInfo.write(out);+ }+ out.writeUI16(releaseSoundId);+ if (releaseSoundId != 0) {+ releaseSoundInfo.write(out);+ }++ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param soundId Description of the Parameter+ *@param info Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagStartSound(int soundId, SoundInfo info) throws IOException {+ startTag(TAG_STARTSOUND, soundId, false);+ info.write(out);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param playbackFrequency Description of the Parameter+ *@param playback16bit Description of the Parameter+ *@param playbackStereo Description of the Parameter+ *@param streamFormat Description of the Parameter+ *@param streamFrequency Description of the Parameter+ *@param stream16bit Description of the Parameter+ *@param streamStereo Description of the Parameter+ *@param averageSampleCount Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagSoundStreamHead(+ int playbackFrequency, boolean playback16bit, boolean playbackStereo,+ int streamFormat, int streamFrequency, boolean stream16bit, boolean streamStereo,+ int averageSampleCount) throws IOException {+ writeSoundStreamHead(TAG_SOUNDSTREAMHEAD,+ playbackFrequency, playback16bit, playbackStereo,+ streamFormat, streamFrequency, stream16bit, streamStereo,+ averageSampleCount);+ }+++ /**+ * SWFTagTypes interface+ *+ *@param playbackFrequency Description of the Parameter+ *@param playback16bit Description of the Parameter+ *@param playbackStereo Description of the Parameter+ *@param streamFormat Description of the Parameter+ *@param streamFrequency Description of the Parameter+ *@param stream16bit Description of the Parameter+ *@param streamStereo Description of the Parameter+ *@param averageSampleCount Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagSoundStreamHead2(+ int playbackFrequency, boolean playback16bit, boolean playbackStereo,+ int streamFormat, int streamFrequency, boolean stream16bit, boolean streamStereo,+ int averageSampleCount) throws IOException {+ writeSoundStreamHead(TAG_SOUNDSTREAMHEAD2,+ playbackFrequency, playback16bit, playbackStereo,+ streamFormat, streamFrequency, stream16bit, streamStereo,+ averageSampleCount);+ }+++ /**+ * Description of the Method+ *+ *@param tag Description of the Parameter+ *@param playbackFrequency Description of the Parameter+ *@param playback16bits Description of the Parameter+ *@param playbackStereo Description of the Parameter+ *@param streamFormat Description of the Parameter+ *@param streamFrequency Description of the Parameter+ *@param stream16bits Description of the Parameter+ *@param streamStereo Description of the Parameter+ *@param averageSampleCount Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void writeSoundStreamHead(int tag,+ int playbackFrequency, boolean playback16bits, boolean playbackStereo,+ int streamFormat, int streamFrequency, boolean stream16bits, boolean streamStereo,+ int averageSampleCount) throws IOException {+ startTag(tag, false);++ out.writeUBits(4, 0);+ out.writeUBits(2, playbackFrequency);+ out.writeUBits(1, playback16bits ? 1 : 0);+ out.writeUBits(1, playbackStereo ? 1 : 0);++ out.writeUBits(4, streamFormat);+ out.writeUBits(2, streamFrequency);+ out.writeUBits(1, stream16bits ? 1 : 0);+ out.writeUBits(1, streamStereo ? 1 : 0);+ out.writeUI16(averageSampleCount);++ if (streamFormat == SWFConstants.SOUND_FORMAT_MP3) {+ out.writeUI16(0);+ //unknown+ }++ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param soundData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagSoundStreamBlock(byte[] soundData) throws IOException {+ startTag(TAG_SOUNDSTREAMBLOCK, true);+ out.write(soundData);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param serialNumber Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagSerialNumber(String serialNumber) throws IOException {+ startTag(TAG_SERIALNUMBER, false);+ out.writeString(serialNumber);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagGenerator(byte[] data) throws IOException {+ startTag(SWFConstants.TAG_FLASHGENERATOR, false);+ out.write(data);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagGeneratorText(byte[] data) throws IOException {+ startTag(SWFConstants.TAG_GENERATOR_TEXT, false);+ out.write(data);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagGeneratorCommand(byte[] data) throws IOException {+ startTag(SWFConstants.TAG_TEMPLATECOMMAND, false);+ out.write(data);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagGeneratorFont(byte[] data) throws IOException {+ startTag(SWFConstants.TAG_GEN_EXTERNAL_FONT, false);+ out.write(data);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagNameCharacter(byte[] data) throws IOException {+ startTag(SWFConstants.TAG_NAMECHARACTER, false);+ out.write(data);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param imageData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBits(int id, byte[] imageData) throws IOException {+ startTag(SWFConstants.TAG_DEFINEBITS, id, true);+ out.write(imageData);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param jpegEncodingData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagJPEGTables(byte[] jpegEncodingData) throws IOException {+ startTag(SWFConstants.TAG_JPEGTABLES, true);+ out.write(jpegEncodingData);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param imageData Description of the Parameter+ *@param alphaData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsJPEG3(int id, byte[] imageData, byte[] alphaData) throws IOException {+ startTag(SWFConstants.TAG_DEFINEBITSJPEG3, id, true);+ out.writeUI32(imageData.length);+ out.write(imageData);+ out.write(alphaData);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFActions tagDoAction() throws IOException {+ startTag(TAG_DOACTION, true);+ return factorySWFActions();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param outline Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFShape tagDefineShape(int id, Rect outline) throws IOException {+ startShape(TAG_DEFINESHAPE, id, outline);+ return factorySWFShape(false, true);+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param outline Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFShape tagDefineShape2(int id, Rect outline) throws IOException {+ startShape(TAG_DEFINESHAPE2, id, outline);+ return factorySWFShape(false, true);+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param outline Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFShape tagDefineShape3(int id, Rect outline) throws IOException {+ startShape(TAG_DEFINESHAPE3, id, outline);+ return factorySWFShape(true, true);+ }+++ /**+ * SWFTagTypes interface+ *+ *@param charId Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagFreeCharacter(int charId) throws IOException {+ startTag(TAG_FREECHARACTER, false);+ out.writeUI16(charId);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param charId Description of the Parameter+ *@param depth Description of the Parameter+ *@param matrix Description of the Parameter+ *@param cxform Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagPlaceObject(int charId, int depth,+ Matrix matrix, AlphaTransform cxform)+ throws IOException {+ startTag(TAG_PLACEOBJECT, false);+ out.writeUI16(charId);+ out.writeUI16(depth);+ matrix.write(out);+ if (cxform != null) {+ cxform.write(out);+ }+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param isMove Description of the Parameter+ *@param clipDepth Description of the Parameter+ *@param depth Description of the Parameter+ *@param charId Description of the Parameter+ *@param matrix Description of the Parameter+ *@param cxform Description of the Parameter+ *@param ratio Description of the Parameter+ *@param name Description of the Parameter+ *@param clipActionFlags Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFActions tagPlaceObject2(boolean isMove,+ int clipDepth,+ int depth,+ int charId,+ Matrix matrix,+ AlphaTransform cxform,+ int ratio,+ String name,+ int clipActionFlags)+ throws IOException {+ boolean hasClipActions = (clipActionFlags != 0);++ startTag(TAG_PLACEOBJECT2, false);++ out.writeUBits(1, hasClipActions ? 1 : 0);+ out.writeUBits(1, (clipDepth > 0) ? 1 : 0);+ out.writeUBits(1, (name != null) ? 1 : 0);+ out.writeUBits(1, (ratio >= 0) ? 1 : 0);+ out.writeUBits(1, (cxform != null) ? 1 : 0);+ out.writeUBits(1, (matrix != null) ? 1 : 0);+ out.writeUBits(1, (charId > 0) ? 1 : 0);+ out.writeUBits(1, isMove ? 1 : 0);++ out.writeUI16(depth);++ if (charId > 0) {+ out.writeUI16(charId);+ }+ if (matrix != null) {+ matrix.write(out);+ }+ if (cxform != null) {+ cxform.write(out);+ }+ if (ratio >= 0) {+ out.writeUI16(ratio);+ }+ if (clipDepth > 0) {+ out.writeUI16(clipDepth);+ }++ if (name != null) {+ out.writeString(name);+ longTag = true;+ }++ if (hasClipActions) {+ out.writeUI16(0);+ //unknown+ out.writeUI16(clipActionFlags);++ return+ new ActionWriter(this, version) {+ public void start(int conditions) throws IOException {+ super.start(conditions);+ tagWriter.out.writeUI16(conditions);+ }+++ protected void writeBytes(byte[] bytes) throws IOException {+ tagWriter.out.writeUI32(bytes.length);+ super.writeBytes(bytes);+ }+++ public void done() throws IOException {+ tagWriter.out.writeUI16(0);+ super.done();+ }+ };+ }++ completeTag();+ return null;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param charId Description of the Parameter+ *@param depth Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagRemoveObject(int charId, int depth) throws IOException {+ startTag(TAG_REMOVEOBJECT, false);+ out.writeUI16(charId);+ out.writeUI16(depth);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param depth Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagRemoveObject2(int depth) throws IOException {+ startTag(TAG_REMOVEOBJECT2, false);+ out.writeUI16(depth);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param color Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagSetBackgroundColor(Color color) throws IOException {+ startTag(TAG_SETBACKGROUNDCOLOR, false);+ color.writeRGB(out);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param label Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagFrameLabel(String label) throws IOException {+ startTag(TAG_FRAMELABEL, true);+ out.writeString(label);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFTagTypes tagDefineSprite(int id) throws IOException {+ startTag(TAG_DEFINESPRITE, id, true);++ out.writeUI16(0);+ //framecount - to be filled in later++ TagWriter writer = new TagWriter(new SpriteTags());+ writer.version = version;++ return writer;+ }+++ /**+ * SWFTagTypes interface+ *+ *@param password Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagProtect(byte[] password) throws IOException {+ tags.tag(TAG_PROTECT, false, password);+ }+++ /**+ * SWFTagTypes interface+ *+ *@param password Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagEnableDebug(byte[] password) throws IOException {+ tags.tag(TAG_ENABLEDEBUG, false, password);+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param numGlyphs Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFVectors tagDefineFont(int id, int numGlyphs) throws IOException {+ startTag(TAG_DEFINEFONT, id, true);++ return new SWFShapeImpl(this, numGlyphs);+ }+++ /**+ * SWFTagTypes interface+ *+ *@param fontId Description of the Parameter+ *@param fontName Description of the Parameter+ *@param flags Description of the Parameter+ *@param codes Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineFontInfo(int fontId, String fontName, int flags, int[] codes)+ throws IOException {+ startTag(TAG_DEFINEFONTINFO, true);+ out.writeUI16(fontId);++ byte[] chars = fontName.getBytes();+ out.writeUI8(chars.length);+ out.write(chars);++ out.writeUI8(flags);++ boolean wide = (flags & FONT_WIDECHARS) != 0;++ for (int i = 0; i < codes.length; i++) {+ if (wide) {+ out.writeUI16(codes[i]);+ } else {+ out.writeUI8(codes[i]);+ }+ }++ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param flags Description of the Parameter+ *@param name Description of the Parameter+ *@param numGlyphs Description of the Parameter+ *@param ascent Description of the Parameter+ *@param descent Description of the Parameter+ *@param leading Description of the Parameter+ *@param codes Description of the Parameter+ *@param advances Description of the Parameter+ *@param bounds Description of the Parameter+ *@param kernCodes1 Description of the Parameter+ *@param kernCodes2 Description of the Parameter+ *@param kernAdjustments Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFVectors tagDefineFont2(int id, int flags, String name, int numGlyphs,+ int ascent, int descent, int leading,+ int[] codes, int[] advances, Rect[] bounds,+ int[] kernCodes1, int[] kernCodes2,+ int[] kernAdjustments) throws IOException {+ startTag(TAG_DEFINEFONT2, id, true);++ out.writeUI8(flags);+ out.writeUI8(0);+ //reserved flags++ byte[] nameBytes = name.getBytes();+ out.writeUI8(nameBytes.length);+ out.write(nameBytes);+ out.writeUI16(numGlyphs);++ return new Font2ShapeImpl(this, flags, numGlyphs, ascent, descent, leading,+ codes, advances, bounds,+ kernCodes1, kernCodes2, kernAdjustments);+ }+++ /**+ * SWFTagTypes interface+ *+ *@param fieldId Description of the Parameter+ *@param fieldName Description of the Parameter+ *@param initialText Description of the Parameter+ *@param boundary Description of the Parameter+ *@param flags Description of the Parameter+ *@param textColor Description of the Parameter+ *@param alignment Description of the Parameter+ *@param fontId Description of the Parameter+ *@param fontSize Description of the Parameter+ *@param charLimit Description of the Parameter+ *@param leftMargin Description of the Parameter+ *@param rightMargin Description of the Parameter+ *@param indentation Description of the Parameter+ *@param lineSpacing Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineTextField(int fieldId, String fieldName,+ String initialText, Rect boundary, int flags2,+ AlphaColor textColor, int alignment, int fontId, int fontSize,+ int charLimit, int leftMargin, int rightMargin, int indentation,+ int lineSpacing)+ throws IOException {+ int flags = flags2 | 0x2005;++ startTag(TAG_DEFINETEXTFIELD, fieldId, true);++ boundary.write(out);++ out.writeUI16(flags);+ out.writeUI16(fontId);+ out.writeUI16(fontSize);+ textColor.write(out);++ if ((flags & TEXTFIELD_LIMIT_CHARS) != 0) {+ out.writeUI16(charLimit);+ }++ out.writeUI8(alignment);+ out.writeUI16(leftMargin);+ out.writeUI16(rightMargin);+ out.writeUI16(indentation);+ out.writeUI16(lineSpacing);++ out.writeString(fieldName);++ if ((flags & TEXTFIELD_HAS_TEXT) != 0) {+ out.writeString(initialText);+ }++ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param bounds Description of the Parameter+ *@param matrix Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFText tagDefineText(int id, Rect bounds, Matrix matrix)+ throws IOException {+ startTag(TAG_DEFINETEXT, id, true);+ return defineText(bounds, matrix, false);+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param bounds Description of the Parameter+ *@param matrix Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFText tagDefineText2(int id, Rect bounds, Matrix matrix) throws IOException {+ startTag(TAG_DEFINETEXT2, id, true);+ return defineText(bounds, matrix, true);+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param buttonRecords Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFActions tagDefineButton(int id, List buttonRecords)+ throws IOException {+ startTag(TAG_DEFINEBUTTON, id, true);++ ButtonRecord.write(out, buttonRecords);+ System.out.println("BUTTON");+ return new ActionWriter(this, version);+ }+++ /**+ * SWFTagTypes interface+ *+ *@param buttonId Description of the Parameter+ *@param transform Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagButtonCXForm(int buttonId, ColorTransform transform)+ throws IOException {+ startTag(TAG_DEFINEBUTTONCXFORM, buttonId, false);+ transform.writeWithoutAlpha(out);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param trackAsMenu Description of the Parameter+ *@param buttonRecord2s Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFActions tagDefineButton2(int id,+ boolean trackAsMenu,+ List buttonRecord2s)+ throws IOException {+ startTag(TAG_DEFINEBUTTON2, id, true);+ out.writeUI8(trackAsMenu ? 1 : 0);++ return new ButtonActionWriter(this, version, buttonRecord2s);+ }+++ /**+ * SWFTagTypes interface+ *+ *@param names Description of the Parameter+ *@param ids Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagExport(String[] names, int[] ids) throws IOException {+ startTag(TAG_EXPORT, true);++ int count = ids.length;++ out.writeUI16(count);++ for (int i = 0; i < count; i++) {+ //System.out.println( "Exporting " + ids[i] + " as " + names[i] );+ out.writeUI16(ids[i]);+ out.writeString(names[i]);+ }++ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param movieName Description of the Parameter+ *@param names Description of the Parameter+ *@param ids Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagImport(String movieName, String[] names, int[] ids)+ throws IOException {+ startTag(TAG_IMPORT, true);++ int count = ids.length;++ out.writeString(movieName);+ out.writeUI16(count);++ for (int i = 0; i < count; i++) {+ //System.out.println( "Importing " + names[i] + " as " + ids[i] + " from " + movieName );+ out.writeUI16(ids[i]);+ out.writeString(names[i]);+ }++ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param filename Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineQuickTimeMovie(int id, String filename) throws IOException {+ startTag(TAG_DEFINEQUICKTIMEMOVIE, id, true);+ out.writeString(filename);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param data Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsJPEG2(int id, byte[] data) throws IOException {+ startTag(TAG_DEFINEBITSJPEG2, id, true);+ out.write(data);+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param format Description of the Parameter+ *@param width Description of the Parameter+ *@param height Description of the Parameter+ *@param colors Description of the Parameter+ *@param imageData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsLossless(int id, int format, int width, int height,+ Color[] colors, byte[] imageData)+ throws IOException {+ writeBitsLossless(id, format, width, height, colors, imageData, false);+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param format Description of the Parameter+ *@param width Description of the Parameter+ *@param height Description of the Parameter+ *@param colors Description of the Parameter+ *@param imageData Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsLossless2(int id, int format, int width, int height,+ Color[] colors, byte[] imageData)+ throws IOException {+ writeBitsLossless(id, format, width, height, colors, imageData, true);+ }+++ /**+ * Description of the Method+ *+ *@param id Description of the Parameter+ *@param format Description of the Parameter+ *@param width Description of the Parameter+ *@param height Description of the Parameter+ *@param colors Description of the Parameter+ *@param imageData Description of the Parameter+ *@param hasAlpha Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void writeBitsLossless(int id, int format, int width, int height,+ Color[] colors, byte[] imageData, boolean hasAlpha)+ throws IOException {+ startTag(hasAlpha ? TAG_DEFINEBITSLOSSLESS2 : TAG_DEFINEBITSLOSSLESS,+ id, true);++ out.writeUI8(format);+ out.writeUI16(width);+ out.writeUI16(height);++ switch (format) {+ case BITMAP_FORMAT_8_BIT:+ out.writeUI8(colors.length - 1);+ break;+ case BITMAP_FORMAT_16_BIT:+ out.writeUI16(colors.length - 1);+ break;+ case BITMAP_FORMAT_32_BIT:+ break;+ default:+ throw new IOException("unknown bitmap format: " + format);+ }++ //--zip up the colors and the bitmap data+ DeflaterOutputStream deflater = new DeflaterOutputStream(bytes);+ OutStream zipOut = new OutStream(deflater);++ if (format == BITMAP_FORMAT_8_BIT || format == BITMAP_FORMAT_16_BIT) {+ for (int i = 0; i < colors.length; i++) {+ if (hasAlpha) {+ colors[i].writeWithAlpha(zipOut);+ } else {+ colors[i].writeRGB(zipOut);+ }+ }+ }+ zipOut.write(imageData);+ zipOut.flush();+ deflater.finish();++ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param jpegImage Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tagDefineBitsJPEG2(int id, InputStream jpegImage) throws IOException {+ startTag(TAG_DEFINEBITSJPEG2, id, true);++ //--Write stream terminator/header+ out.writeUI8(0xff);+ out.writeUI8(0xd9);+ out.writeUI8(0xff);+ out.writeUI8(0xd8);++ int read = 0;+ byte[] bytes = new byte[10000];++ while ((read = jpegImage.read(bytes)) >= 0) {+ out.write(bytes, 0, read);+ }++ jpegImage.close();+ completeTag();+ }+++ /**+ * SWFTagTypes interface+ *+ *@param id Description of the Parameter+ *@param startBounds Description of the Parameter+ *@param endBounds Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ public SWFShape tagDefineMorphShape(int id, Rect startBounds, Rect endBounds)+ throws IOException {+ startTag(TAG_DEFINEMORPHSHAPE, id, true);+ startBounds.write(out);+ endBounds.write(out);+ return new MorphShapeImpl(this);+ }+++ //-----------------------------------------------------------------------++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ protected static class ButtonActionWriter extends ActionWriter {+ //offsets is a vector of int[]{ offsetPtr, offsetValue }+ /**+ * Description of the Field+ */+ protected List offsets = new Vector();+ /**+ * Description of the Field+ */+ protected int lastPtr;+ /**+ * Description of the Field+ */+ protected OutStream tagout;+++ /**+ * Constructor for the ButtonActionWriter object+ *+ *@param tagWriter Description of the Parameter+ *@param flashVersion Description of the Parameter+ *@param buttonRecs Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public ButtonActionWriter(TagWriter tagWriter,+ int flashVersion,+ List buttonRecs)+ throws IOException {+ super(tagWriter, flashVersion);++ tagout = tagWriter.getOutStream();++ //--save ptr to first offset location+ lastPtr = (int) tagout.getBytesWritten();++ tagout.writeUI16(0);+ //will be calculated later++ //--write the button records+ ButtonRecord2.write(tagout, buttonRecs);+ }+++ /**+ * Description of the Method+ *+ *@param conditions Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void start(int conditions) throws IOException {+ super.start(conditions);++ //--save ptr to offset location and offset value+ int ptr = (int) tagout.getBytesWritten();+ int offset = ptr - lastPtr;++ offsets.add(new int[]{lastPtr, offset});++ lastPtr = ptr;++ tagout.writeUI16(0);+ //will be calculated later+ tagout.writeUI16(conditions);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void done() throws IOException {+ //--save last offset+ offsets.add(new int[]{lastPtr, 0});++ tagout.flush();+ byte[] contents = tagWriter.bytes.toByteArray();++ tagWriter.out = null;+ tagWriter.bytes = null;++ //--fix the offsets+ for (Iterator enumerator = offsets.iterator(); enumerator.hasNext(); ) {+ int[] offInfo = (int[]) enumerator.next();+ int ptr = offInfo[0];+ int off = offInfo[1];++ byte[] offbytes = OutStream.uintTo2Bytes(off);+ contents[ptr] = offbytes[0];+ contents[ptr + 1] = offbytes[1];+ }++ tagWriter.tags.tag(tagWriter.tagType, true, contents);+ }+ }+++ /**+ * Description of the Method+ *+ *@param bounds Description of the Parameter+ *@param matrix Description of the Parameter+ *@param hasAlpha Description of the Parameter+ *@return Description of the Return Value+ *@exception IOException Description of the Exception+ */+ protected SWFText defineText(Rect bounds, Matrix matrix, boolean hasAlpha)+ throws IOException {+ bounds.write(out);+ matrix.write(out);++ return new SWFTextImpl(hasAlpha);+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ protected class SWFTextImpl implements SWFText {+ /**+ * Description of the Field+ */+ protected boolean hasAlpha;++ /**+ * Description of the Field+ */+ protected int maxGlyphIndex = 0;+ /**+ * Description of the Field+ */+ protected int maxAdvance = 0;++ // Text records are stored as+ // Object[] { int[]{ font, height }, int[]{ x }, int[]{ y }, Color }, or+ // Object[] { int[] glyphs, int[] advances }+ /**+ * Description of the Field+ */+ protected List recs = new Vector();+ /**+ * Description of the Field+ */+ protected Object[] currentStyleRecord = null;+++ /**+ * Constructor for the SWFTextImpl object+ *+ *@param hasAlpha Description of the Parameter+ */+ public SWFTextImpl(boolean hasAlpha) {+ this.hasAlpha = hasAlpha;+ }+++ /**+ * Gets the currentStyle attribute of the SWFTextImpl object+ *+ *@return The currentStyle value+ */+ protected Object[] getCurrentStyle() {+ if (currentStyleRecord == null) {+ currentStyleRecord = new Object[4];+ recs.add(currentStyleRecord);+ }++ return currentStyleRecord;+ }+++ /**+ * SWFText interface+ *+ *@param fontId Description of the Parameter+ *@param textHeight Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void font(int fontId, int textHeight) throws IOException {+ getCurrentStyle()[0] = new int[]{fontId, textHeight};+ }+++ /**+ * SWFText interface+ *+ *@param color Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void color(Color color) throws IOException {+ getCurrentStyle()[3] = color;+ }+++ /**+ * SWFText interface+ *+ *@param x The new x value+ *@exception IOException Description of the Exception+ */+ public void setX(int x) throws IOException {+ getCurrentStyle()[1] = new int[]{x};+ }+++ /**+ * SWFText interface+ *+ *@param y The new y value+ *@exception IOException Description of the Exception+ */+ public void setY(int y) throws IOException {+ getCurrentStyle()[2] = new int[]{y};+ }+++ /**+ * SWFText interface+ *+ *@param glyphIndices Description of the Parameter+ *@param glyphAdvances Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void text(int[] glyphIndices, int[] glyphAdvances) throws IOException {+ currentStyleRecord = null;+ recs.add(new Object[]{glyphIndices, glyphAdvances});++ for (int i = 0; i < glyphIndices.length; i++) {+ if (glyphIndices[i] > maxGlyphIndex) {+ maxGlyphIndex = glyphIndices[i];+ }+ if (glyphAdvances[i] > maxAdvance) {+ maxAdvance = glyphAdvances[i];+ }+ }+ }+++ /**+ * SWFText interface+ *+ *@exception IOException Description of the Exception+ */+ public void done() throws IOException {+ int glyphBits = OutStream.determineUnsignedBitSize(maxGlyphIndex);+ int advanceBits = OutStream.determineSignedBitSize(maxAdvance);++ out.writeUI8(glyphBits);+ out.writeUI8(advanceBits);++ for (Iterator enumerator = recs.iterator(); enumerator.hasNext(); ) {+ Object[] rec = (Object[]) enumerator.next();++ if (rec.length == 4) {+ //style record++ boolean hasFont = rec[0] != null;+ boolean hasX = rec[1] != null;+ boolean hasY = rec[2] != null;+ boolean hasColor = rec[3] != null;++ int flags = 0x80;+ if (hasFont) {+ flags |= TEXT_HAS_FONT;+ }+ if (hasX) {+ flags |= TEXT_HAS_XOFFSET;+ }+ if (hasY) {+ flags |= TEXT_HAS_YOFFSET;+ }+ if (hasColor) {+ flags |= TEXT_HAS_COLOR;+ }++ out.writeUI8(flags);++ if (hasFont) {+ out.writeUI16(((int[]) rec[0])[0]);+ //fontId+ }++ if (hasColor) {+ Color color = (Color) rec[3];++ if (hasAlpha) {+ color.writeWithAlpha(out);+ } else {+ color.writeRGB(out);+ }+ }++ if (hasX) {+ int xOffset = ((int[]) rec[1])[0];+ out.writeSI16((short) xOffset);+ }++ if (hasY) {+ //x & y are in reverse order from flag bits++ int yOffset = ((int[]) rec[2])[0];+ out.writeSI16((short) yOffset);+ }++ if (hasFont) {+ out.writeUI16(((int[]) rec[0])[1]);+ //textHeight+ }+ } else {+ //glyph record++ int[] glyphs = (int[]) rec[0];+ int[] advances = (int[]) rec[1];++ out.writeUI8(glyphs.length);++ for (int i = 0; i < glyphs.length; i++) {+ out.writeUBits(glyphBits, glyphs[i]);+ out.writeSBits(advanceBits, advances[i]);+ }+ }+ }++ out.writeUI8(0);+ //record terminator++ completeTag();+ }+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ protected class SpriteTags implements SWFTags {+ /**+ * Description of the Field+ */+ protected int frameCount = 0;+++ /**+ * Description of the Method+ *+ *@param tagType2 Description of the Parameter+ *@param longTag2 Description of the Parameter+ *@param contents Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void tag(int tagType2, boolean longTag3,+ byte[] contents2) throws IOException {+ byte[] contents = contents2;+ int length = (contents != null) ? contents.length : 0;+ boolean longTag2 = (length > 62) || longTag3;++ int hdr = (tagType2 << 6) + (longTag2 ? 0x3f : length);++ out.writeUI16(hdr);++ if (longTag2) {+ out.writeUI32(length);+ }++ if (contents != null) {+ out.write(contents);+ }++ if (tagType2 == SWFConstants.TAG_SHOWFRAME) {+ frameCount++;+ }++ if (tagType2 == SWFConstants.TAG_END) {+ out.flush();+ contents = bytes.toByteArray();++ out = null;+ bytes = null;++ byte[] fc = OutStream.uintTo2Bytes(frameCount);+ contents[2] = fc[0];+ contents[3] = fc[1];++ tags.tag(tagType, longTag, contents);+ }+ }+++ /**+ * Description of the Method+ *+ *@param version Description of the Parameter+ *@param length Description of the Parameter+ *@param twipsWidth Description of the Parameter+ *@param twipsHeight Description of the Parameter+ *@param frameRate Description of the Parameter+ *@param frameCount Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void header(int version, long length,+ int twipsWidth, int twipsHeight,+ int frameRate, int frameCount) throws IOException { }+ }+++ /**+ * Description of the Method+ *+ *@param tagType Description of the Parameter+ *@param id Description of the Parameter+ *@param outline Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void startShape(int tagType, int id, Rect outline) throws IOException {+ startTag(tagType, id, true);+ outline.write(out);+ }+++ /**+ * Implementation of the SWFShape interface+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ protected static class SWFShapeImpl implements SWFShape {+ /**+ * Description of the Field+ */+ protected boolean hasAlpha;+ /**+ * Description of the Field+ */+ protected boolean hasStyle;+ /**+ * Description of the Field+ */+ protected boolean outstandingChanges = true;+ /**+ * Description of the Field+ */+ protected boolean initialStyles = false;++ /**+ * Description of the Field+ */+ protected int fill0Index = -1;+ /**+ * Description of the Field+ */+ protected int fill1Index = -1;+ /**+ * Description of the Field+ */+ protected int lineIndex = -1;++ /**+ * Description of the Field+ */+ protected int[] moveXY;+ /**+ * Description of the Field+ */+ protected List lineStyles = new Vector();+ /**+ * Description of the Field+ */+ protected List fillStyles = new Vector();++ /**+ * Description of the Field+ */+ protected int fillBits;+ /**+ * Description of the Field+ */+ protected int lineBits;++ /**+ * Description of the Field+ */+ protected int glyphCount = 0;+ /**+ * Description of the Field+ */+ protected List glyphByteArrays;++ /**+ * Description of the Field+ */+ protected OutStream out;+ /**+ * Description of the Field+ */+ protected TagWriter writer;+ /**+ * Description of the Field+ */+ protected ByteArrayOutputStream bout;+++ /**+ * For shapes (other than glyphs)+ *+ *@param writer Description of the Parameter+ *@param hasAlpha Description of the Parameter+ *@param hasStyle Description of the Parameter+ */+ public SWFShapeImpl(TagWriter writer, boolean hasAlpha, boolean hasStyle) {+ this.hasAlpha = hasAlpha;+ this.hasStyle = hasStyle;+ this.writer = writer;+ out = writer.getOutStream();+ }+++ /**+ * For glyphs+ *+ *@param writer Description of the Parameter+ *@param glyphCount Description of the Parameter+ */+ public SWFShapeImpl(TagWriter writer, int glyphCount) {+ this(writer, false, false);+ this.glyphCount = glyphCount;+ bout = new ByteArrayOutputStream();+ out = new OutStream(bout);+ glyphByteArrays = new Vector();++ fill1Index = 1;+ lineIndex = 0;+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void done() throws IOException {+ if (!initialStyles) {+ writeInitialStyles();+ initialStyles = true;+ }++ out.writeUBits(6, 0);+ //end record+ out.flushBits();++ if (bout != null && glyphCount > 0) {+ //capturing bytes internally++ byte[] glyphBytes = bout.toByteArray();+ glyphByteArrays.add(glyphBytes);+ }++ if (glyphCount > 1) {+ bout = new ByteArrayOutputStream();+ out = new OutStream(bout);+ glyphCount--;++ fill1Index = 1;+ lineIndex = 0;+ outstandingChanges = true;+ initialStyles = false;+ } else {+ if (bout != null) {+ finishFont();+ }+ writer.completeTag();+ }+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ protected void finishFont() throws IOException {+ out = writer.getOutStream();++ int glyphCount = glyphByteArrays.size();++ //--Write first shape offset+ int offset = glyphCount * 2;+ out.writeUI16(offset);++ //--Write subsequent shape offsets+ for (int i = 0; i < glyphCount - 1; i++) {+ offset += ((byte[]) glyphByteArrays.get(i)).length;+ out.writeUI16(offset);+ }++ //--Write shapes+ for (int i = 0; i < glyphCount; i++) {+ out.write((byte[]) glyphByteArrays.get(i));+ }+ }+++ /**+ * Sets the fillStyle0 attribute of the SWFShapeImpl object+ *+ *@param styleIndex The new fillStyle0 value+ *@exception IOException Description of the Exception+ */+ public void setFillStyle0(int styleIndex) throws IOException {+ fill0Index = styleIndex;+ outstandingChanges = true;+ }+++ /**+ * Sets the fillStyle1 attribute of the SWFShapeImpl object+ *+ *@param styleIndex The new fillStyle1 value+ *@exception IOException Description of the Exception+ */+ public void setFillStyle1(int styleIndex) throws IOException {+ fill1Index = styleIndex;+ outstandingChanges = true;+ }+++ /**+ * Sets the lineStyle attribute of the SWFShapeImpl object+ *+ *@param styleIndex The new lineStyle value+ *@exception IOException Description of the Exception+ */+ public void setLineStyle(int styleIndex) throws IOException {+ lineIndex = styleIndex;+ outstandingChanges = true;+ }+++ /**+ * Description of the Method+ *+ *@param color Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void defineFillStyle(Color color) throws IOException {+ fillStyles.add(new FillStyle(color));+ outstandingChanges = true;+ }+++ /**+ * Description of the Method+ *+ *@param matrix Description of the Parameter+ *@param ratios Description of the Parameter+ *@param colors Description of the Parameter+ *@param radial Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void defineFillStyle(Matrix matrix, int[] ratios,+ Color[] colors, boolean radial)+ throws IOException {+ fillStyles.add(new FillStyle(matrix, ratios, colors, radial));+ outstandingChanges = true;+ }+++ /**+ * Description of the Method+ *+ *@param bitmapId Description of the Parameter+ *@param matrix Description of the Parameter+ *@param clipped Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void defineFillStyle(int bitmapId, Matrix matrix, boolean clipped)+ throws IOException {+ fillStyles.add(new FillStyle(bitmapId, matrix, clipped));+ outstandingChanges = true;+ }+++ /**+ * Description of the Method+ *+ *@param width Description of the Parameter+ *@param color Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void defineLineStyle(int width, Color color) throws IOException {+ lineStyles.add(new LineStyle(width, color));+ outstandingChanges = true;+ }+++ /**+ * Description of the Method+ *+ *@param deltaX Description of the Parameter+ *@param deltaY Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void line(int deltaX, int deltaY) throws IOException {+ if (outstandingChanges) {+ flushChangeRecords();+ }++ int numBits = OutStream.determineSignedBitSize(deltaX);+ int dyBits = OutStream.determineSignedBitSize(deltaY);++ if (dyBits > numBits) {+ numBits = dyBits;+ }+ if (numBits < 2) {+ numBits = 2;+ }++ out.writeUBits(2, 3);+ //11b = line record++ out.writeUBits(4, numBits - 2);++ if (deltaX != 0 && deltaY != 0) {+ //general line++ out.writeUBits(1, 1);+ out.writeSBits(numBits, deltaX);+ out.writeSBits(numBits, deltaY);+ } else {+ //horz or vert line++ out.writeUBits(1, 0);++ if (deltaY != 0) {+ //vert line++ out.writeUBits(1, 1);+ out.writeSBits(numBits, deltaY);+ } else {+ ///horz line++ out.writeUBits(1, 0);+ out.writeSBits(numBits, deltaX);+ }+ }+ }+++ /**+ * Description of the Method+ *+ *@param cx Description of the Parameter+ *@param cy Description of the Parameter+ *@param dx Description of the Parameter+ *@param dy Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void curve(int cx, int cy, int dx, int dy) throws IOException {+ if (outstandingChanges) {+ flushChangeRecords();+ }++ int numBits = OutStream.determineSignedBitSize(cx);+ int dyBits = OutStream.determineSignedBitSize(cy);+ int adxBits = OutStream.determineSignedBitSize(dx);+ int adyBits = OutStream.determineSignedBitSize(dy);++ if (dyBits > numBits) {+ numBits = dyBits;+ }+ if (adxBits > numBits) {+ numBits = adxBits;+ }+ if (adyBits > numBits) {+ numBits = adyBits;+ }++ if (numBits < 2) {+ numBits = 2;+ }++ out.writeUBits(2, 2);+ //10b = curve record++ out.writeUBits(4, numBits - 2);++ out.writeSBits(numBits, cx);+ out.writeSBits(numBits, cy);+ out.writeSBits(numBits, dx);+ out.writeSBits(numBits, dy);+ }+++ /**+ * Description of the Method+ *+ *@param x Description of the Parameter+ *@param y Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public void move(int x, int y) throws IOException {+ moveXY = new int[]{x, y};+ outstandingChanges = true;+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ protected void flushChangeRecords() throws IOException {+ if (!initialStyles) {+ writeInitialStyles();+ initialStyles = true;+ }++ writeChangeRecord();++ outstandingChanges = false;+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ protected void writeInitialStyles() throws IOException {+ out.flushBits();++ fillBits = OutStream.determineUnsignedBitSize(fillStyles.size());+ lineBits = OutStream.determineUnsignedBitSize(lineStyles.size());++ //--For fonts - the fillstyle bits must be one+ if (!hasStyle) {+ fillBits = 1;+ } else {+ writeStyles(fillStyles);+ writeStyles(lineStyles);+ out.flushBits();+ }++ out.writeUBits(4, fillBits);+ out.writeUBits(4, lineBits);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ protected void writeChangeRecord() throws IOException {+ boolean hasNewStyles = hasStyle &&+ (fillStyles.size() > 0 || lineStyles.size() > 0);++ boolean hasMoveTo = (moveXY != null);+ boolean hasFillStyle0 = fill0Index >= 0;+ boolean hasFillStyle1 = fill1Index >= 0;+ boolean hasLineStyle = lineIndex >= 0;++ if ((!hasStyle) && hasFillStyle0) {+ hasFillStyle1 = false;+ }++ if (hasNewStyles) {+ out.writeUBits(1, 0);+ //non-edge record+ out.writeUBits(1, 1);+ //defines new styles+ out.writeUBits(1, 1);+ out.writeUBits(1, 1);+ out.writeUBits(1, 1);+ out.writeUBits(1, 1);++ //--Clear existing styles+ writeMoveXY(0, 0);+ out.writeUBits(fillBits, 0);+ out.writeUBits(fillBits, 0);+ out.writeUBits(lineBits, 0);++ if (fill0Index == 0) {+ fill0Index = -1;+ }+ if (fill1Index == 0) {+ fill1Index = -1;+ }+ if (lineIndex == 0) {+ lineIndex = -1;+ }++ fillBits = OutStream.determineUnsignedBitSize(fillStyles.size());+ lineBits = OutStream.determineUnsignedBitSize(lineStyles.size());++ writeStyles(fillStyles);+ writeStyles(lineStyles);++ out.writeUBits(4, fillBits);+ out.writeUBits(4, lineBits);++ writeChangeRecord();+ return;+ }++ if (hasFillStyle0 || hasFillStyle1 || hasLineStyle || hasMoveTo) {+ out.writeUBits(1, 0);+ //non-edge record+ out.writeUBits(1, 0);+ out.writeUBits(1, hasLineStyle ? 1 : 0);+ out.writeUBits(1, hasFillStyle1 ? 1 : 0);+ out.writeUBits(1, hasFillStyle0 ? 1 : 0);+ out.writeUBits(1, hasMoveTo ? 1 : 0);++ if (hasMoveTo) {+ int moveX = moveXY[0];+ int moveY = moveXY[1];+ writeMoveXY(moveX, moveY);+ }++ if (hasFillStyle0) {+ out.writeUBits(fillBits, fill0Index);+ }++ if (hasFillStyle1) {+ out.writeUBits(fillBits, fill1Index);+ }++ if (hasLineStyle) {+ out.writeUBits(lineBits, lineIndex);+ }++ moveXY = null;+ fill0Index = -1;+ fill1Index = -1;+ lineIndex = -1;+ }+ }+++ /**+ * Description of the Method+ *+ *@param moveX Description of the Parameter+ *@param moveY Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void writeMoveXY(int moveX, int moveY) throws IOException {+ int moveBits = OutStream.determineSignedBitSize(moveX);+ int moveYBits = OutStream.determineSignedBitSize(moveY);+ if (moveYBits > moveBits) {+ moveBits = moveYBits;+ }++ out.writeUBits(5, moveBits);+ out.writeSBits(moveBits, moveX);+ out.writeSBits(moveBits, moveY);+ }+++ /**+ * Description of the Method+ *+ *@param styles Description of the Parameter+ *@exception IOException Description of the Exception+ */+ protected void writeStyles(List styles) throws IOException {+ int numStyles = (styles != null) ? styles.size() : 0;++ if (numStyles < 0xff) {+ out.writeUI8(numStyles);+ } else {+ out.writeUI8(0xff);+ out.writeUI16(numStyles);+ }++ if (styles != null) {+ for (Iterator enumumerator = styles.iterator();+ enumumerator.hasNext(); ) {+ Style style = (Style) enumumerator.next();+ style.write(out, hasAlpha);+ }++ styles.clear();+ }+ }+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ protected static class MorphShapeImpl extends TagWriter.SWFShapeImpl {+ /**+ * Description of the Field+ */+ protected int edgeOffsetBase;+ /**+ * Description of the Field+ */+ protected int edgeOffsetTarget;+ /**+ * Description of the Field+ */+ protected int shapeCount;+ /**+ * Description of the Field+ */+ protected int fillBitSize;+ /**+ * Description of the Field+ */+ protected int lineBitSize;+ /**+ * Description of the Field+ */+ protected int shapeStart;+++ /**+ * Constructor for the MorphShapeImpl object+ *+ *@param writer Description of the Parameter+ *@exception IOException Description of the Exception+ */+ public MorphShapeImpl(TagWriter writer) throws IOException {+ super(writer, true, false);+ fill0Index = -1;+ fill1Index = -1;+ lineIndex = -1;++ shapeCount = 2;++ this.out = writer.getOutStream();++ edgeOffsetBase = (int) this.out.getBytesWritten();++ this.out.writeUI32(0);+ //edge offset - to be filled in later+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ public void done() throws IOException {+ if (!initialStyles) {+ writeInitialStyles();+ initialStyles = true;+ }++ this.out.writeUBits(6, 0);+ //end record+ this.out.flushBits();++ if (shapeCount == 2) {+ edgeOffsetTarget = (int) this.out.getBytesWritten();++ fill0Index = -1;+ fill1Index = -1;+ lineIndex = -1;+ moveXY = null;+ outstandingChanges = true;+ initialStyles = false;++ shapeCount--;+ return;+ }++ this.out.flush();+ byte[] bytes = writer.bytes.toByteArray();++ int edgeOffset = edgeOffsetTarget - edgeOffsetBase - 4;++ byte[] offsetBytes = OutStream.uintTo4Bytes(edgeOffset);++ bytes[edgeOffsetBase] = offsetBytes[0];+ bytes[edgeOffsetBase + 1] = offsetBytes[1];+ bytes[edgeOffsetBase + 2] = offsetBytes[2];+ bytes[edgeOffsetBase + 3] = offsetBytes[3];++ writer.out = null;+ writer.bytes = null;++ writer.tags.tag(writer.tagType, writer.longTag, bytes);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ protected void writeInitialStyles() throws IOException {+ this.out.flushBits();++ int fillCount = fillStyles.size() / 2;+ int lineCount = lineStyles.size() / 2;++ fillBitSize = OutStream.determineUnsignedBitSize(fillCount);+ lineBitSize = OutStream.determineUnsignedBitSize(lineCount);++ //--Write style definitions+ if (shapeCount == 2) {+ if (fillCount < 255) {+ this.out.writeUI8(fillCount);+ } else {+ this.out.writeUI8(255);+ this.out.writeUI16(fillCount);+ }++ for (Iterator enumumerator = fillStyles.iterator(); enumumerator.hasNext(); ) {+ FillStyle startStyle = (FillStyle) enumumerator.next();+ FillStyle endStyle = (FillStyle) enumumerator.next();+ FillStyle.writeMorphFillStyle(this.out, startStyle, endStyle);+ }++ if (lineCount < 255) {+ this.out.writeUI8(lineCount);+ } else {+ this.out.writeUI8(255);+ this.out.writeUI16(lineCount);+ }++ for (Iterator enumerator = lineStyles.iterator(); enumerator.hasNext(); ) {+ LineStyle startStyle = (LineStyle) enumerator.next();+ LineStyle endStyle = (LineStyle) enumerator.next();+ LineStyle.writeMorphLineStyle(this.out, startStyle, endStyle);+ }+ }++ if (shapeStart == 0) {+ shapeStart = (int) this.out.getBytesWritten();+ }++ this.out.writeUBits(4, fillBitSize);+ this.out.writeUBits(4, lineBitSize);+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ protected void writeChangeRecord() throws IOException {+ boolean hasMoveTo = (moveXY != null);+ boolean hasFillStyle0 = fill0Index >= 0;+ boolean hasFillStyle1 = fill1Index >= 0;+ boolean hasLineStyle = lineIndex >= 0;++ if (hasFillStyle0 || hasFillStyle1 || hasLineStyle || hasMoveTo) {+ this.out.writeUBits(1, 0);+ //non-edge record+ this.out.writeUBits(1, 0);+ this.out.writeUBits(1, hasLineStyle ? 1 : 0);+ this.out.writeUBits(1, hasFillStyle1 ? 1 : 0);+ this.out.writeUBits(1, hasFillStyle0 ? 1 : 0);+ this.out.writeUBits(1, hasMoveTo ? 1 : 0);++ if (hasMoveTo) {+ int moveX = moveXY[0];+ int moveY = moveXY[1];+ int moveBits = OutStream.determineSignedBitSize(moveX);+ int moveYBits = OutStream.determineSignedBitSize(moveY);+ if (moveYBits > moveBits) {+ moveBits = moveYBits;+ }++ this.out.writeUBits(5, moveBits);+ this.out.writeSBits(moveBits, moveX);+ this.out.writeSBits(moveBits, moveY);+ }++ if (hasFillStyle0) {+ this.out.writeUBits(fillBitSize, fill0Index);+ }++ if (hasFillStyle1) {+ this.out.writeUBits(fillBitSize, fill1Index);+ }++ if (hasLineStyle) {+ this.out.writeUBits(lineBitSize, lineIndex);+ }++ moveXY = null;+ fill0Index = -1;+ fill1Index = -1;+ lineIndex = -1;+ }+ }+ }+++ /**+ * Description of the Class+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+ protected static class Font2ShapeImpl extends TagWriter.SWFShapeImpl {+ /**+ * Description of the Field+ */+ protected int flags;+ /**+ * Description of the Field+ */+ protected int ascent;+ /**+ * Description of the Field+ */+ protected int descent;+ /**+ * Description of the Field+ */+ protected int leading;+ /**+ * Description of the Field+ */+ protected int[] codes;+ /**+ * Description of the Field+ */+ protected int[] advances;+ /**+ * Description of the Field+ */+ protected Rect[] bounds;+ /**+ * Description of the Field+ */+ protected int[] kernCodes1;+ /**+ * Description of the Field+ */+ protected int[] kernCodes2;+ /**+ * Description of the Field+ */+ protected int[] kernAdjustments;+++ /**+ * Constructor for the Font2ShapeImpl object+ *+ *@param writer Description of the Parameter+ *@param flags Description of the Parameter+ *@param glyphCount Description of the Parameter+ *@param ascent Description of the Parameter+ *@param descent Description of the Parameter+ *@param leading Description of the Parameter+ *@param codes Description of the Parameter+ *@param advances Description of the Parameter+ *@param bounds Description of the Parameter+ *@param kernCodes1 Description of the Parameter+ *@param kernCodes2 Description of the Parameter+ *@param kernAdjustments Description of the Parameter+ */+ public Font2ShapeImpl(TagWriter writer, int flags, int glyphCount,+ int ascent, int descent, int leading,+ int[] codes, int[] advances, Rect[] bounds,+ int[] kernCodes1, int[] kernCodes2,+ int[] kernAdjustments) {+ super(writer, glyphCount);++ this.flags = flags;+ this.ascent = ascent;+ this.descent = descent;+ this.leading = leading;+ this.codes = codes;+ this.advances = advances;+ this.bounds = bounds;+ this.kernCodes1 = kernCodes1;+ this.kernCodes2 = kernCodes2;+ this.kernAdjustments = kernAdjustments;+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ protected void finishFont() throws IOException {+ this.out = writer.getOutStream();++ int glyphCount = glyphByteArrays.size();++ boolean is32 = (flags & FONT2_32OFFSETS) != 0;+ int offset = is32 ? ((glyphCount + 1) * 4) : ((glyphCount + 1) * 2);+ for (int i = 0; i <= glyphCount; i++) {+ if (is32) {+ this.out.writeUI32(offset);+ } else {+ this.out.writeUI16(offset);+ }++ if (i < glyphCount) {+ offset += ((byte[]) glyphByteArrays.get(i)).length;+ }+ }++ for (int i = 0; i < glyphCount; i++) {+ this.out.write((byte[]) glyphByteArrays.get(i));+ }++ boolean isWide = (flags & FONT2_WIDECHARS) != 0 || glyphCount > 256;+ for (int i = 0; i < glyphCount; i++) {+ if (isWide) {+ this.out.writeUI16(codes[i]);+ } else {+ this.out.writeUI8(codes[i]);+ }+ }++ if ((flags & FONT2_HAS_LAYOUT) != 0) {+ this.out.writeSI16((short) ascent);+ this.out.writeSI16((short) descent);+ this.out.writeSI16((short) leading);++ for (int i = 0; i < glyphCount; i++) {+ this.out.writeSI16((short) advances[i]);+ }++ for (int i = 0; i < glyphCount; i++) {+ bounds[i].write(this.out);+ }++ int kerningCount = (kernCodes1 != null) ? kernCodes1.length : 0;+ this.out.writeUI16(kerningCount);++ for (int i = 0; i < kerningCount; i++) {+ if (isWide) {+ this.out.writeUI16(kernCodes1[i]);+ this.out.writeUI16(kernCodes2[i]);+ this.out.writeSI16((short) kernAdjustments[i]);+ } else {+ this.out.writeUI8(kernCodes1[i]);+ this.out.writeUI8(kernCodes2[i]);+ this.out.writeSI16((short) kernAdjustments[i]);+ }+ }+ }+ }+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TimeLine.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TimeLine.javanew file mode 100644index 000000000..0586404f4--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TimeLine.java@@ -0,0 +1,52 @@+package pt.tumba.parser.swf;+++/**+ * A Movie or Sprite (Movie Clip) time line (collection of frames)+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public interface TimeLine {+ /**+ * Get the current number of frames in the timeline.+ *+ *@return The frameCount value+ */+ public int getFrameCount();+++ /**+ * Get the Frame object for the given frame number - or create one if none+ * exists. If the frame number is larger than the current frame count then+ * the frame count is increased.+ *+ *@param frameNumber must be 1 or larger+ *@return The frame value+ */+ public Frame getFrame(int frameNumber);+++ /**+ * Append a frame to the end of the timeline+ *+ *@return Description of the Return Value+ */+ public Frame appendFrame();+++ /**+ * Get the next available depth in the timeline+ *+ *@return The availableDepth value+ */+ public int getAvailableDepth();+++ /**+ * Set the next available depth in the timeline+ *+ *@param depth must be >= 1+ */+ public void setAvailableDepth(int depth);+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Transform.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Transform.javanew file mode 100644index 000000000..a2ad56b95--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Transform.java@@ -0,0 +1,139 @@+package pt.tumba.parser.swf;+++/**+ * A Transformation matrix that has translation coordinates in pixels+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class Transform extends Matrix {+ /**+ * Copy an existing matrix+ *+ *@param matrix Description of the Parameter+ */+ public Transform(Matrix matrix) {+ super(matrix);+ }+++ /**+ * An identity transform+ */+ public Transform() { }+++ /**+ * A transform that only translates+ *+ *@param translateX Description of the Parameter+ *@param translateY Description of the Parameter+ */+ public Transform(double translateX, double translateY) {+ super(translateX, translateY);+ }+++ /**+ * A transform that rotates and translates+ *+ *@param radians Description of the Parameter+ *@param translateX Description of the Parameter+ *@param translateY Description of the Parameter+ */+ public Transform(double radians, double translateX, double translateY) {+ this(radians, 1.0, 1.0, translateX, translateY);+ }+++ /**+ * A transform that scales and translates+ *+ *@param scaleX Description of the Parameter+ *@param scaleY Description of the Parameter+ *@param translateX Description of the Parameter+ *@param translateY Description of the Parameter+ */+ public Transform(double scaleX, double scaleY,+ double translateX, double translateY) {+ super(scaleX, scaleY, 0.0, 0.0, translateX, translateY);+ }+++ /**+ * A transform that rotates, scales and translates+ *+ *@param radians Description of the Parameter+ *@param scaleX Description of the Parameter+ *@param scaleY Description of the Parameter+ *@param translateX Description of the Parameter+ *@param translateY Description of the Parameter+ */+ public Transform(double radians,+ double scaleX, double scaleY,+ double translateX, double translateY) {+ super(scaleX * Math.cos(radians),+ scaleY * Math.cos(radians),+ Math.sin(radians),+ -Math.sin(radians),+ translateX, translateY);+ }+++ /**+ * Specify all the matrix components+ *+ *@param scaleX Description of the Parameter+ *@param scaleY Description of the Parameter+ *@param skew0 Description of the Parameter+ *@param skew1 Description of the Parameter+ *@param translateX Description of the Parameter+ *@param translateY Description of the Parameter+ */+ public Transform(double scaleX, double scaleY,+ double skew0, double skew1,+ double translateX, double translateY) {+ super(scaleX, scaleY, skew0, skew1, translateX, translateY);+ }+++ /**+ * Gets the translateX attribute of the Transform object+ *+ *@return The translateX value+ */+ public double getTranslateX() {+ return translateX / (double) SWFConstants.TWIPS;+ }+++ /**+ * Gets the translateY attribute of the Transform object+ *+ *@return The translateY value+ */+ public double getTranslateY() {+ return translateY / (double) SWFConstants.TWIPS;+ }+++ /**+ * Sets the translateX attribute of the Transform object+ *+ *@param translateX The new translateX value+ */+ public void setTranslateX(double translateX) {+ this.translateX = translateX * (double) SWFConstants.TWIPS;+ }+++ /**+ * Sets the translateY attribute of the Transform object+ *+ *@param translateY The new translateY value+ */+ public void setTranslateY(double translateY) {+ this.translateY = translateY * (double) SWFConstants.TWIPS;+ }+}diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/XMLWriter.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/XMLWriter.javanew file mode 100644index 000000000..34582e072--- /dev/null+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/XMLWriter.java@@ -0,0 +1,226 @@+package pt.tumba.parser.swf;++import java.io.IOException;+import java.io.OutputStream;+import java.io.PrintWriter;+import java.io.Writer;++import org.xml.sax.Attributes;+import org.xml.sax.SAXException;++/**+ * Write XML text to an output stream+ *+ *@author unknown+ *@created 15 de Setembro de 2002+ */+public class XMLWriter extends SaxHandlerBase {+ /**+ * Description of the Field+ */+ protected Writer out;+ /**+ * Description of the Field+ */+ protected boolean started = false;+++ /**+ * Constructor for the XMLWriter object+ *+ *@param outstream Description of the Parameter+ */+ public XMLWriter(OutputStream outstream) {+ out = new PrintWriter(outstream);+ }+++ /**+ * Constructor for the XMLWriter object+ *+ *@param writer Description of the Parameter+ */+ public XMLWriter(PrintWriter writer) {+ out = writer;+ }+++ /**+ * Description of the Method+ *+ *@exception SAXException Description of the Exception+ */+ public void startDocument() throws SAXException {+ try {+ out.write("<?xml version='1.0'?>");+ } catch (IOException ioe) {+ throw new SAXException(ioe);+ }+ }+++ /**+ * Description of the Method+ *+ *@exception SAXException Description of the Exception+ */+ public void endDocument() throws SAXException {+ try {+ out.flush();+ } catch (IOException ioe) {+ throw new SAXException(ioe);+ }+ }+++ /**+ * Description of the Method+ *+ *@exception IOException Description of the Exception+ */+ protected void completeElement() throws IOException {+ if (!started) {+ return;+ }++ out.write(" >");+ started = false;+ }+++ /**+ * Description of the Method+ *+ *@param chars Description of the Parameter+ *@param start Description of the Parameter+ *@param length Description of the Parameter+ *@return Description of the Return Value+ */+ public static String normalize(char[] chars, int start, int length) {+ StringBuffer buff = new StringBuffer();++ for (int i = start; i < start + length; i++) {+ char c = chars[i];++ switch (c) {+ case '\'':+ buff.append("'");+ break;+ case '"':+ buff.append(""");+ break;+ case '&':+ buff.append("&");+ break;+ case '<':+ buff.append("<");+ break;+ case '>':+ buff.append(">");+ break;+ default:+ buff.append(""+c);+ break;+ }+ }++ return buff.toString();+ }+++ /**+ * Description of the Method+ *+ *@param namespaceURI Description of the Parameter+ *@param localName Description of the Parameter+ *@param qName Description of the Parameter+ *@param atts Description of the Parameter+ *@exception SAXException Description of the Exception+ */+ public void startElement(String namespaceURI, String localName,+ String qName, Attributes atts)+ throws SAXException {+ try {+ completeElement();+ started = true;++ out.write("<" + qName);++ if (atts != null) {+ int count = atts.getLength();++ for (int i = 0; i < count; i++) {+ String name = atts.getQName(i);+ String value = atts.getValue(i);++ out.write(" " + name + "='" ++ normalize(value.toCharArray(), 0, value.length())+ + "'");+ }+ }+ } catch (IOException ioe) {+ throw new SAXException(ioe);+ }+ }+++ /**+ * Description of the Method+ *+ *@param namespaceURI Description of the Parameter+ *@param localName Description of the Parameter+ *@param qName Description of the Parameter+ *@exception SAXException Description of the Exception+ */+ public void endElement(String namespaceURI, String localName, String qName)+ throws SAXException {+ try {+ if (started) {+ out.write(" />");+ } else {+ out.write("</" + qName + ">");+ }+ started = false;+ } catch (IOException ioe) {+ throw new SAXException(ioe);+ }+ }+++ /**+ * Description of the Method+ *+ *@param ch Description of the Parameter+ *@param start Description of the Parameter+ *@param length Description of the Parameter+ *@exception SAXException Description of the Exception+ */+ public void characters(char ch[], int start, int length)+ throws SAXException {+ try {+ completeElement();+ out.write(normalize(ch, start, length));+ } catch (IOException ioe) {+ throw new SAXException(ioe);+ }+ }+++ /**+ * Description of the Method+ *+ *@param target Description of the Parameter+ *@param data Description of the Parameter+ *@exception SAXException Description of the Exception+ */+ public void processingInstruction(String target, String data)+ throws SAXException {+ try {+ completeElement();+ out.write("<?" + target + " " + data + "?>");+ } catch (IOException ioe) {+ throw new SAXException(ioe);+ }+ }++}diff --git a/libbuild/pom.xml b/libbuild/pom.xmlindex 9482fa501..0ffe00837 100644--- a/libbuild/pom.xml+++ b/libbuild/pom.xml@@ -18,6 +18,7 @@<modules><module>GitRevMavenTask</module>+ <module>WebCat-swf</module><!-- hack to include YaCy as module<module>..</module>-->