public abstract class AbstractIFPainter<T extends IFDocumentHandler> extends Object implements IFPainter
| Modifier and Type | Field and Description |
|---|---|
protected static String |
INSTREAM_OBJECT_URI
non-URI that can be used in feedback messages that an image is an instream-object
|
protected IFState |
state
Holds the intermediate format state
|
| Constructor and Description |
|---|
AbstractIFPainter(T documentHandler)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected Map |
createDefaultImageProcessingHints(org.apache.xmlgraphics.image.loader.ImageSessionContext sessionContext)
Creates the default map of processing hints for the image loading framework.
|
protected abstract RenderingContext |
createRenderingContext()
Creates a new RenderingContext instance.
|
void |
drawBorderRect(Rectangle rect,
BorderProps top,
BorderProps bottom,
BorderProps left,
BorderProps right,
Color innerBackgroundColor)
Draws a border rectangle.
|
protected void |
drawImage(org.apache.xmlgraphics.image.loader.Image image,
Rectangle rect,
RenderingContext context)
Draws an image using a suitable image handler.
|
protected void |
drawImage(org.apache.xmlgraphics.image.loader.Image image,
Rectangle rect,
RenderingContext context,
boolean convert,
Map additionalHints)
Draws an image using a suitable image handler.
|
protected void |
drawImageUsingDocument(Document doc,
Rectangle rect)
Default drawing method for handling a foreign object in the form of a DOM document.
|
protected void |
drawImageUsingImageHandler(org.apache.xmlgraphics.image.loader.ImageInfo info,
Rectangle rect)
Loads a preloaded image and draws it using a suitable image handler.
|
protected void |
drawImageUsingURI(String uri,
Rectangle rect)
Default drawing method for handling an image referenced by a URI.
|
void |
drawLine(Point start,
Point end,
int width,
Color color,
BorderStyle style)
Draws a line.
|
protected boolean |
drawSVGText(MultiByteFont multiByteFont,
FontTriplet triplet,
int x,
int y,
String text,
IFState state) |
void |
drawText(int x,
int y,
int letterSpacing,
int wordSpacing,
int[][] dp,
String text,
boolean nextIsSpace) |
IFContext |
getContext()
Returns the intermediate format context object.
|
protected T |
getDocumentHandler() |
protected FontInfo |
getFontInfo() |
protected String |
getFontKey(FontTriplet triplet) |
protected org.apache.xmlgraphics.image.loader.Image |
getImageForSupportedFlavors(org.apache.xmlgraphics.image.loader.ImageInfo info) |
protected org.apache.xmlgraphics.image.loader.ImageInfo |
getImageInfo(String uri)
Returns an ImageInfo instance for the given URI.
|
protected Rectangle |
getLineBoundingBox(Point start,
Point end,
int width)
Calculates the bounding box for a line.
|
protected FOUserAgent |
getUserAgent()
Returns the user agent.
|
protected boolean |
hasOnlySolidBorders(BorderProps top,
BorderProps bottom,
BorderProps left,
BorderProps right)
Indicates whether the given border segments (if present) have only solid borders, i.e.
|
boolean |
isBackgroundRequired(BorderProps bpsBefore,
BorderProps bpsAfter,
BorderProps bpsStart,
BorderProps bpsEnd)
TODO Painter-specific rounded borders logic required background drawing to be
made optional.
|
void |
setFont(String family,
String style,
Integer weight,
String variant,
Integer size,
Color color)
Updates the current font.
|
void |
startGroup(AffineTransform[] transforms,
String layer)
Starts a new group of graphical elements.
|
void |
startViewport(AffineTransform[] transforms,
Dimension size,
Rectangle clipRect)
Starts a new viewport, establishing a new coordinate system.
|
boolean |
supportsSoftHyphen()
Allows specific painters to indicate whether a soft hyphen is supported.
|
static AffineTransform |
toPoints(AffineTransform transform)
Converts a transformation matrix from millipoints to points.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclipBackground, clipRect, drawImage, drawImage, drawText, endGroup, endViewport, fillRect, startGroup, startViewportprotected static final String INSTREAM_OBJECT_URI
protected IFState state
public AbstractIFPainter(T documentHandler)
protected String getFontKey(FontTriplet triplet) throws IFException
IFExceptionpublic IFContext getContext()
protected FontInfo getFontInfo()
protected T getDocumentHandler()
protected FOUserAgent getUserAgent()
public void startViewport(AffineTransform[] transforms, Dimension size, Rectangle clipRect) throws IFException
startViewport in interface IFPaintertransforms - a series of transformation matrices establishing the new coordinate systemsize - the size of the viewportclipRect - the clipping rectangle (may be null)IFException - if an error occurs while handling this elementpublic void startGroup(AffineTransform[] transforms, String layer) throws IFException
startGroup in interface IFPaintertransforms - a series of transformation matrices establishing the new coordinate systemlayer - an optional layer label (or null if none)IFException - if an error occurs while handling this elementprotected abstract RenderingContext createRenderingContext()
protected void drawImageUsingImageHandler(org.apache.xmlgraphics.image.loader.ImageInfo info,
Rectangle rect)
throws org.apache.xmlgraphics.image.loader.ImageException,
IOException
info - the information object of the preloaded imagerect - the rectangle in which to paint the imageorg.apache.xmlgraphics.image.loader.ImageException - if there's an error while processing the imageIOException - if there's an I/O error while loading the imageprotected org.apache.xmlgraphics.image.loader.Image getImageForSupportedFlavors(org.apache.xmlgraphics.image.loader.ImageInfo info)
protected Map createDefaultImageProcessingHints(org.apache.xmlgraphics.image.loader.ImageSessionContext sessionContext)
sessionContext - the session context for access to resolution informationprotected void drawImage(org.apache.xmlgraphics.image.loader.Image image,
Rectangle rect,
RenderingContext context)
throws IOException,
org.apache.xmlgraphics.image.loader.ImageException
image - the image to be painted (it needs to of a supported image flavor)rect - the rectangle in which to paint the imagecontext - a suitable rendering contextIOException - in case of an I/O error while handling/writing the imageorg.apache.xmlgraphics.image.loader.ImageException - if an error occurs while converting the image to a suitable formatprotected void drawImage(org.apache.xmlgraphics.image.loader.Image image,
Rectangle rect,
RenderingContext context,
boolean convert,
Map additionalHints)
throws IOException,
org.apache.xmlgraphics.image.loader.ImageException
image - the image to be painted (it needs to of a supported image flavor)rect - the rectangle in which to paint the imagecontext - a suitable rendering contextconvert - true to run the image through image conversion if that is necessaryadditionalHints - additional image processing hintsIOException - in case of an I/O error while handling/writing the imageorg.apache.xmlgraphics.image.loader.ImageException - if an error occurs while converting the image to a suitable formatprotected org.apache.xmlgraphics.image.loader.ImageInfo getImageInfo(String uri)
uri - the URI identifying the imageprotected void drawImageUsingURI(String uri, Rectangle rect)
uri - the image's URIrect - the rectangle in which to paint the imageprotected void drawImageUsingDocument(Document doc, Rectangle rect)
doc - the DOM document containing the foreign objectrect - the rectangle in which to paint the imagepublic void drawBorderRect(Rectangle rect, BorderProps top, BorderProps bottom, BorderProps left, BorderProps right, Color innerBackgroundColor) throws IFException
BorderProps
instances.drawBorderRect in interface IFPainterrect - the rectangle's coordinates and extenttop - the border segment on the top edgebottom - the border segment on the bottom edgeleft - the border segment on the left edgeright - the border segment on the right edgeinnerBackgroundColor - the color of the inner backgroundIFException - if an error occurs while handling this eventprotected boolean hasOnlySolidBorders(BorderProps top, BorderProps bottom, BorderProps left, BorderProps right)
top - the border segment on the top edgebottom - the border segment on the bottom edgeleft - the border segment on the left edgeright - the border segment on the right edgepublic void drawLine(Point start, Point end, int width, Color color, BorderStyle style) throws IFException
drawLine in interface IFPainterstart - the start point of the lineend - the end point of the linewidth - the line widthcolor - the line colorstyle - the line style (using the Constants.EN_* constants for the rule-style property)IFException - if an error occurs while handling this eventprotected Rectangle getLineBoundingBox(Point start, Point end, int width)
start - the starting point of the line (coordinates in mpt)end - the ending point of the line (coordinates in mpt)width - the line width (in mpt)public void setFont(String family, String style, Integer weight, String variant, Integer size, Color color) throws IFException
setFont in interface IFPainterfamily - the font family (or null if there's no change)style - the font style (or null if there's no change)weight - the font weight (or null if there's no change)variant - the font variant (or null if there's no change)size - the font size (or null if there's no change)color - the text color (or null if there's no change)IFException - if an error occurs while handling this eventpublic static AffineTransform toPoints(AffineTransform transform)
transform - the transformation matrix (in millipoints)public boolean isBackgroundRequired(BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd)
isBackgroundRequired in interface IFPainterbpsBefore - the before borderbpsAfter - the after borderbpsStart - the start borderbpsEnd - the end borderpublic void drawText(int x,
int y,
int letterSpacing,
int wordSpacing,
int[][] dp,
String text,
boolean nextIsSpace)
throws IFException
drawText in interface IFPainterIFExceptionprotected boolean drawSVGText(MultiByteFont multiByteFont, FontTriplet triplet, int x, int y, String text, IFState state) throws IFException
IFExceptionpublic boolean supportsSoftHyphen()
IFPaintersupportsSoftHyphen in interface IFPainterCopyright © 2026 Apache Software Foundation. All rights reserved.