Mercurial > hg > digilib-old
annotate servlet/src/digilib/io/ImageFileset.java @ 477:7f11ff312063
servlet version 1.6.0
- parsing of URL parameters accepts & and ; in addition to &
- more to come ;-)
author | robcast |
---|---|
date | Mon, 20 Nov 2006 18:59:30 +0100 |
parents | 1fc30116efc3 |
children | e758a49258e8 |
rev | line source |
---|---|
176 | 1 /* ImageFileset -- digilib image file info class. |
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.io.File; | |
21 import java.io.IOException; | |
22 import java.util.ArrayList; | |
259 | 23 import java.util.Arrays; |
159 | 24 import java.util.Iterator; |
25 import java.util.ListIterator; | |
259 | 26 import java.util.Map; |
159 | 27 |
284 | 28 import digilib.image.ImageOps; |
159 | 29 import digilib.image.ImageSize; |
30 | |
31 /** | |
32 * @author casties | |
33 */ | |
34 public class ImageFileset extends DocuDirent { | |
35 | |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
36 /** this is an image file */ |
159 | 37 protected static int fileClass = FileOps.CLASS_IMAGE; |
284 | 38 |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
39 /** list of files (ImageFile) */ |
159 | 40 private ArrayList list = null; |
233 | 41 |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
42 /** aspect ratio (width/height) */ |
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
43 private float aspect = 0; |
233 | 44 |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
45 /** resolution of the biggest image (DPI) */ |
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
46 private float resX = 0; |
233 | 47 |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
48 /** resolution of the biggest image (DPI) */ |
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
49 private float resY = 0; |
159 | 50 |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
51 /** |
259 | 52 * Creator for empty fileset. |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
53 * |
159 | 54 * |
55 * @param initialCapacity | |
56 */ | |
259 | 57 public ImageFileset() { |
58 list = new ArrayList(); | |
159 | 59 } |
60 | |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
61 /** |
259 | 62 * Constructor with a file and hints. |
159 | 63 * |
259 | 64 * The hints are expected to contain 'basedirs' and 'scaledfilext' keys. |
233 | 65 * |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
66 * @param file |
259 | 67 * @param hints |
159 | 68 */ |
259 | 69 public ImageFileset(File file, Map hints) { |
70 Directory[] dirs = (Directory[]) hints.get(FileOps.HINT_BASEDIRS); | |
159 | 71 int nb = dirs.length; |
72 list = new ArrayList(nb); | |
73 parent = dirs[0]; | |
284 | 74 fill(dirs, file, hints); |
159 | 75 } |
284 | 76 |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
77 /** |
176 | 78 * Adds an ImageFile to this Fileset. |
159 | 79 * |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
80 * The files should be added in the order of higher to lower resolutions. |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
81 * The first file is considered the hires "original". |
159 | 82 * |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
83 * |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
84 * @param f |
233 | 85 * file to add |
159 | 86 * @return true (always) |
87 */ | |
88 public boolean add(ImageFile f) { | |
89 f.setParent(this); | |
90 return list.add(f); | |
91 } | |
92 | |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
93 /** |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
94 * The number of image files in this Fileset. |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
95 * |
159 | 96 * |
97 * @return number of image files | |
98 */ | |
99 public int size() { | |
100 return (list != null) ? list.size() : 0; | |
101 } | |
102 | |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
103 /** |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
104 * Gets the default File. |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
105 * |
159 | 106 */ |
107 public File getFile() { | |
108 return (list != null) ? ((ImageFile) list.get(0)).getFile() : null; | |
109 } | |
110 | |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
111 /** |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
112 * Get the ImageFile at the index. |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
113 * |
159 | 114 * |
115 * @param index | |
116 * @return | |
117 */ | |
118 public ImageFile get(int index) { | |
119 return (ImageFile) list.get(index); | |
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 * Get the next smaller ImageFile than the given size. |
159 | 124 * |
233 | 125 * Returns the ImageFile from the set that has a width and height smaller or |
126 * equal the given size. Returns null if there isn't any smaller image. | |
159 | 127 * Needs DocuInfo instance to checkFile(). |
128 * | |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
129 * |
159 | 130 * @param size |
131 * @param info | |
132 * @return | |
133 */ | |
284 | 134 public ImageFile getNextSmaller(ImageSize size) { |
159 | 135 for (Iterator i = getHiresIterator(); i.hasNext();) { |
136 ImageFile f = (ImageFile) i.next(); | |
137 try { | |
138 if (!f.isChecked()) { | |
284 | 139 ImageOps.checkFile(f); |
159 | 140 } |
141 if (f.getSize().isTotallySmallerThan(size)) { | |
142 return f; | |
143 } | |
144 } catch (IOException e) { | |
145 } | |
146 } | |
147 return null; | |
148 } | |
149 | |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
150 /** |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
151 * Get the next bigger ImageFile than the given size. |
159 | 152 * |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
153 * Returns the ImageFile from the set that has a width or height bigger or |
233 | 154 * equal the given size. Returns null if there isn't any bigger image. Needs |
155 * DocuInfo instance to checkFile(). | |
159 | 156 * |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
157 * |
159 | 158 * @param size |
159 * @param info | |
160 * @return | |
161 */ | |
284 | 162 public ImageFile getNextBigger(ImageSize size) { |
159 | 163 for (ListIterator i = getLoresIterator(); i.hasPrevious();) { |
164 ImageFile f = (ImageFile) i.previous(); | |
165 try { | |
166 if (!f.isChecked()) { | |
284 | 167 ImageOps.checkFile(f); |
159 | 168 } |
169 if (f.getSize().isBiggerThan(size)) { | |
170 return f; | |
171 } | |
172 } catch (IOException e) { | |
173 } | |
174 } | |
175 return null; | |
176 } | |
177 | |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
178 /** |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
179 * Returns the biggest ImageFile in the set. |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
180 * |
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 * @return |
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 public ImageFile getBiggest() { |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
185 return this.get(0); |
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 |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
188 /** |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
189 * Returns the biggest ImageFile in the set. |
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 * @return |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
193 */ |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
194 public ImageFile getSmallest() { |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
195 return this.get(this.size() - 1); |
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 /** |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
199 * Get an Iterator for this Fileset starting at the highest resolution |
159 | 200 * images. |
201 * | |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
202 * |
159 | 203 * @return |
204 */ | |
205 public ListIterator getHiresIterator() { | |
206 return list.listIterator(); | |
207 } | |
208 | |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
209 /** |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
210 * Get an Iterator for this Fileset starting at the lowest resolution |
159 | 211 * images. |
212 * | |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
213 * The Iterator starts at the last element, so you have to use it backwards |
159 | 214 * with hasPrevious() and previous(). |
215 * | |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
216 * |
159 | 217 * @return |
218 */ | |
219 public ListIterator getLoresIterator() { | |
220 return list.listIterator(list.size()); | |
221 } | |
222 | |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
223 /** |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
224 * Fill the ImageFileset with files from different base directories. |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
225 * |
159 | 226 * |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
227 * @param dirs |
233 | 228 * list of base directories |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
229 * @param fl |
233 | 230 * file (from first base dir) |
259 | 231 * @param hints |
284 | 232 * |
159 | 233 */ |
259 | 234 void fill(Directory[] dirs, File fl, Map hints) { |
159 | 235 int nb = dirs.length; |
236 String fn = fl.getName(); | |
259 | 237 String baseFn = FileOps.basename(fn); |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
238 // add the first ImageFile to the ImageFileset |
159 | 239 add(new ImageFile(fn, this, parent)); |
240 // iterate the remaining base directories | |
284 | 241 for (int dirIdx = 1; dirIdx < nb; dirIdx++) { |
242 if (dirs[dirIdx] == null) { | |
159 | 243 continue; |
244 } | |
284 | 245 // read the directory |
246 if (dirs[dirIdx].getFilenames() == null) { | |
247 dirs[dirIdx].readDir(); | |
259 | 248 } |
284 | 249 String[] dirFiles = dirs[dirIdx].getFilenames(); |
250 // try the same filename as the original | |
251 int fileIdx = Arrays.binarySearch(dirFiles, fn); | |
252 if (fileIdx < 0) { | |
253 // try closest matches without extension | |
254 fileIdx = -fileIdx - 1; | |
255 // try idx | |
256 if ((fileIdx < dirFiles.length) | |
257 && (FileOps.basename(dirFiles[fileIdx]).equals(baseFn))) { | |
258 // idx ok | |
259 } else if ((fileIdx > 0) | |
260 && (FileOps.basename(dirFiles[fileIdx - 1]) | |
261 .equals(baseFn))) { | |
262 // idx-1 ok | |
263 fileIdx = fileIdx - 1; | |
264 } else if ((fileIdx+1 < dirFiles.length) | |
265 && (FileOps.basename(dirFiles[fileIdx + 1]) | |
266 .equals(baseFn))) { | |
267 // idx+1 ok | |
268 fileIdx = fileIdx + 1; | |
269 } else { | |
270 // basename doesn't match | |
271 continue; | |
259 | 272 } |
159 | 273 } |
284 | 274 if (FileOps.classForFilename(dirFiles[fileIdx]) == FileOps.CLASS_IMAGE) { |
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
275 /* logger.debug("adding file " + dirFiles[fileIdx] |
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
276 + " to Fileset " + this.getName()); */ |
284 | 277 add(new ImageFile(dirFiles[fileIdx], this, dirs[dirIdx])); |
259 | 278 } |
159 | 279 } |
280 } | |
281 | |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
282 /** |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
283 * Checks metadata and sets resolution in resX and resY. |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
284 * |
159 | 285 */ |
286 public void checkMeta() { | |
287 if (metaChecked) { | |
288 return; | |
289 } | |
290 if (fileMeta == null) { | |
291 // try to read metadata file | |
292 readMeta(); | |
293 if (fileMeta == null) { | |
294 // try directory metadata | |
233 | 295 ((DocuDirectory) parent).checkMeta(); |
159 | 296 if (((DocuDirectory) parent).getDirMeta() != null) { |
297 fileMeta = ((DocuDirectory) parent).getDirMeta(); | |
298 } else { | |
233 | 299 // try parent directory metadata |
300 DocuDirectory gp = (DocuDirectory) parent.getParent(); | |
301 if (gp != null) { | |
302 gp.checkMeta(); | |
303 if (gp.getDirMeta() != null) { | |
304 fileMeta = gp.getDirMeta(); | |
305 } | |
306 } | |
159 | 307 } |
308 } | |
309 } | |
354 | 310 if (fileMeta == null) { |
311 // no metadata available | |
312 metaChecked = true; | |
313 return; | |
314 } | |
159 | 315 metaChecked = true; |
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
316 float dpi = 0; |
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
317 float dpix = 0; |
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
318 float dpiy = 0; |
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
319 float sizex = 0; |
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
320 float sizey = 0; |
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
321 float pixx = 0; |
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
322 float pixy = 0; |
159 | 323 // DPI is valid for X and Y |
324 if (fileMeta.containsKey("original-dpi")) { | |
325 try { | |
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
326 dpi = Float.parseFloat((String) fileMeta.get("original-dpi")); |
159 | 327 } catch (NumberFormatException e) { |
328 } | |
329 if (dpi != 0) { | |
330 resX = dpi; | |
331 resY = dpi; | |
332 return; | |
333 } | |
334 } | |
335 // DPI-X and DPI-Y | |
336 if (fileMeta.containsKey("original-dpi-x") | |
233 | 337 && fileMeta.containsKey("original-dpi-y")) { |
159 | 338 try { |
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
339 dpix = Float.parseFloat((String) fileMeta |
233 | 340 .get("original-dpi-x")); |
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
341 dpiy = Float.parseFloat((String) fileMeta |
233 | 342 .get("original-dpi-y")); |
159 | 343 } catch (NumberFormatException e) { |
344 } | |
345 if ((dpix != 0) && (dpiy != 0)) { | |
346 resX = dpix; | |
347 resY = dpiy; | |
348 return; | |
349 } | |
350 } | |
351 // SIZE-X and SIZE-Y and PIXEL-X and PIXEL-Y | |
352 if (fileMeta.containsKey("original-size-x") | |
233 | 353 && fileMeta.containsKey("original-size-y") |
354 && fileMeta.containsKey("original-pixel-x") | |
355 && fileMeta.containsKey("original-pixel-y")) { | |
159 | 356 try { |
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
357 sizex = Float.parseFloat((String) fileMeta |
233 | 358 .get("original-size-x")); |
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
359 sizey = Float.parseFloat((String) fileMeta |
233 | 360 .get("original-size-y")); |
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
361 pixx = Float.parseFloat((String) fileMeta |
233 | 362 .get("original-pixel-x")); |
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
363 pixy = Float.parseFloat((String) fileMeta |
233 | 364 .get("original-pixel-y")); |
159 | 365 } catch (NumberFormatException e) { |
366 } | |
367 if ((sizex != 0) && (sizey != 0) && (pixx != 0) && (pixy != 0)) { | |
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
368 resX = pixx / (sizex * 100 / 2.54f); |
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
369 resY = pixy / (sizey * 100 / 2.54f); |
159 | 370 return; |
371 } | |
372 } | |
373 } | |
374 | |
375 /** | |
376 * @return | |
377 */ | |
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
378 public float getResX() { |
159 | 379 return resX; |
380 } | |
381 | |
382 /** | |
383 * @return | |
384 */ | |
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
385 public float getResY() { |
159 | 386 return resY; |
387 } | |
388 | |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
389 /** |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
390 * Sets the aspect ratio from an ImageSize. |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
391 * |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
392 * |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
393 * @param f |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
394 */ |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
395 public void setAspect(ImageSize s) { |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
396 aspect = s.getAspect(); |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
397 } |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
398 |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
399 /** |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
400 * Returns the aspect ratio. |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
401 * |
233 | 402 * 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
|
403 * landscape. |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
404 * |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
405 * |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
406 * @return |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
407 */ |
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
408 public float getAspect() { |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
409 return aspect; |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
410 } |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
411 |
233 | 412 } |