Thread: [Patchanim-commit] SF.net SVN: patchanim: [42] trunk/patchanim/src/com/mebigfatguy/patchanim/ io
Brought to you by:
dbrosius
From: <dbr...@us...> - 2008-01-28 01:22:27
|
Revision: 42 http://patchanim.svn.sourceforge.net/patchanim/?rev=42&view=rev Author: dbrosius Date: 2008-01-27 17:22:32 -0800 (Sun, 27 Jan 2008) Log Message: ----------- add copyright Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/io/Closer.java trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/Closer.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/Closer.java 2008-01-28 01:21:47 UTC (rev 41) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/Closer.java 2008-01-28 01:22:32 UTC (rev 42) @@ -1,3 +1,21 @@ +/* + * patchanim - A bezier surface patch color blend gif builder + * Copyright (C) 2008 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ package com.mebigfatguy.patchanim.io; import java.io.Closeable; Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java 2008-01-28 01:21:47 UTC (rev 41) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java 2008-01-28 01:22:32 UTC (rev 42) @@ -1,3 +1,21 @@ +/* + * patchanim - A bezier surface patch color blend gif builder + * Copyright (C) 2008 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ package com.mebigfatguy.patchanim.io; import java.beans.XMLDecoder; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-02-09 05:56:13
|
Revision: 110 http://patchanim.svn.sourceforge.net/patchanim/?rev=110&view=rev Author: dbrosius Date: 2008-02-08 21:53:58 -0800 (Fri, 08 Feb 2008) Log Message: ----------- rework io to use xml Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java Added Paths: ----------- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsd trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsl trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimExtension.java Added: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsd =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsd (rev 0) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsd 2008-02-09 05:53:58 UTC (rev 110) @@ -0,0 +1,72 @@ +<!-- +/* + * patchanim - A bezier surface patch color blend gif builder + * Copyright (C) 2008 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + --> + <?xml version="1.0" encoding="UTF-8" standalone="no"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <xsd:simpleType name="ColorClass"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="Green"/> + <xsd:enumeration value="Blue"/> + <xsd:enumeration value="Red"/> + </xsd:restriction> + </xsd:simpleType> + <xsd:complexType name="CoordinateClass"> + <xsd:attribute name="color" type="xsd:double" use="required"/> + <xsd:attribute name="x" type="xsd:double" use="required"/> + <xsd:attribute name="y" type="xsd:double" use="required"/> + </xsd:complexType> + <xsd:complexType name="PatchClass"> + <xsd:sequence> + <xsd:element maxOccurs="unbounded" minOccurs="1" name="Coordinate" type="CoordinateClass"/> + </xsd:sequence> + <xsd:attribute name="color" type="ColorClass" use="required"/> + </xsd:complexType> + <xsd:complexType name="CombinedPatchClass"> + <xsd:sequence> + <xsd:element maxOccurs="3" minOccurs="3" name="Patch" type="PatchClass"/> + </xsd:sequence> + <xsd:attribute name="name" type="NameClass" use="required"/> + </xsd:complexType> + <xsd:complexType name="PatchAnimDocClass"> + <xsd:sequence> + <xsd:element maxOccurs="1" minOccurs="1" name="Settings" type="SettingsClass"/> + <xsd:element maxOccurs="1" minOccurs="1" name="Patches" type="PatchesClass"/> + </xsd:sequence> + <xsd:attribute name="version" type="xsd:string" use="required"/> + </xsd:complexType> + <xsd:simpleType name="NameClass"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="Patch Coordinates"/> + </xsd:restriction> + </xsd:simpleType> + <xsd:complexType name="PatchesClass"> + <xsd:sequence> + <xsd:element maxOccurs="4" minOccurs="4" name="CombinedPatch" type="CombinedPatchClass"/> + </xsd:sequence> + </xsd:complexType> + <xsd:complexType name="SettingsClass"> + <xsd:attribute name="animationType" type="xsd:string" use="required"/> + <xsd:attribute name="height" type="xsd:integer" use="required"/> + <xsd:attribute name="outOfBoundsColor" type="xsd:string" use="required"/> + <xsd:attribute name="tweenCount" type="xsd:integer" use="required"/> + <xsd:attribute name="width" type="xsd:integer" use="required"/> + </xsd:complexType> + <xsd:element name="PatchAnimDoc" type="PatchAnimDocClass"/> +</xsd:schema> Property changes on: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsd ___________________________________________________________________ Name: svn:mime-type + text/xml Name: svn:eol-style + native Added: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsl =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsl (rev 0) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsl 2008-02-09 05:53:58 UTC (rev 110) @@ -0,0 +1,111 @@ +<!-- +/* + * patchanim - A bezier surface patch color blend gif builder + * Copyright (C) 2008 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + --> +<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:xalan="http://xml.apache.org/xalan" + xmlns:pae="xalan://com.mebigfatguy.patchanim.io.PatchAnimExtension" + extension-element-prefixes="pae"> + + <xsl:output method="xml" + encoding="UTF-8" + indent="yes" + xalan:indent-amount="4"/> + + <xsl:param name="doc"/> + <xsl:variable name="ext" select="pae:new($doc)"/> + + <xsl:template match="/"> + <PatchAnimDoc version="0.2.0"> + <Settings> + <xsl:attribute name="width"> + <xsl:value-of select="pae:getWidth($ext)"/> + </xsl:attribute> + <xsl:attribute name="height"> + <xsl:value-of select="pae:getHeight($ext)"/> + </xsl:attribute> + <xsl:attribute name="animationType"> + <xsl:value-of select="pae:getAnimationType($ext)"/> + </xsl:attribute> + <xsl:attribute name="outOfBoundsColor"> + <xsl:value-of select="pae:getOutOfBoundsColor($ext)"/> + </xsl:attribute> + <xsl:attribute name="tweenCount"> + <xsl:value-of select="pae:getTweenCount($ext)"/> + </xsl:attribute> + </Settings> + <Patches> + <xsl:for-each select="pae:getPatches($ext)"> + <xsl:variable name="patchIndex" select="."/> + <CombinedPatch> + <xsl:attribute name="name"> + <xsl:value-of select="pae:getPatchName($ext, $patchIndex)"/> + </xsl:attribute> + <Patch color="Red"> + <xsl:for-each select="pae:getCoordinates($ext, 'Red', $patchIndex)"> + <Coordinate> + <xsl:attribute name="x"> + <xsl:value-of select="pae:getX($ext, 'Red', $patchIndex, .)"/> + </xsl:attribute> + <xsl:attribute name="y"> + <xsl:value-of select="pae:getY($ext, 'Red', $patchIndex, .)"/> + </xsl:attribute> + <xsl:attribute name="color"> + <xsl:value-of select="pae:getColor($ext, 'Red', $patchIndex, .)"/> + </xsl:attribute> + </Coordinate> + </xsl:for-each> + </Patch> + <Patch color="Green"> + <xsl:for-each select="pae:getCoordinates($ext, 'Green', $patchIndex)"> + <Coordinate> + <xsl:attribute name="x"> + <xsl:value-of select="pae:getX($ext, 'Green', $patchIndex, .)"/> + </xsl:attribute> + <xsl:attribute name="y"> + <xsl:value-of select="pae:getY($ext, 'Green', $patchIndex, .)"/> + </xsl:attribute> + <xsl:attribute name="color"> + <xsl:value-of select="pae:getColor($ext, 'Green', $patchIndex, .)"/> + </xsl:attribute> + </Coordinate> + </xsl:for-each> + </Patch> + <Patch color="Blue"> + <xsl:for-each select="pae:getCoordinates($ext, 'Blue', $patchIndex)"> + <Coordinate> + <xsl:attribute name="x"> + <xsl:value-of select="pae:getX($ext, 'Blue', $patchIndex, .)"/> + </xsl:attribute> + <xsl:attribute name="y"> + <xsl:value-of select="pae:getY($ext, 'Blue', $patchIndex, .)"/> + </xsl:attribute> + <xsl:attribute name="color"> + <xsl:value-of select="pae:getColor($ext, 'Blue', $patchIndex, .)"/> + </xsl:attribute> + </Coordinate> + </xsl:for-each> + </Patch> + </CombinedPatch> + </xsl:for-each> + </Patches> + </PatchAnimDoc> + </xsl:template> + +</xsl:transform> \ No newline at end of file Property changes on: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsl ___________________________________________________________________ Name: svn:mime-type + text/xml Name: svn:eol-style + native Added: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimExtension.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimExtension.java (rev 0) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimExtension.java 2008-02-09 05:53:58 UTC (rev 110) @@ -0,0 +1,134 @@ +/* + * patchanim - A bezier surface patch color blend gif builder + * Copyright (C) 2008 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.patchanim.io; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.apache.xalan.extensions.ExpressionContext; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import com.mebigfatguy.patchanim.PatchAnimDocument; +import com.mebigfatguy.patchanim.PatchColor; +import com.mebigfatguy.patchanim.surface.Coordinate; +import com.mebigfatguy.patchanim.surface.PatchCoords; + +public class PatchAnimExtension { + + private PatchAnimDocument paDoc; + private Document d; + private Node n; + + public PatchAnimExtension(PatchAnimDocument doc) throws ParserConfigurationException { + paDoc = doc; + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + d = db.newDocument(); + n = d.createElement("Patch"); + } + + public String getWidth(@SuppressWarnings("unused") ExpressionContext context) { + return String.valueOf(paDoc.getWidth()); + } + + public String getHeight(@SuppressWarnings("unused") ExpressionContext context) { + return String.valueOf(paDoc.getHeight()); + } + + public String getAnimationType(@SuppressWarnings("unused") ExpressionContext context) { + return paDoc.getAnimationType().name(); + } + + public String getOutOfBoundsColor(@SuppressWarnings("unused") ExpressionContext context) { + return paDoc.getOutOfBoundsColor().name(); + } + + public String getTweenCount(@SuppressWarnings("unused") ExpressionContext context) { + return String.valueOf(paDoc.getTweenCount()); + } + + public NodeList getPatches(@SuppressWarnings("unused") ExpressionContext context) { + NodeList nl = new NodeList() { + + public int getLength() { + return paDoc.getPatches().size(); + } + + public Node item(int index) { + // TODO Auto-generated method stub + return d.createTextNode(String.valueOf(index)); + } + }; + + return nl; + } + + public String getPatchName(@SuppressWarnings("unused") ExpressionContext context, Node patchIndexNode) { + int patchIndex = Integer.parseInt(patchIndexNode.getNodeValue()); + return paDoc.getPatches().get(patchIndex).getName(); + } + + public NodeList getCoordinates(@SuppressWarnings("unused") ExpressionContext context, String color, Node n) { + NodeList nl = new NodeList() { + + public int getLength() { + return PatchCoords.ORDER * PatchCoords.ORDER; + } + + public Node item(int index) { + // TODO Auto-generated method stub + return d.createTextNode(String.valueOf(index)); + } + }; + + return nl; + } + + public String getX(@SuppressWarnings("unused") ExpressionContext context, String color, Node patchIndexNode, Node coordIndexNode) { + PatchColor patchColor = PatchColor.valueOf(PatchColor.class, color); + int patchIndex = Integer.parseInt(patchIndexNode.getNodeValue()); + int coordIndex = Integer.parseInt(coordIndexNode.getNodeValue()); + + Coordinate coord = paDoc.getPatches().get(patchIndex).getPatch(patchColor).getCoordinate(coordIndex % PatchCoords.ORDER, coordIndex / PatchCoords.ORDER); + return String.valueOf(coord.getX()); + } + + public String getY(@SuppressWarnings("unused") ExpressionContext context, String color, Node patchIndexNode, Node coordIndexNode) { + PatchColor patchColor = PatchColor.valueOf(PatchColor.class, color); + int patchIndex = Integer.parseInt(patchIndexNode.getNodeValue()); + int coordIndex = Integer.parseInt(coordIndexNode.getNodeValue()); + + Coordinate coord = paDoc.getPatches().get(patchIndex).getPatch(patchColor).getCoordinate(coordIndex % PatchCoords.ORDER, coordIndex / PatchCoords.ORDER); + return String.valueOf(coord.getY()); + } + + public String getColor(@SuppressWarnings("unused") ExpressionContext context, String color, Node patchIndexNode, Node coordIndexNode) { + PatchColor patchColor = PatchColor.valueOf(PatchColor.class, color); + int patchIndex = Integer.parseInt(patchIndexNode.getNodeValue()); + int coordIndex = Integer.parseInt(coordIndexNode.getNodeValue()); + + Coordinate coord = paDoc.getPatches().get(patchIndex).getPatch(patchColor).getCoordinate(coordIndex % PatchCoords.ORDER, coordIndex / PatchCoords.ORDER); + return String.valueOf(coord.getColor()); + } + + +} Property changes on: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimExtension.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java 2008-02-09 05:51:40 UTC (rev 109) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java 2008-02-09 05:53:58 UTC (rev 110) @@ -24,38 +24,143 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; + +import org.w3c.dom.Document; +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.DefaultHandler; +import org.xml.sax.helpers.XMLReaderFactory; + +import com.mebigfatguy.patchanim.AnimationType; +import com.mebigfatguy.patchanim.OutOfBoundsColor; import com.mebigfatguy.patchanim.PatchAnimDocument; +import com.mebigfatguy.patchanim.PatchColor; +import com.mebigfatguy.patchanim.surface.CombinedPatch; +import com.mebigfatguy.patchanim.surface.Coordinate; +import com.mebigfatguy.patchanim.surface.PatchCoords; public class PatchAnimIO { + private static final String PATCHANIMDOC_SCHEMA = "/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsd"; private PatchAnimIO() { } - + public static void saveFile(File f, PatchAnimDocument document) throws IOException { - ObjectOutputStream os = null; + InputStream xslIs = null; + OutputStream xmlOs = null; try { document.setDirty(false); - os = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(f))); - os.writeObject(document); - os.flush(); + + TransformerFactory tf = TransformerFactory.newInstance(); + xslIs = new BufferedInputStream(PatchAnimIO.class.getResourceAsStream("/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsl")); + Transformer t = tf.newTransformer(new StreamSource(xslIs)); + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + Document d = db.newDocument(); + xmlOs = new BufferedOutputStream(new FileOutputStream(f)); + t.setParameter("doc", document); + t.transform(new DOMSource(d), new StreamResult(xmlOs)); + } catch (IOException ioe) { + throw ioe; + } catch (Exception e) { + IOException ioe = new IOException("Failed saving document"); + ioe.initCause(e); + throw ioe; } finally { - Closer.close(os); + Closer.close(xslIs); + Closer.close(xmlOs); } } - - public static PatchAnimDocument loadFile(File f) throws IOException, ClassNotFoundException { - ObjectInputStream is = null; + + public static PatchAnimDocument loadFile(File f) throws IOException { + InputStream xmlIs = null; + final PatchAnimDocument doc = new PatchAnimDocument(); + doc.getPatches().clear(); + try { - is = new ObjectInputStream(new BufferedInputStream(new FileInputStream(f))); - return (PatchAnimDocument)is.readObject(); + XMLReader reader = XMLReaderFactory.createXMLReader(); + reader.setContentHandler(new DefaultHandler() { + private static final String SETTINGS = "Settings"; + private static final String WIDTH = "width"; + private static final String HEIGHT = "height"; + private static final String ANIMATIONTYPE = "animationType"; + private static final String OUTOFBOUNDSCOLOR = "outOfBoundsColor"; + private static final String TWEENCOUNT = "tweenCount"; + private static final String COMBINEDPATCH = "CombinedPatch"; + private static final String PATCH = "Patch"; + private static final String COLOR = "color"; + private static final String COORDINATE = "Coordinate"; + private static final String X = "x"; + private static final String Y = "y"; + + private CombinedPatch cPatch = null; + private PatchCoords patchCoords = null; + private PatchColor patchColor = null; + private int coordIndex = 0; + + @Override + public void startElement(String uri, String localName, String qName, Attributes atts) { + if (SETTINGS.equals(localName)) { + doc.setWidth(Integer.parseInt(atts.getValue(WIDTH))); + doc.setHeight(Integer.parseInt(atts.getValue(HEIGHT))); + doc.setAnimationType(AnimationType.valueOf(AnimationType.class, atts.getValue(ANIMATIONTYPE))); + doc.setOutOfBoundsColor(OutOfBoundsColor.valueOf(OutOfBoundsColor.class, atts.getValue(OUTOFBOUNDSCOLOR))); + doc.setTweenCount(Integer.parseInt(atts.getValue(TWEENCOUNT))); + } else if (COMBINEDPATCH.equals(localName)) { + cPatch = new CombinedPatch(false); + } else if (PATCH.equals(localName)) { + patchCoords = new PatchCoords(); + patchColor = PatchColor.valueOf(PatchColor.class, atts.getValue(COLOR)); + } else if (COORDINATE.equals(localName)) { + Coordinate c = new Coordinate(Double.parseDouble(atts.getValue(X)), + Double.parseDouble(atts.getValue(Y)), + Double.parseDouble(atts.getValue(COLOR))); + patchCoords.setCoordinate(coordIndex / PatchCoords.ORDER, coordIndex % PatchCoords.ORDER, c); + coordIndex++; + c = null; + } + } + + @Override + public void endElement(String uri, String localName, String qName) { + if (COMBINEDPATCH.equals(localName)) { + doc.getPatches().add(cPatch); + cPatch = null; + } else if (PATCH.equals(localName)) { + cPatch.setPatch(patchColor, patchCoords); + patchColor = null; + patchCoords = null; + coordIndex = 0; + } + } + }); + xmlIs = new BufferedInputStream(new FileInputStream(f)); + reader.setFeature("http://apache.org/xml/features/validation/schema", true); + reader.setFeature("http://xml.org/sax/features/validation", true); + reader.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", PatchAnimDocument.class.getResource(PATCHANIMDOC_SCHEMA).getPath()); + + reader.parse(new InputSource(xmlIs)); + return doc; + } catch (IOException ioe) { + throw ioe; + } catch (Exception e) { + IOException ioe = new IOException("Failed loading document"); + ioe.initCause(e); + throw ioe; } finally { - Closer.close(is); + Closer.close(xmlIs); } } - - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-02-09 06:46:44
|
Revision: 118 http://patchanim.svn.sourceforge.net/patchanim/?rev=118&view=rev Author: dbrosius Date: 2008-02-08 22:46:49 -0800 (Fri, 08 Feb 2008) Log Message: ----------- cleanup unused Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsl trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimExtension.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsl =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsl 2008-02-09 06:40:32 UTC (rev 117) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsl 2008-02-09 06:46:49 UTC (rev 118) @@ -58,7 +58,7 @@ <xsl:value-of select="pae:getPatchName($ext, $patchIndex)"/> </xsl:attribute> <Patch color="Red"> - <xsl:for-each select="pae:getCoordinates($ext, 'Red', $patchIndex)"> + <xsl:for-each select="pae:getCoordinates($ext)"> <Coordinate> <xsl:attribute name="x"> <xsl:value-of select="pae:getX($ext, 'Red', $patchIndex, .)"/> @@ -73,7 +73,7 @@ </xsl:for-each> </Patch> <Patch color="Green"> - <xsl:for-each select="pae:getCoordinates($ext, 'Green', $patchIndex)"> + <xsl:for-each select="pae:getCoordinates($ext)"> <Coordinate> <xsl:attribute name="x"> <xsl:value-of select="pae:getX($ext, 'Green', $patchIndex, .)"/> @@ -88,7 +88,7 @@ </xsl:for-each> </Patch> <Patch color="Blue"> - <xsl:for-each select="pae:getCoordinates($ext, 'Blue', $patchIndex)"> + <xsl:for-each select="pae:getCoordinates($ext)"> <Coordinate> <xsl:attribute name="x"> <xsl:value-of select="pae:getX($ext, 'Blue', $patchIndex, .)"/> Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimExtension.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimExtension.java 2008-02-09 06:40:32 UTC (rev 117) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimExtension.java 2008-02-09 06:46:49 UTC (rev 118) @@ -36,14 +36,12 @@ private PatchAnimDocument paDoc; private Document d; - private Node n; public PatchAnimExtension(PatchAnimDocument doc) throws ParserConfigurationException { paDoc = doc; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); d = db.newDocument(); - n = d.createElement("Patch"); } public String getWidth(@SuppressWarnings("unused") ExpressionContext context) { @@ -74,7 +72,6 @@ } public Node item(int index) { - // TODO Auto-generated method stub return d.createTextNode(String.valueOf(index)); } }; @@ -87,7 +84,7 @@ return paDoc.getPatches().get(patchIndex).getName(); } - public NodeList getCoordinates(@SuppressWarnings("unused") ExpressionContext context, String color, Node n) { + public NodeList getCoordinates(@SuppressWarnings("unused") ExpressionContext context) { NodeList nl = new NodeList() { public int getLength() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-06-07 22:58:32
|
Revision: 248 http://patchanim.svn.sourceforge.net/patchanim/?rev=248&view=rev Author: dbrosius Date: 2008-06-07 15:57:14 -0700 (Sat, 07 Jun 2008) Log Message: ----------- WEM fixes Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java 2008-06-07 22:53:31 UTC (rev 247) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java 2008-06-07 22:57:14 UTC (rev 248) @@ -75,7 +75,7 @@ } catch (IOException ioe) { throw ioe; } catch (Exception e) { - IOException ioe = new IOException("Failed saving document"); + IOException ioe = new IOException("Failed saving document " + f.getPath()); ioe.initCause(e); throw ioe; } finally { @@ -104,7 +104,7 @@ } catch (IOException ioe) { throw ioe; } catch (Exception e) { - IOException ioe = new IOException("Failed loading document"); + IOException ioe = new IOException("Failed loading document " + f.getPath()); ioe.initCause(e); throw ioe; } finally { Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java 2008-06-07 22:53:31 UTC (rev 247) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java 2008-06-07 22:57:14 UTC (rev 248) @@ -131,7 +131,7 @@ try { writeSingleFile(pce.getImage(), imageIndex++, loc, baseName, type); } catch (IOException ioe) { - InterruptedException ie = new InterruptedException("Failed saving animation"); + InterruptedException ie = new InterruptedException("Failed saving animation at index " + (imageIndex-1)); ie.initCause(ioe); throw ie; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |