Class ImageSimilarity

java.lang.Object
org.mapfish.print.test.util.ImageSimilarity

public final class ImageSimilarity extends Object
Class for comparing an expected image to an actual image.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ImageSimilarity(File expectedFile)
    The constructor, which creates the GUI and start the image processing task.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    assertSimilarity(byte[] graphicData, double maxDistance)
    Check that the actual image and the image calculated by this object are within the given distance.
    void
    Check that the actual image and the image calculated by this object are within a relay small distance.
    void
    assertSimilarity(BufferedImage actualImage, double maxDistance)
    Check that the actual image and the image calculated by this object are within the given distance.
    void
    Check that the actual image and the image calculated by this object are within the given distance.
    void
    assertSimilarity(File actualFile, double maxDistance)
    Check that the actual image and the image calculated by this object are within the given distance.
    void
    assertSimilarity(URI svgFile, int width, int height, double maxDistance)
    Check that the actual image and the image calculated by this object are within the given distance.
    void
    assertSimilarity(List<URI> graphicFiles, int width, int height, double maxDistance)
    Check that the actual image and the image calculated by this object are within the given distance.
    void
    assertSimilarity(net.sf.jasperreports.engine.JasperPrint jasperPrint, Integer page, double maxDistance)
    Check that the actual image and the image calculated by this object are within the given distance.
    convertFromSvg(URI svgFile, int width, int height)
    Renders an SVG image into a BufferedImage.
    exportReportToImage(net.sf.jasperreports.engine.JasperPrint jasperPrint, Integer page)
    Exports a rendered JasperPrint to a BufferedImage.
    static void
    main(String[] args)
     
    mergeImages(List<URI> graphicFiles, int width, int height)
    Merges a list of graphic files into a single graphic.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • REGENERATE_EXPECTED_IMAGES

      public static final boolean REGENERATE_EXPECTED_IMAGES
      See Also:
  • Constructor Details

    • ImageSimilarity

      public ImageSimilarity(File expectedFile) throws IOException
      The constructor, which creates the GUI and start the image processing task.
      Throws:
      IOException
  • Method Details

    • mergeImages

      public static BufferedImage mergeImages(List<URI> graphicFiles, int width, int height) throws IOException, org.apache.batik.transcoder.TranscoderException
      Merges a list of graphic files into a single graphic.
      Parameters:
      graphicFiles - a list of graphic files
      width - the graphic width (required for svg files)
      height - the graphic height (required for svg files)
      Returns:
      a single graphic
      Throws:
      IOException
      org.apache.batik.transcoder.TranscoderException
    • convertFromSvg

      public static BufferedImage convertFromSvg(URI svgFile, int width, int height) throws org.apache.batik.transcoder.TranscoderException
      Renders an SVG image into a BufferedImage.
      Throws:
      org.apache.batik.transcoder.TranscoderException
    • exportReportToImage

      public static BufferedImage exportReportToImage(net.sf.jasperreports.engine.JasperPrint jasperPrint, Integer page) throws net.sf.jasperreports.engine.JRException
      Exports a rendered JasperPrint to a BufferedImage.
      Throws:
      net.sf.jasperreports.engine.JRException
    • main

      public static void main(String[] args) throws IOException
      Throws:
      IOException
    • assertSimilarity

      public void assertSimilarity(File actual) throws IOException
      Check that the actual image and the image calculated by this object are within the given distance.
      Parameters:
      actual - the image to compare to "this" image.
      Throws:
      IOException - if the image could not be written.
    • assertSimilarity

      public void assertSimilarity(byte[] graphicData, double maxDistance) throws IOException
      Check that the actual image and the image calculated by this object are within the given distance.
      Parameters:
      maxDistance - the maximum distance between the two images.
      Throws:
      IOException - if the image could not be written.
    • assertSimilarity

      public void assertSimilarity(List<URI> graphicFiles, int width, int height, double maxDistance) throws IOException, org.apache.batik.transcoder.TranscoderException
      Check that the actual image and the image calculated by this object are within the given distance.
      Parameters:
      graphicFiles - a list of graphic files
      width - the graphic width (required for svg files)
      height - the graphic height (required for svg files)
      maxDistance - the maximum distance between the two images.
      Throws:
      IOException - if the image could not be written.
      org.apache.batik.transcoder.TranscoderException
    • assertSimilarity

      public void assertSimilarity(URI svgFile, int width, int height, double maxDistance) throws IOException, org.apache.batik.transcoder.TranscoderException
      Check that the actual image and the image calculated by this object are within the given distance.
      Parameters:
      maxDistance - the maximum distance between the two images.
      Throws:
      IOException - if the image could not be written.
      org.apache.batik.transcoder.TranscoderException
    • assertSimilarity

      public void assertSimilarity(net.sf.jasperreports.engine.JasperPrint jasperPrint, Integer page, double maxDistance) throws IOException, net.sf.jasperreports.engine.JRException
      Check that the actual image and the image calculated by this object are within the given distance.
      Parameters:
      maxDistance - the maximum distance between the two images.
      Throws:
      IOException - if the image could not be written.
      net.sf.jasperreports.engine.JRException
    • assertSimilarity

      public void assertSimilarity(File actualFile, double maxDistance) throws IOException
      Check that the actual image and the image calculated by this object are within the given distance.
      Parameters:
      actualFile - the file to compare to "this" image.
      maxDistance - the maximum distance between the two images.
      Throws:
      IOException - if the image could not be written.
    • assertSimilarity

      public void assertSimilarity(BufferedImage actualImage) throws IOException
      Check that the actual image and the image calculated by this object are within a relay small distance.
      Parameters:
      actualImage - the image to compare to "this" image.
      Throws:
      IOException - if the image could not be written.
    • assertSimilarity

      public void assertSimilarity(BufferedImage actualImage, double maxDistance) throws IOException
      Check that the actual image and the image calculated by this object are within the given distance.
      Parameters:
      actualImage - the image to compare to "this" image.
      maxDistance - the maximum distance between the two images.
      Throws:
      IOException - if the image could not be written.