1 18 package org.apache.batik.transcoder.image; 19 20 import java.awt.geom.Rectangle2D ; 21 22 import java.util.Map ; 23 import java.util.HashMap ; 24 25 import org.apache.batik.transcoder.TranscoderInput; 26 27 33 public class AOITest extends AbstractImageTranscoderTest { 34 35 36 protected String inputURI; 37 38 39 protected String refImageURI; 40 41 42 protected Rectangle2D aoi; 43 44 45 protected Float imgWidth; 46 47 48 protected Float imgHeight; 49 50 60 public AOITest(String inputURI, 61 String refImageURI, 62 Float x, 63 Float y, 64 Float width, 65 Float height) { 66 this(inputURI, 67 refImageURI, 68 x, 69 y, 70 width, 71 height, 72 new Float (-1), 73 new Float (-1)); 74 } 75 76 88 public AOITest(String inputURI, 89 String refImageURI, 90 Float x, 91 Float y, 92 Float width, 93 Float height, 94 Float imgWidth, 95 Float imgHeight) { 96 this.inputURI = inputURI; 97 this.refImageURI = refImageURI; 98 this.aoi = new Rectangle2D.Float (x.floatValue(), 99 y.floatValue(), 100 width.floatValue(), 101 height.floatValue()); 102 this.imgWidth = imgWidth; 103 this.imgHeight = imgHeight; 104 } 105 106 109 protected TranscoderInput createTranscoderInput() { 110 return new TranscoderInput(resolveURL(inputURI).toString()); 111 } 112 113 116 protected Map createTranscodingHints() { 117 Map hints = new HashMap (11); 118 hints.put(ImageTranscoder.KEY_AOI, aoi); 119 if (imgWidth.floatValue() > 0) { 120 hints.put(ImageTranscoder.KEY_WIDTH, imgWidth); 121 } 122 if (imgHeight.floatValue() > 0) { 123 hints.put(ImageTranscoder.KEY_HEIGHT, imgHeight); 124 } 125 return hints; 126 } 127 128 131 protected byte [] getReferenceImageData() { 132 return createBufferedImageData(resolveURL(refImageURI)); 133 } 134 } 135 | Popular Tags |