Package org.mapfish.print.test.util
Class ImageSimilarity
java.lang.Object
org.mapfish.print.test.util.ImageSimilarity
Class for comparing an expected image to an actual image.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionImageSimilarity
(File expectedFile) The constructor, which creates the GUI and start the image processing task. -
Method Summary
Modifier and TypeMethodDescriptionvoid
assertSimilarity
(byte[] graphicData, double maxDistance) Check that the actual image and the image calculated by this object are within the given distance.void
assertSimilarity
(BufferedImage actualImage) 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
assertSimilarity
(File actual) 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.static BufferedImage
convertFromSvg
(URI svgFile, int width, int height) Renders an SVG image into aBufferedImage
.static BufferedImage
exportReportToImage
(net.sf.jasperreports.engine.JasperPrint jasperPrint, Integer page) Exports a renderedJasperPrint
to aBufferedImage
.static void
static BufferedImage
mergeImages
(List<URI> graphicFiles, int width, int height) Merges a list of graphic files into a single graphic.
-
Field Details
-
REGENERATE_EXPECTED_IMAGES
public static final boolean REGENERATE_EXPECTED_IMAGES- See Also:
-
-
Constructor Details
-
ImageSimilarity
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 fileswidth
- 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 aBufferedImage
.- 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 renderedJasperPrint
to aBufferedImage
.- Throws:
net.sf.jasperreports.engine.JRException
-
main
- Throws:
IOException
-
assertSimilarity
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
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 fileswidth
- 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
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
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
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.
-