hillion 01/10/12 00:33:10 Modified: sources/org/apache/batik/bridge CSSUtilities.java SVGAltGlyphElementBridge.java SVGFontUtilities.java URIResolver.java sources/org/apache/batik/dom/svg SVGOMElement.java sources/org/apache/batik/dom/util XMLSupport.java test-resources/org/apache/batik/test samplesRendering.xml Added: sources/org/apache/batik/dom/svg XMLBaseSupport.java Log: - Moved xml:base stuff from dom/util/XMLUtilities.java to dom/svg/XMLBaseSupport.java to address a modularity issue. - More tests setup. Revision Changes Path 1.32 +5 -4 xml-batik/sources/org/apache/batik/bridge/CSSUtilities.java Index: CSSUtilities.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/CSSUtilities.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- CSSUtilities.java 2001/10/09 22:17:10 1.31 +++ CSSUtilities.java 2001/10/12 07:33:09 1.32 @@ -29,7 +29,6 @@ import org.apache.batik.dom.svg.SVGOMDocument; import org.apache.batik.dom.util.XLinkSupport; -import org.apache.batik.dom.util.XMLSupport; import org.apache.batik.ext.awt.MultipleGradientPaint; import org.apache.batik.ext.awt.color.ICCColorSpaceExt; @@ -67,7 +66,7 @@ * concrete objects regarding to CSS properties. * * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> - * @version $Id: CSSUtilities.java,v 1.31 2001/10/09 22:17:10 deweese Exp $ + * @version $Id: CSSUtilities.java,v 1.32 2001/10/12 07:33:09 hillion Exp $ */ public abstract class CSSUtilities implements CSSConstants, ErrorConstants, XMLConstants { @@ -825,14 +824,16 @@ Element localRefElement, String uri) { Attr xmlBase = localRefElement.getAttributeNodeNS - (XML_NAMESPACE_URI, "base"); + (XML_NAMESPACE_URI, "xml:base"); if (xmlBase != null) { // We have a current base so merge it with our new base and // set the result... ParsedURL purl = new ParsedURL(uri, xmlBase.getNodeValue()); uri = purl.toString(); } - XMLSupport.setXMLBase(localRefElement, uri); + localRefElement.setAttributeNS(XML_NAMESPACE_URI, + "xml:base", + uri); SVGOMDocument document = (SVGOMDocument)localRefElement.getOwnerDocument(); 1.7 +10 -6 xml-batik/sources/org/apache/batik/bridge/SVGAltGlyphElementBridge.java Index: SVGAltGlyphElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGAltGlyphElementBridge.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- SVGAltGlyphElementBridge.java 2001/10/09 22:17:10 1.6 +++ SVGAltGlyphElementBridge.java 2001/10/12 07:33:09 1.7 @@ -9,8 +9,8 @@ package org.apache.batik.bridge; import org.apache.batik.dom.svg.SVGOMDocument; +import org.apache.batik.dom.svg.XMLBaseSupport; import org.apache.batik.dom.util.XLinkSupport; -import org.apache.batik.dom.util.XMLSupport; import org.apache.batik.gvt.font.Glyph; import org.apache.batik.gvt.text.GVTAttributedCharacterIterator; @@ -28,7 +28,7 @@ * Bridge class for the <altGlyph> element. * * @author <a href="mailto:[EMAIL PROTECTED]">Bella Robinson</a> - * @version $Id: SVGAltGlyphElementBridge.java,v 1.6 2001/10/09 22:17:10 deweese Exp $ + * @version $Id: SVGAltGlyphElementBridge.java,v 1.7 2001/10/12 07:33:09 hillion Exp $ */ public class SVGAltGlyphElementBridge extends AbstractSVGBridge implements ErrorConstants { @@ -103,10 +103,12 @@ if (!isLocal) { // need to attach the imported element to the document and // then compute the styles and uris - String base = XMLSupport.getXMLBase(altGlyphElement); + String base = XMLBaseSupport.getXMLBase(altGlyphElement); Element g = document.createElementNS(SVG_NAMESPACE_URI, SVG_G_TAG); g.appendChild(localRefElement); - XMLSupport.setXMLBase(g, base); + g.setAttributeNS(XMLBaseSupport.XML_NAMESPACE_URI, + "xml:base", + base); CSSUtilities.computeStyleAndURIs(refElement, localRefElement, uri); @@ -251,10 +253,12 @@ // import the whole font Element localFontElement = (Element)document.importNode(refGlyphElement.getParentNode(), true); - String base = XMLSupport.getXMLBase(altGlyphElement); + String base = XMLBaseSupport.getXMLBase(altGlyphElement); Element g = document.createElementNS(SVG_NAMESPACE_URI, SVG_G_TAG); g.appendChild(localFontElement); - XMLSupport.setXMLBase(g, base); + g.setAttributeNS(XMLBaseSupport.XML_NAMESPACE_URI, + "xml:base", + base); CSSUtilities.computeStyleAndURIs( (Element)refGlyphElement.getParentNode(), localFontElement, glyphUri); 1.7 +6 -4 xml-batik/sources/org/apache/batik/bridge/SVGFontUtilities.java Index: SVGFontUtilities.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGFontUtilities.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- SVGFontUtilities.java 2001/10/09 22:17:10 1.6 +++ SVGFontUtilities.java 2001/10/12 07:33:09 1.7 @@ -13,8 +13,8 @@ import org.apache.batik.gvt.font.GVTFontFamily; import org.apache.batik.gvt.font.UnresolvedFontFamily; import org.apache.batik.dom.util.XLinkSupport; -import org.apache.batik.dom.util.XMLSupport; import org.apache.batik.dom.svg.SVGOMDocument; +import org.apache.batik.dom.svg.XMLBaseSupport; import org.w3c.dom.Element; import org.w3c.dom.Document; @@ -28,7 +28,7 @@ * Utility class for SVG fonts. * * @author <a href="mailto:[EMAIL PROTECTED]">Bella Robinson</a> - * @version $Id: SVGFontUtilities.java,v 1.6 2001/10/09 22:17:10 deweese Exp $ + * @version $Id: SVGFontUtilities.java,v 1.7 2001/10/12 07:33:09 hillion Exp $ */ public abstract class SVGFontUtilities implements SVGConstants { @@ -134,14 +134,16 @@ fontElement = (isLocal) ? refElement : (Element)document.importNode(refElement, true); if (!isLocal) { - String base = XMLSupport.getXMLBase(fontFaceUriElement); + String base = XMLBaseSupport.getXMLBase(fontFaceUriElement); // need to attach the imported // element to the document and // then compute the styles and // uris Element g = document.createElementNS(SVG_NAMESPACE_URI, SVG_G_TAG); g.appendChild(fontElement); - XMLSupport.setXMLBase(g, base); + g.setAttributeNS(XMLBaseSupport.XML_NAMESPACE_URI, + "xml:base", + base); CSSUtilities.computeStyleAndURIs(refElement, fontElement, uri); } } 1.10 +3 -3 xml-batik/sources/org/apache/batik/bridge/URIResolver.java Index: URIResolver.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/URIResolver.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- URIResolver.java 2001/10/09 22:17:10 1.9 +++ URIResolver.java 2001/10/12 07:33:09 1.10 @@ -15,8 +15,8 @@ import org.apache.batik.css.CSSOMReadOnlyStyleDeclaration; import org.apache.batik.css.CSSOMReadOnlyValue; import org.apache.batik.dom.svg.SVGOMDocument; +import org.apache.batik.dom.svg.XMLBaseSupport; import org.apache.batik.dom.util.XLinkSupport; -import org.apache.batik.dom.util.XMLSupport; import org.apache.batik.util.ParsedURL; import org.w3c.dom.Document; @@ -28,7 +28,7 @@ * This class is used to resolve the URI that can be found in a SVG document. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: URIResolver.java,v 1.9 2001/10/09 22:17:10 deweese Exp $ + * @version $Id: URIResolver.java,v 1.10 2001/10/12 07:33:09 hillion Exp $ */ public class URIResolver { /** @@ -79,7 +79,7 @@ public Node getNode(String uri, Element ref) throws MalformedURLException, IOException { - String baseURI = XMLSupport.getXMLBase(ref); + String baseURI = XMLBaseSupport.getXMLBase(ref); if ((baseURI == null) && (uri.startsWith("#"))) return document.getElementById(uri.substring(1)); 1.9 +5 -3 xml-batik/sources/org/apache/batik/dom/svg/SVGOMElement.java Index: SVGOMElement.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/svg/SVGOMElement.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- SVGOMElement.java 2001/09/12 16:57:07 1.8 +++ SVGOMElement.java 2001/10/12 07:33:09 1.9 @@ -15,6 +15,7 @@ import org.apache.batik.dom.util.DOMUtilities; import org.apache.batik.util.SVGConstants; +import org.apache.batik.util.XMLConstants; import org.w3c.dom.DOMException; import org.w3c.dom.Element; @@ -28,7 +29,7 @@ * This class implements the {@link SVGElement} interface. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: SVGOMElement.java,v 1.8 2001/09/12 16:57:07 hillion Exp $ + * @version $Id: SVGOMElement.java,v 1.9 2001/10/12 07:33:09 hillion Exp $ */ public abstract class SVGOMElement extends AbstractElement @@ -78,13 +79,14 @@ * <b>DOM</b>: Implements {@link SVGElement#getXMLbase()}. */ public String getXMLbase() { - throw new RuntimeException("!!! TODO: getXMLbase()"); + return XMLBaseSupport.getXMLBase(this); } + /** * <b>DOM</b>: Implements {@link SVGElement#setXMLbase(String)}. */ public void setXMLbase(String xmlbase) throws DOMException { - throw new RuntimeException("!!! TODO: setXMLbase()"); + setAttributeNS(XMLConstants.XML_NAMESPACE_URI, "xml:base", xmlbase); } /** 1.1 xml-batik/sources/org/apache/batik/dom/svg/XMLBaseSupport.java Index: XMLBaseSupport.java =================================================================== /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.batik.dom.svg; import java.net.URL; import org.apache.batik.css.HiddenChildElement; import org.apache.batik.util.XMLConstants; import org.apache.batik.util.ParsedURL; import org.w3c.dom.Attr; import org.w3c.dom.Element; import org.w3c.dom.Node; /** * This class provides support for the xml:base attribute. * * @author <a href="mailto:[EMAIL PROTECTED]">Thomas DeWeese</a> * @version $Id: XMLBaseSupport.java,v 1.1 2001/10/12 07:33:09 hillion Exp $ */ public class XMLBaseSupport implements XMLConstants { /** * This class does not need to be instanciated. */ protected XMLBaseSupport() { } /** * Returns the xml:base attribute value of the given element * Resolving any dependency on parent bases if needed. */ public static String getXMLBase(Element elt) { String base = null; Node n = elt; while (true) { if (n.getParentNode() != null) { n = n.getParentNode(); } else if (n instanceof HiddenChildElement) { n = ((HiddenChildElement)n).getParentElement(); } else { break; } // new Exception("N: " + n).printStackTrace(); if (n== null) break; if (n.getNodeType() == Node.ELEMENT_NODE) { base = getXMLBase((Element)n); break; } } if (base == null) { SVGOMDocument svgDoc; svgDoc = (SVGOMDocument)elt.getOwnerDocument(); URL url = svgDoc.getURLObject(); if (url != null) { base = url.toString(); } } Attr attr = elt.getAttributeNodeNS(XML_NAMESPACE_URI, "base"); if (attr != null) { // System.out.println("Base: " + base + // " attr: " + attr.getNodeValue()); if (base == null) { base = attr.getNodeValue(); } else { base = new ParsedURL(base, attr.getNodeValue()).toString(); } } return base; } } 1.6 +3 -55 xml-batik/sources/org/apache/batik/dom/util/XMLSupport.java Index: XMLSupport.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/util/XMLSupport.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- XMLSupport.java 2001/10/09 22:17:10 1.5 +++ XMLSupport.java 2001/10/12 07:33:09 1.6 @@ -8,10 +8,7 @@ package org.apache.batik.dom.util; -import java.net.URL; - import org.apache.batik.util.XMLConstants; -import org.apache.batik.util.ParsedURL; import org.w3c.dom.Attr; import org.w3c.dom.DOMException; @@ -22,12 +19,13 @@ * This class provides support for XML features. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: XMLSupport.java,v 1.5 2001/10/09 22:17:10 deweese Exp $ + * @version $Id: XMLSupport.java,v 1.6 2001/10/12 07:33:09 hillion Exp $ */ public class XMLSupport implements XMLConstants { + /** - * This class do not need to be instanciated. + * This class does not need to be instanciated. */ protected XMLSupport() { } @@ -71,56 +69,6 @@ } return "default"; } - - /** - * Returns the xml:base attribute value of the given element - * Resolving any dependency on parent bases if needed. - */ - public static String getXMLBase(Element elt) { - String base = null; - Node n = elt; - while (true) { - if (n.getParentNode() != null) - n = n.getParentNode(); - else if (n instanceof org.apache.batik.css.HiddenChildElement) - n = ((org.apache.batik.css.HiddenChildElement)n) - .getParentElement(); - else - break; - - // new Exception("N: " + n).printStackTrace(); - if (n== null) break; - if (n.getNodeType() == Node.ELEMENT_NODE) { - base = getXMLBase((Element)n); - break; - } - } - - if (base == null) { - // try to load the image as an svg document - org.apache.batik.dom.svg.SVGOMDocument svgDoc; - svgDoc = (org.apache.batik.dom.svg.SVGOMDocument) - elt.getOwnerDocument(); - URL url = svgDoc.getURLObject(); - if (url != null) - base = url.toString(); - } - Attr attr = elt.getAttributeNodeNS(XML_NAMESPACE_URI, "base"); - if (attr != null) { - // System.out.println("Base: " + base + - // " attr: " + attr.getNodeValue()); - if (base == null) - base = attr.getNodeValue(); - else - base = new ParsedURL(base, attr.getNodeValue()).toString(); - } - return base; - } - - public static void setXMLBase(Element elt, String base) { - elt.setAttributeNS(XML_NAMESPACE_URI, "base", base); - } - /** * Strips the white spaces in the given string according to the xml:space 1.29 +23 -7 xml-batik/test-resources/org/apache/batik/test/samplesRendering.xml Index: samplesRendering.xml =================================================================== RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/test/samplesRendering.xml,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- samplesRendering.xml 2001/10/11 19:22:13 1.28 +++ samplesRendering.xml 2001/10/12 07:33:09 1.29 @@ -8,7 +8,7 @@ <!-- ========================================================================= --> <!-- @author [EMAIL PROTECTED] --> -<!-- @version $Id: samplesRendering.xml,v 1.28 2001/10/11 19:22:13 hillion Exp $ --> +<!-- @version $Id: samplesRendering.xml,v 1.29 2001/10/12 07:33:09 hillion Exp $ --> <!-- ========================================================================= --> <testSuite id="samplesRendering" name="samples and samples/test Rendering"> <!-- ========================================================================== --> @@ -878,12 +878,28 @@ </test> <!-- Sample tests, media test --> - <test id="samples/tests/smiley.svg-Smiling" class="org.apache.batik.test.svg.SVGAlternateStyleSheetRenderingAccuracyTest"> - <arg class="java.lang.String" value="samples/tests/smiley.svg"/> - <arg class="java.lang.String" value="test-references/samples/tests/smileySmiling.png"/> - <arg class="java.lang.String" value="Smiling"/> - <property name="VariationURL" class="java.lang.String" value="test-references/samples/accepted-variation/smileySmiling.png"/> - <property name="SaveVariation" class="java.io.File" value="test-references/samples/candidate-variation/smileySmiling.png"/> + <test id="samples/tests/cssMedia.svg-screen" class="org.apache.batik.test.svg.SVGMediaRenderingAccuracyTest"> + <arg class="java.lang.String" value="samples/tests/cssMedia.svg"/> + <arg class="java.lang.String" value="test-references/samples/tests/cssMediaScreen.png"/> + <arg class="java.lang.String" value="screen"/> + <property name="VariationURL" class="java.lang.String" value="test-references/samples/accepted-variation/cssMediaScreen.png"/> + <property name="SaveVariation" class="java.io.File" value="test-references/samples/candidate-variation/cssMediaScreen.png"/> + </test> + + <test id="samples/tests/cssMedia.svg-print" class="org.apache.batik.test.svg.SVGMediaRenderingAccuracyTest"> + <arg class="java.lang.String" value="samples/tests/cssMedia.svg"/> + <arg class="java.lang.String" value="test-references/samples/tests/cssMediaPrint.png"/> + <arg class="java.lang.String" value="print"/> + <property name="VariationURL" class="java.lang.String" value="test-references/samples/accepted-variation/cssMediaPrint.png"/> + <property name="SaveVariation" class="java.io.File" value="test-references/samples/candidate-variation/cssMediaPrint.png"/> + </test> + + <test id="samples/tests/cssMedia.svg-projection" class="org.apache.batik.test.svg.SVGMediaRenderingAccuracyTest"> + <arg class="java.lang.String" value="samples/tests/cssMedia.svg"/> + <arg class="java.lang.String" value="test-references/samples/tests/cssMediaProjection.png"/> + <arg class="java.lang.String" value="projection"/> + <property name="VariationURL" class="java.lang.String" value="test-references/samples/accepted-variation/cssMediaProjection.png"/> + <property name="SaveVariation" class="java.io.File" value="test-references/samples/candidate-variation/cssMediaProjection.png"/> </test>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]