org.apache.batik.gvt

Class TextNode

public class TextNode extends AbstractGraphicsNode implements Selectable

A graphics node that represents text.
Nested Class Summary
static classTextNode.Anchor
Defines where the text of a TextNode can be anchored relative to its location.
Field Summary
protected AttributedCharacterIteratoraci
Attributed Character Iterator describing the text
protected MarkbeginMark
The begin mark.
protected MarkendMark
The end mark.
protected Point2Dlocation
Location of this text node (inherited, independent of explicit X and Y attributes applied to children).
static AttributePAINT_INFO
protected Stringtext
The text of this TextNode.
protected TextPaintertextPainter
The text painter used to display the text of this text node.
protected ListtextRuns
The list of text runs.
Constructor Summary
TextNode()
Constructs a new empty TextNode.
Method Summary
booleancontains(Point2D p)
Returns true if the specified Point2D is inside the boundary of this node, false otherwise.
protected booleancontains(Point2D p, Rectangle2D b)
AttributedCharacterIteratorgetAttributedCharacterIterator()
Returns the attributed character iterator of this text node.
Rectangle2DgetGeometryBounds()
Returns the bounds of the area covered by this node, without taking any of its rendering attribute into account.
ShapegetHighlightShape()
Returns the shape used to outline this text node.
Point2DgetLocation()
Returns the location of this text node.
MarkgetMarkerForChar(int index, boolean beforeChar)
Return the marker for the character at index in this nodes AttributedCharacterIterator.
ShapegetOutline()
Returns the outline of this node.
Rectangle2DgetPrimitiveBounds()
Returns the bounds of the area covered by this node's primitive paint.
ObjectgetSelection()
Gets the current text selection.
Rectangle2DgetSensitiveBounds()
Returns the bounds of the sensitive area covered by this node, This includes the stroked area but does not include the effects of clipping, masking or filtering.
StringgetText()
Returns the text of this TextNode as a string.
TextPaintergetTextPainter()
Returns the text painter of this text node.
ListgetTextRuns()
Returns a list of text runs.
protected voidinvalidateGeometryCache()
Invalidates this TextNode.
voidprimitivePaint(Graphics2D g2d)
Paints this node without applying Filter, Mask, Composite, and clip.
booleanselectAll(double x, double y)
Selects all the text in this TextNode.
booleanselectAt(double x, double y)
Initializes the current selection to begin with the character at (x, y).
booleanselectTo(double x, double y)
Extends the current selection to the character at (x, y).
voidsetAttributedCharacterIterator(AttributedCharacterIterator newAci)
Sets the attributed character iterator of this text node.
voidsetLocation(Point2D newLocation)
Sets the location of this text node.
voidsetSelection(Mark begin, Mark end)
voidsetTextPainter(TextPainter textPainter)
Sets the text painter of this text node.
voidsetTextRuns(List textRuns)
Sets the list of text runs of this text node.
voidswapTextPaintInfo(TextPaintInfo newInfo, TextPaintInfo oldInfo)

Field Detail

aci

protected AttributedCharacterIterator aci
Attributed Character Iterator describing the text

beginMark

protected Mark beginMark
The begin mark.

endMark

protected Mark endMark
The end mark.

location

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

PAINT_INFO

public static final Attribute PAINT_INFO

text

protected String text
The text of this TextNode.

textPainter

protected TextPainter textPainter
The text painter used to display the text of this text node.

textRuns

protected List textRuns
The list of text runs.

Constructor Detail

TextNode

public TextNode()
Constructs a new empty TextNode.

Method Detail

contains

public boolean contains(Point2D p)
Returns true if the specified Point2D is inside the boundary of this node, false otherwise.

Parameters: p the specified Point2D in the user space

contains

protected boolean contains(Point2D p, Rectangle2D b)

getAttributedCharacterIterator

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

Returns: the attributed character iterator

getGeometryBounds

public Rectangle2D getGeometryBounds()
Returns the bounds of the area covered by this node, without taking any of its rendering attribute into account. That is, exclusive of any clipping, masking, filtering or stroking, for example.

getHighlightShape

public Shape getHighlightShape()
Returns the shape used to outline this text node.

Returns: a Shape which encloses the current text selection.

getLocation

public Point2D getLocation()
Returns the location of this text node.

Returns: the location of this text node

getMarkerForChar

public Mark getMarkerForChar(int index, boolean beforeChar)
Return the marker for the character at index in this nodes AttributedCharacterIterator. Before Char indicates if the Marker should be considered before or after char.

getOutline

public Shape getOutline()
Returns the outline of this node.

getPrimitiveBounds

public Rectangle2D getPrimitiveBounds()
Returns the bounds of the area covered by this node's primitive paint.

getSelection

public Object getSelection()
Gets the current text selection.

Returns: an object containing the selected content.

getSensitiveBounds

public Rectangle2D getSensitiveBounds()
Returns the bounds of the sensitive area covered by this node, This includes the stroked area but does not include the effects of clipping, masking or filtering.

getText

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

getTextPainter

public TextPainter getTextPainter()
Returns the text painter of this text node.

getTextRuns

public List getTextRuns()
Returns a list of text runs.

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.

primitivePaint

public void primitivePaint(Graphics2D g2d)
Paints this node without applying Filter, Mask, Composite, and clip.

Parameters: g2d the Graphics2D to use

selectAll

public boolean selectAll(double x, double y)
Selects all the text in this TextNode. The coordinates are ignored.

Parameters: x the x coordinate of the point the selection was made y the y coordinate of the point the selection was made

selectAt

public boolean selectAt(double x, double y)
Initializes the current selection to begin with the character at (x, y).

Parameters: x the x coordinate of the start of the selection y the y coordinate of the start of the selection

selectTo

public boolean selectTo(double x, double y)
Extends the current selection to the character at (x, y).

Parameters: x the x coordinate of the end of the selection y the y coordinate of the end of the selection

setAttributedCharacterIterator

public void setAttributedCharacterIterator(AttributedCharacterIterator newAci)
Sets the attributed character iterator of this text node.

Parameters: newAci the new attributed character iterator

setLocation

public void setLocation(Point2D newLocation)
Sets the location of this text node.

Parameters: newLocation the new location of this text node

setSelection

public void setSelection(Mark begin, Mark end)

setTextPainter

public void setTextPainter(TextPainter textPainter)
Sets the text painter of this text node. If the specified text painter is null, this text node will use its default text painter (StrokingTextPainter.getInstance()).

Parameters: textPainter the text painter to use

setTextRuns

public void setTextRuns(List textRuns)
Sets the list of text runs of this text node.

Parameters: textRuns the new list of text runs

swapTextPaintInfo

public void swapTextPaintInfo(TextPaintInfo newInfo, TextPaintInfo oldInfo)
Copyright B) 2008 Apache Software Foundation. All Rights Reserved.