Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| fop 2.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.fop.render.intermediate
Class AbstractIFPainter<T extends IFDocumentHandler>

    java.lang.Object
      org.apache.fop.render.intermediate.AbstractIFPainter<T>

All Implemented Interfaces:
  IFPainter

Direct Known Subclasses:
  AFPPainter, Java2DPainter, PCLPainter, PDFPainter, PSPainter

    public abstract class AbstractIFPainter<T extends IFDocumentHandler>

extends java.lang.Object
implements IFPainter

Abstract base class for IFPainter implementations.

Field Summary
`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 Summary
`AbstractIFPainter(T documentHandler)` Default constructor.

Method Summary
`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 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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.apache.fop.render.intermediate.IFPainter
`clipBackground, clipRect, drawImage, drawImage, drawText, endGroup, endViewport, fillRect, startGroup, startViewport`

Field Detail

### INSTREAM_OBJECT_URI

    protected static final java.lang.String INSTREAM_OBJECT_URI

  non-URI that can be used in feedback messages that an image is an instream-object

  See Also:
    Constant Field Values

### state

    protected IFState state

  Holds the intermediate format state

Constructor Detail

### AbstractIFPainter

    public AbstractIFPainter(T documentHandler)

  Default constructor.

Method Detail

### getFontKey

    protected java.lang.String getFontKey(FontTriplet triplet)
                                   throws IFException

  Throws:
    `IFException`

### getContext

    protected IFContext getContext()

  Returns the intermediate format context object.

  Returns:
    the context object

### getFontInfo

    protected FontInfo getFontInfo()

### getDocumentHandler

    protected T getDocumentHandler()

### getUserAgent

    protected FOUserAgent getUserAgent()

  Returns the user agent.

  Returns:
    the user agent

### startViewport

    public void startViewport(java.awt.geom.AffineTransform[] transforms,
                              java.awt.Dimension size,
                              java.awt.Rectangle clipRect)
                       throws IFException

  Starts a new viewport, establishing a new coordinate system. A viewport has a size and can optionally be clipped. Corresponds to SVG's svg element.

  Specified by:
    `startViewport` in interface `IFPainter`
  Parameters:
    `transforms` - a series of transformation matrices establishing the new coordinate system
    `size` - the size of the viewport
    `clipRect` - the clipping rectangle (may be null)
  Throws:
    `IFException` - if an error occurs while handling this element

### startGroup

    public void startGroup(java.awt.geom.AffineTransform[] transforms,
                           java.lang.String layer)
                    throws IFException

  Starts a new group of graphical elements. Corresponds to SVG's g element.

  Specified by:
    `startGroup` in interface `IFPainter`
  Parameters:
    `transforms` - a series of transformation matrices establishing the new coordinate system
    `layer` - an optional layer label (or null if none)
  Throws:
    `IFException` - if an error occurs while handling this element

### createRenderingContext

    protected abstract RenderingContext createRenderingContext()

  Creates a new RenderingContext instance.

  Returns:
    the new rendering context.

### drawImageUsingImageHandler

    protected void drawImageUsingImageHandler(org.apache.xmlgraphics.image.loader.ImageInfo info,
                                              java.awt.Rectangle rect)
                                       throws org.apache.xmlgraphics.image.loader.ImageException,
                                              java.io.IOException

  Loads a preloaded image and draws it using a suitable image handler.

  Parameters:
    `info` - the information object of the preloaded image
    `rect` - the rectangle in which to paint the image
  Throws:
    `org.apache.xmlgraphics.image.loader.ImageException` - if there's an error while processing the image
    `java.io.IOException` - if there's an I/O error while loading the image

### createDefaultImageProcessingHints

    protected java.util.Map createDefaultImageProcessingHints(org.apache.xmlgraphics.image.loader.ImageSessionContext sessionContext)

  Creates the default map of processing hints for the image loading framework.

  Parameters:
    `sessionContext` - the session context for access to resolution information
  Returns:
    the default processing hints

### drawImage

    protected 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

  Draws an image using a suitable image handler.

  Parameters:
    `image` - the image to be painted (it needs to of a supported image flavor)
    `rect` - the rectangle in which to paint the image
    `context` - a suitable rendering context
  Throws:
    `java.io.IOException` - in case of an I/O error while handling/writing the image
    `org.apache.xmlgraphics.image.loader.ImageException` - if an error occurs while converting the image to a suitable format

### drawImage

    protected 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

  Draws an image using a suitable image handler.

  Parameters:
    `image` - the image to be painted (it needs to of a supported image flavor)
    `rect` - the rectangle in which to paint the image
    `context` - a suitable rendering context
    `convert` - true to run the image through image conversion if that is necessary
    `additionalHints` - additional image processing hints
  Throws:
    `java.io.IOException` - in case of an I/O error while handling/writing the image
    `org.apache.xmlgraphics.image.loader.ImageException` - if an error occurs while converting the image to a suitable format

### getImageInfo

    protected org.apache.xmlgraphics.image.loader.ImageInfo getImageInfo(java.lang.String uri)

  Returns an ImageInfo instance for the given URI. If there's an error, null is returned. The caller can assume that any exceptions have already been handled properly. The caller simply skips painting anything in this case.

  Parameters:
    `uri` - the URI identifying the image
  Returns:
    the ImageInfo instance or null if there has been an error.

### drawImageUsingURI

    protected void drawImageUsingURI(java.lang.String uri,
                                     java.awt.Rectangle rect)

  Default drawing method for handling an image referenced by a URI.

  Parameters:
    `uri` - the image's URI
    `rect` - the rectangle in which to paint the image

### drawImageUsingDocument

    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.

  Parameters:
    `doc` - the DOM document containing the foreign object
    `rect` - the rectangle in which to paint the image

### drawBorderRect

    public void drawBorderRect(java.awt.Rectangle rect,
                               BorderProps top,
                               BorderProps bottom,
                               BorderProps left,
                               BorderProps right,
                               java.awt.Color innerBackgroundColor)
                        throws IFException

  Draws a border rectangle. The border segments are specified through `BorderProps` instances.

  Specified by:
    `drawBorderRect` in interface `IFPainter`
  Parameters:
    `rect` - the rectangle's coordinates and extent
    `top` - the border segment on the top edge
    `bottom` - the border segment on the bottom edge
    `left` - the border segment on the left edge
    `right` - the border segment on the right edge
    `innerBackgroundColor` - the color of the inner background
  Throws:
    `IFException` - if an error occurs while handling this event

### hasOnlySolidBorders

    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. could be painted in a simplified fashion keeping the output file smaller.

  Parameters:
    `top` - the border segment on the top edge
    `bottom` - the border segment on the bottom edge
    `left` - the border segment on the left edge
    `right` - the border segment on the right edge
  Returns:
    true if any border segment has a non-solid border style

### drawLine

    public void drawLine(java.awt.Point start,
                         java.awt.Point end,
                         int width,
                         java.awt.Color color,
                         RuleStyle style)
                  throws IFException

  Draws a line. NOTE: Currently, only horizontal lines are implemented!

  Specified by:
    `drawLine` in interface `IFPainter`
  Parameters:
    `start` - the start point of the line
    `end` - the end point of the line
    `width` - the line width
    `color` - the line color
    `style` - the line style (using the Constants.EN_* constants for the rule-style property)
  Throws:
    `IFException` - if an error occurs while handling this event

### getLineBoundingBox

    protected java.awt.Rectangle getLineBoundingBox(java.awt.Point start,
                                                    java.awt.Point end,
                                                    int width)

  Calculates the bounding box for a line. Currently, only horizontal and vertical lines are needed and supported.

  Parameters:
    `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)
  Returns:
    the bounding box (coordinates in mpt)

### setFont

    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

  Updates the current font.

  Specified by:
    `setFont` in interface `IFPainter`
  Parameters:
    `family` - 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)
  Throws:
    `IFException` - if an error occurs while handling this event

### toPoints

    public static java.awt.geom.AffineTransform toPoints(java.awt.geom.AffineTransform transform)

  Converts a transformation matrix from millipoints to points.

  Parameters:
    `transform` - the transformation matrix (in millipoints)
  Returns:
    the converted transformation matrix (in points)

### isBackgroundRequired

    public boolean isBackgroundRequired(BorderProps bpsBefore,
                                        BorderProps bpsAfter,
                                        BorderProps bpsStart,
                                        BorderProps bpsEnd)

  TODO Painter-specific rounded borders logic required background drawing to be made optional. A future refactoring of the rounded borders code should aim to make the need for this abstraction obsolete

  Specified by:
    `isBackgroundRequired` in interface `IFPainter`
  Parameters:
    `bpsBefore` - the before border
    `bpsAfter` - the after border
    `bpsStart` - the start border
    `bpsEnd` - the end border
  Returns:
    true if and only if background drawing is required

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| fop 2.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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