1 18 19 package org.apache.batik.extension.svg; 20 21 import java.text.AttributedCharacterIterator ; 22 import java.util.ArrayList ; 23 import java.util.List ; 24 import java.util.Iterator ; 25 26 import org.apache.batik.gvt.TextNode; 27 import org.apache.batik.gvt.TextPainter; 28 import org.apache.batik.gvt.renderer.StrokingTextPainter; 29 30 38 public class FlowExtTextPainter extends StrokingTextPainter { 39 40 43 protected static TextPainter singleton = new FlowExtTextPainter(); 44 45 48 public static TextPainter getInstance() { 49 return singleton; 50 } 51 52 public List getTextRuns(TextNode node, AttributedCharacterIterator aci) { 53 List textRuns = node.getTextRuns(); 54 if (textRuns != null) { 55 return textRuns; 56 } 57 58 AttributedCharacterIterator [] chunkACIs = getTextChunkACIs(aci); 59 textRuns = computeTextRuns(node, aci, chunkACIs); 60 61 aci.first(); 62 List rgns = (List )aci.getAttribute(FLOW_REGIONS); 63 64 if (rgns != null) { 65 Iterator i = textRuns.iterator(); 66 List chunkLayouts = new ArrayList (); 67 TextRun tr = (TextRun)i.next(); 68 List layouts = new ArrayList (); 69 chunkLayouts.add(layouts); 70 layouts.add(tr.getLayout()); 71 while (i.hasNext()) { 72 tr = (TextRun)i.next(); 73 if (tr.isFirstRunInChunk()) { 74 layouts = new ArrayList (); 75 chunkLayouts.add(layouts); 76 } 77 layouts.add(tr.getLayout()); 78 } 79 80 FlowExtGlyphLayout.textWrapTextChunk 81 (chunkACIs, chunkLayouts, rgns); 82 } 83 84 node.setTextRuns(textRuns); 85 return textRuns; 86 } 87 }; 88 | Popular Tags |