Mercurial > hg > digilib-old
annotate servlet/src/main/java/digilib/io/ImageInput.java @ 892:ba1eb2d821a2 mvnify
rearrange sources to maven directory standard
author | robcast |
---|---|
date | Tue, 19 Apr 2011 18:44:25 +0200 |
parents | servlet/src/digilib/io/ImageInput.java@a630d0303cce |
children |
rev | line source |
---|---|
566 | 1 /* ImageInput-- digilib image input interface. |
2 | |
3 Digital Image Library servlet components | |
4 | |
5 Copyright (C) 2010 Robert Casties (robcast@mail.berlios.de) | |
6 | |
7 This program is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
9 Free Software Foundation; either version 2 of the License, or (at your | |
10 option) any later version. | |
11 | |
12 Please read license.txt for the full details. A copy of the GPL | |
13 may be found at http://www.gnu.org/copyleft/lgpl.html | |
14 | |
15 You should have received a copy of the GNU General Public License | |
16 along with this program; if not, write to the Free Software | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 * Created on 20.12.2010 | |
20 */ | |
21 | |
22 package digilib.io; | |
23 | |
587 | 24 import java.io.File; |
588 | 25 import java.io.InputStream; |
566 | 26 |
587 | 27 import javax.imageio.stream.ImageInputStream; |
28 | |
596 | 29 import digilib.util.ImageSize; |
566 | 30 |
568 | 31 public abstract class ImageInput { |
32 | |
33 // mime file type | |
34 protected String mimetype = null; | |
35 // image size in pixels | |
36 protected ImageSize pixelSize = null; | |
588 | 37 protected ImageSet parent = null; |
568 | 38 |
566 | 39 /** |
40 * @return ImageSize | |
41 */ | |
568 | 42 public ImageSize getSize() { |
43 return pixelSize; | |
44 } | |
566 | 45 |
46 /** | |
47 * Sets the imageSize. | |
48 * @param imageSize The imageSize to set | |
49 */ | |
568 | 50 public void setSize(ImageSize imageSize) { |
51 this.pixelSize = imageSize; | |
52 } | |
53 | |
819
a23c4c15a6a8
clean up possible resource leaks. better behaviour with unknown image types.
robcast
parents:
596
diff
changeset
|
54 /** returns if mimetype has been set. |
a23c4c15a6a8
clean up possible resource leaks. better behaviour with unknown image types.
robcast
parents:
596
diff
changeset
|
55 * |
a23c4c15a6a8
clean up possible resource leaks. better behaviour with unknown image types.
robcast
parents:
596
diff
changeset
|
56 * @return String |
579
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
57 */ |
819
a23c4c15a6a8
clean up possible resource leaks. better behaviour with unknown image types.
robcast
parents:
596
diff
changeset
|
58 public boolean hasMimetype() { |
a23c4c15a6a8
clean up possible resource leaks. better behaviour with unknown image types.
robcast
parents:
596
diff
changeset
|
59 return (mimetype != null); |
a23c4c15a6a8
clean up possible resource leaks. better behaviour with unknown image types.
robcast
parents:
596
diff
changeset
|
60 } |
a23c4c15a6a8
clean up possible resource leaks. better behaviour with unknown image types.
robcast
parents:
596
diff
changeset
|
61 |
a23c4c15a6a8
clean up possible resource leaks. better behaviour with unknown image types.
robcast
parents:
596
diff
changeset
|
62 /** |
568 | 63 * @return String |
64 */ | |
65 public String getMimetype() { | |
66 return mimetype; | |
67 } | |
566 | 68 |
69 /** | |
70 * Sets the mimetype. | |
71 * @param mimetype The mimetype to set | |
72 */ | |
568 | 73 public void setMimetype(String filetype) { |
74 this.mimetype = filetype; | |
75 } | |
566 | 76 |
77 /** returns if this image has been checked | |
581 | 78 * (i.e. has size and mimetype) |
79 * TODO: deprecated | |
566 | 80 * @return boolean |
81 */ | |
568 | 82 public boolean isChecked() { |
83 return (pixelSize != null); | |
84 } | |
85 | |
566 | 86 /** Returns the aspect ratio of the image (width/height). |
87 * | |
88 * @return | |
89 */ | |
568 | 90 public float getAspect() { |
585 | 91 return (pixelSize != null) ? pixelSize.getAspect() : 0f; |
568 | 92 } |
566 | 93 |
588 | 94 /** |
95 * @return ImageSet | |
579
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
96 */ |
588 | 97 public ImageSet getParent() { |
98 return parent; | |
99 } | |
100 | |
101 /** | |
102 * Sets the parent. | |
103 * @param parent The parent to set | |
104 */ | |
105 public void setParent(ImageSet parent) { | |
106 this.parent = parent; | |
107 } | |
108 | |
109 /** Returns if the input can be returned as ImageInputStream. | |
587 | 110 * |
111 * @return | |
112 */ | |
113 public boolean hasImageInputStream() { | |
114 return false; | |
568 | 115 } |
566 | 116 |
587 | 117 /** Returns the input as ImageInputStream (if available) |
118 * | |
119 * @return | |
120 */ | |
121 public ImageInputStream getImageInputStream() { | |
122 return null; | |
123 } | |
124 | |
588 | 125 /** Returns if the input can be returned as InputStream. |
126 * | |
127 * @return | |
128 */ | |
129 public boolean hasInputStream() { | |
130 return false; | |
131 } | |
132 | |
133 /** Returns the input as InputStream (if available) | |
134 * | |
135 * @return | |
136 */ | |
137 public InputStream getInputStream() { | |
138 return null; | |
139 } | |
140 | |
587 | 141 /** Returns if the input can be returned as File. |
142 * | |
143 * @return | |
144 */ | |
145 public boolean hasFile() { | |
146 return false; | |
147 } | |
148 | |
149 /** Returns the input as File (if available) | |
150 * | |
151 * @return | |
152 */ | |
153 public File getFile() { | |
154 return null; | |
155 } | |
588 | 156 |
587 | 157 |
158 | |
566 | 159 } |