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;
|
587
|
26
|
|
27 import javax.imageio.stream.ImageInputStream;
|
|
28
|
566
|
29 import digilib.image.ImageSize;
|
|
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
|
|
54 /**
|
|
55 * @return String
|
|
56 */
|
|
57 public String getMimetype() {
|
|
58 return mimetype;
|
|
59 }
|
566
|
60
|
|
61 /**
|
|
62 * Sets the mimetype.
|
|
63 * @param mimetype The mimetype to set
|
|
64 */
|
568
|
65 public void setMimetype(String filetype) {
|
|
66 this.mimetype = filetype;
|
|
67 }
|
566
|
68
|
|
69 /** returns if this image has been checked
|
581
|
70 * (i.e. has size and mimetype)
|
|
71 * TODO: deprecated
|
566
|
72 * @return boolean
|
|
73 */
|
568
|
74 public boolean isChecked() {
|
|
75 return (pixelSize != null);
|
|
76 }
|
|
77
|
566
|
78 /** Returns the aspect ratio of the image (width/height).
|
|
79 *
|
|
80 * @return
|
|
81 */
|
568
|
82 public float getAspect() {
|
585
|
83 return (pixelSize != null) ? pixelSize.getAspect() : 0f;
|
568
|
84 }
|
566
|
85
|
588
|
86 /**
|
|
87 * @return ImageSet
|
|
88 */
|
|
89 public ImageSet getParent() {
|
|
90 return parent;
|
|
91 }
|
|
92
|
|
93 /**
|
|
94 * Sets the parent.
|
|
95 * @param parent The parent to set
|
|
96 */
|
|
97 public void setParent(ImageSet parent) {
|
|
98 this.parent = parent;
|
|
99 }
|
|
100
|
|
101 /** Returns if the input can be returned as ImageInputStream.
|
587
|
102 *
|
|
103 * @return
|
|
104 */
|
|
105 public boolean hasImageInputStream() {
|
|
106 return false;
|
|
107 }
|
|
108
|
|
109 /** Returns the input as ImageInputStream (if available)
|
|
110 *
|
|
111 * @return
|
|
112 */
|
|
113 public ImageInputStream getImageInputStream() {
|
|
114 return null;
|
|
115 }
|
|
116
|
588
|
117 /** Returns if the input can be returned as InputStream.
|
|
118 *
|
|
119 * @return
|
|
120 */
|
|
121 public boolean hasInputStream() {
|
|
122 return false;
|
|
123 }
|
|
124
|
|
125 /** Returns the input as InputStream (if available)
|
|
126 *
|
|
127 * @return
|
|
128 */
|
|
129 public InputStream getInputStream() {
|
|
130 return null;
|
|
131 }
|
|
132
|
587
|
133 /** Returns if the input can be returned as File.
|
|
134 *
|
|
135 * @return
|
|
136 */
|
|
137 public boolean hasFile() {
|
|
138 return false;
|
|
139 }
|
|
140
|
|
141 /** Returns the input as File (if available)
|
|
142 *
|
|
143 * @return
|
|
144 */
|
|
145 public File getFile() {
|
|
146 return null;
|
|
147 }
|
588
|
148
|
587
|
149
|
|
150
|
566
|
151 } |