Class TextNode

All Implemented Interfaces:
GraphicsNode, Selectable
Direct Known Subclasses:
FlowExtTextNode, FlowTextNode

public class TextNode extends AbstractGraphicsNode implements Selectable
A graphics node that represents text.
Version:
$Id: TextNode.java 1808888 2017-09-19 14:22:11Z ssteiner $
  • Field Details

    • PAINT_INFO

      public static final AttributedCharacterIterator.Attribute PAINT_INFO
    • location

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

      Attributed Character Iterator describing the text
    • text

      protected String text
      The text of this TextNode.
    • beginMark

      protected Mark beginMark
      The begin mark.
    • endMark

      protected Mark endMark
      The end mark.
    • textRuns

      protected List textRuns
      The list of text runs.
    • textPainter

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

      private Rectangle2D geometryBounds
      Internal Cache: Bounds for this text node, without taking any of the rendering attributes (e.g., stroke) into account
    • primitiveBounds

      private Rectangle2D primitiveBounds
      Internal Cache: Primitive Bounds.
    • outline

      private Shape outline
      Internal Cache: the outline.
  • Constructor Details

    • TextNode

      public TextNode()
      Constructs a new empty TextNode.
  • Method Details

    • 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
    • getTextPainter

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

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

      public void setTextRuns(List textRuns)
      Sets the list of text runs of this text node.
      Parameters:
      textRuns - the new list of text runs
    • getText

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

      public void setLocation(Point2D newLocation)
      Sets the location of this text node.
      Parameters:
      newLocation - the new location of this text node
    • getLocation

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

      public void swapTextPaintInfo(TextPaintInfo newInfo, TextPaintInfo oldInfo)
    • setAttributedCharacterIterator

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

      public 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 Rectangle2D getPrimitiveBounds()
      Returns the bounds of the area covered by this node's primitive paint.
      Specified by:
      getPrimitiveBounds in interface GraphicsNode
    • 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.
      Specified by:
      getGeometryBounds in interface GraphicsNode
    • 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.
      Specified by:
      getSensitiveBounds in interface GraphicsNode
    • getOutline

      public Shape getOutline()
      Returns the outline of this node.
      Specified by:
      getOutline in interface GraphicsNode
    • 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.
    • setSelection

      public void setSelection(Mark begin, Mark end)
    • selectAt

      public boolean selectAt(double x, double y)
      Initializes the current selection to begin with the character at (x, y).
      Specified by:
      selectAt in interface Selectable
      Parameters:
      x - the x coordinate of the start of the selection
      y - the y coordinate of the start of the selection
      Returns:
      true if action resulted in change of selection.
    • selectTo

      public boolean selectTo(double x, double y)
      Extends the current selection to the character at (x, y).
      Specified by:
      selectTo in interface Selectable
      Parameters:
      x - the x coordinate of the end of the selection
      y - the y coordinate of the end of the selection
      Returns:
      true if action resulted in change of selection.
    • selectAll

      public boolean selectAll(double x, double y)
      Selects all the text in this TextNode. The coordinates are ignored.
      Specified by:
      selectAll in interface Selectable
      Parameters:
      x - the x coordinate of the point the selection was made
      y - the y coordinate of the point the selection was made
      Returns:
      true if action resulted in change of selection.
    • getSelection

      public Object getSelection()
      Gets the current text selection.
      Specified by:
      getSelection in interface Selectable
      Returns:
      an object containing the selected content.
    • getHighlightShape

      public Shape getHighlightShape()
      Returns the shape used to outline this text node.
      Specified by:
      getHighlightShape in interface Selectable
      Returns:
      a Shape which encloses the current text selection.
    • primitivePaint

      public void primitivePaint(Graphics2D g2d)
      Paints this node without applying Filter, Mask, Composite, and clip.
      Specified by:
      primitivePaint in interface GraphicsNode
      Parameters:
      g2d - the Graphics2D to use
    • contains

      public boolean contains(Point2D p)
      Returns true if the specified Point2D is inside the boundary of this node, false otherwise.
      Specified by:
      contains in interface GraphicsNode
      Overrides:
      contains in class AbstractGraphicsNode
      Parameters:
      p - the specified Point2D in the user space
    • contains

      protected boolean contains(Point2D p, Rectangle2D b)