PSImageHandlerGraphics2D (Apache FOP Core 2.11 API)
Date: 2025-04-24

org.apache.fop.render.ps

## Class PSImageHandlerGraphics2D

- java.lang.Object
- - org.apache.fop.render.ps.PSImageHandlerGraphics2D

- All Implemented Interfaces:
    ImageHandler, ImageHandlerBase, PSImageHandler

      public class PSImageHandlerGraphics2D
      extends Object
      implements PSImageHandler

  Image handler implementation which handles vector graphics (Java2D) for PostScript output.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PSImageHandlerGraphics2D()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `generateForm(RenderingContext context, org.apache.xmlgraphics.image.loader.Image image, PSImageFormResource form)` Generates a PostScript form for the given `Image` instance.
    `int` | `getPriority()` Returns the priority for this image handler.
    `Class` | `getSupportedImageClass()` Returns the `Class` subclass supported by this instance.
    `org.apache.xmlgraphics.image.loader.ImageFlavor[]` | `getSupportedImageFlavors()` Returns the `ImageFlavor`s supported by this instance
    `void` | `handleImage(RenderingContext context, org.apache.xmlgraphics.image.loader.Image image, Rectangle pos)` Handles the given `Image` instance painting it at the indicated position in the output format being generated.
    `boolean` | `isCompatible(RenderingContext targetContext, org.apache.xmlgraphics.image.loader.Image image)` Indicates whether the image handler is compatible with the indicated target represented by the rendering context object and with the image to be processed.

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

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

- - ### Constructor Detail

    - #### PSImageHandlerGraphics2D

          public PSImageHandlerGraphics2D()

  - ### Method Detail

    - #### handleImage

          public void handleImage(RenderingContext context,
                                  org.apache.xmlgraphics.image.loader.Image image,
                                  Rectangle pos)
                           throws IOException

      Handles the given `Image` instance painting it at the indicated position in the output format being generated.
      Specified by:
        `handleImage` in interface `ImageHandler`
      Parameters:
        `context` - the rendering context
        `image` - the image to be handled
        `pos` - the position and scaling of the image relative to the origin point of the current viewport (in millipoints)
      Throws:
        `IOException` - if an I/O error occurs

    - #### generateForm

          public void generateForm(RenderingContext context,
                                   org.apache.xmlgraphics.image.loader.Image image,
                                   PSImageFormResource form)
                            throws IOException

      Generates a PostScript form for the given `Image` instance.
      Specified by:
        `generateForm` in interface `PSImageHandler`
      Parameters:
        `context` - the rendering context
        `image` - the image to be handled
        `form` - the associated form resource
      Throws:
        `IOException` - if an I/O error occurs

    - #### getPriority

          public int getPriority()

      Returns the priority for this image handler. A lower value means higher priority. This information is used to build the ordered/prioritized list of supported ImageFlavors. The built-in handlers use priorities between 100 and 999.
      Specified by:
        `getPriority` in interface `ImageHandlerBase`
      Returns:
        a positive integer (>0) indicating the priority

    - #### getSupportedImageClass

          public Class getSupportedImageClass()

      Returns the `Class` subclass supported by this instance.
      Specified by:
        `getSupportedImageClass` in interface `ImageHandlerBase`
      Returns:
        the image Class type

    - #### getSupportedImageFlavors

          public org.apache.xmlgraphics.image.loader.ImageFlavor[] getSupportedImageFlavors()

      Returns the `ImageFlavor`s supported by this instance
      Specified by:
        `getSupportedImageFlavors` in interface `ImageHandlerBase`
      Returns:
        the supported image flavors

    - #### isCompatible

          public boolean isCompatible(RenderingContext targetContext,
                                      org.apache.xmlgraphics.image.loader.Image image)

      Indicates whether the image handler is compatible with the indicated target represented by the rendering context object and with the image to be processed. The image is also passed as a parameter because a handler might not support every subtype of image that is presented. For example: in the case of `ImageXMLDOM`, the image might carry an SVG or some other XML format. One handler might only handle SVG but no other XML format.
      Specified by:
        `isCompatible` in interface `ImageHandler`
      Parameters:
        `targetContext` - the target rendering context
        `image` - the image to be processed (or null if only to check based on the rendering context)
      Returns:
        true if this handler is compatible with the target rendering context

Copyright © 2025 Apache Software Foundation. All rights reserved.