KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > transcoder > image > DimensionTest


1 /*
2
3    Copyright 2001-2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.transcoder.image;
19
20 import java.util.HashMap JavaDoc;
21 import java.util.Map JavaDoc;
22
23 import org.apache.batik.transcoder.TranscoderInput;
24
25 /**
26  * Test the ImageTranscoder with the KEY_WIDTH and/or the KEY_HEIGHT transcoding
27  * hint.
28  *
29  * @author <a HREF="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
30  * @version $Id: DimensionTest.java,v 1.5 2004/08/18 07:17:12 vhardy Exp $
31  */

32 public class DimensionTest extends AbstractImageTranscoderTest {
33
34     /** The URI of the input image. */
35     protected String JavaDoc inputURI;
36
37     /** The URI of the reference image. */
38     protected String JavaDoc refImageURI;
39
40     /** The width of the image. */
41     protected Float JavaDoc width;
42
43     /** The height of the image. */
44     protected Float JavaDoc height;
45
46     /**
47      * Constructs a new <tt>DimensionTest</tt>.
48      *
49      * @param inputURI the URI of the input image
50      * @param the URI of the reference image
51      * @param width the image width
52      * @param height the image height
53      */

54     public DimensionTest(String JavaDoc inputURI,
55              String JavaDoc refImageURI,
56              Float JavaDoc width,
57              Float JavaDoc height) {
58     this.inputURI = inputURI;
59     this.refImageURI = refImageURI;
60     this.width = width;
61     this.height = height;
62     }
63
64     /**
65      * Creates the <tt>TranscoderInput</tt>.
66      */

67     protected TranscoderInput createTranscoderInput() {
68     return new TranscoderInput(resolveURL(inputURI).toString());
69     }
70     
71     /**
72      * Creates a Map that contains additional transcoding hints.
73      */

74     protected Map JavaDoc createTranscodingHints() {
75     Map JavaDoc hints = new HashMap JavaDoc(7);
76     if (width.floatValue() > 0) {
77         hints.put(ImageTranscoder.KEY_WIDTH, width);
78     }
79     if (height.floatValue() > 0) {
80         hints.put(ImageTranscoder.KEY_HEIGHT, height);
81     }
82     return hints;
83     }
84
85     /**
86      * Returns the reference image for this test.
87      */

88     protected byte [] getReferenceImageData() {
89     return createBufferedImageData(resolveURL(refImageURI));
90     }
91 }
92
Popular Tags