You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by tk...@apache.org on 2001/05/03 16:52:12 UTC

cvs commit: xml-batik/sources/org/apache/batik/gvt TextNode.java

tkormann    01/05/03 07:52:11

  Modified:    sources/org/apache/batik/gvt TextNode.java
  Log:
  Add a useful method
  
  Revision  Changes    Path
  1.8       +25 -1     xml-batik/sources/org/apache/batik/gvt/TextNode.java
  
  Index: TextNode.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/TextNode.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TextNode.java	2001/03/21 15:03:26	1.7
  +++ TextNode.java	2001/05/03 14:52:07	1.8
  @@ -12,11 +12,15 @@
   import java.awt.Graphics2D;
   import java.awt.RenderingHints;
   import java.awt.Shape;
  +
   import java.awt.geom.AffineTransform;
   import java.awt.geom.GeneralPath;
   import java.awt.geom.Point2D;
   import java.awt.geom.Rectangle2D;
  +
   import java.text.AttributedCharacterIterator;
  +import java.text.CharacterIterator;
  +
   import org.apache.batik.gvt.text.AttributedCharacterSpanIterator;
   import org.apache.batik.gvt.text.GVTAttributedCharacterIterator;
   import org.apache.batik.gvt.text.Mark;
  @@ -25,7 +29,7 @@
    * A graphics node that represents text.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: TextNode.java,v 1.7 2001/03/21 15:03:26 cjolif Exp $
  + * @version $Id: TextNode.java,v 1.8 2001/05/03 14:52:07 tkormann Exp $
    */
   public class TextNode extends AbstractGraphicsNode implements Selectable {
   
  @@ -52,11 +56,30 @@
       private Rectangle2D primitiveBounds;
   
       /**
  +     * The text of this <tt>TextNode</tt>.
  +     */
  +    protected String text;
  +
  +    /**
        * Constructs a new empty <tt>TextNode</tt>.
        */
       public TextNode() {}
   
       /**
  +     * Returns the text of this <tt>TextNode</tt> as a string.
  +     */
  +    public String getText() {
  +        if (text == null) {
  +            StringBuffer buf = new StringBuffer(aci.getEndIndex());
  +            for (char c=aci.first(); c != CharacterIterator.DONE; c=aci.next()) {
  +                buf.append(c);
  +            }
  +            text = buf.toString();
  +        }
  +        return text;
  +    }
  +
  +    /**
        * Sets the location of this raster text node.
        * @param newLocation the new location of this raster image node
        */
  @@ -81,6 +104,7 @@
                                                  newAci) {
           invalidateGeometryCache();
           this.aci = newAci;
  +        text = null;
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org