org.apache.batik.gvt
Class TextNode

java.lang.Object
  |
  +--org.apache.batik.gvt.AbstractGraphicsNode
        |
        +--org.apache.batik.gvt.TextNode
All Implemented Interfaces:
java.lang.Cloneable, GraphicsNode, Selectable

public class TextNode
extends AbstractGraphicsNode
implements Selectable

A graphics node that represents text.


Inner Class Summary
static class TextNode.Anchor
          Defines where the text of a TextNode can be anchored relative to its location.
 
Field Summary
protected  java.text.AttributedCharacterIterator aci
          Attributed Character Iterator describing the text
protected  java.awt.geom.Point2D location
          Location of this text node (inherited, independent of explicit X and Y attributes applied to children).
protected  java.lang.String text
          The text of this TextNode.
protected  java.util.List textRuns
           
 
Fields inherited from class org.apache.batik.gvt.AbstractGraphicsNode
clip, composite, filter, gnr, hints, hitDetector, inverseTransform, isVisible, listeners, mask, parent, root, transform
 
Fields inherited from interface org.apache.batik.gvt.GraphicsNode
IDENTITY
 
Constructor Summary
TextNode()
          Constructs a new empty TextNode.
 
Method Summary
 boolean contains(java.awt.geom.Point2D p, GraphicsNodeRenderContext rc)
          Returns whether a given point is enclosed by the text node's bounds.
 java.text.AttributedCharacterIterator getAttributedCharacterIterator()
          Returns the attributed character iterator of this text node.
 java.awt.geom.Rectangle2D getGeometryBounds(GraphicsNodeRenderContext rc)
          Returns the geometric bounds in user space of this text node.
 java.awt.Shape getHighlightShape(GraphicsNodeRenderContext rc)
          Return a shape in user coords which encloses the current selection.
 java.awt.geom.Point2D getLocation()
          Returns the location of this raster image node.
 java.awt.Shape getOutline(GraphicsNodeRenderContext rc)
          Returns a shape which matches the text's geometry.
 java.awt.geom.Rectangle2D getPrimitiveBounds(GraphicsNodeRenderContext rc)
          Returns the primitive bounds in user space of this text node.
 java.lang.Object getSelection(GraphicsNodeRenderContext rc)
          Gets the current text selection.
 java.lang.String getText()
          Returns the text of this TextNode as a string.
 java.util.List getTextRuns()
           
protected  void invalidateGeometryCache()
          Invalidates this TextNode.
 void paint(java.awt.Graphics2D g2d, GraphicsNodeRenderContext rc)
          Paints this node if visible.
 void primitivePaint(java.awt.Graphics2D g2d, GraphicsNodeRenderContext rc)
          Paints this node without applying Filter, Mask, Composite and clip.
 boolean selectAll(double x, double y, GraphicsNodeRenderContext rc)
          Extends the current selection to the character at (x, y)..
 boolean selectAt(double x, double y, GraphicsNodeRenderContext rc)
          Initializes the current selection to begin with the character at (x, y).
 boolean selectTo(double x, double y, GraphicsNodeRenderContext rc)
          Extends the current selection to the character at (x, y)..
 void setAttributedCharacterIterator(java.text.AttributedCharacterIterator newAci)
          Sets the attributed character iterator of this text node.
 void setLocation(java.awt.geom.Point2D newLocation)
          Sets the location of this raster text node.
 void setTextRuns(java.util.List textRuns)
           
 
Methods inherited from class org.apache.batik.gvt.AbstractGraphicsNode
acceptEvent, addGraphicsNodeKeyListener, addGraphicsNodeMouseListener, dispatchEvent, getBounds, getClip, getComposite, getFilter, getGlobalTransform, getGraphicsNodeHitDetector, getInverseTransform, getListeners, getMask, getParent, getRenderingHints, getRoot, getTransform, getTransformedBounds, getTransformedGeometryBounds, getTransformedPrimitiveBounds, intersects, isAntialiasedClip, isOffscreenBufferNeeded, isVisible, nodeHitAt, processKeyEvent, processMouseEvent, removeGraphicsNodeKeyListener, removeGraphicsNodeMouseListener, renderingClone, setClip, setComposite, setFilter, setGraphicsNodeHitDetector, setMask, setParent, setRenderingHint, setRenderingHints, setRenderingHints, setRoot, setTransform, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

location

protected java.awt.geom.Point2D location
Location of this text node (inherited, independent of explicit X and Y attributes applied to children).

aci

protected java.text.AttributedCharacterIterator aci
Attributed Character Iterator describing the text

text

protected java.lang.String text
The text of this TextNode.

textRuns

protected java.util.List textRuns
Constructor Detail

TextNode

public TextNode()
Constructs a new empty TextNode.
Method Detail

getTextRuns

public java.util.List getTextRuns()

setTextRuns

public void setTextRuns(java.util.List textRuns)

getText

public java.lang.String getText()
Returns the text of this TextNode as a string.

setLocation

public void setLocation(java.awt.geom.Point2D newLocation)
Sets the location of this raster text node.
Parameters:
newLocation - the new location of this raster image node

getLocation

public java.awt.geom.Point2D getLocation()
Returns the location of this raster image node.
Returns:
the location of this raster image node

setAttributedCharacterIterator

public void setAttributedCharacterIterator(java.text.AttributedCharacterIterator newAci)
Sets the attributed character iterator of this text node.
Parameters:
newAci - the new attributed character iterator

getAttributedCharacterIterator

public java.text.AttributedCharacterIterator getAttributedCharacterIterator()
Returns the attributed character iterator of this text node.
Returns:
the attributed character iterator

invalidateGeometryCache

protected void invalidateGeometryCache()
Invalidates this TextNode. This node and all its ancestors have been informed that all its cached values related to its bounds must be recomputed.
Overrides:
invalidateGeometryCache in class AbstractGraphicsNode

getPrimitiveBounds

public java.awt.geom.Rectangle2D getPrimitiveBounds(GraphicsNodeRenderContext rc)
Returns the primitive bounds in user space of this text node.
Following copied from interface: org.apache.batik.gvt.GraphicsNode
Parameters:
rc - the GraphicsNodeRenderContext for which this dimension applies

getGeometryBounds

public java.awt.geom.Rectangle2D getGeometryBounds(GraphicsNodeRenderContext rc)
Returns the geometric bounds in user space of this text node.
Following copied from interface: org.apache.batik.gvt.GraphicsNode
Parameters:
rc - the GraphicsNodeRenderContext for which this dimension applies

contains

public boolean contains(java.awt.geom.Point2D p,
                        GraphicsNodeRenderContext rc)
Returns whether a given point is enclosed by the text node's bounds.
Overrides:
contains in class AbstractGraphicsNode
Following copied from class: org.apache.batik.gvt.AbstractGraphicsNode
Parameters:
p - the specified Point2D in the user space
rc - the GraphicsNodeRenderContext for which this dimension applies
Returns:
true if the coordinates are inside, false otherwise

getOutline

public java.awt.Shape getOutline(GraphicsNodeRenderContext rc)
Returns a shape which matches the text's geometry.
Following copied from interface: org.apache.batik.gvt.GraphicsNode
Parameters:
rc - the GraphicsNodeRenderContext for which this dimension applies
Returns:
the outline of this node

selectAt

public boolean selectAt(double x,
                        double y,
                        GraphicsNodeRenderContext rc)
Initializes the current selection to begin with the character at (x, y).
Specified by:
selectAt in interface Selectable
Parameters:
the - anchor of this node

selectTo

public boolean selectTo(double x,
                        double y,
                        GraphicsNodeRenderContext rc)
Extends the current selection to the character at (x, y)..
Specified by:
selectTo in interface Selectable
Parameters:
the - anchor of this node

selectAll

public boolean selectAll(double x,
                         double y,
                         GraphicsNodeRenderContext rc)
Extends the current selection to the character at (x, y)..
Specified by:
selectAll in interface Selectable
Parameters:
the - anchor of this node

getSelection

public java.lang.Object getSelection(GraphicsNodeRenderContext rc)
Gets the current text selection.
Specified by:
getSelection in interface Selectable
Returns:
an object containing the selected content.

getHighlightShape

public java.awt.Shape getHighlightShape(GraphicsNodeRenderContext rc)
Description copied from interface: Selectable
Return a shape in user coords which encloses the current selection.
Specified by:
getHighlightShape in interface Selectable
Returns:
a Shape which encloses the current text selection.

paint

public void paint(java.awt.Graphics2D g2d,
                  GraphicsNodeRenderContext rc)
Paints this node if visible.
Overrides:
paint in class AbstractGraphicsNode
Parameters:
g2d - the Graphics2D to use
rc - the GraphicsNodeRenderContext to use

primitivePaint

public void primitivePaint(java.awt.Graphics2D g2d,
                           GraphicsNodeRenderContext rc)
Description copied from interface: GraphicsNode
Paints this node without applying Filter, Mask, Composite and clip.
Following copied from interface: org.apache.batik.gvt.GraphicsNode
Parameters:
g2d - the Graphics2D to use
rc - the GraphicsNodeRenderContext to use


Copyright © 2001 Apache Software Foundation. All Rights Reserved.