summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkitfox2007-04-11 23:22:12 +0200
committerkitfox2007-04-11 23:22:12 +0200
commitb0b0b4a54c394b47aa64ce6cef12c5a8ec9e6992 (patch)
treea7a3adc625af71c727af9af758360c14ee14fe1e
downloadsvg-salamander-core-b0b0b4a54c394b47aa64ce6cef12c5a8ec9e6992.tar.gz
svg-salamander-core-b0b0b4a54c394b47aa64ce6cef12c5a8ec9e6992.tar.xz
svg-salamander-core-b0b0b4a54c394b47aa64ce6cef12c5a8ec9e6992.zip
Added SAX parser
git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@7 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b
-rwxr-xr-xbuild.xml193
-rwxr-xr-xlib/library/ant.jarbin0 -> 999966 bytes
-rwxr-xr-xlib/library/javacc.jarbin0 -> 378781 bytes
-rwxr-xr-xlib/library/junit.jarbin0 -> 121070 bytes
-rwxr-xr-xmanifest.mf14
-rwxr-xr-xnbproject/private/private.xml4
-rwxr-xr-xnbproject/project.xml107
-rwxr-xr-xsrc/main/java/com/kitfox/salamander/parser/SVGParser.java58
-rwxr-xr-xsrc/main/java/com/kitfox/salamander/parser/SVGParserAntTask.java98
-rwxr-xr-xsrc/main/java/com/kitfox/salamander/parser/SVGParserHandler.java80
10 files changed, 554 insertions, 0 deletions
diff --git a/build.xml b/build.xml
new file mode 100755
index 0000000..967d469
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project basedir="." default="all" name="svg-salamander-core">
+ <description>
+ General 2D and 3D graphics routines
+ </description>
+
+ <import file="../build-NBUtil.xml"/>
+
+ <target name="all" depends="build,release" description="Build jars, obfuscate and sign."/>
+ <target name="build" depends="compile-test" description="Build jars."/>
+
+ <target name="init">
+ <tstamp/>
+
+ <property name="build.dir" location="build"/>
+ <property name="gen.main.src.dir" location="${build.dir}/gen/src/main/java"/>
+ <property name="gen.main.res.dir" location="${build.dir}/gen/src/main/res"/>
+ <property name="classes.main.dir" location="${build.dir}/classes/main"/>
+ <property name="classes.test.dir" location="${build.dir}/classes/test"/>
+ <property name="src.main.dir" location="src/main/java"/>
+ <property name="src.test.dir" location="src/test/java"/>
+
+ <property name="res.main.dir" location="src/main/res"/>
+ <property name="res.test.dir" location="src/test/res"/>
+ <property name="jar.dir" location="${build.dir}/jar"/>
+ <property name="manifest.file" location="manifest.mf"/>
+ <property name="project.name" value="${ant.project.name}"/>
+ <property name="project.title" value="SVG Salamander"/>
+ <property name="version" value="1"/>
+ <property name="project.jar" location="${jar.dir}/${project.name}.jar"/>
+
+ <property name="project.debug.mainClass" value="com.kitfox.Main"/>
+ <property name="project.debug.jvm" location="C:\bin\jdk1.6.0\fastdebug/bin/java"/>
+ <property name="project.run.mainClass" value="com.kitfox.Main"/>
+ <property name="project.run.jvm" location="C:\bin\jdk1.6.0\fastdebug/bin/java"/>
+
+ <property name="javadoc.dir" location="${build.dir}/javadoc"/>
+ <property name="javadoc.zip" location="${www.localDir}/doc/javadoc.zip"/>
+
+ <path id="lib.include">
+ <pathelement path="${netbeans.home}/modules/org-jdesktop-layout.jar"/>
+ <fileset dir="lib/include">
+ <include name="**/*.jar"/>
+ </fileset>
+ </path>
+
+ <path id="lib.library">
+ <!--pathelement path="C:\Program Files\Java\jdk1.6.0\lib\tools.jar"/-->
+ <fileset dir="lib/library">
+ <include name="**/*.jar"/>
+ </fileset>
+ </path>
+
+ <path id="path.sourcepath">
+ <pathelement path="${src.main.dir}"/>
+ <pathelement path="${src.test.dir}"/>
+ </path>
+
+ <path id="path.sourcepath.debug">
+ <path refid="path.sourcepath"/>
+ </path>
+
+ <path id="path.classpath">
+ <path refid="lib.include"/>
+ <path refid="lib.library"/>
+
+ <pathelement path="${gen.main.res.dir}"/>
+ <pathelement path="${res.main.dir}"/>
+ <pathelement path="${res.test.dir}"/>
+ </path>
+ </target>
+
+ <target name="prepareBuild" depends="init" description="Create empty directories necessary for building">
+ <mkdir dir="${build.dir}"/>
+ <mkdir dir="${classes.main.dir}"/>
+ <mkdir dir="${classes.test.dir}"/>
+ <mkdir dir="${jar.dir}"/>
+ <mkdir dir="${gen.main.src.dir}"/>
+ <mkdir dir="${gen.main.res.dir}"/>
+ </target>
+
+ <target name="compile" depends="init,prepareBuild" description="Compile source">
+ <javac debug="true" destdir="${classes.main.dir}" srcdir="${src.main.dir}">
+ <compilerarg value="-Xlint:all,-unchecked,-serial"/>
+ <classpath>
+ <path refid="path.classpath"/>
+ </classpath>
+ </javac>
+ </target>
+
+ <target name="compile-test" depends="jar">
+ <javac debug="true" destdir="${classes.test.dir}" srcdir="${src.test.dir}">
+ <compilerarg value="-Xlint:all,-unchecked,-serial"/>
+ <classpath>
+ <path refid="path.classpath"/>
+ <pathelement path="${classes.main.dir}"/>
+ </classpath>
+ </javac>
+ </target>
+
+ <target name="run" depends="compile">
+ <java classname="${project.run.mainClass}" fork="true">
+ <jvmarg value="-ea"/>
+ <!--jvmarg value="-Djogl.verbose"/-->
+ <!--jvmarg value="-Xmx256M"/-->
+ <jvmarg value="-XX:+HeapDumpOnOutOfMemoryError"/>
+ <classpath>
+ <pathelement location="${classes.main.dir}"/>
+ <path refid="path.classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="runJar" depends="init">
+ <java jar="${project.jar}" fork="true">
+ </java>
+ </target>
+
+ <target name="jar" depends="init,compile">
+ <manifest file="${manifest.file}">
+ <attribute name="Main-Class" value="${project.run.mainClass}"/>
+ <attribute name="Built-By" value="${user.name}"/>
+ <section name="common">
+ <attribute name="Specification-Title" value="${project.title}"/>
+ <attribute name="Specification-Version" value="${version}"/>
+ <attribute name="Specification-Vendor" value="Kitfox"/>
+ <attribute name="Implementation-Title" value="${project.name}"/>
+ <attribute name="Implementation-Version" value="Version ${version}, Date ${TODAY}"/>
+ <attribute name="Implementation-Vendor" value="Mark McKay, mark@kitfox.com"/>
+ </section>
+ </manifest>
+
+ <jar compress="true" jarfile="${project.jar}" manifest="${manifest.file}">
+ <fileset dir="${classes.main.dir}">
+ <include name="**/*.class"/>
+ </fileset>
+ <fileset dir="${res.main.dir}">
+ <include name="**/*"/>
+ </fileset>
+ <fileset dir="${gen.main.res.dir}">
+ <include name="**/*"/>
+ </fileset>
+ </jar>
+ </target>
+
+ <target name="release" depends="init,jar,generateKey" description="Obfuscates and sign jar, copies result to binaries directory.">
+ <proguard
+ defaultpackage=""
+ printmapping="${project.obfuscated.names}"
+ overloadaggressively="false"
+ usemixedcaseclassnames="false"
+ verbose="true"
+ shrink="false"
+ optimize="false"
+ obfuscate="false"
+ ignorewarnings="true">
+
+ <libraryjar>
+ <pathelement path="${java.home}/lib/rt.jar"/>
+ <!--pathelement path="C:\Program Files\Java\jdk1.6.0\jre\lib/rt.jar"/-->
+ <path refid="lib.library"/>
+ </libraryjar>
+
+ <injar file="${project.jar}"/>
+ <injar filter="!META-INF/MANIFEST.MF">
+ <path refid="lib.include"/>
+ </injar>
+
+ <outjar file="${project.obfuscated.jar}"/>
+
+ <keep access="public" type="class" name="${project.run.mainClass}">
+ <method name="main"/>
+ </keep>
+ </proguard>
+
+ <signjar jar="${project.obfuscated.jar}" alias="${key.user}" storepass="${key.password}" keystore="${key.location}"/>
+ </target>
+
+ <target name="clean" depends="init" description="Clean all build products.">
+ <delete dir="${build.dir}"/>
+ <delete dir="${javadoc.dir}"/>
+ <delete file="${project.obfuscated.jar}"/>
+
+ <!--
+ <delete>
+ <fileset dir="${src.main.dir}">
+ <include name="**/*.class"/>
+ </fileset>
+ </delete>
+ -->
+ </target>
+
+</project>
diff --git a/lib/library/ant.jar b/lib/library/ant.jar
new file mode 100755
index 0000000..3a67607
--- /dev/null
+++ b/lib/library/ant.jar
Binary files differ
diff --git a/lib/library/javacc.jar b/lib/library/javacc.jar
new file mode 100755
index 0000000..5506008
--- /dev/null
+++ b/lib/library/javacc.jar
Binary files differ
diff --git a/lib/library/junit.jar b/lib/library/junit.jar
new file mode 100755
index 0000000..674d71e
--- /dev/null
+++ b/lib/library/junit.jar
Binary files differ
diff --git a/manifest.mf b/manifest.mf
new file mode 100755
index 0000000..b8c9199
--- /dev/null
+++ b/manifest.mf
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Ant-Version: Apache Ant 1.7.0Beta3
+Created-By: 1.6.0-b105 (Sun Microsystems Inc.)
+Main-Class: com.kitfox.Main
+Built-By: kitfox
+
+Name: common
+Specification-Title: SVG Salamander
+Specification-Version: 1
+Specification-Vendor: Kitfox
+Implementation-Title: svg-salamander-core
+Implementation-Version: Version 1, Date April 11 2007
+Implementation-Vendor: Mark McKay, mark@kitfox.com
+
diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml
new file mode 100755
index 0000000..cc2c0e5
--- /dev/null
+++ b/nbproject/private/private.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
+ <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
+</project-private>
diff --git a/nbproject/project.xml b/nbproject/project.xml
new file mode 100755
index 0000000..c074c4b
--- /dev/null
+++ b/nbproject/project.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+ <type>org.netbeans.modules.ant.freeform</type>
+ <configuration>
+ <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
+ <!-- Do not use Project Properties customizer when editing this file manually. -->
+ <name>svg-salamander-core</name>
+ <properties/>
+ <folders>
+ <source-folder>
+ <label>src\main\java</label>
+ <type>java</type>
+ <location>src/main/java</location>
+ </source-folder>
+ <source-folder>
+ <label>src\main\res</label>
+ <type>java</type>
+ <location>src/main/res</location>
+ </source-folder>
+ <source-folder>
+ <label>src\test\java</label>
+ <type>java</type>
+ <location>src/test/java</location>
+ </source-folder>
+ <source-folder>
+ <label>src\test\res</label>
+ <type>java</type>
+ <location>src/test/res</location>
+ </source-folder>
+ </folders>
+ <ide-actions>
+ <action name="build">
+ <target>build</target>
+ </action>
+ <action name="clean">
+ <target>clean</target>
+ </action>
+ <action name="javadoc">
+ <target>javadoc</target>
+ </action>
+ <action name="run">
+ <target>run</target>
+ </action>
+ <action name="test">
+ <target>checkintest</target>
+ </action>
+ <action name="rebuild">
+ <target>clean</target>
+ <target>build</target>
+ </action>
+ </ide-actions>
+ <view>
+ <items>
+ <source-folder style="packages">
+ <label>src\main\java</label>
+ <location>src/main/java</location>
+ </source-folder>
+ <source-folder style="packages">
+ <label>src\main\res</label>
+ <location>src/main/res</location>
+ </source-folder>
+ <source-folder style="packages">
+ <label>src\test\java</label>
+ <location>src/test/java</location>
+ </source-folder>
+ <source-folder style="packages">
+ <label>src\test\res</label>
+ <location>src/test/res</location>
+ </source-folder>
+ <source-file>
+ <location>build.xml</location>
+ </source-file>
+ </items>
+ <context-menu>
+ <ide-action name="build"/>
+ <ide-action name="clean"/>
+ <ide-action name="javadoc"/>
+ <ide-action name="run"/>
+ <ide-action name="test"/>
+ <ide-action name="rebuild"/>
+ </context-menu>
+ </view>
+ <subprojects/>
+ </general-data>
+ <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/2">
+ <compilation-unit>
+ <package-root>src/main/java</package-root>
+ <classpath mode="compile">lib/library/ant.jar;lib/library/javacc.jar;lib/library/junit.jar</classpath>
+ <source-level>1.5</source-level>
+ </compilation-unit>
+ <compilation-unit>
+ <package-root>src/main/res</package-root>
+ <source-level>1.5</source-level>
+ </compilation-unit>
+ <compilation-unit>
+ <package-root>src/test/java</package-root>
+ <unit-tests/>
+ <source-level>1.5</source-level>
+ </compilation-unit>
+ <compilation-unit>
+ <package-root>src/test/res</package-root>
+ <unit-tests/>
+ <source-level>1.5</source-level>
+ </compilation-unit>
+ </java-data>
+ </configuration>
+</project>
diff --git a/src/main/java/com/kitfox/salamander/parser/SVGParser.java b/src/main/java/com/kitfox/salamander/parser/SVGParser.java
new file mode 100755
index 0000000..efdf6b9
--- /dev/null
+++ b/src/main/java/com/kitfox/salamander/parser/SVGParser.java
@@ -0,0 +1,58 @@
+/*
+ * SVGParser.java
+ *
+ * Created on April 11, 2007, 5:07 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package com.kitfox.salamander.parser;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ *
+ * @author kitfox
+ */
+public class SVGParser
+{
+ public static interface SVGParserListener
+ {
+
+ }
+
+ /** Creates a new instance of SVGParser */
+ public SVGParser()
+ {
+ }
+
+ public static void parse(File source, SVGParserListener listener, boolean skipUpToDateFiles)
+ {
+ try
+ {
+ XMLReader parser;
+ parser = XMLReaderFactory.createXMLReader();
+ SVGParserHandler handler = new SVGParserHandler(listener);
+ parser.setContentHandler(handler);
+
+ InputSource is = new InputSource(new FileInputStream(source));
+ parser.parse(is);
+
+ }
+ catch (SAXException ex)
+ {
+ ex.printStackTrace();
+ }
+ catch (IOException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+}
diff --git a/src/main/java/com/kitfox/salamander/parser/SVGParserAntTask.java b/src/main/java/com/kitfox/salamander/parser/SVGParserAntTask.java
new file mode 100755
index 0000000..4c7a251
--- /dev/null
+++ b/src/main/java/com/kitfox/salamander/parser/SVGParserAntTask.java
@@ -0,0 +1,98 @@
+/*
+ * GraphicsCodeGenAntTask.java
+ *
+ * Created on March 3, 2007, 9:31 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package com.kitfox.salamander.parser;
+
+import java.io.File;
+import java.util.ArrayList;
+import javax.imageio.ImageIO;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.FileScanner;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.FileSet;
+
+/**
+ * This ant task examines a directory hierarchy containing .xml files and
+ * for the XML files rooted in the GraphicsCodeGen.GRAPHICS_NS namespace,
+ * causes code generation to be run. Task will only update code that is missing
+ * or out of date to minimize processing time.
+ *
+ * <code>
+ * &lt;graphicsCodeGeneration&gt;
+ * &lt;fileset dir="${root.dir}"&gt;
+ * &lt;include name="com/kitfox/monsters/** / *"/&gt;
+ * &lt;/fileset&gt;
+ * &lt;fileset dir="${dir2}"&gt;
+ * &lt;/fileset&gt;
+ * &lt;/graphicsCodeGeneration&gt;
+ * </code>
+ *
+ * @author kitfox
+ */
+public class SVGParserAntTask extends Task
+{
+// Path examinePath;
+ private ArrayList<FileSet> filesets = new ArrayList<FileSet>();
+
+
+ /** Creates a new instance of GraphicsCodeGenAntTask */
+ public SVGParserAntTask()
+ {
+ }
+
+ /**
+ * Adds a set of files.
+ */
+ public void addFileset(FileSet set)
+ {
+ filesets.add(set);
+ }
+
+ /**
+ * The examine path should be a subset of the classpath and include all the
+ * classes that should be examined for possible inclusion in the services list.
+ */
+// public Path createExaminePath() throws BuildException
+// {
+// if (examinePath == null)
+// {
+// examinePath = new Path(getProject());
+// return examinePath;
+// }
+// throw new BuildException("Only one examine path can be set");
+// }
+
+ public void execute() throws BuildException
+ {
+ /*
+ //This is necessary for ImageIO to find all pluggable image readers on the
+ // classpath
+ ImageIO.scanForPlugins();
+
+ for (FileSet fileSet: filesets)
+ {
+ FileScanner scanner = fileSet.getDirectoryScanner(getProject());
+ String[] files = scanner.getIncludedFiles();
+
+ File dir = fileSet.getDir();
+
+ for (String fileName: files)
+ {
+// if (!fileName.getName().endsWith(".xml")) continue;
+ File file = new File(dir, fileName);
+//System.err.println("*****File " + file);
+
+ //Conditionally generate code
+ GraphicsCodeGen.generateCode(file, true);
+ }
+ }
+ */
+ }
+
+}
diff --git a/src/main/java/com/kitfox/salamander/parser/SVGParserHandler.java b/src/main/java/com/kitfox/salamander/parser/SVGParserHandler.java
new file mode 100755
index 0000000..8119984
--- /dev/null
+++ b/src/main/java/com/kitfox/salamander/parser/SVGParserHandler.java
@@ -0,0 +1,80 @@
+/*
+ * GraphicsDocumentHandler.java
+ *
+ * Created on March 3, 2007, 7:49 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package com.kitfox.salamander.parser;
+
+import com.kitfox.salamander.parser.SVGParser.SVGParserListener;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+
+/**
+ *
+ * @author kitfox
+ */
+public class SVGParserHandler implements ContentHandler
+{
+// LinkedList<CodeGenNode> nodeStack = new LinkedList<CodeGenNode>();
+
+ final SVGParserListener listener;
+
+ /** Creates a new instance of GraphicsDocumentHandler */
+ public SVGParserHandler(SVGParserListener listener)
+ {
+ this.listener = listener;
+ }
+
+ public void setDocumentLocator(Locator locator)
+ {
+ }
+
+ public void startDocument() throws SAXException
+ {
+ }
+
+ public void endDocument() throws SAXException
+ {
+ }
+
+ public void startPrefixMapping(String prefix, String uri) throws SAXException
+ {
+ }
+
+ public void endPrefixMapping(String prefix) throws SAXException
+ {
+ }
+
+ public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException
+ {
+ }
+
+
+ public void endElement(String uri, String localName, String qName) throws SAXException
+ {
+ }
+
+ public void characters(char[] ch, int start, int length) throws SAXException
+ {
+ }
+
+ public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
+ {
+ }
+
+ public void processingInstruction(String target, String data) throws SAXException
+ {
+ }
+
+ public void skippedEntity(String name) throws SAXException
+ {
+ }
+
+}