deweese 02/04/27 15:41:58 Modified: resources/org/apache/batik/bridge/resources Messages.properties sources/org/apache/batik/bridge AbstractSVGGradientElementBridge.java ErrorConstants.java SVGColorProfileElementBridge.java SVGGVTFont.java SVGImageElementBridge.java SVGPatternElementBridge.java SVGTextElementBridge.java SVGUtilities.java URIResolver.java sources/org/apache/batik/gvt/text GlyphLayout.java Log: 1) Fixed a bug that prevented circular refernce errors from being printed. (resource id had a ':' in it). 2) Changed a bunch of code from URL to ParsedURL. 3) Fixed a bug with empty text in flows. 4) Fixed how lineMetrics are generated in SVGGVTFont. Revision Changes Path 1.8 +1 -1 xml-batik/resources/org/apache/batik/bridge/resources/Messages.properties Index: Messages.properties =================================================================== RCS file: /home/cvs/xml-batik/resources/org/apache/batik/bridge/resources/Messages.properties,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Messages.properties 7 Mar 2002 10:47:49 -0000 1.7 +++ Messages.properties 27 Apr 2002 22:41:57 -0000 1.8 @@ -26,7 +26,7 @@ {0}:{1}\n\ The URI ''{3}'' for a CSS property found on the element <{2}> is invalid -xlink:href.circularDependencies = \ +xlink.href.circularDependencies = \ {0}:{1}\n\ A circular dependency has been detected on the element <{2}> for the URI ''{3}'' 1.9 +8 -14 xml-batik/sources/org/apache/batik/bridge/AbstractSVGGradientElementBridge.java Index: AbstractSVGGradientElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/AbstractSVGGradientElementBridge.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- AbstractSVGGradientElementBridge.java 20 Mar 2002 16:34:43 -0000 1.8 +++ AbstractSVGGradientElementBridge.java 27 Apr 2002 22:41:57 -0000 1.9 @@ -11,8 +11,6 @@ import java.awt.Color; import java.awt.Paint; import java.awt.geom.AffineTransform; -import java.net.MalformedURLException; -import java.net.URL; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -21,6 +19,7 @@ import org.apache.batik.dom.util.XLinkSupport; import org.apache.batik.ext.awt.MultipleGradientPaint; import org.apache.batik.gvt.GraphicsNode; +import org.apache.batik.util.ParsedURL; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -33,7 +32,7 @@ * Bridge class for vending gradients. * * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> - * @version $Id: AbstractSVGGradientElementBridge.java,v 1.8 2002/03/20 16:34:43 tkormann Exp $ + * @version $Id: AbstractSVGGradientElementBridge.java,v 1.9 2002/04/27 22:41:57 deweese Exp $ */ public abstract class AbstractSVGGradientElementBridge extends AbstractSVGBridge implements PaintBridge, ErrorConstants { @@ -189,21 +188,18 @@ } // check if there is circular dependencies SVGOMDocument doc = (SVGOMDocument)paintElement.getOwnerDocument(); - URL url; - try { - url = new URL(doc.getURLObject(), uri); - } catch (MalformedURLException ex) { + ParsedURL purl = new ParsedURL(doc.getURL(), uri); + if (!purl.complete()) throw new BridgeException(paintElement, ERR_URI_MALFORMED, new Object[] {uri}); - } - if (contains(refs, url)) { + if (contains(refs, purl)) { throw new BridgeException(paintElement, ERR_XLINK_HREF_CIRCULAR_DEPENDENCIES, new Object[] {uri}); } - refs.add(url); + refs.add(purl); paintElement = ctx.getReferencedElement(paintElement, uri); } } @@ -256,13 +252,11 @@ * @param urls the list of URLs * @param key the url to search for */ - private static boolean contains(List urls, URL key) { + private static boolean contains(List urls, ParsedURL key) { Iterator iter = urls.iterator(); while (iter.hasNext()) { - URL url = (URL)iter.next(); - if (url.sameFile(key) && url.getRef().equals(key.getRef())) { + if (key.equals(iter.next())) return true; - } } return false; } 1.4 +2 -2 xml-batik/sources/org/apache/batik/bridge/ErrorConstants.java Index: ErrorConstants.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/ErrorConstants.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ErrorConstants.java 19 Sep 2001 12:11:50 -0000 1.3 +++ ErrorConstants.java 27 Apr 2002 22:41:57 -0000 1.4 @@ -12,7 +12,7 @@ * The error code. * * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> - * @version $Id: ErrorConstants.java,v 1.3 2001/09/19 12:11:50 deweese Exp $ + * @version $Id: ErrorConstants.java,v 1.4 2002/04/27 22:41:57 deweese Exp $ */ public interface ErrorConstants { @@ -66,7 +66,7 @@ * {0} = the uri */ public static final String ERR_XLINK_HREF_CIRCULAR_DEPENDENCIES - = "xlink:href.circularDependencies"; + = "xlink.href.circularDependencies"; /** * The error code when the bridge try to load a URI 1.9 +8 -8 xml-batik/sources/org/apache/batik/bridge/SVGColorProfileElementBridge.java Index: SVGColorProfileElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGColorProfileElementBridge.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- SVGColorProfileElementBridge.java 2 May 2001 15:50:02 -0000 1.8 +++ SVGColorProfileElementBridge.java 27 Apr 2002 22:41:57 -0000 1.9 @@ -12,14 +12,14 @@ import java.awt.color.ICC_ColorSpace; import java.awt.color.ICC_Profile; import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; import org.apache.batik.dom.svg.SVGOMDocument; import org.apache.batik.dom.util.XLinkSupport; import org.apache.batik.ext.awt.color.ICCColorSpaceExt; import org.apache.batik.ext.awt.color.NamedProfileCache; + import org.apache.batik.util.SVGConstants; +import org.apache.batik.util.ParsedURL; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -31,7 +31,7 @@ * <tt>ICC_ColorSpace</tt> object. * * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Hardy</a> - * @version $Id: SVGColorProfileElementBridge.java,v 1.8 2001/05/02 15:50:02 tkormann Exp $ */ + * @version $Id: SVGColorProfileElementBridge.java,v 1.9 2002/04/27 22:41:57 deweese Exp $ */ public class SVGColorProfileElementBridge extends AbstractSVGBridge implements ErrorConstants { @@ -94,13 +94,13 @@ String href = XLinkSupport.getXLinkHref(profile); ICC_Profile p = null; if (href != null) { - try{ - URL baseURL = ((SVGOMDocument)doc).getURLObject(); - URL url = new URL(baseURL, href); - p = ICC_Profile.getInstance(url.openStream()); - } catch(MalformedURLException e) { + String baseURI= ((SVGOMDocument)doc).getURL(); + ParsedURL purl = new ParsedURL(baseURI, href); + if (!purl.complete()) throw new BridgeException(paintedElement, ERR_URI_MALFORMED, new Object[] {href}); + try{ + p = ICC_Profile.getInstance(purl.openStream()); } catch(IOException e) { throw new BridgeException(paintedElement, ERR_URI_IO, new Object[] {href}); 1.9 +12 -32 xml-batik/sources/org/apache/batik/bridge/SVGGVTFont.java Index: SVGGVTFont.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGGVTFont.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- SVGGVTFont.java 18 Mar 2002 10:28:19 -0000 1.8 +++ SVGGVTFont.java 27 Apr 2002 22:41:57 -0000 1.9 @@ -42,7 +42,7 @@ * Represents an SVG font. * * @author <a href="mailto:[EMAIL PROTECTED]">Bella Robinson</a> - * @version $Id: SVGGVTFont.java,v 1.8 2002/03/18 10:28:19 hillion Exp $ + * @version $Id: SVGGVTFont.java,v 1.9 2002/04/27 22:41:57 deweese Exp $ */ public final class SVGGVTFont implements GVTFont, SVGConstants { @@ -767,53 +767,33 @@ */ public GVTLineMetrics getLineMetrics(CharacterIterator ci, int beginIndex, int limit, FontRenderContext frc) { - - // first create the character iterator that represents the subset - // from beginIndex to limit - String s = ""; - char c = ci.setIndex(beginIndex); - int currentIndex = beginIndex; - - while (c != ci.DONE && currentIndex < limit) { - s += c; - currentIndex++; - c = ci.next(); - } - - StringCharacterIterator sci = new StringCharacterIterator(s); - GVTGlyphVector gv = createGlyphVector(frc, sci); - float fontHeight = fontFace.getUnitsPerEm(); float scale = fontSize/fontHeight; float ascent = fontFace.getAscent() * scale; float descent = fontFace.getDescent() * scale; - int numGlyphs = gv.getNumGlyphs(); - - float[] baselineOffsets = new float[numGlyphs]; - for (int i = 0; i < numGlyphs; i++) { - baselineOffsets[i] = - (float)( gv.getGlyphMetrics(i).getBounds2D().getMaxY() - - gv.getGlyphPosition(i).getY()); - } + float[] baselineOffsets = new float[3]; + baselineOffsets[Font.ROMAN_BASELINE] = 0; + baselineOffsets[Font.CENTER_BASELINE] = (ascent+descent)/2-ascent; + baselineOffsets[Font.HANGING_BASELINE] = -ascent; float strikethroughOffset = fontFace.getStrikethroughPosition() * -scale; float strikethroughThickness = fontFace.getStrikethroughThickness() * scale; - float underlineOffset = fontFace.getUnderlinePosition() * scale; + float underlineOffset = fontFace.getUnderlinePosition() * scale; float underlineThickness = fontFace.getUnderlineThickness() * scale; - float overlineOffset = fontFace.getOverlinePosition() * -scale; - float overlineThickness = fontFace.getOverlineThickness() * scale; + float overlineOffset = fontFace.getOverlinePosition() * -scale; + float overlineThickness = fontFace.getOverlineThickness() * scale; return new GVTLineMetrics(ascent, Font.ROMAN_BASELINE, baselineOffsets, descent, fontHeight, - fontHeight, numGlyphs, strikethroughOffset, - strikethroughThickness, underlineOffset, - underlineThickness, overlineOffset, - overlineThickness); + fontHeight, limit-beginIndex, + strikethroughOffset, strikethroughThickness, + underlineOffset, underlineThickness, + overlineOffset, overlineThickness); } /** 1.44 +1 -3 xml-batik/sources/org/apache/batik/bridge/SVGImageElementBridge.java Index: SVGImageElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGImageElementBridge.java,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- SVGImageElementBridge.java 21 Mar 2002 10:59:34 -0000 1.43 +++ SVGImageElementBridge.java 27 Apr 2002 22:41:57 -0000 1.44 @@ -16,8 +16,6 @@ import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D; import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; import java.util.Map; import org.apache.batik.css.engine.SVGCSSEngine; @@ -57,7 +55,7 @@ * Bridge class for the <image> element. * * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> - * @version $Id: SVGImageElementBridge.java,v 1.43 2002/03/21 10:59:34 hillion Exp $ + * @version $Id: SVGImageElementBridge.java,v 1.44 2002/04/27 22:41:57 deweese Exp $ */ public class SVGImageElementBridge extends AbstractGraphicsNodeBridge { 1.22 +13 -18 xml-batik/sources/org/apache/batik/bridge/SVGPatternElementBridge.java Index: SVGPatternElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGPatternElementBridge.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- SVGPatternElementBridge.java 23 Jan 2002 14:14:07 -0000 1.21 +++ SVGPatternElementBridge.java 27 Apr 2002 22:41:57 -0000 1.22 @@ -11,8 +11,6 @@ import java.awt.Paint; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; -import java.net.MalformedURLException; -import java.net.URL; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -29,6 +27,8 @@ import org.apache.batik.gvt.GraphicsNode; import org.apache.batik.gvt.PatternPaint; +import org.apache.batik.util.ParsedURL; + import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -36,7 +36,7 @@ * Bridge class for the <pattern> element. * * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> - * @version $Id: SVGPatternElementBridge.java,v 1.21 2002/01/23 14:14:07 deweese Exp $ + * @version $Id: SVGPatternElementBridge.java,v 1.22 2002/04/27 22:41:57 deweese Exp $ */ public class SVGPatternElementBridge extends AbstractSVGBridge implements PaintBridge, ErrorConstants { @@ -233,21 +233,18 @@ // check if there is circular dependencies SVGOMDocument doc = (SVGOMDocument)patternElement.getOwnerDocument(); - URL url; - try { - url = new URL(doc.getURLObject(), uri); - } catch (MalformedURLException ex) { + ParsedURL purl = new ParsedURL(doc.getURL(), uri); + if (!purl.complete()) throw new BridgeException(patternElement, ERR_URI_MALFORMED, new Object[] {uri}); - } - if (contains(refs, url)) { + if (contains(refs, purl)) { throw new BridgeException(patternElement, ERR_XLINK_HREF_CIRCULAR_DEPENDENCIES, new Object[] {uri}); } - refs.add(url); + refs.add(purl); patternElement = ctx.getReferencedElement(patternElement, uri); } } @@ -284,18 +281,16 @@ } /** - * Returns true if the specified list of URLs contains the specified url. + * Returns true if the specified list of ParsedURLs contains the + * specified url. * - * @param urls the list of URLs - * @param key the url to search for - */ - private static boolean contains(List urls, URL key) { + * @param urls the list of ParsedURLs + * @param key the url to search for */ + private static boolean contains(List urls, ParsedURL key) { Iterator iter = urls.iterator(); while (iter.hasNext()) { - URL url = (URL)iter.next(); - if (url.sameFile(key) && url.getRef().equals(key.getRef())) { + if (key.equals(iter.next())) return true; - } } return false; } 1.64 +2 -3 xml-batik/sources/org/apache/batik/bridge/SVGTextElementBridge.java Index: SVGTextElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGTextElementBridge.java,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- SVGTextElementBridge.java 26 Apr 2002 08:48:53 -0000 1.63 +++ SVGTextElementBridge.java 27 Apr 2002 22:41:57 -0000 1.64 @@ -19,8 +19,7 @@ import java.awt.geom.AffineTransform; import java.awt.geom.Point2D; import java.io.StringReader; -import java.net.MalformedURLException; -import java.net.URL; + import java.text.AttributedCharacterIterator; import java.text.AttributedCharacterIterator.Attribute; import java.text.AttributedString; @@ -69,7 +68,7 @@ * * @author <a href="[EMAIL PROTECTED]">Stephane Hillion</a> * @author <a href="[EMAIL PROTECTED]">Bill Haneman</a> - * @version $Id: SVGTextElementBridge.java,v 1.63 2002/04/26 08:48:53 vhardy Exp $ + * @version $Id: SVGTextElementBridge.java,v 1.64 2002/04/27 22:41:57 deweese Exp $ */ public class SVGTextElementBridge extends AbstractGraphicsNodeBridge { 1.20 +19 -18 xml-batik/sources/org/apache/batik/bridge/SVGUtilities.java Index: SVGUtilities.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGUtilities.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- SVGUtilities.java 18 Mar 2002 10:28:20 -0000 1.19 +++ SVGUtilities.java 27 Apr 2002 22:41:57 -0000 1.20 @@ -37,6 +37,7 @@ import org.apache.batik.parser.PreserveAspectRatioParser; import org.apache.batik.util.SVGConstants; +import org.apache.batik.util.ParsedURL; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -52,7 +53,7 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: SVGUtilities.java,v 1.19 2002/03/18 10:28:20 hillion Exp $ + * @version $Id: SVGUtilities.java,v 1.20 2002/04/27 22:41:57 deweese Exp $ */ public abstract class SVGUtilities implements SVGConstants, ErrorConstants { @@ -259,25 +260,25 @@ return ""; } SVGDocument svgDoc = (SVGDocument)e.getOwnerDocument(); - URL baseURL = ((SVGOMDocument)svgDoc).getURLObject(); - try { - URL url = new URL(baseURL, uriStr); - Iterator iter = refs.iterator(); - while (iter.hasNext()) { - URL urlTmp = (URL)iter.next(); - if (urlTmp.sameFile(url) && - urlTmp.getRef().equals(url.getRef())) { - throw new BridgeException - (e, ERR_XLINK_HREF_CIRCULAR_DEPENDENCIES, - new Object[] {uriStr}); - } - } - URIResolver resolver = new URIResolver(svgDoc, loader); - e = resolver.getElement(url.toString(), e); - refs.add(url); - } catch(MalformedURLException ex) { + String baseURI = ((SVGOMDocument)svgDoc).getURL(); + + ParsedURL purl = new ParsedURL(baseURI, uriStr); + if (!purl.complete()) throw new BridgeException(e, ERR_URI_MALFORMED, new Object[] {uriStr}); + + Iterator iter = refs.iterator(); + while (iter.hasNext()) { + if (purl.equals(iter.next())) + throw new BridgeException + (e, ERR_XLINK_HREF_CIRCULAR_DEPENDENCIES, + new Object[] {uriStr}); + } + + try { + URIResolver resolver = new URIResolver(svgDoc, loader); + e = resolver.getElement(purl.toString(), e); + refs.add(purl); } catch(IOException ex) { throw new BridgeException(e, ERR_URI_IO, new Object[] {uriStr}); 1.16 +1 -2 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.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- URIResolver.java 18 Mar 2002 10:28:20 -0000 1.15 +++ URIResolver.java 27 Apr 2002 22:41:57 -0000 1.16 @@ -10,7 +10,6 @@ import java.io.IOException; import java.net.MalformedURLException; -import java.net.URL; import org.apache.batik.dom.svg.SVGOMDocument; import org.apache.batik.dom.svg.XMLBaseSupport; import org.apache.batik.dom.util.XLinkSupport; @@ -25,7 +24,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.15 2002/03/18 10:28:20 hillion Exp $ + * @version $Id: URIResolver.java,v 1.16 2002/04/27 22:41:57 deweese Exp $ */ public class URIResolver { /** 1.40 +7 -3 xml-batik/sources/org/apache/batik/gvt/text/GlyphLayout.java Index: GlyphLayout.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/text/GlyphLayout.java,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- GlyphLayout.java 12 Apr 2002 14:36:48 -0000 1.39 +++ GlyphLayout.java 27 Apr 2002 22:41:57 -0000 1.40 @@ -47,7 +47,7 @@ * @see org.apache.batik.gvt.text.TextSpanLayout * * @author <a href="[EMAIL PROTECTED]>Bill Haneman</a> - * @version $Id: GlyphLayout.java,v 1.39 2002/04/12 14:36:48 deweese Exp $ + * @version $Id: GlyphLayout.java,v 1.40 2002/04/27 22:41:57 deweese Exp $ */ public class GlyphLayout implements TextSpanLayout { @@ -2214,8 +2214,12 @@ gv.setGlyphPosition(i, new Point2D.Float(x, y)); } - float x = lineLoc.x + (gp[2*i] -xOrig)*xScale+xAdj; - float y = lineLoc.y + (gp[2*i+1]-yOrig); + float x = xOrig; + float y = yOrig; + if (lineLoc != null) { + x = lineLoc.x + (gp[2*i] -xOrig)*xScale+xAdj; + y = lineLoc.y + (gp[2*i+1]-yOrig); + } gv.setGlyphPosition(i, new Point2D.Float(x, y)); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]