Index: src/java/org/apache/fop/svg/SVGUtilities.java =================================================================== --- src/java/org/apache/fop/svg/SVGUtilities.java (revision 921772) +++ src/java/org/apache/fop/svg/SVGUtilities.java (working copy) @@ -20,17 +20,15 @@ package org.apache.fop.svg; import java.awt.font.FontRenderContext; -import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; import java.util.StringTokenizer; +import org.apache.batik.dom.svg.SVGDOMImplementation; +import org.apache.batik.util.XMLConstants; import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.apache.batik.dom.svg.SVGDOMImplementation; -import org.apache.batik.util.XMLConstants; - /** * Some utilities for creating svg DOM documents and elements. */ @@ -61,11 +59,7 @@ * @return the width of the string in the given font */ public static final float getStringWidth(String str, java.awt.Font font) { - Rectangle2D rect = - font.getStringBounds(str, 0, str.length(), - new FontRenderContext(new AffineTransform(), - true, true)); - return (float)rect.getWidth(); + return (float)getStringBounds(str, font).getWidth(); } /** @@ -74,13 +68,8 @@ * @param font the font * @return the height of the string in the given font */ - public static final float getStringHeight(String str, - java.awt.Font font) { - Rectangle2D rect = - font.getStringBounds(str, 0, str.length(), - new FontRenderContext(new AffineTransform(), - true, true)); - return (float)rect.getHeight(); + public static final float getStringHeight(String str, java.awt.Font font) { + return (float)getStringBounds(str, font).getHeight(); } /** @@ -92,8 +81,7 @@ public static final Rectangle2D getStringBounds(String str, java.awt.Font font) { return font.getStringBounds(str, 0, str.length(), - new FontRenderContext(new AffineTransform(), - true, true)); + new FontRenderContext(null, true, true)); } /** @@ -107,19 +95,19 @@ */ public static final Element createLine(Document doc, float x, float y, float x2, float y2) { - Element ellipse = doc.createElementNS(SVG_NS, "line"); - ellipse.setAttributeNS(null, "x1", "" + x); - ellipse.setAttributeNS(null, "x2", "" + x2); - ellipse.setAttributeNS(null, "y1", "" + y); - ellipse.setAttributeNS(null, "y2", "" + y2); - return ellipse; + Element line = doc.createElementNS(SVG_NS, "line"); + line.setAttributeNS(null, "x1", "" + x); + line.setAttributeNS(null, "x2", "" + x2); + line.setAttributeNS(null, "y1", "" + y); + line.setAttributeNS(null, "y2", "" + y2); + return line; } /** * Create an SVG Ellipse * @param doc the document to create the element - * @param cx the centre x position - * @param cy the centre y position + * @param cx the center x position + * @param cy the center y position * @param rx the x axis radius * @param ry the y axis radius * @return the new ellipse element @@ -175,12 +163,12 @@ */ public static final Element createRect(Document doc, float x, float y, float width, float height) { - Element border = doc.createElementNS(SVG_NS, "rect"); - border.setAttributeNS(null, "x", "" + x); - border.setAttributeNS(null, "y", "" + y); - border.setAttributeNS(null, "width", "" + width); - border.setAttributeNS(null, "height", "" + height); - return border; + Element rect = doc.createElementNS(SVG_NS, "rect"); + rect.setAttributeNS(null, "x", "" + x); + rect.setAttributeNS(null, "y", "" + y); + rect.setAttributeNS(null, "width", "" + width); + rect.setAttributeNS(null, "height", "" + height); + return rect; } /** @@ -189,8 +177,8 @@ * @return the new g element */ public static final Element createG(Document doc) { - Element border = doc.createElementNS(SVG_NS, "g"); - return border; + Element g = doc.createElementNS(SVG_NS, "g"); + return g; } /** @@ -202,10 +190,10 @@ */ public static final Element createClip(Document doc, Element els, String id) { - Element border = doc.createElementNS(SVG_NS, "clipPath"); - border.setAttributeNS(null, "id", id); - border.appendChild(els); - return border; + Element clip = doc.createElementNS(SVG_NS, "clipPath"); + clip.setAttributeNS(null, "id", id); + clip.appendChild(els); + return clip; } /** @@ -218,12 +206,11 @@ */ public static final Element createImage(Document doc, String ref, float width, float height) { - Element border = doc.createElementNS(SVG_NS, "image"); - border.setAttributeNS(XMLConstants.XLINK_NAMESPACE_URI, "href", - ref); - border.setAttributeNS(null, "width", "" + width); - border.setAttributeNS(null, "height", "" + height); - return border; + Element img = doc.createElementNS(SVG_NS, "image"); + img.setAttributeNS(XMLConstants.XLINK_NAMESPACE_URI, "href", ref); + img.setAttributeNS(null, "width", "" + width); + img.setAttributeNS(null, "height", "" + height); + return img; } /**