Mercurial > hg > digilib-old
annotate servlet/src/digilib/io/ImageSet.java @ 603:3292343f64d6 stream
very small fix
| author | robcast |
|---|---|
| date | Tue, 11 Jan 2011 21:08:12 +0100 |
| parents | 2b58d2783ef0 |
| children | a23c4c15a6a8 |
| rev | line source |
|---|---|
| 574 | 1 /* ImageSet -- digilib image file info class. |
| 176 | 2 * Digital Image Library servlet components |
| 3 * Copyright (C) 2003 Robert Casties (robcast@mail.berlios.de) | |
| 4 * | |
| 5 * This program is free software; you can | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
6 * redistribute it and/or modify it under the terms of the GNU General Public |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
7 * License as published by the Free Software Foundation; either version 2 of |
| 176 | 8 * the License, or (at your option) any later version. |
| 9 * | |
| 10 * Please read license.txt for the full details. A copy of the GPL may be | |
| 11 * found at http://www.gnu.org/copyleft/lgpl.html | |
| 12 * | |
| 13 * You should have received a copy of the GNU General Public License along | |
| 14 * with this program; if not, write to the Free Software Foundation, Inc., | |
| 15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 159 | 16 */ |
| 176 | 17 |
| 159 | 18 package digilib.io; |
| 19 | |
| 20 import java.util.ArrayList; | |
| 531 | 21 import java.util.List; |
| 159 | 22 import java.util.ListIterator; |
| 23 | |
| 596 | 24 import digilib.util.ImageSize; |
| 159 | 25 |
| 26 /** | |
| 27 * @author casties | |
| 28 */ | |
| 574 | 29 public class ImageSet { |
| 159 | 30 |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
31 /** list of files (ImageFile) */ |
|
576
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
32 protected List<ImageInput> list = null; |
| 233 | 33 |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
34 /** aspect ratio (width/height) */ |
|
576
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
35 protected float aspect = 0f; |
| 574 | 36 |
| 37 /** resolution of the biggest image (DPI) */ | |
|
576
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
38 protected float resX = 0f; |
| 233 | 39 |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
40 /** resolution of the biggest image (DPI) */ |
|
576
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
41 protected float resY = 0f; |
| 159 | 42 |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
43 /** |
| 259 | 44 * Creator for empty fileset. |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
45 * |
| 159 | 46 * |
| 47 * @param initialCapacity | |
| 48 */ | |
| 574 | 49 public ImageSet() { |
| 50 list = new ArrayList<ImageInput>(); | |
| 159 | 51 } |
| 52 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
53 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
54 * The number of image files in this Fileset. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
55 * |
| 159 | 56 * |
| 57 * @return number of image files | |
| 58 */ | |
| 59 public int size() { | |
| 60 return (list != null) ? list.size() : 0; | |
| 61 } | |
| 62 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
63 /** |
|
576
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
64 * Gets the default Input. |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
65 * |
| 159 | 66 */ |
|
576
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
67 public ImageInput get() { |
|
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
68 return (list != null) ? list.get(0) : null; |
| 159 | 69 } |
| 70 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
71 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
72 * Get the ImageFile at the index. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
73 * |
| 159 | 74 * |
| 75 * @param index | |
| 76 * @return | |
| 77 */ | |
| 574 | 78 public ImageInput get(int index) { |
| 531 | 79 return list.get(index); |
| 159 | 80 } |
| 81 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
82 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
83 * Get the next smaller ImageFile than the given size. |
| 159 | 84 * |
| 233 | 85 * Returns the ImageFile from the set that has a width and height smaller or |
| 86 * equal the given size. Returns null if there isn't any smaller image. | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
87 * |
| 159 | 88 * @param size |
| 89 * @param info | |
| 90 * @return | |
| 91 */ | |
| 574 | 92 public ImageInput getNextSmaller(ImageSize size) { |
| 93 for (ListIterator<ImageInput> i = getHiresIterator(); i.hasNext();) { | |
| 94 ImageInput f = i.next(); | |
| 581 | 95 if (f.getSize().isTotallySmallerThan(size)) { |
| 96 return f; | |
| 159 | 97 } |
| 98 } | |
| 99 return null; | |
| 100 } | |
| 101 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
102 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
103 * Get the next bigger ImageFile than the given size. |
| 159 | 104 * |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
105 * Returns the ImageFile from the set that has a width or height bigger or |
| 581 | 106 * equal the given size. Returns null if there isn't any bigger image. |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
107 * |
| 159 | 108 * @param size |
| 109 * @param info | |
| 110 * @return | |
| 111 */ | |
| 574 | 112 public ImageInput getNextBigger(ImageSize size) { |
| 113 for (ListIterator<ImageInput> i = getLoresIterator(); i.hasPrevious();) { | |
| 114 ImageInput f = i.previous(); | |
| 581 | 115 if (f.getSize().isBiggerThan(size)) { |
| 116 return f; | |
| 159 | 117 } |
| 118 } | |
| 119 return null; | |
| 120 } | |
| 121 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
122 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
123 * Returns the biggest ImageFile in the set. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
124 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
125 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
126 * @return |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
127 */ |
| 574 | 128 public ImageInput getBiggest() { |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
129 return this.get(0); |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
130 } |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
131 |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
132 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
133 * Returns the biggest ImageFile in the set. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
134 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
135 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
136 * @return |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
137 */ |
| 574 | 138 public ImageInput getSmallest() { |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
139 return this.get(this.size() - 1); |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
140 } |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
141 |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
142 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
143 * Get an Iterator for this Fileset starting at the highest resolution |
| 159 | 144 * images. |
| 145 * | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
146 * |
| 159 | 147 * @return |
| 148 */ | |
| 574 | 149 public ListIterator<ImageInput> getHiresIterator() { |
| 159 | 150 return list.listIterator(); |
| 151 } | |
| 152 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
153 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
154 * Get an Iterator for this Fileset starting at the lowest resolution |
| 159 | 155 * images. |
| 156 * | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
157 * The Iterator starts at the last element, so you have to use it backwards |
| 159 | 158 * with hasPrevious() and previous(). |
| 159 * | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
160 * |
| 159 | 161 * @return |
| 162 */ | |
| 574 | 163 public ListIterator<ImageInput> getLoresIterator() { |
| 159 | 164 return list.listIterator(list.size()); |
| 165 } | |
| 166 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
167 /** |
| 159 | 168 * @return |
| 169 */ | |
|
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
170 public float getResX() { |
| 159 | 171 return resX; |
| 172 } | |
| 173 | |
| 174 /** | |
| 175 * @return | |
| 176 */ | |
|
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
177 public float getResY() { |
| 159 | 178 return resY; |
| 179 } | |
| 180 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
181 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
182 * Sets the aspect ratio from an ImageSize. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
183 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
184 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
185 * @param f |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
186 */ |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
187 public void setAspect(ImageSize s) { |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
188 aspect = s.getAspect(); |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
189 } |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
190 |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
191 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
192 * Returns the aspect ratio. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
193 * |
| 233 | 194 * Aspect ratio is (width/height). So it's <1 for portrait and >1 for |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
195 * landscape. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
196 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
197 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
198 * @return |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
199 */ |
|
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
200 public float getAspect() { |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
201 return aspect; |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
202 } |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
203 |
|
576
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
204 public void checkMeta() { |
|
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
205 // TODO Auto-generated method stub |
|
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
206 |
|
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
207 } |
|
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
208 |
| 233 | 209 } |
