Package org.mapfish.print.test.util
Class ImageSimilarity
- java.lang.Object
-
- org.mapfish.print.test.util.ImageSimilarity
-
public final class ImageSimilarity extends java.lang.Object
Class for comparing an expected image to an actual image.
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
REGENERATE_EXPECTED_IMAGES
-
Constructor Summary
Constructors Constructor Description ImageSimilarity(java.io.File expectedFile)
The constructor, which creates the GUI and start the image processing task.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods 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
assertSimilarity(java.awt.image.BufferedImage actualImage)
Check that the actual image and the image calculated by this object are within a relay small distance.void
assertSimilarity(java.awt.image.BufferedImage actualImage, double maxDistance)
Check that the actual image and the image calculated by this object are within the given distance.void
assertSimilarity(java.io.File actual)
Check that the actual image and the image calculated by this object are within the given distance.void
assertSimilarity(java.io.File actualFile, double maxDistance)
Check that the actual image and the image calculated by this object are within the given distance.void
assertSimilarity(java.net.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(java.util.List<java.net.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, java.lang.Integer page, double maxDistance)
Check that the actual image and the image calculated by this object are within the given distance.static java.awt.image.BufferedImage
convertFromSvg(java.net.URI svgFile, int width, int height)
Renders an SVG image into aBufferedImage
.static java.awt.image.BufferedImage
exportReportToImage(net.sf.jasperreports.engine.JasperPrint jasperPrint, java.lang.Integer page)
Exports a renderedJasperPrint
to aBufferedImage
.static void
main(java.lang.String[] args)
static java.awt.image.BufferedImage
mergeImages(java.util.List<java.net.URI> graphicFiles, int width, int height)
Merges a list of graphic files into a single graphic.
-
-
-
Field Detail
-
REGENERATE_EXPECTED_IMAGES
public static final boolean REGENERATE_EXPECTED_IMAGES
- See Also:
- Constant Field Values
-
-
Method Detail
-
mergeImages
public static java.awt.image.BufferedImage mergeImages(java.util.List<java.net.URI> graphicFiles, int width, int height) throws java.io.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:
java.io.IOException
org.apache.batik.transcoder.TranscoderException
-
convertFromSvg
public static java.awt.image.BufferedImage convertFromSvg(java.net.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 java.awt.image.BufferedImage exportReportToImage(net.sf.jasperreports.engine.JasperPrint jasperPrint, java.lang.Integer page) throws net.sf.jasperreports.engine.JRException
Exports a renderedJasperPrint
to aBufferedImage
.- Throws:
net.sf.jasperreports.engine.JRException
-
main
public static void main(java.lang.String[] args) throws java.io.IOException
- Throws:
java.io.IOException
-
assertSimilarity
public void assertSimilarity(java.io.File actual) throws java.io.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:
java.io.IOException
- if the image could not be written.
-
assertSimilarity
public void assertSimilarity(byte[] graphicData, double maxDistance) throws java.io.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:
java.io.IOException
- if the image could not be written.
-
assertSimilarity
public void assertSimilarity(java.util.List<java.net.URI> graphicFiles, int width, int height, double maxDistance) throws java.io.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:
java.io.IOException
- if the image could not be written.org.apache.batik.transcoder.TranscoderException
-
assertSimilarity
public void assertSimilarity(java.net.URI svgFile, int width, int height, double maxDistance) throws java.io.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:
java.io.IOException
- if the image could not be written.org.apache.batik.transcoder.TranscoderException
-
assertSimilarity
public void assertSimilarity(net.sf.jasperreports.engine.JasperPrint jasperPrint, java.lang.Integer page, double maxDistance) throws java.io.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:
java.io.IOException
- if the image could not be written.net.sf.jasperreports.engine.JRException
-
assertSimilarity
public void assertSimilarity(java.io.File actualFile, double maxDistance) throws java.io.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:
java.io.IOException
- if the image could not be written.
-
assertSimilarity
public void assertSimilarity(java.awt.image.BufferedImage actualImage) throws java.io.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:
java.io.IOException
- if the image could not be written.
-
assertSimilarity
public void assertSimilarity(java.awt.image.BufferedImage actualImage, double maxDistance) throws java.io.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:
java.io.IOException
- if the image could not be written.
-
-