Class ImageHandler

  • Direct Known Subclasses:
    BinaryImageHandler, EditImageHandler

    @API(type=EXTENDABLE,
         src=PUBLIC)
    public abstract class ImageHandler
    extends java.lang.Object
    Base class for all the image handlers.
    Since:
    18
    • Constructor Detail

      • ImageHandler

        public ImageHandler()
    • Method Detail

      • getImage

        public abstract java.awt.Image getImage​(ImageContentProvider contentProvider,
                                                ImageRenderingContext renderingContext)
                                         throws java.io.IOException
        Get an image for the corresponding URL.
        Parameters:
        contentProvider - Provides access to the image contents. If the image is embedded in the content, the content provider is an instance of EmbeddedImageContentProvider
        renderingContext - The rendering context. Never null. Should contain the font of the parent element where the equation/graphic resides. Can be ignored for raster graphics.
        Returns:
        the image, never null.
        Throws:
        java.io.IOException - When the image could not be loaded.
      • canHandleFileType

        public abstract boolean canHandleFileType​(java.lang.String extension)
        Checks if the handler can "deal with" a certain type of XML application, or other image.
        Parameters:
        extension - The extension of the file, or the type of the XML content to be rendered. The implementation should accept the string in a case insensitive manner. Examples: "mathml", "SVG", "svg"..
        Returns:
        True if the extension is known by the handler.
      • getImageLayoutInformation

        public abstract ImageLayoutInformation getImageLayoutInformation​(ImageContentProvider contentProvider,
                                                                         ImageRenderingContext renderingContext)
                                                                  throws java.io.IOException
        Get the size of the image. Ideally the handler should compute it as fast as possible, without loading the entire image in memory.
        Parameters:
        contentProvider - Provides access to the image contents. If the image is embedded in the content, the content provider is an instance of EmbeddedImageContentProvider
        renderingContext - The rendering context. Should contain the font of the parent element where the equation/graphic resides. Can be ignored for raster graphics.
        Returns:
        The size of the image. Never null.
        Throws:
        java.io.IOException - When the image size could not be determined.
      • clearCache

        public abstract void clearCache()
        Clear the individual cache the image handler might store internally.