org.apache.fop.svg

## Class AbstractFOPTextPainter

- java.lang.Object
- - org.apache.fop.svg.AbstractFOPTextPainter

- All Implemented Interfaces:
    org.apache.batik.bridge.TextPainter
  Direct Known Subclasses:
    AFPTextPainter

      public abstract class AbstractFOPTextPainter
      extends Object
      implements org.apache.batik.bridge.TextPainter

  Renders the attributed character iterator of a `TextNode`. This class draws the text directly into the Graphics2D so that the text is not drawn using shapes. If the text is simple enough to draw then it sets the font and calls drawString. If the text is complex or the cannot be translated into a simple drawString the StrokingTextPainter is used instead.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected org.apache.commons.logging.Log` | `log` the logger for this class

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractFOPTextPainter(FOPTextHandler nativeTextHandler, org.apache.batik.bridge.TextPainter proxyTextPainter)` Create a new PS text painter with the given font information.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Rectangle2D` | `getBounds2D(org.apache.batik.bridge.TextNode node)` Get the bounds.
    `Rectangle2D` | `getGeometryBounds(org.apache.batik.bridge.TextNode node)` Get the geometry bounds.
    `Shape` | `getHighlightShape(org.apache.batik.bridge.Mark beginMark, org.apache.batik.bridge.Mark endMark)` Get the highlighted shape.
    `org.apache.batik.bridge.Mark` | `getMark(org.apache.batik.bridge.TextNode node, int pos, boolean all)` Get the mark.
    `Shape` | `getOutline(org.apache.batik.bridge.TextNode node)` Get the outline shape of the text characters.
    `int[]` | `getSelected(org.apache.batik.bridge.Mark start, org.apache.batik.bridge.Mark finish)` Get selected.
    `protected String` | `getText(AttributedCharacterIterator aci)` Extract the raw text from an ACI.
    `protected abstract boolean` | `isSupportedGraphics2D(Graphics2D g2d)` Checks whether the Graphics2D is compatible with this text painter.
    `void` | `paint(org.apache.batik.bridge.TextNode node, Graphics2D g2d)` Paints the specified attributed character iterator using the specified Graphics2D and context and font context.
    `org.apache.batik.bridge.Mark` | `selectAt(double x, double y, org.apache.batik.bridge.TextNode node)` Select at.
    `org.apache.batik.bridge.Mark` | `selectFirst(org.apache.batik.bridge.TextNode node)` Selec first.
    `org.apache.batik.bridge.Mark` | `selectLast(org.apache.batik.bridge.TextNode node)` Select last.
    `org.apache.batik.bridge.Mark` | `selectTo(double x, double y, org.apache.batik.bridge.Mark beginMark)` Select to.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### log

          protected org.apache.commons.logging.Log log

      the logger for this class

  - ### Constructor Detail

    - #### AbstractFOPTextPainter

          public AbstractFOPTextPainter(FOPTextHandler nativeTextHandler,
                                        org.apache.batik.bridge.TextPainter proxyTextPainter)

      Create a new PS text painter with the given font information.
      Parameters:
        `nativeTextHandler` - the NativeTextHandler instance used for text painting

  - ### Method Detail

    - #### paint

          public void paint(org.apache.batik.bridge.TextNode node,
                            Graphics2D g2d)

      Paints the specified attributed character iterator using the specified Graphics2D and context and font context.
      Specified by:
        `paint` in interface `org.apache.batik.bridge.TextPainter`
      Parameters:
        `node` - the TextNode to paint
        `g2d` - the Graphics2D to use

    - #### isSupportedGraphics2D

          protected abstract boolean isSupportedGraphics2D(Graphics2D g2d)

      Checks whether the Graphics2D is compatible with this text painter. Batik may pass in a Graphics2D instance that paints on a special buffer image, for example for filtering operations. In that case, the text painter should be bypassed.
      Parameters:
        `g2d` - the Graphics2D instance to check
      Returns:
        true if the Graphics2D is supported

    - #### getText

          protected String getText(AttributedCharacterIterator aci)

      Extract the raw text from an ACI.
      Parameters:
        `aci` - ACI to inspect
      Returns:
        the extracted text

    - #### getOutline

          public Shape getOutline(org.apache.batik.bridge.TextNode node)

      Get the outline shape of the text characters. This uses the StrokingTextPainter to get the outline shape since in theory it should be the same.
      Specified by:
        `getOutline` in interface `org.apache.batik.bridge.TextPainter`
      Parameters:
        `node` - the text node
      Returns:
        the outline shape of the text characters

    - #### getBounds2D

          public Rectangle2D getBounds2D(org.apache.batik.bridge.TextNode node)

      Get the bounds. This uses the StrokingTextPainter to get the bounds since in theory it should be the same.
      Specified by:
        `getBounds2D` in interface `org.apache.batik.bridge.TextPainter`
      Parameters:
        `node` - the text node
      Returns:
        the bounds of the text

    - #### getGeometryBounds

          public Rectangle2D getGeometryBounds(org.apache.batik.bridge.TextNode node)

      Get the geometry bounds. This uses the StrokingTextPainter to get the bounds since in theory it should be the same.
      Specified by:
        `getGeometryBounds` in interface `org.apache.batik.bridge.TextPainter`
      Parameters:
        `node` - the text node
      Returns:
        the bounds of the text

    - #### getMark

          public org.apache.batik.bridge.Mark getMark(org.apache.batik.bridge.TextNode node,
                                                      int pos,
                                                      boolean all)

      Get the mark. This does nothing since the output is AFP and not interactive.
      Specified by:
        `getMark` in interface `org.apache.batik.bridge.TextPainter`
      Parameters:
        `node` - the text node
        `pos` - the position
        `all` - select all
      Returns:
        null

    - #### selectAt

          public org.apache.batik.bridge.Mark selectAt(double x,
                                                       double y,
                                                       org.apache.batik.bridge.TextNode node)

      Select at. This does nothing since the output is AFP and not interactive.
      Specified by:
        `selectAt` in interface `org.apache.batik.bridge.TextPainter`
      Parameters:
        `x` - the x position
        `y` - the y position
        `node` - the text node
      Returns:
        null

    - #### selectTo

          public org.apache.batik.bridge.Mark selectTo(double x,
                                                       double y,
                                                       org.apache.batik.bridge.Mark beginMark)

      Select to. This does nothing since the output is AFP and not interactive.
      Specified by:
        `selectTo` in interface `org.apache.batik.bridge.TextPainter`
      Parameters:
        `x` - the x position
        `y` - the y position
        `beginMark` - the start mark
      Returns:
        null

    - #### selectFirst

          public org.apache.batik.bridge.Mark selectFirst(org.apache.batik.bridge.TextNode node)

      Selec first. This does nothing since the output is AFP and not interactive.
      Specified by:
        `selectFirst` in interface `org.apache.batik.bridge.TextPainter`
      Parameters:
        `node` - the text node
      Returns:
        null

    - #### selectLast

          public org.apache.batik.bridge.Mark selectLast(org.apache.batik.bridge.TextNode node)

      Select last. This does nothing since the output is AFP and not interactive.
      Specified by:
        `selectLast` in interface `org.apache.batik.bridge.TextPainter`
      Parameters:
        `node` - the text node
      Returns:
        null

    - #### getSelected

          public int[] getSelected(org.apache.batik.bridge.Mark start,
                                   org.apache.batik.bridge.Mark finish)

      Get selected. This does nothing since the output is AFP and not interactive.
      Specified by:
        `getSelected` in interface `org.apache.batik.bridge.TextPainter`
      Parameters:
        `start` - the start mark
        `finish` - the finish mark
      Returns:
        null

    - #### getHighlightShape

          public Shape getHighlightShape(org.apache.batik.bridge.Mark beginMark,
                                         org.apache.batik.bridge.Mark endMark)

      Get the highlighted shape. This does nothing since the output is AFP and not interactive.
      Specified by:
        `getHighlightShape` in interface `org.apache.batik.bridge.TextPainter`
      Parameters:
        `beginMark` - the start mark
        `endMark` - the end mark
      Returns:
        null

Copyright © 2025 Apache Software Foundation. All rights reserved.