diff options
| author | Thomas Koch <thomas@koch.ro> | 2022-07-10 09:43:03 +0000 |
|---|---|---|
| committer | Thomas Koch <thomas@koch.ro> | 2022-07-10 12:33:28 +0000 |
| commit | c98d09b664fe2a6f69b99f035a73c4d78e16c7db (patch) | |
| tree | 9cc95c7199ed4a57244a781125118173179b3d7d | |
| parent | 3116713672bbcf6aec50439537e451646bc9a11a (diff) | |
rm GitRevTask
The releaseNr is now set to a static value in build.properties. We
can increment it there manually and eventually switch to another
version number scheme if we like.
70 files changed, 414 insertions, 20624 deletions
diff --git a/build.properties b/build.properties index c2438f437..bf18d35c9 100644 --- a/build.properties +++ b/build.properties @@ -4,6 +4,7 @@ javacTarget=1.8 # Release Configuration
releaseVersion=1.925
+releaseNr=9749
stdReleaseFile=yacy_v${releaseVersion}_${releaseNr}.tar.gz
releaseFileParentDir=yacy
privateKeyFile=private.key
@@ -54,9 +54,6 @@ <property name="defaults" location="defaults"/> <property name="RDFaParser" location="RDFaParser"/> - <!-- pseudo default releaseNr as fallback --> - <property name="releaseNr" value="9000" /> - <!-- defining all needed directory names for packing search widget--> <property name="jquery" location="htroot/jquery/"/> <property name="portalsearch" location="htroot/portalsearch/"/> @@ -97,44 +94,12 @@ --> <ivy:retrieve conf="compile" pathid="compile.path" pattern="${ivy.lib.dir}/[artifact]-[revision].[ext]" /> <ivy:retrieve conf="test" pathid="test.path" pattern="${libt}/[artifact]-[revision].[ext]" /> - <ivy:retrieve conf="libbuild" pathid="libbuild.path" pattern="${libbuild}/[artifact]-[revision].[ext]" /> <property name="target-resolve-already-run" value="true" /> </target> - <target name="buildGitRevTask" depends="resolve"> - <!-- <delete file="${libbuild}/GitRevTask.jar" failonerror="false" /> deleted via clean no need to do it all the time --> - <javac srcdir="${libbuild}/GitRevTask" includeantruntime="true" encoding="UTF-8" classpathref="libbuild.path"> - </javac> - <jar destfile="${libbuild}/GitRevTask.jar" basedir="${libbuild}/GitRevTask"> - <manifest> - <attribute name="Main-Class" value="GitRevTask"/> - </manifest> - </jar> - </target> - - <target name="determineGitRevision" if="isGit" depends="buildGitRevTask"> - <taskdef resource="GitRevTask.properties"> - <classpath> - <pathelement location="${libbuild}/GitRevTask.jar" /> - <pathelement location="${libbuild}/org.eclipse.jgit-4.5.0.201609210915-r.jar" /> - <!-- Next are the jgit dependencies --> - <pathelement location="${libbuild}/httpclient-4.3.6.jar" /> - <pathelement location="${libbuild}/JavaEWAH-0.7.9.jar" /> - <pathelement location="${libbuild}/jsch-0.1.53.jar" /> - <pathelement location="${libbuild}/slf4j-api-1.7.2.jar" /> - </classpath> - </taskdef> - <gitRev repoPath="${yacyroot}" branchprop="branch" revprop="releaseNr" dateprop="DSTAMP" /> - </target> - - <!-- reading the build properties from file --> - <target name="readBuildProperties" depends="determineGitRevision"> - <!-- loading some property values from file --> - <loadproperties srcFile="build.properties" /> - </target> - <!-- initializing all needed variables --> - <target name="init" depends="readBuildProperties"> + <target name="init"> + <loadproperties srcFile="build.properties" /> <mkdir dir="${data}"/> <mkdir dir="${release}"/> @@ -242,13 +207,6 @@ includes="**/*"/> </copy> - <!-- copy build libs --> - <copy todir="${release_main}/libbuild"> - <fileset dir="${libbuild}" - includes="**/*" - excludes="**/target/**"/> - </copy> - <!-- copy configuration files --> <copy todir="${release_main}"> <fileset dir="."> @@ -442,16 +400,11 @@ <delete dir="${release_main}" failonerror="false"/> <delete file="${build}/log4j.properties" failonerror="false"/> <delete file="${lib}/yacycore.jar" failonerror="false"/> - <delete file="${lib}/svnRevNr.jar" failonerror="false"/> <!-- @TODO: obsolete, never generated --> - <delete file="${libbuild}/svnRevNr.jar" failonerror="false"/> <!-- @TODO: obsolete, never generated --> - <delete file="${libbuild}/GitRevTask.jar" failonerror="false"/> <delete failonerror="false"> <fileset dir="${src}" includes="**/*.class" /> <fileset dir="${build}" includes="**/*.class" /> <fileset dir="${htroot}" includes="**/*.class" /> <fileset dir="test/" includes="**/*.class" /> - <fileset dir="${libbuild}/svnRevNr" includes="**/*.class" /> <!-- @TODO: obsolete, never generated --> - <fileset dir="${libbuild}/GitRevTask" includes="**/*.class" /> <fileset dir="." includes="TEST-*" /> </delete> <delete dir="test/DATA" failonerror="false"/> diff --git a/gitbuildnumber.properties b/gitbuildnumber.properties deleted file mode 100644 index 05ee0c4c8..000000000 --- a/gitbuildnumber.properties +++ /dev/null @@ -1,7 +0,0 @@ -# -#Wed Jan 26 14:44:44 CET 2022 -DSTAMP=20220126 -branch= -REPL_REVISION_NR=10210 -releaseNr=10210 -REPL_DATE=20220126 @@ -4,7 +4,6 @@ <!-- https://wrongnotes.blogspot.com/2014/02/simplest-explanation-of-ivy.html --> <conf name="compile" visibility="public"/> <conf name="test" visibility="public"/> - <conf name="libbuild" visibility="public"/> </configurations> <dependencies defaultconf="compile->default"> <dependency org="commons-fileupload" name="commons-fileupload" rev="1.4" conf="compile->master" /> @@ -101,11 +100,5 @@ <dependency org="org.hamcrest" name="hamcrest" rev="2.2" conf="test->default"/> <dependency org="org.hamcrest" name="hamcrest-core" rev="2.2" conf="test->default"/> <dependency org="org.hamcrest" name="hamcrest-library" rev="2.2" conf="test->default"/> - - <dependency org="com.googlecode.javaewah" name="JavaEWAH" rev="0.7.9" conf="libbuild->master"/> - <dependency org="com.jcraft" name="jsch" rev="0.1.53" conf="libbuild->master"/> - <dependency org="org.apache.httpcomponents" name="httpclient" rev="4.3.6" conf="libbuild->master"/> - <dependency org="org.eclipse.jgit" name="org.eclipse.jgit" rev="4.5.0.201609210915-r" conf="libbuild->master"/> - <dependency org="org.slf4j" name="slf4j-api" rev="1.7.2" conf="libbuild->master"/> </dependencies> </ivy-module> diff --git a/libbuild/GitComInf-1.0-all.jar b/libbuild/GitComInf-1.0-all.jar Binary files differdeleted file mode 100644 index c89d199cd..000000000 --- a/libbuild/GitComInf-1.0-all.jar +++ /dev/null diff --git a/libbuild/GitComInf/.gitattributes b/libbuild/GitComInf/.gitattributes deleted file mode 100644 index 00a51aff5..000000000 --- a/libbuild/GitComInf/.gitattributes +++ /dev/null @@ -1,6 +0,0 @@ -# -# https://help.github.com/articles/dealing-with-line-endings/ -# -# These are explicitly windows files and should use crlf -*.bat text eol=crlf - diff --git a/libbuild/GitComInf/src/main/java/GitComInf.java b/libbuild/GitComInf/src/main/java/GitComInf.java deleted file mode 100644 index 5a14c3595..000000000 --- a/libbuild/GitComInf/src/main/java/GitComInf.java +++ /dev/null @@ -1,150 +0,0 @@ - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.api.errors.GitAPIException; -import org.eclipse.jgit.lib.ObjectId; -import org.eclipse.jgit.lib.Ref; -import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.revwalk.RevCommit; -import org.eclipse.jgit.revwalk.RevWalk; -import org.eclipse.jgit.storage.file.FileRepositoryBuilder; - -public class GitComInf extends Properties { - - final private String BRANCHPROP_LABEL = "branch"; - final private String REVPROP_LABEL = "releaseNr"; // git commit number - final private String DATEPROP_LABEL = "DSTAMP"; // git commit date - private String repoPath; // path to repository root directory - - public void setRepoPath(final String repoPath) { - this.repoPath = repoPath; - } - - public void execute() { - - String branch = null; - String revision = null; - String commitDate = null; - - Repository repo = null; - Git git = null; - RevWalk walk = null; - Ref lastTag = null; - - try { - final File src = new File(this.repoPath); - repo = new FileRepositoryBuilder().readEnvironment() - .findGitDir(src).build(); - - branch = repo.getBranch(); - branch = "master".equals(branch) ? "" : "_" + branch; - this.setProperty(this.BRANCHPROP_LABEL, branch); - final ObjectId head = repo.resolve("HEAD"); - - git = new Git(repo); - final List<Ref> tags = git.tagList().call(); - - walk = new RevWalk(repo); - final RevCommit headCommit = walk.parseCommit(head); - final SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd"); - commitDate = df.format(headCommit.getAuthorIdent().getWhen()); - walk.markStart(headCommit); - int distance = 0; - - /* Peel known tags */ - final List<Ref> peeledTags = new ArrayList<>(); - for (final Ref tag : tags) { - lastTag = tag; - } - - /* Look for the last tag commit and calculate distance with the HEAD commit */ - for (final RevCommit commit : walk) { - if (commit.equals(lastTag.getPeeledObjectId()) || commit.equals(lastTag.getObjectId())) { - break; - } - if (distance++ > 90999) { - break; - } - } - walk.dispose(); - if (lastTag == null) { - revision = "0000"; - } else { - revision = Integer.toString(distance + 9000); - } - - this.setProperty(this.BRANCHPROP_LABEL, branch); - this.setProperty(this.REVPROP_LABEL, revision); - this.setProperty("REPL_REVISION_NR", revision); - this.setProperty(this.DATEPROP_LABEL, commitDate); - this.setProperty("REPL_DATE", commitDate); - } catch (final IOException e) { - System.err.println(e.getMessage()); - } catch (GitAPIException e) { - System.err.println(e.getMessage()); - } catch (IllegalArgumentException e) { - System.err.println(e.getMessage()); - } finally { - /* In all cases, properly release resources */ - if (walk != null) { - walk.close(); - } - if (git != null) { - git.close(); - } - if (repo != null) { - repo.close(); - } - - } - } - - /** - * use: GitComInf.jar pathtoGitRepro outputfile gitbuildnumber.properties - * - * @param args = [0] path to Git repository (default . ) - * [1] (optional) = filename for result (default ./gitbuildnumber.properties) - */ - public static void main(String[] args) { - GitComInf gitRevTask = new GitComInf(); - if (args.length == 0) { - gitRevTask.setRepoPath("."); // path to root of git repository - } else { - gitRevTask.setRepoPath(args[0]); - } - gitRevTask.execute(); - if (gitRevTask.isEmpty()) { - System.err.println("no Git repository found" + (args.length == 0 ? " in " + System.getProperty("user.dir") : " in " + args[0])); - } else { - - System.out.println("Git Commit Info: " + gitRevTask.toString()); - - // output result to property file - File f; - if (args.length > 1) { - f = new File(args[1]); - if (!f.exists()) { - f.getParentFile().mkdirs(); // just make sure missing dir is not a problem - } - } else { - f = new File("gitbuildnumber.properties"); - } - try { - f.createNewFile(); - FileWriter w = new FileWriter(f); - gitRevTask.store(w, ""); - w.close(); - } catch (final IOException ex) { - System.out.println(ex.toString()); - System.out.println(args[1]); - } - } - } -} diff --git a/libbuild/GitRevTask/GitRevTask.java b/libbuild/GitRevTask/GitRevTask.java deleted file mode 100644 index 5df9021e9..000000000 --- a/libbuild/GitRevTask/GitRevTask.java +++ /dev/null @@ -1,172 +0,0 @@ -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; - -import org.apache.tools.ant.Project; - -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.api.errors.GitAPIException; -import org.eclipse.jgit.lib.ObjectId; -import org.eclipse.jgit.lib.Ref; -import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.revwalk.RevCommit; -import org.eclipse.jgit.revwalk.RevWalk; -import org.eclipse.jgit.storage.file.FileRepositoryBuilder; - - -public class GitRevTask extends org.apache.tools.ant.Task { - - private String repoPath; - private String branchprop; - private String revprop; - private String dateprop; - - public void setRepoPath(final String repoPath) { - this.repoPath = repoPath; - } - - public void setBranchprop(final String branchprop) { - this.branchprop = branchprop; - } - - public void setRevprop(final String revprop) { - this.revprop = revprop; - } - - public void setDateprop(final String dateprop) { - this.dateprop = dateprop; - } - - public void execute() { - if (this.revprop==null || this.revprop.isEmpty()) { - log("git entries file name revprop was not set properly",Project.MSG_ERR); - return; - } - if (this.dateprop==null || this.dateprop.isEmpty()) { - log("git entries file name dateprop was not set properly",Project.MSG_ERR); - return; - } - - String branch = null; - String revision = null; - String lastTag = null; - String commitDate = null; - - Repository repo = null; - Git git = null; - RevWalk walk = null; - try { - final File src = new File(repoPath); - repo = new FileRepositoryBuilder().readEnvironment() - .findGitDir(src).build(); - branch = repo.getBranch(); - branch = "master".equals(branch)? "" : "_" + branch; - final ObjectId head = repo.resolve("HEAD"); - - git = new Git(repo); - final List<Ref> tags = git.tagList().call(); - - walk = new RevWalk(repo); - final RevCommit headCommit = walk.parseCommit(head); - final SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd"); - commitDate = df.format(headCommit.getAuthorIdent().getWhen()); - walk.markStart(headCommit); - int distance = 0; - - /* Peel known tags */ - final List<Ref> peeledTags = new ArrayList<>(); - for(final Ref tag : tags) { - peeledTags.add(repo.peel(tag)); - } - - /* Look for the last tag commit and calculate distance with the HEAD commit */ - for (final RevCommit commit : walk) { - for (final Ref tag : peeledTags) { - if (commit.equals(tag.getPeeledObjectId()) || commit.equals(tag.getObjectId())) { - lastTag = commit.getShortMessage(); - break; - } - } - if (lastTag != null || distance++ > 90999) { - break; - } - } - walk.dispose(); - if (lastTag == null) { - revision = "0000"; - } else { - revision = Integer.toString(distance + 9000); - } - } catch (final IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (GitAPIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - /* In all cases, properly release resources */ - if(walk != null) { - walk.close(); - } - if(git != null) { - git.close(); - } - if(repo != null) { - repo.close(); - } - } - - Project theProject = getProject(); - if (theProject != null) { - theProject.setProperty(this.branchprop, branch); - log("Property '" + this.branchprop + "' set to '" + branch + "'", Project.MSG_VERBOSE); - theProject.setProperty(this.revprop, revision); - log("Property '" + this.revprop + "' set to '" + revision + "'", Project.MSG_VERBOSE); - theProject.setProperty(this.dateprop, commitDate); - log("Property '" + this.dateprop + "' set to '" + commitDate + "'", Project.MSG_VERBOSE); - } - } - - /** use: GitRevTask.jar pathtoGitRepro outputfile - * optional parameter - * 1st parameter = path to Git repository (default ..) - * 2nd parameter = ouputfile (default gitbuild.properties) - * */ - public static void main(String[] args) { - GitRevTask gitRevTask = new GitRevTask(); - if (args.length == 0) { - gitRevTask.setRepoPath(".."); // path to root of git repository - } else { - gitRevTask.setRepoPath(args[0]); - } - gitRevTask.setBranchprop("branch"); - gitRevTask.setRevprop("baseRevisionNr"); - gitRevTask.setDateprop("DSTAMP"); - - Project p = new Project(); - gitRevTask.setProject(p); - gitRevTask.execute(); - String branch = gitRevTask.getProject().getProperty("branch"); - String version = gitRevTask.getProject().getProperty("baseRevisionNr"); - String commitDate = gitRevTask.getProject().getProperty("DSTAMP"); - - File f; - if (args.length > 1) { - f = new File (args[1]); - } else { - f = new File("gitbuildnumber.properties"); - } - try { - f.createNewFile(); - FileWriter w = new FileWriter(f); - w.append("branch=" + branch + "\n"); - w.append("releaseNr=" + version + "\n"); - w.append("DSTAMP=" + commitDate + "\n"); - w.close(); - - } catch (final IOException ex) {} - } -} diff --git a/libbuild/GitRevTask/GitRevTask.properties b/libbuild/GitRevTask/GitRevTask.properties deleted file mode 100644 index 13effd982..000000000 --- a/libbuild/GitRevTask/GitRevTask.properties +++ /dev/null @@ -1 +0,0 @@ -gitRev=GitRevTask
\ No newline at end of file diff --git a/libbuild/J7Zip-modified/build.gradle b/libbuild/J7Zip-modified/build.gradle new file mode 100644 index 000000000..3599cb594 --- /dev/null +++ b/libbuild/J7Zip-modified/build.gradle @@ -0,0 +1,72 @@ + +plugins { + id 'java-library' + id 'maven-publish' +} + +/** Port of older support library to be build with Gradle +previous Maven Info + <groupId>net.yacy.extlib</groupId> + <artifactId>J7Zip-modified</artifactId> + <packaging>jar</packaging> + <version>1.02</version> + <description>J7Zip library for YaCy sevenzipParser (not available in external maven repository)</description> +*/ + +sourceSets { + main { + java { + srcDirs = ['src'] + } + } +} + +version = '1.0.2' +group = 'net.yacy.extlib' + +publishing { + publications { + mavenJava(MavenPublication) { + artifactId = 'J7Zip-modified' + from components.java + versionMapping { + usage('java-api') { + fromResolutionOf('runtimeClasspath') + } + usage('java-runtime') { + fromResolutionResult() + } + } + pom { + name = 'J7Zip' + description = 'J7Zip library for YaCy sevenzipParser (not available in external maven repository)' + licenses { + license { + name = 'GNU Lesser General Public License 2.1' + url = 'http://www.gnu.org/licenses/lgpl-2.1.txt' + } + } + scm { + connection = 'scm:git:https://github.com/yacy/yacy_search_server.git' + url = 'https://github.com/yacy/yacy_search_server' + } + } + } + } + repositories { + maven { + // change URLs to point to your repos, e.g. http://my.org/repo + def releasesRepoUrl = layout.buildDirectory.dir('repos/releases') + } + } +} + +// copy jar to yacycore /lib directory (used as dependencies) +task installJarToRoot (type: Copy, dependsOn: jar) { + from jar.archiveFile + into "${projectDir.getParent()}/../lib" + doLast { + logger.lifecycle ("copied jar to ${projectDir.getParent()}/../lib/" + jar.archiveFileName.get()) + } +} + diff --git a/libbuild/J7Zip-modified/gradle/wrapper/gradle-wrapper.jar b/libbuild/J7Zip-modified/gradle/wrapper/gradle-wrapper.jar Binary files differnew file mode 100644 index 000000000..7454180f2 --- /dev/null +++ b/libbuild/J7Zip-modified/gradle/wrapper/gradle-wrapper.jar diff --git a/libbuild/J7Zip-modified/gradle/wrapper/gradle-wrapper.properties b/libbuild/J7Zip-modified/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..e750102e0 --- /dev/null +++ b/libbuild/J7Zip-modified/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/libbuild/J7Zip-modified/gradlew b/libbuild/J7Zip-modified/gradlew new file mode 100644 index 000000000..c53aefaa5 --- /dev/null +++ b/libbuild/J7Zip-modified/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/libbuild/J7Zip-modified/gradlew.bat b/libbuild/J7Zip-modified/gradlew.bat new file mode 100644 index 000000000..107acd32c --- /dev/null +++ b/libbuild/J7Zip-modified/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/libbuild/J7Zip-modified/settings.gradle b/libbuild/J7Zip-modified/settings.gradle new file mode 100644 index 000000000..6ba1b9c00 --- /dev/null +++ b/libbuild/J7Zip-modified/settings.gradle @@ -0,0 +1,11 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * The settings file is used to specify which projects to include in your build. + * + * Detailed information about configuring a multi-project build in Gradle can be found + * in the user manual at https://docs.gradle.org/7.3/userguide/multi_project_builds.html + */ + +rootProject.name = 'J7Zip-modified' + diff --git a/libbuild/WebCat-swf/.gitignore b/libbuild/WebCat-swf/.gitignore deleted file mode 100755 index b83d22266..000000000 --- a/libbuild/WebCat-swf/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target/ diff --git a/libbuild/WebCat-swf/JavaSWF2-BSD.LICENSE.txt b/libbuild/WebCat-swf/JavaSWF2-BSD.LICENSE.txt deleted file mode 100644 index b80d4ac6d..000000000 --- a/libbuild/WebCat-swf/JavaSWF2-BSD.LICENSE.txt +++ /dev/null @@ -1,33 +0,0 @@ -
- Copyright (c) 2001, David N. Main, All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, are permitted provided that the
- following conditions are met:
-
- 1. Redistributions of source code must retain the above
- copyright notice, this list of conditions and the following
- disclaimer.
-
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- 3. The name of the author may not be used to endorse or
- promote products derived from this software without specific
- prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
diff --git a/libbuild/WebCat-swf/pom.xml b/libbuild/WebCat-swf/pom.xml deleted file mode 100644 index a1b262fab..000000000 --- a/libbuild/WebCat-swf/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ -<?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-swf</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> <!-- WebCat --> - </developer> - <developer> - <name>David N. Main</name> <!-- JavaSWF2 --> - <url>http://anotherbigidea.com/</url> - </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> - <dependencies> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-compress</artifactId> - <version>1.20</version> - <type>jar</type> - </dependency> - <dependency> - <groupId>org.tukaani</groupId> - <artifactId>xz</artifactId> - <version>1.8</version> - <type>jar</type> - </dependency> - <dependency> - <groupId>com.adobe.xmp</groupId> - <artifactId>xmpcore</artifactId> - <version>5.1.2</version> - <type>jar</type> - </dependency> - </dependencies> -</project>
\ No newline at end of file diff --git a/libbuild/WebCat-swf/readme.txt b/libbuild/WebCat-swf/readme.txt deleted file mode 100644 index 232f5ddab..000000000 --- a/libbuild/WebCat-swf/readme.txt +++ /dev/null @@ -1,53 +0,0 @@ -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/com/anotherbigidea/flash/SWFActionCodes.java b/libbuild/WebCat-swf/src/com/anotherbigidea/flash/SWFActionCodes.java deleted file mode 100644 index 5cbf9ab15..000000000 --- a/libbuild/WebCat-swf/src/com/anotherbigidea/flash/SWFActionCodes.java +++ /dev/null @@ -1,194 +0,0 @@ -/****************************************************************
- * Copyright (c) 2001, David N. Main, All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the
- * following conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * 3. The name of the author may not be used to endorse or
- * promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- ****************************************************************/
-package com.anotherbigidea.flash;
-
-/**
- * Action Codes and associated constants
- */
-public interface SWFActionCodes
-{
- public static final int NEXT_FRAME = 0x04; //F3 ***
- public static final int PREVIOUS_FRAME = 0x05; //F3 ***
- public static final int PLAY = 0x06; //F3 ***
- public static final int STOP = 0x07; //F3 ***
- public static final int TOGGLE_QUALITY = 0x08; //F3 ***
- public static final int STOP_SOUNDS = 0x09; //F3 ***
- public static final int ADD = 0x0a; //F4
- public static final int SUBTRACT = 0x0b; //F4
- public static final int MULTIPLY = 0x0c; //F4
- public static final int DIVIDE = 0x0d; //F4
- public static final int EQUALS = 0x0e; //F4
- public static final int LESS = 0x0f; //F4
- public static final int AND = 0x10; //F4
- public static final int OR = 0x11; //F4
- public static final int NOT = 0x12; //F4
- public static final int STRING_EQUALS = 0x13; //F4
- public static final int STRING_LENGTH = 0x14; //F4
- public static final int STRING_EXTRACT = 0x15; //F4
-
- public static final int POP = 0x17; //F4
- public static final int TO_INTEGER = 0x18; //F4
-
- public static final int GET_VARIABLE = 0x1c; //F4
- public static final int SET_VARIABLE = 0x1d; //F4
-
- public static final int SET_TARGET_2 = 0x20; //F4
- public static final int STRING_ADD = 0x21; //F4
- public static final int GET_PROPERTY = 0x22; //F4
- public static final int SET_PROPERTY = 0x23; //F4
- public static final int CLONE_SPRITE = 0x24; //F4
- public static final int REMOVE_SPRITE = 0x25; //F4
- public static final int TRACE = 0x26; //F4
- public static final int START_DRAG = 0x27; //F4
- public static final int END_DRAG = 0x28; //F4
- public static final int STRING_LESS = 0x29; //F4
-
- public static final int RANDOM_NUMBER = 0x30; //F4
- public static final int MB_STRING_LENGTH = 0x31; //F4
- public static final int CHAR_TO_ASCII = 0x32; //F4
- public static final int ASCII_TO_CHAR = 0x33; //F4
- public static final int GET_TIME = 0x34; //F4
- public static final int MB_STRING_EXTRACT = 0x35; //F4
- public static final int MB_CHAR_TO_ASCII = 0x36; //F4
- public static final int MB_ASCII_TO_CHAR = 0x37; //F4
-
- public static final int DEL_VAR = 0x3a; //F5 ---
- public static final int DEL_THREAD_VARS = 0x3b; //F5 ---
- public static final int DEFINE_LOCAL_VAL = 0x3c; //F5 ---
- public static final int CALL_FUNCTION = 0x3d; //F5 ---
- public static final int RETURN = 0x3e; //F5 ---
- public static final int MODULO = 0x3f; //F5 ---
- public static final int NEW_OBJECT = 0x40; //F5 ---
- public static final int DEFINE_LOCAL = 0x41; //F5 ---
- public static final int INIT_ARRAY = 0x42; //F5 ---
- public static final int INIT_OBJECT = 0x43; //F5 ---
- public static final int TYPEOF = 0x44; //F5 ---
- public static final int GET_TARGET_PATH = 0x45; //F5 ---
- public static final int ENUMERATE = 0x46; //F5 ---
- public static final int TYPED_ADD = 0x47; //F5 ---
- public static final int TYPED_LESS_THAN = 0x48; //F5 ---
- public static final int TYPED_EQUALS = 0x49; //F5 ---
- public static final int CONVERT_TO_NUMBER = 0x4a; //F5 ---
- public static final int CONVERT_TO_STRING = 0x4b; //F5 ---
- public static final int DUPLICATE = 0x4c; //F5 ---
- public static final int SWAP = 0x4d; //F5 ---
- public static final int GET_MEMBER = 0x4e; //F5 ---
- public static final int SET_MEMBER = 0x4f; //F5 ---
- public static final int INCREMENT = 0x50; //F5 ---
- public static final int DECREMENT = 0x51; //F5 ---
- public static final int CALL_METHOD = 0x52; //F5 ---
- public static final int CALL_NEW_METHOD = 0x53; //F5 ---
- public static final int INSTANCE_OF = 0x54; //MX <<<
- public static final int ENUMERATE_OBJECT = 0x55; //MX <<<
-
- public static final int BIT_AND = 0x60; //F5 ---
- public static final int BIT_OR = 0x61; //F5 ---
- public static final int BIT_XOR = 0x62; //F5 ---
- public static final int SHIFT_LEFT = 0x63; //F5 ---
- public static final int SHIFT_RIGHT = 0x64; //F5 ---
- public static final int SHIFT_UNSIGNED = 0x65; //F5 ---
- public static final int STRICT_EQUALS = 0x66; //MX <<<
- public static final int GREATER = 0x67; //MX <<<
- public static final int STRING_GREATER = 0x68; //MX <<<
-
- public static final int GOTO_FRAME = 0x81; //F3 ***
-
- public static final int GET_URL = 0x83; //F3 ***
-
- public static final int REGISTER = 0x87; //F5 ---
- public static final int LOOKUP_TABLE = 0x88; //F5 ---
-
- public static final int WAIT_FOR_FRAME = 0x8a; //F3 ***
- public static final int SET_TARGET = 0x8b; //F3 ***
- public static final int GOTO_LABEL = 0x8c; //F3 ***
- public static final int WAIT_FOR_FRAME_2 = 0x8d; //F4
-
- public static final int WITH = 0x94; //F5 ---
-
- public static final int PUSH = 0x96; //F4
-
- public static final int JUMP = 0x99; //F4
- public static final int GET_URL_2 = 0x9a; //F4
- public static final int DEFINE_FUNCTION = 0x9b; //F5 ---
-
- public static final int IF = 0x9d; //F4
- public static final int CALL = 0x9e; //F4
- public static final int GOTO_FRAME_2 = 0x9f; //F4
-
- //--Property Constants
- public static final int PROP_X = 0;
- public static final int PROP_Y = 1;
- public static final int PROP_XSCALE = 2;
- public static final int PROP_YSCALE = 3;
- public static final int PROP_CURRENTFRAME = 4;
- public static final int PROP_TOTALFRAMES = 5;
- public static final int PROP_ALPHA = 6;
- public static final int PROP_VISIBLE = 7;
- public static final int PROP_WIDTH = 8;
- public static final int PROP_HEIGHT = 9;
- public static final int PROP_ROTATION = 10;
- public static final int PROP_TARGET = 11;
- public static final int PROP_FRAMESLOADED = 12;
- public static final int PROP_NAME = 13;
- public static final int PROP_DROPTARGET = 14;
- public static final int PROP_URL = 15;
- public static final int PROP_HIGHQUALITY = 16;
- public static final int PROP_FOCUSRECT = 17;
- public static final int PROP_SOUNDBUFTIME = 18;
- public static final int PROP_QUALITY = 19; //flash 5 only
- public static final int PROP_XMOUSE = 20; //flash 5 only
- public static final int PROP_YMOUSE = 21; //flash 5 only
-
-
- //--TypeOf Strings (from the ActionScript typeof() operator)
- public static final String TYPEOF_NUMBER = "number";
- public static final String TYPEOF_BOOLEAN = "boolean";
- public static final String TYPEOF_STRING = "string";
- public static final String TYPEOF_OBJECT = "object";
- public static final String TYPEOF_MOVIECLIP = "movieclip";
- public static final String TYPEOF_NULL = "null";
- public static final String TYPEOF_UNDEFINED = "undefined";
- public static final String TYPEOF_FUNCTION = "function";
-
- //--Types for Flash 5 push action
- public static final int PUSHTYPE_STRING = 0;
- public static final int PUSHTYPE_FLOAT = 1;
- public static final int PUSHTYPE_NULL = 2;
- public static final int PUSHTYPE_03 = 3; //unknown
- public static final int PUSHTYPE_REGISTER = 4;
- public static final int PUSHTYPE_BOOLEAN = 5;
- public static final int PUSHTYPE_DOUBLE = 6;
- public static final int PUSHTYPE_INTEGER = 7;
- public static final int PUSHTYPE_LOOKUP = 8;
-}
diff --git a/libbuild/WebCat-swf/src/com/anotherbigidea/flash/SWFConstants.java b/libbuild/WebCat-swf/src/com/anotherbigidea/flash/SWFConstants.java deleted file mode 100644 index bfb03b205..000000000 --- a/libbuild/WebCat-swf/src/com/anotherbigidea/flash/SWFConstants.java +++ /dev/null @@ -1,239 +0,0 @@ -/****************************************************************
- * Copyright (c) 2001, David N. Main, All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the
- * following conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * 3. The name of the author may not be used to endorse or
- * promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- ****************************************************************/
-package com.anotherbigidea.flash;
-
-/**
- * Various SWF Constant Values
- */
-public interface SWFConstants
-{
- public static final int TWIPS = 20; //number of TWIPS per pixel
-
- public static final int TAG_END = 0;
- public static final int TAG_SHOWFRAME = 1;
- public static final int TAG_DEFINESHAPE = 2;
- public static final int TAG_FREECHARACTER = 3;
- public static final int TAG_PLACEOBJECT = 4;
- public static final int TAG_REMOVEOBJECT = 5;
- public static final int TAG_DEFINEBITS = 6;
- public static final int TAG_DEFINEBUTTON = 7;
- public static final int TAG_JPEGTABLES = 8;
- public static final int TAG_SETBACKGROUNDCOLOR = 9;
- public static final int TAG_DEFINEFONT = 10;
- public static final int TAG_DEFINETEXT = 11;
- public static final int TAG_DOACTION = 12;
- public static final int TAG_DEFINEFONTINFO = 13;
- public static final int TAG_DEFINESOUND = 14;
- public static final int TAG_STARTSOUND = 15;
- //???
- public static final int TAG_DEFINEBUTTONSOUND = 17;
- public static final int TAG_SOUNDSTREAMHEAD = 18;
- public static final int TAG_SOUNDSTREAMBLOCK = 19;
- public static final int TAG_DEFINEBITSLOSSLESS = 20;
- public static final int TAG_DEFINEBITSJPEG2 = 21;
- public static final int TAG_DEFINESHAPE2 = 22;
- public static final int TAG_DEFINEBUTTONCXFORM = 23;
- public static final int TAG_PROTECT = 24;
- //???
- public static final int TAG_PLACEOBJECT2 = 26;
- //???
- public static final int TAG_REMOVEOBJECT2 = 28;
- //???
- public static final int TAG_DEFINESHAPE3 = 32;
- public static final int TAG_DEFINETEXT2 = 33;
- public static final int TAG_DEFINEBUTTON2 = 34;
- public static final int TAG_DEFINEBITSJPEG3 = 35;
- public static final int TAG_DEFINEBITSLOSSLESS2 = 36;
- public static final int TAG_DEFINETEXTFIELD = 37;
- public static final int TAG_DEFINEQUICKTIMEMOVIE = 38;
- public static final int TAG_DEFINESPRITE = 39;
- public static final int TAG_NAMECHARACTER = 40;
- public static final int TAG_SERIALNUMBER = 41;
- public static final int TAG_GENERATOR_TEXT = 42;
- public static final int TAG_FRAMELABEL = 43;
- //???
- public static final int TAG_SOUNDSTREAMHEAD2 = 45;
- public static final int TAG_DEFINEMORPHSHAPE = 46;
- //???
- public static final int TAG_DEFINEFONT2 = 48;
- public static final int TAG_TEMPLATECOMMAND = 49;
- //???
- public static final int TAG_FLASHGENERATOR = 51;
- public static final int TAG_GEN_EXTERNAL_FONT = 52;
- //???
- //???
- //???
- public static final int TAG_EXPORT = 56;
- public static final int TAG_IMPORT = 57;
- public static final int TAG_ENABLEDEBUG = 58;
- public static final int TAG_DOINITACTION = 59;
- public static final int TAG_DEFINEVIDEOSTREAM = 60;
- public static final int TAG_VIDEOFRAME = 61;
- public static final int TAG_DEFINEFONTINFO2 = 62;
- //???
- public static final int TAG_ENABLEDEBUGGER2 = 64;
- public static final int TAG_SCRIPTLIMITS = 65;
- public static final int TAG_SETTABINDEX = 66;
-
- public static final int TAG_FILEATTRIBUTES = 69;
- public static final int TAG_PLACEOBJECT3 = 70;
- public static final int TAG_IMPORTASSETS2 = 71;
-
- public static final int TAG_DEFINEFONTALIGNZONES = 73;
- public static final int TAG_CSMTEXTSETTINGS = 74;
- public static final int TAG_DEFINEFONT3 = 75;
- public static final int TAG_SYMBOLCLASS = 76;
- public static final int TAG_METADATA = 77;
- public static final int TAG_DEFINESCALINGGRID = 78;
-
- public static final int TAG_DOABC = 82;
- public static final int TAG_DEFINESHAPE4 = 83;
- public static final int TAG_DEFINEMORPHSHAPE2 = 84;
-
- public static final int TAG_DEFINESCENEANDFRAMELABELDATA = 86;
- public static final int TAG_DEFINEBINARYDATA = 87;
- public static final int TAG_DEFINEFONTNAME = 88;
- public static final int TAG_STARTSOUND2 = 89;
- public static final int TAG_DEFINEBITSJPEG4 = 90;
- public static final int TAG_DEFINEFONT4 = 91;
-
- public static final int TAG_ENABLETELEMETRY = 93;
-
- //--Fill Types
- public static final int FILL_SOLID = 0x00;
- public static final int FILL_LINEAR_GRADIENT = 0x10;
- public static final int FILL_RADIAL_GRADIENT = 0x12;
- public static final int FILL_TILED_BITMAP = 0x40;
- public static final int FILL_CLIPPED_BITMAP = 0x41;
-
- //--Clip Action Conditions
- public static final int CLIP_ACTION_ON_LOAD = 0x01;
- public static final int CLIP_ACTION_ENTER_FRAME = 0x02;
- public static final int CLIP_ACTION_UNLOAD = 0x04;
- public static final int CLIP_ACTION_MOUSE_MOVE = 0x08;
- public static final int CLIP_ACTION_MOUSE_DOWN = 0x10;
- public static final int CLIP_ACTION_MOUSE_UP = 0x20;
- public static final int CLIP_ACTION_KEY_DOWN = 0x40;
- public static final int CLIP_ACTION_KEY_UP = 0x80;
- public static final int CLIP_ACTION_DATA = 0x100;
-
- //--Font Info flags
- public static final int FONT_UNICODE = 0x20;
- public static final int FONT_SHIFTJIS = 0x10;
- public static final int FONT_ANSI = 0x08;
- public static final int FONT_ITALIC = 0x04;
- public static final int FONT_BOLD = 0x02;
- public static final int FONT_WIDECHARS = 0x01;
-
- //--DefineFont2 flags
- public static final int FONT2_HAS_LAYOUT = 0x80;
- public static final int FONT2_SHIFTJIS = 0x40;
- public static final int FONT2_UNICODE = 0x20;
- public static final int FONT2_ANSI = 0x10;
- public static final int FONT2_32OFFSETS = 0x08;
- public static final int FONT2_WIDECHARS = 0x04;
- public static final int FONT2_ITALIC = 0x02;
- public static final int FONT2_BOLD = 0x01;
-
- //--Text Field flags
- public static final int TEXTFIELD_HAS_LAYOUT = 0x2000; //author always sets this
- public static final int TEXTFIELD_NO_SELECTION = 0x1000;
- public static final int TEXTFIELD_DRAW_BORDER = 0x0800;
- public static final int TEXTFIELD_HTML = 0x0200;
- public static final int TEXTFIELD_FONT_GLYPHS = 0x0100;
- public static final int TEXTFIELD_HAS_TEXT = 0x0080;
- public static final int TEXTFIELD_WORD_WRAP = 0x0040;
- public static final int TEXTFIELD_IS_MULTILINE = 0x0020;
- public static final int TEXTFIELD_IS_PASSWORD = 0x0010;
- public static final int TEXTFIELD_DISABLE_EDIT = 0x0008;
- public static final int TEXTFIELD_HAS_TEXT_COLOR = 0x0004; //author always sets this
- public static final int TEXTFIELD_LIMIT_CHARS = 0x0002;
- public static final int TEXTFIELD_HAS_FONT = 0x0001; //author always sets this
-
- //--Text Field alignment
- public static final int TEXTFIELD_ALIGN_LEFT = 0;
- public static final int TEXTFIELD_ALIGN_RIGHT = 1;
- public static final int TEXTFIELD_ALIGN_CENTER = 2;
- public static final int TEXTFIELD_ALIGN_JUSTIFY = 3;
-
- //--Used by TagDefineText(2)..
- public static final int TEXT_HAS_FONT = 0x08;
- public static final int TEXT_HAS_COLOR = 0x04;
- public static final int TEXT_HAS_YOFFSET = 0x02;
- public static final int TEXT_HAS_XOFFSET = 0x01;
-
- //--Action Conditions for DefineButton2..
- public static final int BUTTON2_OVERDOWN2IDLE = 0x100;
- public static final int BUTTON2_IDLE2OVERDOWN = 0x080;
- public static final int BUTTON2_OUTDOWN2IDLE = 0x040;
- public static final int BUTTON2_OUTDOWN2OVERDOWN = 0x020;
- public static final int BUTTON2_OVERDOWN2OUTDOWN = 0x010;
- public static final int BUTTON2_OVERDOWN2OVERUP = 0x008;
- public static final int BUTTON2_OVERUP2OVERDOWN = 0x004;
- public static final int BUTTON2_OVERUP2IDLE = 0x002;
- public static final int BUTTON2_IDLE2OVERUP = 0x001;
-
- //--Formats for DefineBitsLossless..
- public static final int BITMAP_FORMAT_8_BIT = 3;
- public static final int BITMAP_FORMAT_16_BIT = 4;
- public static final int BITMAP_FORMAT_32_BIT = 5;
-
- //--Sound Constants..
- public static final int SOUND_FORMAT_RAW = 0;
- public static final int SOUND_FORMAT_ADPCM = 1;
- public static final int SOUND_FORMAT_MP3 = 2;
- public static final int SOUND_FORMAT_RAW_LITTLEENDIAN = 3;
- public static final int SOUND_FORMAT_NELLYMOSER = 6;
-
- public static final int SOUND_FREQ_5_5KHZ = 0; //5.5 kHz
- public static final int SOUND_FREQ_11KHZ = 1;
- public static final int SOUND_FREQ_22KHZ = 2;
- public static final int SOUND_FREQ_44KHZ = 3;
-
- //--Language Codes for DefineFontInfo2
- public static final int LANGUAGE_CODE_NONE = 0;
- public static final int LANGUAGE_CODE_LATIN = 1;
- public static final int LANGUAGE_CODE_JAPANESE = 2;
- public static final int LANGUAGE_CODE_KOREAN = 3;
- public static final int LANGUAGE_CODE_SIMPLIFIED_CHINESE = 4;
- public static final int LANGUAGE_CODE_TRADITIONAL_CHINESE = 5;
-
- //--String Encodings
- public static final String STRING_ENCODING_PRE_MX = "US-ASCII";
- public static final String STRING_ENCODING_MX = "UTF-8";
-
- //--MX Version number
- public static final int FLASH_MX_VERSION = 6;
-
-}
diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ActionParser.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ActionParser.java deleted file mode 100644 index 33b819fe9..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ActionParser.java +++ /dev/null @@ -1,667 +0,0 @@ -package pt.tumba.parser.swf; - -import com.anotherbigidea.flash.SWFActionCodes; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Stack; - -/** - * Parse action bytes and drive a SWFActions interface - * - *@author unknown - *@created 15 de Setembro de 2002 - */ -public class ActionParser implements SWFActionCodes { - - protected SWFActions actions; - 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; - public String label; - public String jumpLabel; - public byte[] data; - 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 { - List records = new ArrayList(); - List<ActionRecord> jumpers = new ArrayList(); - List<Integer> skippers = new ArrayList(); - HashMap offsetTable = new HashMap(); - - 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.add(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.add(new Integer(records.size() - 1)); - } else if (code == IF || code == JUMP) { - jumpers.add(rec); - } - } - - //--Tie up the jumpers with the offsets - for (ActionRecord rec : jumpers) { - - 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 (Integer idx : skippers) { - - ActionRecord rec = (ActionRecord) records.get(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.get(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.java deleted file mode 100644 index ef737affc..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ActionTextWriter.java +++ /dev/null @@ -1,1209 +0,0 @@ -package pt.tumba.parser.swf; - -import com.anotherbigidea.flash.SWFActionCodes; -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.java deleted file mode 100644 index 2df453581..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ActionWriter.java +++ /dev/null @@ -1,1497 +0,0 @@ -package pt.tumba.parser.swf; - -import com.anotherbigidea.flash.SWFActionCodes; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Stack; - -/** - * 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 { - - protected TagWriter tagWriter; - protected OutStream out; - protected ByteArrayOutputStream bout; - protected int count; - protected int flashVersion; - - protected List pushValues; - - protected HashMap labels; - protected List jumps; - protected List skips; - - //--for fixing up functions and WITH blocks.. - protected List blocks; - 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 ArrayList(); - 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 HashMap(); - } - 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 ArrayList(); - } - 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 ArrayList(); - } - 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 ArrayList(); - } - 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 ArrayList(); - } - - 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(Float.valueOf(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.java deleted file mode 100644 index f2ea73334..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Actions.java +++ /dev/null @@ -1,115 +0,0 @@ -package pt.tumba.parser.swf; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; - -/** - * A set of actions - * - *@author unknown - *@created 15 de Setembro de 2002 - */ -public class Actions extends ActionWriter { - - protected int conditions; - 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 ArrayList(); - 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.java deleted file mode 100644 index fc8bac7c3..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/AlphaColor.java +++ /dev/null @@ -1,121 +0,0 @@ -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.java deleted file mode 100644 index 5c918c679..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/AlphaTransform.java +++ /dev/null @@ -1,193 +0,0 @@ -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.java deleted file mode 100644 index ebc49eb0a..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Base64.java +++ /dev/null @@ -1,306 +0,0 @@ -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.HashMap; - -/** - * 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; - } - - - 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', '+', '/' - }; - - public final static char paddingChar = '='; - - protected static HashMap charLookup = new HashMap(); - - 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.java deleted file mode 100644 index 3e5584170..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ButtonRecord.java +++ /dev/null @@ -1,237 +0,0 @@ -package pt.tumba.parser.swf; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Description of the Class - * - *@author unknown - *@created 15 de Setembro de 2002 - */ -public class ButtonRecord { - - public final static int BUTTON_HITTEST = 0x08; - public final static int BUTTON_DOWN = 0x04; - public final static int BUTTON_OVER = 0x02; - public final static int BUTTON_UP = 0x01; - - protected int flags; - protected int id; - protected int layer; - 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 { - List records = new ArrayList(); - - int firstByte = 0; - while ((firstByte = in.readUI8()) != 0) { - records.add(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.java deleted file mode 100644 index 459f6f621..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ButtonRecord2.java +++ /dev/null @@ -1,127 +0,0 @@ -package pt.tumba.parser.swf; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Description of the Class - * - *@author unknown - *@created 15 de Setembro de 2002 - */ -public class ButtonRecord2 extends ButtonRecord { - - 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 { - List records = new ArrayList(); - - int firstByte = 0; - while ((firstByte = in.readUI8()) != 0) { - records.add(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.java deleted file mode 100644 index 58a607fac..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Color.java +++ /dev/null @@ -1,176 +0,0 @@ -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.java deleted file mode 100644 index 2d9e7dae4..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ColorTransform.java +++ /dev/null @@ -1,442 +0,0 @@ -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.java deleted file mode 100644 index ae854649e..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ExportedSymbol.java +++ /dev/null @@ -1,51 +0,0 @@ -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.java deleted file mode 100644 index 4f8e9e821..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/FillStyle.java +++ /dev/null @@ -1,241 +0,0 @@ -package pt.tumba.parser.swf; - -import com.anotherbigidea.flash.SWFConstants; -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.java deleted file mode 100644 index 0ba76ade3..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Font.java +++ /dev/null @@ -1,647 +0,0 @@ -package pt.tumba.parser.swf; - -import com.anotherbigidea.flash.SWFConstants; -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.java deleted file mode 100644 index 72b2ed93c..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/FontDefinition.java +++ /dev/null @@ -1,551 +0,0 @@ -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.java deleted file mode 100644 index de8467502..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Frame.java +++ /dev/null @@ -1,435 +0,0 @@ -package pt.tumba.parser.swf; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * A Movie or Movie Clip frame - * - *@author unknown - *@created 15 de Setembro de 2002 - */ -public class Frame { - - protected int frameNumber; - protected String label; - protected List<Placement> placements = new ArrayList(); - protected boolean stop; - protected TimeLine timeline; - 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 (Placement placement : placements) { - 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 (Placement placement : placements) { - 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.java deleted file mode 100644 index 92adb607d..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ImportedSymbol.java +++ /dev/null @@ -1,72 +0,0 @@ -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.java deleted file mode 100644 index 1bfaa2fc2..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/InStream.java +++ /dev/null @@ -1,474 +0,0 @@ -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.ArrayList; -import java.util.List; -import java.util.zip.InflaterInputStream; - -/** - * Input Stream Wrapper - * - *@author unknown - *@created 15 de Setembro de 2002 - */ -public class InStream { - - protected InputStream in; - protected long bytesRead = 0L; - //--Bit buffer.. - protected int bitBuf; - 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(); - - List<Byte> chars = new ArrayList(); - 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 (Object b : chars) { - string[i++] = ((Byte) b).byteValue(); - } - return string; - } - chars.add(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(); - } - - /** - * Start reading compressed data - all further input is assumed to come from - * a zip compressed stream. - */ - public void readCompressed() { - in = new InflaterInputStream(in); - } - - /** - * 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.java deleted file mode 100644 index 0dfb3828f..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Instance.java +++ /dev/null @@ -1,50 +0,0 @@ -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.java deleted file mode 100644 index 7ac870251..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/LineStyle.java +++ /dev/null @@ -1,90 +0,0 @@ -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.java deleted file mode 100644 index 82d0a4321..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Matrix.java +++ /dev/null @@ -1,327 +0,0 @@ -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.java deleted file mode 100644 index 2c0f4bcc9..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Movie.java +++ /dev/null @@ -1,494 +0,0 @@ -package pt.tumba.parser.swf; - -import com.anotherbigidea.flash.SWFConstants; -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; - -/** - * A Flash Movie - * - *@author unknown - *@created 15 de Setembro de 2002 - */ -public class Movie implements TimeLine { - - protected int width; - protected int height; - protected int frameRate; - protected Color backColor; - protected int version; - protected boolean isProtected; - - protected Map<String, List> importLibraries; - protected List<ExportedSymbol> exportedSymbols; - - protected SortedMap<Integer, Frame> frames = new TreeMap(); - protected int frameCount = 0; - - //--Table of characters defined so far in the movie - while writing out - protected Map definedSymbols = new HashMap(); - - protected int depth = 1; //the next available depth - 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]; - } - - List imports = new ArrayList(); - - for (List list : importLibraries.values()) { - for (Iterator i2 = list.iterator(); i2.hasNext(); ) { - imports.add(i2.next()); - } - } - - ImportedSymbol[] imps = new ImportedSymbol[imports.size()]; - return (ImportedSymbol[])imports.toArray(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 ArrayList(); - } - - 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.java deleted file mode 100644 index b53787744..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/OutStream.java +++ /dev/null @@ -1,553 +0,0 @@ -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 { - - protected OutputStream out; - protected long bytesWritten = 0L; - - //--Bit buffer.. - protected int bitBuf; - 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 { - flushBits(); - 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.java deleted file mode 100644 index 2617f7efc..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Placement.java +++ /dev/null @@ -1,309 +0,0 @@ -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.java deleted file mode 100644 index ccaa57e3a..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Rect.java +++ /dev/null @@ -1,234 +0,0 @@ -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.java deleted file mode 100644 index 45792b5a5..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWF2HTML.java +++ /dev/null @@ -1,375 +0,0 @@ -package pt.tumba.parser.swf; - -import com.adobe.xmp.XMPConst; -import com.adobe.xmp.XMPException; -import com.adobe.xmp.XMPMeta; -import com.adobe.xmp.XMPMetaFactory; -import com.adobe.xmp.properties.XMPProperty; -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; - - -/** - * Description of the Class - * - *@author bmartins - *@created 22 de Agosto de 2002 - */ -public class SWF2HTML extends SWFTagTypesImpl { - - private int sizeCount = 0; - - - /** - * Description of the Method - * - *@return Description of the Return Value - */ - public int originalSize() { - return sizeCount; - } - - - protected Map fontCodes = new HashMap(); - protected String headerstr =""; - protected PrintWriter output; // body of html output (containing all text) - - //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(); - } - - /** - * Parse and interprete Metadata string (xmp rdf format) and create a - * html header tags for the html output - * - * @param xml Metadata - * @throws IOException - */ - @Override - public void tagMetaData(String xml) throws IOException { - - try { - XMPMeta xmpmeta = XMPMetaFactory.parseFromString(xml); - XMPProperty xp = xmpmeta.getProperty(XMPConst.NS_DC, "title"); - if (xp != null) { - headerstr = "<title>" + xp.getValue() + "</title>"; - } - - xp = xmpmeta.getProperty(XMPConst.NS_DC, "creator"); - if (xp != null) { - headerstr += "<meta name=\"author\" content=\"" + xp.getValue() + "\">"; - } - - xp = xmpmeta.getProperty(XMPConst.NS_DC, "description"); - if (xp != null) { - headerstr += "<meta name=\"description\" content=\"" + xp.getValue() + "\">"; - } - xp = xmpmeta.getProperty(XMPConst.NS_DC, "subject"); - if (xp != null) { - headerstr += "<meta name=\"keywords\" content=\"" + xp.getValue() + "\">"; - } - - // get a date (modified , created) - xp = xmpmeta.getProperty(XMPConst.NS_XMP, "ModifyDate"); - if (xp != null) { - headerstr += "<meta name=\"date\" content=\"" + xp.getValue() + "\">"; - } else { - xp = xmpmeta.getProperty(XMPConst.NS_XMP, "CreateDate"); - if (xp != null) { - headerstr += "<meta name=\"date\" content=\"" + xp.getValue() + "\">"; - } else { - xp = xmpmeta.getProperty(XMPConst.NS_DC, "date"); - if (xp != null) { - headerstr += "<meta name=\"date\" content=\"" + xp.getValue() + "\">"; - } - } - } - - xp = xmpmeta.getProperty(XMPConst.NS_XMP, "CreatorTool"); - if (xp != null) { - headerstr += "<meta name=\"generator\" content=\"" + xp.getValue() + "\">"; - } - - xp = xmpmeta.getProperty(XMPConst.NS_DC, "publisher"); - if (xp != null) { - headerstr += "<meta name=\"publisher\" content=\"" + xp.getValue() + "\">"; - } - - } catch (XMPException ex) { } - } - - /** - * Description of the Class - * - *@author unknown - *@created 15 de Setembro de 2002 - */ - public class TextDumper implements SWFText { - - protected Integer fontId; - 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()); - } - - - /** - * Parses swf input and extracts text and wrap it as html - * - * @param in SWF inputstream - * @return html of text in swf - * @exception Exception Description of the Exception - */ - public String convertSWFToHTML(InputStream in) throws Exception { - StringWriter out1 = new StringWriter(); - output = new PrintWriter(out1); - TagParser parser = new TagParser(this); - SWFReader reader = new SWFReader(parser, in); - reader.readFile(); - in.close(); - sizeCount = reader.size; - // generate html output string - final String ret = "<html>" - + (headerstr.isEmpty() ? "<body>" : "<header>" + headerstr + "</header><body>") - + out1.toString() - + "</body></html>"; - return ret; - } - - - /** - * 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/SWFActions.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFActions.java deleted file mode 100644 index 220b0cf21..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFActions.java +++ /dev/null @@ -1,912 +0,0 @@ -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/SWFHeader.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFHeader.java deleted file mode 100644 index 768777c49..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFHeader.java +++ /dev/null @@ -1,27 +0,0 @@ -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.java deleted file mode 100644 index 4803e3e14..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFReader.java +++ /dev/null @@ -1,181 +0,0 @@ -package pt.tumba.parser.swf; - -import com.anotherbigidea.flash.SWFConstants; -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 { - - protected SWFTags consumer; - protected InStream in; - protected InputStream inputstream; - protected boolean zipCompressed = false; // flag swf zip compressed - 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. Reading first the file signature (3 byte) and throws IOException if - * no match or file version not supported - * - *@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; - } - - - /** - * Read the SWF file header - including the signature. - */ - public void readHeader() throws IOException { - //--Verify File Signature - // magic bytes according to specification http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/swf/pdf/swf-file-format-spec.pdf - // 0x46, 0x57, 0x53 (“FWSâ€) signature indicates an uncompressed SWF file - // 0x43, 0x57, 0x53 (“CWSâ€) indicates that the entire file after the first 8 bytes was compressed by using the ZLIB - // 0x5a, 0x57, 0x53 (“ZWSâ€) indicates that the entire file after the first 8 bytes was compressed by using the LZMA - int magic = in.readUI8(); - switch (magic) { // F=uncompressed, C= ZIP-compressed Z=LZMA-compressed - case 'C': - zipCompressed = true; - break; - case 'F': - break; - case 'Z': - throw new IOException("LZMA compressed SWF file not supported"); // lzma compressed not supported yet - default: - throw new IOException("Invalid SWF File Signature"); - } - - magic = in.readUI8(); // always 'W' - if (magic != 'W') { - throw new IOException("Invalid SWF File Signature"); - } - magic = in.readUI8(); // always 'S' - if (magic != 'S') { - throw new IOException("Invalid SWF File Signature"); - } - - int version = in.readUI8(); - long length = in.readUI32(); - - //may be compressed from this point onwards - if (zipCompressed) { - in.readCompressed(); - } - - 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/SWFShape.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFShape.java deleted file mode 100644 index 61aa7e40d..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFShape.java +++ /dev/null @@ -1,84 +0,0 @@ -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.java deleted file mode 100644 index 09ca775e0..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFSpriteTagTypes.java +++ /dev/null @@ -1,163 +0,0 @@ -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.java deleted file mode 100644 index 279fa4b08..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTagTypes.java +++ /dev/null @@ -1,438 +0,0 @@ -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; - - /** - * Metadata such as title in xml format - * The format of the metadata is RDF that is compliant with Adobe’s - * Extensible Metadata Platform (XMPâ„¢) specification. - * - * @param data xml data as string - * @throws IOException - */ - public void tagMetaData(String 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.java deleted file mode 100644 index a0adaffb2..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTagTypesImpl.java +++ /dev/null @@ -1,900 +0,0 @@ -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); - } - } - - /** - * SWFTagTypes METADATA - * Metadata such as title in xml format - * The format of the metadata is RDF that is compliant with Adobe’s - * Extensible Metadata Platform (XMPâ„¢) specification. - * - * @param data xml data as string - * @throws IOException - */ - @Override - public void tagMetaData (String xml) throws IOException { - if (tags != null) { - tags.tagMetaData(xml); - } - } -} diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTags.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTags.java deleted file mode 100644 index e4d33a285..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFTags.java +++ /dev/null @@ -1,25 +0,0 @@ -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.java deleted file mode 100644 index 91a617599..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFText.java +++ /dev/null @@ -1,65 +0,0 @@ -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.java deleted file mode 100644 index e19f93c1c..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFVectors.java +++ /dev/null @@ -1,50 +0,0 @@ -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.java deleted file mode 100644 index 67f308da0..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SWFWriter.java +++ /dev/null @@ -1,240 +0,0 @@ -package pt.tumba.parser.swf; - -import com.anotherbigidea.flash.SWFConstants; -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.java deleted file mode 100644 index 5cf8f65dd..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SaxHandlerBase.java +++ /dev/null @@ -1,505 +0,0 @@ -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/Shape.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Shape.java deleted file mode 100644 index f13c49fdd..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Shape.java +++ /dev/null @@ -1,1152 +0,0 @@ -package pt.tumba.parser.swf; - -import com.anotherbigidea.flash.SWFConstants; -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.java deleted file mode 100644 index a8814da6a..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/SoundInfo.java +++ /dev/null @@ -1,278 +0,0 @@ -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.java deleted file mode 100644 index 74980b279..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Style.java +++ /dev/null @@ -1,20 +0,0 @@ -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.java deleted file mode 100644 index 56241c995..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Symbol.java +++ /dev/null @@ -1,98 +0,0 @@ -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.java deleted file mode 100644 index 497543b8a..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TagParser.java +++ /dev/null @@ -1,1428 +0,0 @@ -package pt.tumba.parser.swf; - -import com.anotherbigidea.flash.SWFConstants; -import java.io.ByteArrayInputStream; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -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 { - - 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: - case TAG_DEFINEFONT3: - 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: - if (in != null) parseDefineJPEGTables(in); // TODO: content length=0 (in==null) occurs for unknown reason - find out! - break; - case TAG_DEFINEBITSJPEG3: - parseDefineBitsJPEG3(in); - break; - case TAG_METADATA: - if (in != null) parseMetaData(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); - } - - /** - * parse METADATA tag (TAG_METADATA = 77) - * @param in - * @throws IOException - */ - protected void parseMetaData(InStream in) throws IOException { - String xmlMetaData = in.readString(); - tagtypes.tagMetaData(xmlMetaData); - } - - /** - * 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(); - List<byte[]> glyphs = new ArrayList(); - - 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.add(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 (byte[] glyphBytes : glyphs) { - 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.java deleted file mode 100644 index bb40f91e2..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TagWriter.java +++ /dev/null @@ -1,2576 +0,0 @@ -package pt.tumba.parser.swf; - -import com.anotherbigidea.flash.SWFConstants; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -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 { - - protected SWFTags tags; - - protected OutStream out; - protected ByteArrayOutputStream bytes; - protected int tagType; - protected boolean longTag; - 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); - } - - - @Override - public void tagMetaData (String xml) throws IOException { - startTag(TAG_METADATA, true); - out.writeString(xml); - completeTag(); - } - //----------------------------------------------------------------------- - - /** - * 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 ArrayList(); - /** - * 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 ArrayList(); - /** - * 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 ArrayList(); - /** - * Description of the Field - */ - protected List fillStyles = new ArrayList(); - - /** - * 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 ArrayList(); - - 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.java deleted file mode 100644 index 0586404f4..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/TimeLine.java +++ /dev/null @@ -1,52 +0,0 @@ -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.java deleted file mode 100644 index 44f5e1cb1..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/Transform.java +++ /dev/null @@ -1,140 +0,0 @@ -package pt.tumba.parser.swf; - -import com.anotherbigidea.flash.SWFConstants; - -/** - * 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.java deleted file mode 100644 index 34582e072..000000000 --- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/XMLWriter.java +++ /dev/null @@ -1,226 +0,0 @@ -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/svnRevNr/svnRevNrParser.java b/libbuild/svnRevNr/svnRevNrParser.java deleted file mode 100644 index 73720f1df..000000000 --- a/libbuild/svnRevNr/svnRevNrParser.java +++ /dev/null @@ -1,96 +0,0 @@ -
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-
-public class svnRevNrParser extends org.apache.tools.ant.Task{
-
- private String fileName=null;
- private String property=null;
-
- public void setFile(String name) {
- this.fileName = name;
- }
-
- public String getFile() {
- return this.fileName;
- }
-
- public void setProperty(String property) {
- this.property = property;
- }
-
- public String getProperty() {
- return this.property;
- }
-
- public void execute() {
- if (this.property==null || this.property.isEmpty()) {
- log("svn entries file name property was not set properly",Project.MSG_ERR);
- return;
- }
-
- if (this.fileName != null && this.fileName.length() > 0) {
- File entriesFile = new File(this.fileName);
- if (!entriesFile.exists()) throw new BuildException("SVN entries file '" + this.fileName + "' does not exist.");
- if (!entriesFile.canRead()) throw new BuildException("SVN entries file '" + this.fileName + "' is not readable.");
-
- // read the content of the file into memory
- String dataStr;
- try {
- byte[] data = new byte[(int) entriesFile.length()];
- FileInputStream input = new FileInputStream(entriesFile);
- input.read(data);
- dataStr = new String(data);
- } catch (final Exception e) {
- throw new BuildException("Unable to read the SVN entries file '" + this.fileName + "'");
- }
-
- // parse the content
- Pattern pattern;
- if (dataStr.startsWith("<?xml")) {
- pattern = Pattern.compile("<entry[^>]*(?:name=\"\"[^>]*revision=\"(\\d*)\"|revision=\"(\\d*)\"[^>]*name=\"\")[^>]*/>");
- } else {
- pattern = Pattern.compile("\\s\\sdir\\s*(\\d*)\\s*(svn(\\+ssh)?|http(s?))://");
- }
-
- Matcher matcher = pattern.matcher(dataStr);
- String revNr;
- if (matcher.find()) {
- revNr = matcher.group(1);
- if (revNr == null) revNr = matcher.group(2);
-
- System.out.println(revNr);
- log("SVN revision number found: " + revNr, Project.MSG_VERBOSE);
- } else {
- log("Unable to determine the SVN revision number", Project.MSG_WARN);
- revNr = "0000";
- }
-
- Project theProject = getProject();
- if (theProject != null) {
- theProject.setProperty(this.property, revNr);
- log("Property '" + this.property + "' set to '" + revNr + "'", Project.MSG_VERBOSE);
- }
- } else {
- throw new BuildException("File name attribute is required.");
- }
-
- }
-
- public static void main(String[] args) {
- svnRevNrParser parser = new svnRevNrParser();
-// parser.setFile(".svn/entries");
-// parser.setProperty("test");
-// parser.execute();
-
- parser.setFile("/home/theli/.eclipse/yacy/.svn/entries");
- parser.setProperty("test");
- parser.execute();
- }
-}
diff --git a/libbuild/svnRevNr/svnRevNrParser.properties b/libbuild/svnRevNr/svnRevNrParser.properties deleted file mode 100644 index ac577405d..000000000 --- a/libbuild/svnRevNr/svnRevNrParser.properties +++ /dev/null @@ -1 +0,0 @@ -svnrevnr=svnRevNrParser
\ No newline at end of file |
