Hi, I found strange GVT TextNode AttributedCharacterIterator, the question is this intentional or bug?
suppose I have svg doc like this <text x="208.0" y="300">text</text> iterating the aci from GVT text node give the following output t index: 0 runStart: 0 runLimit: 1 e index: 1 runStart: 1 runLimit: 4 x index: 2 runStart: 1 runLimit: 4 t index: 3 runStart: 1 runLimit: 4 does the first line should be runStart=1 runLimit=4? Here I attached the sample program to reproduce this. What I am trying to do is to get the TEXT_COMPOUND_DELIMITER, to determine the SVG text element part (Text,TSpan,TRef,etc) Regards Tonny Kohar -- Sketsa SVG Graphics Editor http://www.kiyut.com
/* * BugGVTTextNodeACI.java * * Created on March 4, 2004, 11:02 AM */ package kiyut.bug; import java.text.*; import javax.swing.*; import org.apache.batik.dom.svg.*; import org.apache.batik.bridge.*; import org.apache.batik.gvt.*; import org.apache.batik.util.SVGConstants; import org.w3c.dom.*; import org.w3c.dom.css.*; import org.w3c.dom.svg.*; /** * * @author Tonny Kohar */ public class BugGVTTextNodeACI { public static void main(String[] args) { BugGVTTextNodeACI bug = new BugGVTTextNodeACI(); bug.runTest(); } /** Creates a new instance of BugGVTTextNodeACI */ public BugGVTTextNodeACI() { } private SVGDocument createSVGDocument() { String svgNS = SVGConstants.SVG_NAMESPACE_URI; DOMImplementation impl = SVGDOMImplementation.getDOMImplementation(); SVGDocument doc = (SVGDocument)impl.createDocument(svgNS, "svg", null); // get the root element (the svg element) Element svgRoot = doc.getRootElement(); // set the width and height attribute on the root svg element svgRoot.setAttributeNS(null, "width", "400"); svgRoot.setAttributeNS(null, "height", "400"); // create the text element SVGElement element = (SVGElement)doc.createElementNS(svgNS, "text"); element.setId("bugACI"); element.setAttributeNS(null, SVGConstants.SVG_X_ATTRIBUTE, Float.toString(100)); element.setAttributeNS(null, SVGConstants.SVG_Y_ATTRIBUTE, Float.toString(100)); element.setAttributeNS(null, SVGConstants.SVG_FONT_FAMILY_ATTRIBUTE, "Verdana"); element.setAttributeNS(null, SVGConstants.SVG_FONT_SIZE_ATTRIBUTE, "24"); element.setAttributeNS(null, SVGConstants.SVG_FILL_ATTRIBUTE, "blue"); Text text = doc.createTextNode("text"); element.appendChild(text); svgRoot.appendChild(element); return doc; } private void runTest() { SVGDocument doc = createSVGDocument(); // load gvt UserAgentAdapter userAgent = new UserAgentAdapter(); DocumentLoader documentLoader = new DocumentLoader(userAgent); BridgeContext bridgeContext = new BridgeContext(userAgent, documentLoader); bridgeContext.setDynamic(true); GVTBuilder gvtBuilder = new DynamicGVTBuilder(); GraphicsNode root = gvtBuilder.build(bridgeContext, doc); Element elt = doc.getElementById("bugACI"); System.out.println(elt); TextNode textNode = (TextNode)bridgeContext.getGraphicsNode(elt); AttributedCharacterIterator aci = textNode.getAttributedCharacterIterator(); int runStart; int runLimit; char c; for (int i=0; i<aci.getEndIndex(); i++) { c = aci.setIndex(i); runStart = aci.getRunStart(); runLimit = aci.getRunLimit(); System.out.println(c + " index: " + i + " runStart: " + runStart + " runLimit: " + runLimit); } } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]