deweese 2003/02/08 05:25:12 Modified: resources/org/apache/batik/apps/svgbrowser/resources init.svg sources/org/apache/batik/bridge SVGTextElementBridge.java sources/org/apache/batik/css/engine/value/svg GlyphOrientationManager.java sources/org/apache/batik/ext/awt/image/codec/tiff TIFFEncodeParam.java sources/org/apache/batik/gvt/text GVTAttributedCharacterIterator.java GlyphLayout.java sources/org/apache/batik/util ParsedURLJarProtocolHandler.java test-resources/org/apache/batik/test samplesRendering.xml test-resources/org/apache/batik/util unitTesting.xml test-resources/org/apache/batik/util/resources TestMessages.properties test-sources/org/apache/batik/util Base64Test.java ParsedURLDataTest.java ParsedURLTest.java Added: contrib/tiledTranscoder TiledImageTranscoder.java samples/tests/spec/text textGlyphOrientationHorizontal.svg test-sources/org/apache/batik/util TestMessages.java Removed: test-sources/org/apache/batik/util Messages.java Log: 1) glyph-orientation-horizontal now works properly. glyph-orientation-v/h no longer require a unit as per the SVG specification. added tests for glyph-orientation-horizontal 2) ParsedURL now handles 'jar' protocol URL's better. Also includes tests (Thanks to Keven Ring). Fixed error message handling in bati.util tests. 3) TIFFEncodeParam now uses correct values for compression types (Thanks to Felicia Ionascu) 4) Added example TiledImageTranscoder to contrib/tiledTranscoder. Revision Changes Path 1.1 xml-batik/contrib/tiledTranscoder/TiledImageTranscoder.java Index: TiledImageTranscoder.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.apps.tiledTranscoder; import java.awt.image.renderable.*; import java.awt.image.*; import java.io.*; import org.apache.batik.transcoder.*; import org.apache.batik.transcoder.image.*; import org.apache.batik.ext.awt.image.*; import org.apache.batik.ext.awt.image.codec.*; import org.apache.batik.ext.awt.image.codec.tiff.*; import org.apache.batik.ext.awt.image.rendered.*; import org.apache.batik.ext.awt.image.renderable.*; import org.w3c.dom.Document; public class TiledImageTranscoder extends SVGAbstractTranscoder { /** * Constructs a new <tt>ImageTranscoder</tt>. */ protected TiledImageTranscoder() { } /** * Transcodes the specified Document as an image in the specified output. * * @param document the document to transcode * @param uri the uri of the document or null if any * @param output the ouput where to transcode * @exception TranscoderException if an error occured while transcoding */ protected void transcode(Document document, String uri, TranscoderOutput output) throws TranscoderException { // Sets up root, curTxf & curAoi super.transcode(document, uri, output); Filter f = this.root.getGraphicsNodeRable(true); RenderContext rc = new RenderContext(curTxf, null, null); RenderedImage img = f.createRendering(rc); // prepare the image to be painted int w = img.getWidth(); int h = img.getHeight(); try { int bands = img.getSampleModel().getNumBands(); int [] off = new int[bands]; for (int i=0; i<bands; i++) off[i] = i; SampleModel sm = new PixelInterleavedSampleModel (DataBuffer.TYPE_BYTE, w, (100000+w-1)/w, bands, w*bands, off); RenderedImage rimg = new FormatRed(GraphicsUtil.wrap(img), sm); TIFFImageEncoder enc = new TIFFImageEncoder (output.getOutputStream(), null); enc.encode(rimg); } catch (IOException ioe) { ioe.printStackTrace(); } } public static void main (String [] args) { try { FileOutputStream fos = new FileOutputStream(args[1]); TiledImageTranscoder tit = new TiledImageTranscoder(); tit.addTranscodingHint(KEY_WIDTH, new Float(10240)); tit.transcode(new TranscoderInput("file:" + args[0]), new TranscoderOutput(fos)); } catch (IOException ioe) { ioe.printStackTrace(); } catch (TranscoderException te) { te.printStackTrace(); } } } 1.6 +3 -3 xml-batik/resources/org/apache/batik/apps/svgbrowser/resources/init.svg Index: init.svg =================================================================== RCS file: /home/cvs/xml-batik/resources/org/apache/batik/apps/svgbrowser/resources/init.svg,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- init.svg 6 Dec 2001 09:04:51 -0000 1.5 +++ init.svg 8 Feb 2003 13:25:11 -0000 1.6 @@ -1,11 +1,11 @@ <?xml version="1.0" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" + "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> + <!-- =================================================================== --> <!-- A dummy document used to preload classes. --> <!-- =================================================================== --> - -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" - "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="100" viewBox="0 0 100 100"> 1.1 xml-batik/samples/tests/spec/text/textGlyphOrientationHorizontal.svg Index: textGlyphOrientationHorizontal.svg =================================================================== <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <!-- ====================================================================== --> <!-- 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. --> <!-- ====================================================================== --> <!-- ====================================================================== --> <!-- Test the x,dx and y,dy attributes --> <!-- --> <!-- @author [EMAIL PROTECTED] --> <!-- @version $Id: textGlyphOrientationHorizontal.svg,v 1.1 2003/02/08 13:25:11 deweese Exp $ --> <!-- ====================================================================== --> <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?> <svg width="450" height="500" viewBox="0 0 450 500" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" > <title>Text Orientation Horizontal</title> <!-- ============================================================= --> <!-- Test content --> <!-- ============================================================= --> <defs> <path id="path" style="fill:none; stroke:blue;" d="M 20 40 C 40 20 60 0 80 20 C 100 40 120 60 140 40 C 160 20 180 20 180 20"/> <path id="lpath" style="fill:none; stroke:blue;" d="M 20 40 c 40 -20 80 -40 120 -20 c 40 20 80 40 120 20 c 40 -20 80 -20 80 -20"/> </defs> <text class="title" x="50%" y="30">Text Orientation Horizontal</text> <g id="testContent" style="font-family:Arial; font-size:24"> <line x1="50" x2="200" y1="80" y2="80" stroke="blue" stroke-width="2"/> <text x="50" y="80" glyph-orientation-horizontal="0">Batik is Good</text> <g transform="translate(220, 60)"> <use xlink:href="#path" fill="none" stroke="blue" stroke-width="2"/> <text glyph-orientation-horizontal="0"> <textPath xlink:href="#path">Batik <tspan fill="red" dy="-10">is</tspan><tspan dy="10"> Good</tspan></textPath> </text> </g> <line x1="50" x2="400" y1="130" y2="130" stroke="blue" stroke-width="2"/> <text x="50" y="130" glyph-orientation-horizontal="90" >Batik is Good</text> <g transform="translate(30, 150)"> <use xlink:href="#lpath" fill="none" stroke="blue" stroke-width="2"/> <text glyph-orientation-horizontal="90"> <textPath xlink:href="#lpath">Batik <tspan fill="red" dy="-10">is</tspan><tspan dy="10"> Good</tspan></textPath> </text> </g> <line x1="50" x2="200" y1="240" y2="240" stroke="blue" stroke-width="2"/> <text x="50" y="240" glyph-orientation-horizontal="180" >Batik is Good</text> <g transform="translate(220, 220)"> <use xlink:href="#path" fill="none" stroke="blue" stroke-width="2"/> <text glyph-orientation-horizontal="180"> <textPath xlink:href="#path">Batik <tspan fill="red" dy="-10">is</tspan><tspan dy="10"> Good</tspan></textPath> </text> </g> <line x1="50" x2="400" y1="320" y2="320" stroke="blue" stroke-width="2"/> <text x="50" y="320" glyph-orientation-horizontal="270" >Batik is Good</text> <g transform="translate(30, 340)"> <use xlink:href="#lpath" fill="none" stroke="blue" stroke-width="2"/> <text glyph-orientation-horizontal="270"> <textPath xlink:href="#lpath">Batik <tspan fill="red" dy="-10">is</tspan><tspan dy="10"> Good</tspan></textPath> </text> </g> </g> </svg> 1.72 +27 -1 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.71 retrieving revision 1.72 diff -u -r1.71 -r1.72 --- SVGTextElementBridge.java 12 Nov 2002 09:51:34 -0000 1.71 +++ SVGTextElementBridge.java 8 Feb 2003 13:25:11 -0000 1.72 @@ -544,6 +544,7 @@ case SVGCSSEngine.DIRECTION_INDEX: case SVGCSSEngine.WRITING_MODE_INDEX: case SVGCSSEngine.GLYPH_ORIENTATION_VERTICAL_INDEX: + case SVGCSSEngine.GLYPH_ORIENTATION_HORIZONTAL_INDEX: case SVGCSSEngine.LETTER_SPACING_INDEX: case SVGCSSEngine.WORD_SPACING_INDEX: case SVGCSSEngine.KERNING_INDEX: { @@ -1514,6 +1515,31 @@ TextAttribute.ORIENTATION_ANGLE); result.put(GVTAttributedCharacterIterator. TextAttribute.VERTICAL_ORIENTATION_ANGLE, + new Float(val.getFloatValue() * 9 / 5)); + break; + default: + // Cannot happen + throw new InternalError(); + } + + // glyph-orientation-horizontal + + val = CSSUtilities.getComputedStyle + (element, SVGCSSEngine.GLYPH_ORIENTATION_HORIZONTAL_INDEX); + switch (val.getPrimitiveType()) { + case CSSPrimitiveValue.CSS_DEG: + result.put(GVTAttributedCharacterIterator. + TextAttribute.HORIZONTAL_ORIENTATION_ANGLE, + new Float(val.getFloatValue())); + break; + case CSSPrimitiveValue.CSS_RAD: + result.put(GVTAttributedCharacterIterator. + TextAttribute.HORIZONTAL_ORIENTATION_ANGLE, + new Float(val.getFloatValue() * 180 / Math.PI)); + break; + case CSSPrimitiveValue.CSS_GRAD: + result.put(GVTAttributedCharacterIterator. + TextAttribute.HORIZONTAL_ORIENTATION_ANGLE, new Float(val.getFloatValue() * 9 / 5)); break; default: 1.3 +20 -22 xml-batik/sources/org/apache/batik/css/engine/value/svg/GlyphOrientationManager.java Index: GlyphOrientationManager.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/engine/value/svg/GlyphOrientationManager.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- GlyphOrientationManager.java 31 Jul 2002 16:00:08 -0000 1.2 +++ GlyphOrientationManager.java 8 Feb 2003 13:25:12 -0000 1.3 @@ -45,37 +45,35 @@ */ public Value createValue(LexicalUnit lu, CSSEngine engine) throws DOMException { - switch (lu.getLexicalUnitType()) { - case LexicalUnit.SAC_INHERIT: - return SVGValueConstants.INHERIT_VALUE; + switch (lu.getLexicalUnitType()) { + case LexicalUnit.SAC_INHERIT: + return SVGValueConstants.INHERIT_VALUE; - case LexicalUnit.SAC_DEGREE: + case LexicalUnit.SAC_DEGREE: return new FloatValue(CSSPrimitiveValue.CSS_DEG, lu.getFloatValue()); - case LexicalUnit.SAC_GRADIAN: + case LexicalUnit.SAC_GRADIAN: return new FloatValue(CSSPrimitiveValue.CSS_GRAD, lu.getFloatValue()); - case LexicalUnit.SAC_RADIAN: + case LexicalUnit.SAC_RADIAN: return new FloatValue(CSSPrimitiveValue.CSS_RAD, lu.getFloatValue()); - case LexicalUnit.SAC_INTEGER: - { - float n = lu.getIntegerValue(); - if (n == 0f) - return new FloatValue(CSSPrimitiveValue.CSS_DEG, 0f); - break; - } - case LexicalUnit.SAC_REAL: - { - float n = lu.getFloatValue(); - if (n == 0f) - return new FloatValue(CSSPrimitiveValue.CSS_DEG, 0f); - break; + + // For SVG angle properties unit defaults to 'deg'. + case LexicalUnit.SAC_INTEGER: + { + int n = lu.getIntegerValue(); + return new FloatValue(CSSPrimitiveValue.CSS_DEG, n); + } + case LexicalUnit.SAC_REAL: + { + float n = lu.getFloatValue(); + return new FloatValue(CSSPrimitiveValue.CSS_DEG, n); + } } - } - + throw createInvalidLexicalUnitDOMException(lu.getLexicalUnitType()); } 1.2 +15 -7 xml-batik/sources/org/apache/batik/ext/awt/image/codec/tiff/TIFFEncodeParam.java Index: TIFFEncodeParam.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/codec/tiff/TIFFEncodeParam.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TIFFEncodeParam.java 16 May 2001 12:33:33 -0000 1.1 +++ TIFFEncodeParam.java 8 Feb 2003 13:25:12 -0000 1.2 @@ -41,38 +41,46 @@ /** No compression. */ public static final int COMPRESSION_NONE = 1; - /** Byte-oriented run-length encoding "PackBits" compression. */ - public static final int COMPRESSION_PACKBITS = 2; - /** * Modified Huffman Compression (CCITT Group 3 1D facsimile compression). * <p><b>Not currently supported.</b> */ - public static final int COMPRESSION_GROUP3_1D = 3; + public static final int COMPRESSION_GROUP3_1D = 2; /** * CCITT T.4 bilevel compression (CCITT Group 3 2D facsimile compression). * <p><b>Not currently supported.</b> */ - public static final int COMPRESSION_GROUP3_2D = 4; + public static final int COMPRESSION_GROUP3_2D = 3; /** * CCITT T.6 bilevel compression (CCITT Group 4 facsimile compression). * <p><b>Not currently supported.</b> */ - public static final int COMPRESSION_GROUP4 = 5; + public static final int COMPRESSION_GROUP4 = 4; /** * LZW compression. * <p><b>Not supported.</b> */ - public static final int COMPRESSION_LZW = 6; + public static final int COMPRESSION_LZW = 5; + + /** + * Code for original JPEG-in-TIFF compression which has been + * depricated (for many good reasons) in favor of Tech Note 2 + * JPEG compression (compression scheme 7). + * <p><b>Not supported.</b> + */ + public static final int COMPRESSION_JPEG_BROKEN = 6; /** * <a href="ftp://ftp.sgi.com/graphics/tiff/TTN2.draft.txt"> * JPEG-in-TIFF</a> compression. */ public static final int COMPRESSION_JPEG_TTN2 = 7; + + /** Byte-oriented run-length encoding "PackBits" compression. */ + public static final int COMPRESSION_PACKBITS = 32773; /** * <a href="http://info.internet.isi.edu:80/in-notes/rfc/files/rfc1951.txt"> 1.20 +4 -1 xml-batik/sources/org/apache/batik/gvt/text/GVTAttributedCharacterIterator.java Index: GVTAttributedCharacterIterator.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/text/GVTAttributedCharacterIterator.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- GVTAttributedCharacterIterator.java 22 May 2002 21:50:40 -0000 1.19 +++ GVTAttributedCharacterIterator.java 8 Feb 2003 13:25:12 -0000 1.20 @@ -363,6 +363,9 @@ public final static TextAttribute VERTICAL_ORIENTATION_ANGLE = new TextAttribute("VERTICAL_ORIENTATION_ANGLE"); + public final static TextAttribute HORIZONTAL_ORIENTATION_ANGLE = + new TextAttribute("HORIZONTAL_ORIENTATION_ANGLE"); + public final static TextAttribute GVT_FONT_FAMILIES = new TextAttribute("GVT_FONT_FAMILIES"); 1.46 +121 -53 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.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- GlyphLayout.java 13 Aug 2002 21:33:16 -0000 1.45 +++ GlyphLayout.java 8 Feb 2003 13:25:12 -0000 1.46 @@ -100,6 +100,18 @@ TEXT_COMPOUND_DELIMITER = GVTAttributedCharacterIterator.TextAttribute.TEXT_COMPOUND_DELIMITER; + public static final AttributedCharacterIterator.Attribute + VERTICAL_ORIENTATION + = GVTAttributedCharacterIterator.TextAttribute.VERTICAL_ORIENTATION; + + public static final + AttributedCharacterIterator.Attribute VERTICAL_ORIENTATION_ANGLE = + GVTAttributedCharacterIterator.TextAttribute.VERTICAL_ORIENTATION_ANGLE; + + public static final + AttributedCharacterIterator.Attribute HORIZONTAL_ORIENTATION_ANGLE = + GVTAttributedCharacterIterator.TextAttribute.HORIZONTAL_ORIENTATION_ANGLE; + private static final AttributedCharacterIterator.Attribute X = GVTAttributedCharacterIterator.TextAttribute.X; @@ -124,6 +136,9 @@ private static final Integer WRITING_MODE_TTB = GVTAttributedCharacterIterator.TextAttribute.WRITING_MODE_TTB; + private static final Integer ORIENTATION_AUTO + = GVTAttributedCharacterIterator.TextAttribute.ORIENTATION_AUTO; + static Set runAtts = new HashSet(); static { @@ -476,11 +491,6 @@ int start = aci.getBeginIndex(); int numGlyphs = getGlyphCount(); - boolean glyphOrientationAuto = isGlyphOrientationAuto(); - int glyphOrientationAngle = 90; - if (!glyphOrientationAuto) { - glyphOrientationAngle = getGlyphOrientationAngle(); - } Point2D.Float [] topPts = new Point2D.Float[2*numGlyphs]; Point2D.Float [] botPts = new Point2D.Float[2*numGlyphs]; @@ -509,14 +519,6 @@ PathIterator pi = gbounds.getPathIterator(null); Point2D.Float firstPt = null; - if (isVertical()) { - if (glyphOrientationAuto) { - if (isLatinChar(ch)) - glyphOrientationAngle = 90; - else - glyphOrientationAngle = 0; - } - } while (!pi.isDone()) { type = pi.currentSegment(pts); @@ -1001,6 +1003,7 @@ float[] gp = gv.getGlyphPositions(0, numGlyphs+1, null); float verticalFirstOffset = 0f; + float horizontalFirstOffset = 0f; boolean glyphOrientationAuto = isGlyphOrientationAuto(); int glyphOrientationAngle = 0; @@ -1034,23 +1037,37 @@ GVTGlyphMetrics gm = gv.getGlyphMetrics(i); if (i==0) { - if (glyphOrientationAuto) { - if (isLatinChar(ch)) { - // it will be rotated 90 - verticalFirstOffset = 0f; + if (isVertical()) { + if (glyphOrientationAuto) { + if (isLatinChar(ch)) { + // it will be rotated 90 + verticalFirstOffset = 0f; + } else { + // it won't be rotated + verticalFirstOffset = + (float)gm.getBounds2D().getHeight(); + } } else { - // it won't be rotated - verticalFirstOffset = (float)gm.getBounds2D().getHeight(); + if (glyphOrientationAngle == 0) { + verticalFirstOffset = + (float)gm.getBounds2D().getHeight(); + } else { + // 90, 180, 270 + verticalFirstOffset = 0f; + } } } else { - if (glyphOrientationAngle == 0) { - verticalFirstOffset = (float)gm.getBounds2D().getHeight(); + if ((glyphOrientationAngle == 270)) { + horizontalFirstOffset = + (float)gm.getBounds2D().getHeight(); } else { - verticalFirstOffset = 0f; + // 0, 90, 180 + horizontalFirstOffset = 0; } } } else { - if (glyphOrientationAuto && (verticalFirstOffset == 0f) + if (glyphOrientationAuto && + (verticalFirstOffset == 0f) && !isLatinChar(ch)) { verticalFirstOffset = (float)gm.getBounds2D().getHeight(); @@ -1061,7 +1078,7 @@ // computed on the basis of baseline-shifts, etc. float ox = 0f; float oy = 0f; - float verticalGlyphRotation = 0f; + float glyphOrientationRotation = 0f; float glyphRotation = 0f; @@ -1071,18 +1088,19 @@ if (isLatinChar(ch)) { // If character is Latin, then rotate by // 90 degrees - verticalGlyphRotation = (float) (Math.PI / 2f); + glyphOrientationRotation = (float) (Math.PI / 2f); } else { - verticalGlyphRotation = 0f; + glyphOrientationRotation = 0f; } } else { - verticalGlyphRotation = (float)Math.toRadians(glyphOrientationAngle); + glyphOrientationRotation = (float)Math.toRadians(glyphOrientationAngle); } if (textPath != null) { // if vertical and on a path, any x's are ignored x = null; } } else { + glyphOrientationRotation = (float)Math.toRadians(glyphOrientationAngle); if (textPath != null) { // if horizontal and on a path, any y's are ignored y = null; @@ -1091,10 +1109,10 @@ // calculate the total rotation for this glyph if (rotation == null || rotation.isNaN()) { - glyphRotation = verticalGlyphRotation; + glyphRotation = glyphOrientationRotation; } else { glyphRotation = (rotation.floatValue() + - verticalGlyphRotation); + glyphOrientationRotation); } if ((x != null) && !x.isNaN()) { @@ -1143,13 +1161,15 @@ if (isLatinChar(ch)) { ox += metrics.getStrikethroughOffset(); } else { - Rectangle2D glyphBounds = gv.getGlyphVisualBounds(i).getBounds2D(); + Rectangle2D glyphBounds + = gv.getGlyphVisualBounds(i).getBounds2D(); ox -= (float)((glyphBounds.getMaxX() - gp[2*i]) - glyphBounds.getWidth()/2); } } else { // center the character if it's not auto orient - Rectangle2D glyphBounds = gv.getGlyphVisualBounds(i).getBounds2D(); + Rectangle2D glyphBounds + = gv.getGlyphVisualBounds(i).getBounds2D(); if (glyphOrientationAngle == 0) { ox -= (float)((glyphBounds.getMaxX() - gp[2*i]) - glyphBounds.getWidth()/2); @@ -1162,11 +1182,19 @@ ox -= metrics.getStrikethroughOffset(); } } + } else { + ox += horizontalFirstOffset; + if (glyphOrientationAngle == 90) { + oy -= gm.getHorizontalAdvance(); + } else if (glyphOrientationAngle == 180) { + oy -= metrics.getAscent(); + } } } // set the new glyph position - gv.setGlyphPosition(i, new Point2D.Float(curr_x_pos+ox,curr_y_pos+oy)); + gv.setGlyphPosition(i, new Point2D.Float + (curr_x_pos+ox,curr_y_pos+oy)); // calculte the position of the next glyph if (!ArabicTextHandler.arabicCharTransparent(ch)) { @@ -1189,12 +1217,28 @@ advanceY = gm.getHorizontalAdvance(); // need to translate so that the spacing // between chars is correct - gv.setGlyphTransform(i, AffineTransform.getTranslateInstance(0, advanceY)); + gv.setGlyphTransform + (i, AffineTransform.getTranslateInstance + (0, advanceY)); } } curr_y_pos += advanceY; } else { - curr_x_pos += gm.getHorizontalAdvance(); + float advanceX = 0; + if (glyphOrientationAngle == 0) { + advanceX = gm.getHorizontalAdvance(); + } else if (glyphOrientationAngle == 180) { + advanceX = gm.getHorizontalAdvance(); + // need to translate so that the spacing + // between chars is correct + gv.setGlyphTransform + (i, AffineTransform.getTranslateInstance + (advanceX, 0)); + } else { + // 90, 270 + advanceX = gm.getVerticalAdvance(); + } + curr_x_pos += advanceX; } } @@ -1598,7 +1642,12 @@ // last glyph, use the glyph metrics GVTGlyphMetrics gm = gv.getGlyphMetrics(i); if (horizontal) { - glyphAdvance = gm.getHorizontalAdvance(); + if ((glyphOrientationAngle == 0) || + (glyphOrientationAngle == 180)) { + glyphAdvance = gm.getHorizontalAdvance(); + } else { // 90 || 270 + glyphAdvance = gm.getVerticalAdvance(); + } } else { if (glyphOrientationAuto) { if (isLatinChar(ch)) { @@ -1658,7 +1707,12 @@ // translate glyph backwards so we rotate about the // center of the glyph if (horizontal) { - glyphPathTransform.translate(glyphWidth / -2f, 0f); + if (glyphOrientationAngle == 270) { + glyphPathTransform.translate(glyphWidth / 2f, 0f); + } else { + // 0 || 90 || 180 + glyphPathTransform.translate(-glyphWidth / 2f, 0f); + } } else { if (glyphOrientationAuto) { if (isLatinChar(ch)) { @@ -1667,10 +1721,11 @@ glyphPathTransform.translate(0f, glyphHeight/2f); } } else { - if (glyphOrientationAngle == 0 ) { - glyphPathTransform.translate(0f, glyphHeight/2f); - } else { // 90 || 180 - glyphPathTransform.translate(0f, -glyphHeight/2f); + if (glyphOrientationAngle == 0) { + glyphPathTransform.translate(0, glyphHeight / 2f); + } else { + // 90 || 180 || 270 + glyphPathTransform.translate(0, -glyphHeight / 2f); } } } @@ -1753,13 +1808,13 @@ * Returns whether or not the vertical glyph orientation value is "auto". */ protected boolean isGlyphOrientationAuto() { - boolean glyphOrientationAuto = true; + if (!isVertical()) return false; aci.first(); - if (aci.getAttribute(GVTAttributedCharacterIterator.TextAttribute.VERTICAL_ORIENTATION) != null) { - glyphOrientationAuto = (aci.getAttribute(GVTAttributedCharacterIterator.TextAttribute.VERTICAL_ORIENTATION) - == GVTAttributedCharacterIterator.TextAttribute.ORIENTATION_AUTO); + Integer vOrient = (Integer)aci.getAttribute(VERTICAL_ORIENTATION); + if (vOrient != null) { + return (vOrient == ORIENTATION_AUTO); } - return glyphOrientationAuto; + return true; } /** @@ -1771,25 +1826,38 @@ int glyphOrientationAngle = 0; aci.first(); - Float angle = (Float)aci.getAttribute(GVTAttributedCharacterIterator. - TextAttribute.VERTICAL_ORIENTATION_ANGLE); + Float angle; + + if (isVertical()) { + angle = (Float)aci.getAttribute(VERTICAL_ORIENTATION_ANGLE); + } else { + angle = (Float)aci.getAttribute(HORIZONTAL_ORIENTATION_ANGLE); + } + if (angle != null) { glyphOrientationAngle = (int)angle.floatValue(); } + // if not one of 0, 90, 180 or 270, round to nearest value - if (glyphOrientationAngle != 0 || glyphOrientationAngle != 90 - || glyphOrientationAngle != 180 || glyphOrientationAngle != 270) { + if ((glyphOrientationAngle != 0) || (glyphOrientationAngle != 90) || + (glyphOrientationAngle != 180) || (glyphOrientationAngle != 270)) { + while (glyphOrientationAngle < 0) { glyphOrientationAngle += 360; } + while (glyphOrientationAngle >= 360) { glyphOrientationAngle -= 360; } - if (glyphOrientationAngle <= 45 || glyphOrientationAngle > 315) { + + if ((glyphOrientationAngle <= 45) || + (glyphOrientationAngle > 315)) { glyphOrientationAngle = 0; - } else if (glyphOrientationAngle > 45 && glyphOrientationAngle <= 135) { + } else if ((glyphOrientationAngle > 45) && + (glyphOrientationAngle <= 135)) { glyphOrientationAngle = 90; - } else if (glyphOrientationAngle > 135 && glyphOrientationAngle <= 225) { + } else if ((glyphOrientationAngle > 135) && + (glyphOrientationAngle <= 225)) { glyphOrientationAngle = 180; } else { glyphOrientationAngle = 270; 1.4 +11 -2 xml-batik/sources/org/apache/batik/util/ParsedURLJarProtocolHandler.java Index: ParsedURLJarProtocolHandler.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/ParsedURLJarProtocolHandler.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ParsedURLJarProtocolHandler.java 20 May 2002 17:18:57 -0000 1.3 +++ ParsedURLJarProtocolHandler.java 8 Feb 2003 13:25:12 -0000 1.4 @@ -13,6 +13,9 @@ import java.io.IOException; import java.util.Iterator; +import java.net.URL; +import java.net.MalformedURLException; + /** * Protocol Handler for the 'jar' protocol. * This appears to have the format: @@ -42,7 +45,13 @@ return parseURL(urlStr); // It's relative so base it off baseURL. - return super.parseURL(baseURL, urlStr); + try { + URL context = new URL(baseURL.toString()); + URL url = new URL(context, urlStr); + return constructParsedURLData(url); + } catch (MalformedURLException mue) { + return super.parseURL(baseURL, urlStr); + } } } 1.90 +2 -1 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.89 retrieving revision 1.90 diff -u -r1.89 -r1.90 --- samplesRendering.xml 10 Dec 2002 16:19:17 -0000 1.89 +++ samplesRendering.xml 8 Feb 2003 13:25:12 -0000 1.90 @@ -298,6 +298,7 @@ <test id="samples/tests/spec/text/verticalTextOnPath.svg" /> <test id="samples/tests/spec/text/textPosition.svg" /> <test id="samples/tests/spec/text/textPosition2.svg" /> + <test id="samples/tests/spec/text/textGlyphOrientationHorizontal.svg"/> </testGroup> <testGroup id="tests.spec.scripting"> 1.6 +56 -2 xml-batik/test-resources/org/apache/batik/util/unitTesting.xml Index: unitTesting.xml =================================================================== RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/util/unitTesting.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- unitTesting.xml 11 Jul 2002 16:26:20 -0000 1.5 +++ unitTesting.xml 8 Feb 2003 13:25:12 -0000 1.6 @@ -268,7 +268,7 @@ value="jar:file:dir/file.jar!/p/a/t/h/init.svg" /> <arg class="java.lang.String" value="../base.svg" /> <arg class="java.lang.String" - value="jar:file:dir/file.jar!/p/a/t/h/../base.svg" /> + value="jar:file:dir/file.jar!/p/a/t/base.svg" /> </test> <test id="ParsedURL.18" class="org.apache.batik.util.ParsedURLTest"> <!-- Test fragment from base jar URL --> @@ -303,6 +303,60 @@ value="jar:file:dir/file.jar!/b/a/t/i/k/new.svg#bar" /> <arg class="java.lang.String" value="jar:file:dir/file.jar!/b/a/t/i/k/new.svg#bar" /> + </test> + <test id="ParsedURL.22" class="org.apache.batik.util.ParsedURLTest"> + <!-- Test absolute path, relative jar --> + <arg class="java.lang.String" + value="jar:file:dir/file.jar!/p/a/t/h/init.svg" /> + <arg class="java.lang.String" + value="/b/a/t/i/k/new.svg" /> + <arg class="java.lang.String" + value="jar:file:dir/file.jar!/b/a/t/i/k/new.svg" /> + </test> + <test id="ParsedURL.23" class="org.apache.batik.util.ParsedURLTest"> + <!-- Test absolute path, relative jar --> + <arg class="java.lang.String" + value="jar:file:dir/file.jar!/p/a/t/h/init.svg" /> + <arg class="java.lang.String" + value="/b/a/t/i/k/new.svg#bar" /> + <arg class="java.lang.String" + value="jar:file:dir/file.jar!/b/a/t/i/k/new.svg#bar" /> + </test> + <test id="ParsedURL.24" class="org.apache.batik.util.ParsedURLTest"> + <!-- Test relative path, relative jar --> + <arg class="java.lang.String" + value="jar:file:dir/file.jar!/p/a/t/h/init.svg" /> + <arg class="java.lang.String" + value="t/o/new.svg" /> + <arg class="java.lang.String" + value="jar:file:dir/file.jar!/p/a/t/h/t/o/new.svg" /> + </test> + <test id="ParsedURL.25" class="org.apache.batik.util.ParsedURLTest"> + <!-- Test relative path, relative jar --> + <arg class="java.lang.String" + value="jar:file:dir/file.jar!/p/a/t/h/init.svg" /> + <arg class="java.lang.String" + value="t/o/new.svg#foo" /> + <arg class="java.lang.String" + value="jar:file:dir/file.jar!/p/a/t/h/t/o/new.svg#foo" /> + </test> + <test id="ParsedURL.26" class="org.apache.batik.util.ParsedURLTest"> + <!-- Test relative path, relative jar --> + <arg class="java.lang.String" + value="jar:file:dir/file.jar!/p/a/t/h/init.svg" /> + <arg class="java.lang.String" + value="../c/h/new.svg" /> + <arg class="java.lang.String" + value="jar:file:dir/file.jar!/p/a/t/c/h/new.svg" /> + </test> + <test id="ParsedURL.27" class="org.apache.batik.util.ParsedURLTest"> + <!-- Test relative path, relative jar --> + <arg class="java.lang.String" + value="jar:file:dir/file.jar!/p/a/t/h/init.svg" /> + <arg class="java.lang.String" + value="../c/h/new.svg#foo" /> + <arg class="java.lang.String" + value="jar:file:dir/file.jar!/p/a/t/c/h/new.svg#foo" /> </test> <test id="ParsedURLData.1" class="org.apache.batik.util.ParsedURLDataTest"> 1.2 +1 -2 xml-batik/test-resources/org/apache/batik/util/resources/TestMessages.properties Index: TestMessages.properties =================================================================== RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/util/resources/TestMessages.properties,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestMessages.properties 5 Jul 2001 16:54:34 -0000 1.1 +++ TestMessages.properties 8 Feb 2003 13:25:12 -0000 1.2 @@ -42,8 +42,7 @@ # # Entry Keys # -ParsedURLTest.entry.key.error.description = \ -Error Description. +ParsedURLTest.entry.key.error.description = Error Description. Base64Test.entry.key.error.description = \ Error Description. 1.3 +12 -9 xml-batik/test-sources/org/apache/batik/util/Base64Test.java Index: Base64Test.java =================================================================== RCS file: /home/cvs/xml-batik/test-sources/org/apache/batik/util/Base64Test.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Base64Test.java 23 Oct 2001 13:42:30 -0000 1.2 +++ Base64Test.java 8 Feb 2003 13:25:12 -0000 1.3 @@ -115,8 +115,9 @@ report.setErrorCode(ERROR_CANNOT_READ_IN_URL); report.setDescription(new TestReport.Entry[] { new TestReport.Entry - (Messages.formatMessage(ENTRY_KEY_ERROR_DESCRIPTION, null), - Messages.formatMessage + (TestMessages.formatMessage + (ENTRY_KEY_ERROR_DESCRIPTION, null), + TestMessages.formatMessage (ERROR_CANNOT_READ_IN_URL, new String[]{in.toString(), trace.toString()})) }); @@ -131,8 +132,9 @@ report.setErrorCode(ERROR_BAD_ACTION_STRING); report.setDescription(new TestReport.Entry[] { new TestReport.Entry - (Messages.formatMessage(ENTRY_KEY_ERROR_DESCRIPTION, null), - Messages.formatMessage(ERROR_BAD_ACTION_STRING, + (TestMessages.formatMessage + (ENTRY_KEY_ERROR_DESCRIPTION, null), + TestMessages.formatMessage(ERROR_BAD_ACTION_STRING, new String[]{action})) }); report.setPassed(false); @@ -148,8 +150,9 @@ report.setErrorCode(ERROR_CANNOT_READ_REF_URL); report.setDescription(new TestReport.Entry[] { new TestReport.Entry - (Messages.formatMessage(ENTRY_KEY_ERROR_DESCRIPTION, null), - Messages.formatMessage + (TestMessages.formatMessage + (ENTRY_KEY_ERROR_DESCRIPTION, null), + TestMessages.formatMessage (ERROR_CANNOT_READ_REF_URL, new String[]{ref.toString(), trace.toString()})) }); @@ -187,8 +190,8 @@ report.setErrorCode(ERROR_WRONG_RESULT); report.setDescription(new TestReport.Entry[] { new TestReport.Entry - (Messages.formatMessage(ENTRY_KEY_ERROR_DESCRIPTION, null), - Messages.formatMessage(ERROR_WRONG_RESULT, + (TestMessages.formatMessage(ENTRY_KEY_ERROR_DESCRIPTION, null), + TestMessages.formatMessage(ERROR_WRONG_RESULT, new String[]{""+mismatch})) }); report.setPassed(false); 1.2 +6 -5 xml-batik/test-sources/org/apache/batik/util/ParsedURLDataTest.java Index: ParsedURLDataTest.java =================================================================== RCS file: /home/cvs/xml-batik/test-sources/org/apache/batik/util/ParsedURLDataTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ParsedURLDataTest.java 11 Jul 2002 16:26:20 -0000 1.1 +++ ParsedURLDataTest.java 8 Feb 2003 13:25:12 -0000 1.2 @@ -80,8 +80,9 @@ report.setErrorCode(ERROR_CANNOT_PARSE_URL); report.setDescription(new TestReport.Entry[] { new TestReport.Entry - (Messages.formatMessage(ENTRY_KEY_ERROR_DESCRIPTION, null), - Messages.formatMessage + (TestMessages.formatMessage + (ENTRY_KEY_ERROR_DESCRIPTION, null), + TestMessages.formatMessage (ERROR_CANNOT_PARSE_URL, new String[]{"null", base, @@ -121,8 +122,8 @@ report.setErrorCode(ERROR_WRONG_RESULT); report.setDescription(new TestReport.Entry[] { new TestReport.Entry - (Messages.formatMessage(ENTRY_KEY_ERROR_DESCRIPTION, null), - Messages.formatMessage + (TestMessages.formatMessage(ENTRY_KEY_ERROR_DESCRIPTION, null), + TestMessages.formatMessage (ERROR_WRONG_RESULT, new String[]{info, ref })) }); report.setPassed(false); 1.3 +6 -5 xml-batik/test-sources/org/apache/batik/util/ParsedURLTest.java Index: ParsedURLTest.java =================================================================== RCS file: /home/cvs/xml-batik/test-sources/org/apache/batik/util/ParsedURLTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ParsedURLTest.java 11 Jul 2002 16:26:20 -0000 1.2 +++ ParsedURLTest.java 8 Feb 2003 13:25:12 -0000 1.3 @@ -95,8 +95,9 @@ report.setErrorCode(ERROR_CANNOT_PARSE_URL); report.setDescription(new TestReport.Entry[] { new TestReport.Entry - (Messages.formatMessage(ENTRY_KEY_ERROR_DESCRIPTION, null), - Messages.formatMessage + (TestMessages.formatMessage + (ENTRY_KEY_ERROR_DESCRIPTION, null), + TestMessages.formatMessage (ERROR_CANNOT_PARSE_URL, new String[]{base, (sub == null) ? "null" : sub, @@ -114,8 +115,8 @@ report.setErrorCode(ERROR_WRONG_RESULT); report.setDescription(new TestReport.Entry[] { new TestReport.Entry - (Messages.formatMessage(ENTRY_KEY_ERROR_DESCRIPTION, null), - Messages.formatMessage + (TestMessages.formatMessage(ENTRY_KEY_ERROR_DESCRIPTION, null), + TestMessages.formatMessage (ERROR_WRONG_RESULT, new String[]{url.toString(), ref })) }); report.setPassed(false); 1.1 xml-batik/test-sources/org/apache/batik/util/TestMessages.java Index: TestMessages.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.util; import java.util.Locale; import java.util.MissingResourceException; import org.apache.batik.i18n.Localizable; import org.apache.batik.i18n.LocalizableSupport; /** * This class manages the message for the test.svg module. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> * @version $Id: TestMessages.java,v 1.1 2003/02/08 13:25:12 deweese Exp $ */ public class TestMessages { /** * This class does not need to be instantiated. */ protected TestMessages() { } /** * The error messages bundle class name. */ protected final static String RESOURCES = "org.apache.batik.util.resources.TestMessages"; /** * The localizable support for the error messages. */ protected static LocalizableSupport localizableSupport = new LocalizableSupport(RESOURCES); /** * Implements {@link org.apache.batik.i18n.Localizable#setLocale(Locale)}. */ public static void setLocale(Locale l) { localizableSupport.setLocale(l); } /** * Implements {@link org.apache.batik.i18n.Localizable#getLocale()}. */ public static Locale getLocale() { return localizableSupport.getLocale(); } /** * Implements {@link * org.apache.batik.i18n.Localizable#formatMessage(String,Object[])}. */ public static String formatMessage(String key, Object[] args) throws MissingResourceException { return localizableSupport.formatMessage(key, args); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]