org.apache.fop.svg

Class PDFTextPainter

Implemented Interfaces:
TextPainter

public class PDFTextPainter
extends java.lang.Object
implements TextPainter

Renders the attributed character iterator of a TextNode. This class draws the text directly into the PDFGraphics2D so that the text is not drawn using shapes which makes the PDF files larger. 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. (todo) handle underline, overline and strikethrough (todo) use drawString(AttributedCharacterIterator iterator...) for some
Version:
$Id: PDFTextPainter.java 542237 2007-05-28 14:31:24Z jeremias $
Author:
Keiron Liddle

Field Summary

protected static TextPainter
PROXY_PAINTER
Use the stroking text painter to get the bounds and shape.

Constructor Summary

PDFTextPainter(FontInfo fi)
Create a new PDF text painter with the given font information.

Method Summary

Rectangle2D
getBounds2D(TextNode node)
Get the bounds.
Rectangle2D
getGeometryBounds(TextNode node)
Get the geometry bounds.
Shape
getHighlightShape(Mark beginMark, Mark endMark)
Get the highlighted shape.
Mark
getMark(TextNode node, int pos, boolean all)
Get the mark.
Shape
getOutline(TextNode node)
Get the outline shape of the text characters.
int[]
getSelected(Mark start, Mark finish)
Get selected.
void
paint(TextNode node, Graphics2D g2d)
Paints the specified attributed character iterator using the specified Graphics2D and context and font context.
Mark
selectAt(double x, double y, TextNode node)
Select at.
Mark
selectFirst(TextNode node)
Selec first.
Mark
selectLast(TextNode node)
Select last.
Mark
selectTo(double x, double y, Mark beginMark)
Select to.

Field Details

PROXY_PAINTER

protected static final TextPainter PROXY_PAINTER
Use the stroking text painter to get the bounds and shape. Also used as a fallback to draw the string with strokes.

Constructor Details

PDFTextPainter

public PDFTextPainter(FontInfo fi)
Create a new PDF text painter with the given font information.
Parameters:
fi - the fint info

Method Details

getBounds2D

public Rectangle2D getBounds2D(TextNode node)
Get the bounds. This uses the StrokingTextPainter to get the bounds since in theory it should be the same.
Parameters:
node - the text node
Returns:
the bounds of the text

getGeometryBounds

public Rectangle2D getGeometryBounds(TextNode node)
Get the geometry bounds. This uses the StrokingTextPainter to get the bounds since in theory it should be the same.
Parameters:
node - the text node
Returns:
the bounds of the text

getHighlightShape

public Shape getHighlightShape(Mark beginMark,
                               Mark endMark)
Get the highlighted shape. This does nothing since the output is pdf and not interactive.
Parameters:
beginMark - the start mark
endMark - the end mark
Returns:
null

getMark

public Mark getMark(TextNode node,
                    int pos,
                    boolean all)
Get the mark. This does nothing since the output is pdf and not interactive.
Parameters:
node - the text node
pos - the position
all - select all
Returns:
null

getOutline

public Shape getOutline(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.
Parameters:
node - the text node
Returns:
the outline shape of the text characters

getSelected

public int[] getSelected(Mark start,
                         Mark finish)
Get selected. This does nothing since the output is pdf and not interactive.
Parameters:
start - the start mark
finish - the finish mark
Returns:
null

paint

public void paint(TextNode node,
                  Graphics2D g2d)
Paints the specified attributed character iterator using the specified Graphics2D and context and font context.
Parameters:
node - the TextNode to paint
g2d - the Graphics2D to use

selectAt

public Mark selectAt(double x,
                     double y,
                     TextNode node)
Select at. This does nothing since the output is pdf and not interactive.
Parameters:
x - the x position
y - the y position
node - the text node
Returns:
null

selectFirst

public Mark selectFirst(TextNode node)
Selec first. This does nothing since the output is pdf and not interactive.
Parameters:
node - the text node
Returns:
null

selectLast

public Mark selectLast(TextNode node)
Select last. This does nothing since the output is pdf and not interactive.
Parameters:
node - the text node
Returns:
null

selectTo

public Mark selectTo(double x,
                     double y,
                     Mark beginMark)
Select to. This does nothing since the output is pdf and not interactive.
Parameters:
x - the x position
y - the y position
beginMark - the start mark
Returns:
null

Copyright 1999-2007 The Apache Software Foundation. All Rights Reserved.