public abstract class AbstractIFPainter<T extends IFDocumentHandler> extends java.lang.Object implements IFPainter
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.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 java.util.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(java.awt.Rectangle rect,
BorderProps top,
BorderProps bottom,
BorderProps left,
BorderProps right,
java.awt.Color innerBackgroundColor)
Draws a border rectangle.
|
protected void |
drawImage(org.apache.xmlgraphics.image.loader.Image image,
java.awt.Rectangle rect,
RenderingContext context)
Draws an image using a suitable image handler.
|
protected void |
drawImage(org.apache.xmlgraphics.image.loader.Image image,
java.awt.Rectangle rect,
RenderingContext context,
boolean convert,
java.util.Map additionalHints)
Draws an image using a suitable image handler.
|
protected void |
drawImageUsingDocument(org.w3c.dom.Document doc,
java.awt.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,
java.awt.Rectangle rect)
Loads a preloaded image and draws it using a suitable image handler.
|
protected void |
drawImageUsingURI(java.lang.String uri,
java.awt.Rectangle rect)
Default drawing method for handling an image referenced by a URI.
|
void |
drawLine(java.awt.Point start,
java.awt.Point end,
int width,
java.awt.Color color,
RuleStyle style)
Draws a line.
|
protected void |
drawSVGText(MultiByteFont multiByteFont,
FontTriplet triplet,
int x,
int y,
java.lang.String text,
IFState state) |
void |
drawText(int x,
int y,
int letterSpacing,
int wordSpacing,
int[][] dp,
java.lang.String text,
boolean nextIsSpace) |
IFContext |
getContext()
Returns the intermediate format context object.
|
protected T |
getDocumentHandler() |
protected FontInfo |
getFontInfo() |
protected java.lang.String |
getFontKey(FontTriplet triplet) |
protected org.apache.xmlgraphics.image.loader.ImageInfo |
getImageInfo(java.lang.String uri)
Returns an ImageInfo instance for the given URI.
|
protected java.awt.Rectangle |
getLineBoundingBox(java.awt.Point start,
java.awt.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(java.lang.String family,
java.lang.String style,
java.lang.Integer weight,
java.lang.String variant,
java.lang.Integer size,
java.awt.Color color)
Updates the current font.
|
void |
startGroup(java.awt.geom.AffineTransform[] transforms,
java.lang.String layer)
Starts a new group of graphical elements.
|
void |
startViewport(java.awt.geom.AffineTransform[] transforms,
java.awt.Dimension size,
java.awt.Rectangle clipRect)
Starts a new viewport, establishing a new coordinate system.
|
static java.awt.geom.AffineTransform |
toPoints(java.awt.geom.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 java.lang.String INSTREAM_OBJECT_URI
protected IFState state
public AbstractIFPainter(T documentHandler)
protected java.lang.String getFontKey(FontTriplet triplet) throws IFException
IFExceptionpublic IFContext getContext()
protected FontInfo getFontInfo()
protected T getDocumentHandler()
protected FOUserAgent getUserAgent()
public void startViewport(java.awt.geom.AffineTransform[] transforms,
java.awt.Dimension size,
java.awt.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(java.awt.geom.AffineTransform[] transforms,
java.lang.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,
java.awt.Rectangle rect)
throws org.apache.xmlgraphics.image.loader.ImageException,
java.io.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 imagejava.io.IOException - if there's an I/O error while loading the imageprotected java.util.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,
java.awt.Rectangle rect,
RenderingContext context)
throws java.io.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 contextjava.io.IOException - 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,
java.awt.Rectangle rect,
RenderingContext context,
boolean convert,
java.util.Map additionalHints)
throws java.io.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 hintsjava.io.IOException - 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(java.lang.String uri)
uri - the URI identifying the imageprotected void drawImageUsingURI(java.lang.String uri,
java.awt.Rectangle rect)
uri - the image's URIrect - the rectangle in which to paint the imageprotected void drawImageUsingDocument(org.w3c.dom.Document doc,
java.awt.Rectangle rect)
doc - the DOM document containing the foreign objectrect - the rectangle in which to paint the imagepublic void drawBorderRect(java.awt.Rectangle rect,
BorderProps top,
BorderProps bottom,
BorderProps left,
BorderProps right,
java.awt.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(java.awt.Point start,
java.awt.Point end,
int width,
java.awt.Color color,
RuleStyle 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 java.awt.Rectangle getLineBoundingBox(java.awt.Point start,
java.awt.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(java.lang.String family,
java.lang.String style,
java.lang.Integer weight,
java.lang.String variant,
java.lang.Integer size,
java.awt.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 java.awt.geom.AffineTransform toPoints(java.awt.geom.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,
java.lang.String text,
boolean nextIsSpace)
throws IFException
drawText in interface IFPainterIFExceptionprotected void drawSVGText(MultiByteFont multiByteFont, FontTriplet triplet, int x, int y, java.lang.String text, IFState state) throws IFException
IFExceptionCopyright 1999-2022 The Apache Software Foundation. All Rights Reserved.