1 package org.apache.batik.transcoder.image; 18 19 import java.util.Map ; 20 import java.util.HashMap ; 21 22 import org.apache.batik.transcoder.TranscoderInput; 23 24 31 public class MaxDimensionTest extends AbstractImageTranscoderTest { 32 33 35 protected String inputURI; 36 37 protected String refImageURI; 38 39 protected Float maxWidth = new Float (Float.NaN); 40 41 protected Float maxHeight = new Float (Float.NaN); 42 43 protected Float width = new Float (Float.NaN); 44 45 protected Float height = new Float (Float.NaN); 46 47 48 57 public MaxDimensionTest(String inputURI, String refImageURI, Float maxWidth, Float maxHeight) { 58 this.inputURI = inputURI; 59 this.refImageURI = refImageURI; 60 this.maxWidth = maxWidth; 61 this.maxHeight = maxHeight; 62 } 63 64 74 public MaxDimensionTest(String inputURI, String refImageURI, Float maxWidth, Float maxHeight, Float width, Float height) { 75 this.inputURI = inputURI; 76 this.refImageURI = refImageURI; 77 this.maxWidth = maxWidth; 78 this.maxHeight = maxHeight; 79 this.width = width; 80 this.height = height; 81 } 82 83 84 88 protected TranscoderInput createTranscoderInput() { 89 return new TranscoderInput(resolveURL(inputURI).toString()); 90 } 91 92 97 protected Map createTranscodingHints() { 98 Map hints = new HashMap (7); 99 if (!width.isNaN() && width.floatValue() > 0) { 100 hints.put(ImageTranscoder.KEY_WIDTH, width); 101 } 102 if (!height.isNaN() && height.floatValue() > 0) { 103 hints.put(ImageTranscoder.KEY_HEIGHT, height); 104 } 105 if (maxWidth.floatValue() > 0) { 106 hints.put(ImageTranscoder.KEY_MAX_WIDTH, maxWidth); 107 } 108 if (maxHeight.floatValue() > 0) { 109 hints.put(ImageTranscoder.KEY_MAX_HEIGHT, maxHeight); 110 } 111 return hints; 112 } 113 114 117 protected byte [] getReferenceImageData() { 118 return createBufferedImageData(resolveURL(refImageURI)); 119 } 120 } 121 122 | Popular Tags |