Mercurial > hg > digilib-old
annotate servlet/src/digilib/io/ImageFileset.java @ 196:8125a068af80
Servlet version 1.18b5
- fix for config file names on non-unix systems
| author | robcast |
|---|---|
| date | Mon, 08 Dec 2003 16:50:59 +0100 |
| parents | afe7ff98bb71 |
| children | e40d8b2e3978 |
| 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; | |
| 23 import java.util.Iterator; | |
| 24 import java.util.ListIterator; | |
| 25 | |
| 26 import digilib.image.DocuInfo; | |
| 27 import digilib.image.ImageSize; | |
| 28 | |
| 29 /** | |
| 30 * @author casties | |
| 31 */ | |
| 32 public class ImageFileset extends DocuDirent { | |
| 33 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
34 /** this is an image file */ |
| 159 | 35 protected static int fileClass = FileOps.CLASS_IMAGE; |
| 36 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
37 /** list of files (ImageFile) */ |
| 159 | 38 private ArrayList list = null; |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
39 /** aspect ratio (width/height) */ |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
40 private double aspect = 0; |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
41 /** resolution of the biggest image (DPI) */ |
| 159 | 42 private double resX = 0; |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
43 /** resolution of the biggest image (DPI) */ |
| 159 | 44 private double resY = 0; |
| 45 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
46 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
47 * Creator for empty fileset with size for file list. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
48 * |
| 159 | 49 * |
| 50 * @param initialCapacity | |
| 51 */ | |
| 52 public ImageFileset(int initialCapacity) { | |
| 53 list = new ArrayList(initialCapacity); | |
| 54 } | |
| 55 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
56 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
57 * Creator with a file and base directories. |
| 159 | 58 * |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
59 * Reads the file and fills the fileset with corresponding files from the |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
60 * other base directories. First entry in dirs is the parent of this |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
61 * fileset. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
62 * |
| 159 | 63 * |
| 64 * @see fill | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
65 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
66 * @param dirs |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
67 * array of base directories |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
68 * @param file |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
69 * first file to read |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
70 * @param scalext |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
71 * extension for scaled images |
| 159 | 72 */ |
| 73 public ImageFileset(Directory[] dirs, File file, String scalext) { | |
| 74 int nb = dirs.length; | |
| 75 list = new ArrayList(nb); | |
| 76 parent = dirs[0]; | |
| 77 fill(dirs, file, scalext); | |
| 78 } | |
| 79 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
80 /** |
| 176 | 81 * Adds an ImageFile to this Fileset. |
| 159 | 82 * |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
83 * 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
|
84 * The first file is considered the hires "original". |
| 159 | 85 * |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
86 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
87 * @param f |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
88 * file to add |
| 159 | 89 * @return true (always) |
| 90 */ | |
| 91 public boolean add(ImageFile f) { | |
| 92 f.setParent(this); | |
| 93 return list.add(f); | |
| 94 } | |
| 95 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
96 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
97 * The number of image files in this Fileset. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
98 * |
| 159 | 99 * |
| 100 * @return number of image files | |
| 101 */ | |
| 102 public int size() { | |
| 103 return (list != null) ? list.size() : 0; | |
| 104 } | |
| 105 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
106 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
107 * Gets the default File. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
108 * |
| 159 | 109 */ |
| 110 public File getFile() { | |
| 111 return (list != null) ? ((ImageFile) list.get(0)).getFile() : null; | |
| 112 } | |
| 113 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
114 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
115 * Get the ImageFile at the index. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
116 * |
| 159 | 117 * |
| 118 * @param index | |
| 119 * @return | |
| 120 */ | |
| 121 public ImageFile get(int index) { | |
| 122 return (ImageFile) list.get(index); | |
| 123 } | |
| 124 | |
|
170
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 * Get the next smaller ImageFile than the given size. |
| 159 | 127 * |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
128 * Returns the ImageFile from the set that has a width and height smaller |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
129 * or equal the given size. Returns null if there isn't any smaller image. |
| 159 | 130 * Needs DocuInfo instance to checkFile(). |
| 131 * | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
132 * |
| 159 | 133 * @param size |
| 134 * @param info | |
| 135 * @return | |
| 136 */ | |
| 137 public ImageFile getNextSmaller(ImageSize size, DocuInfo info) { | |
| 138 for (Iterator i = getHiresIterator(); i.hasNext();) { | |
| 139 ImageFile f = (ImageFile) i.next(); | |
| 140 try { | |
| 141 if (!f.isChecked()) { | |
| 142 info.checkFile(f); | |
| 143 } | |
| 144 if (f.getSize().isTotallySmallerThan(size)) { | |
| 145 return f; | |
| 146 } | |
| 147 } catch (IOException e) { | |
| 148 } | |
| 149 } | |
| 150 return null; | |
| 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 the next bigger ImageFile than the given size. |
| 159 | 155 * |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
156 * Returns the ImageFile from the set that has a width or height bigger or |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
157 * equal the given size. Returns null if there isn't any bigger image. |
| 159 | 158 * Needs DocuInfo instance to checkFile(). |
| 159 * | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
160 * |
| 159 | 161 * @param size |
| 162 * @param info | |
| 163 * @return | |
| 164 */ | |
| 165 public ImageFile getNextBigger(ImageSize size, DocuInfo info) { | |
| 166 for (ListIterator i = getLoresIterator(); i.hasPrevious();) { | |
| 167 ImageFile f = (ImageFile) i.previous(); | |
| 168 try { | |
| 169 if (!f.isChecked()) { | |
| 170 info.checkFile(f); | |
| 171 } | |
| 172 if (f.getSize().isBiggerThan(size)) { | |
| 173 return f; | |
| 174 } | |
| 175 } catch (IOException e) { | |
| 176 } | |
| 177 } | |
| 178 return null; | |
| 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 * Returns the biggest ImageFile in the set. |
|
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 * @return |
|
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 ImageFile getBiggest() { |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
188 return this.get(0); |
|
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 biggest ImageFile in the set. |
|
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 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
195 * @return |
|
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 public ImageFile getSmallest() { |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
198 return this.get(this.size() - 1); |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
199 } |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
200 |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
201 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
202 * Get an Iterator for this Fileset starting at the highest resolution |
| 159 | 203 * images. |
| 204 * | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
205 * |
| 159 | 206 * @return |
| 207 */ | |
| 208 public ListIterator getHiresIterator() { | |
| 209 return list.listIterator(); | |
| 210 } | |
| 211 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
212 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
213 * Get an Iterator for this Fileset starting at the lowest resolution |
| 159 | 214 * images. |
| 215 * | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
216 * The Iterator starts at the last element, so you have to use it backwards |
| 159 | 217 * with hasPrevious() and previous(). |
| 218 * | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
219 * |
| 159 | 220 * @return |
| 221 */ | |
| 222 public ListIterator getLoresIterator() { | |
| 223 return list.listIterator(list.size()); | |
| 224 } | |
| 225 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
226 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
227 * Fill the ImageFileset with files from different base directories. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
228 * |
| 159 | 229 * |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
230 * @param dirs |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
231 * list of base directories |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
232 * @param fl |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
233 * file (from first base dir) |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
234 * @param scalext |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
235 * first extension to try in other base dirs |
| 159 | 236 */ |
| 237 void fill(Directory[] dirs, File fl, String scalext) { | |
| 238 int nb = dirs.length; | |
| 239 String fn = fl.getName(); | |
| 240 String fnx = fn.substring(0, fn.lastIndexOf('.') + 1); | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
241 // add the first ImageFile to the ImageFileset |
| 159 | 242 add(new ImageFile(fn, this, parent)); |
| 243 // iterate the remaining base directories | |
| 244 for (int j = 1; j < nb; j++) { | |
| 245 if (dirs[j] == null) { | |
| 246 continue; | |
| 247 } | |
| 248 File f; | |
| 249 if (scalext != null) { | |
| 250 // use the last extension | |
| 251 f = new File(dirs[j].getDir(), fnx + scalext); | |
| 252 } else { | |
| 253 // try the same filename as the original | |
| 254 f = new File(dirs[j].getDir(), fn); | |
| 255 } | |
| 256 // if the file exists, add to the ImageFileset | |
| 257 if (f.canRead()) { | |
| 258 add(new ImageFile(f.getName(), this, dirs[j])); | |
| 259 } else { | |
| 260 // try other file extensions | |
| 261 Iterator exts = FileOps.getImageExtensionIterator(); | |
| 262 while (exts.hasNext()) { | |
| 263 String s = (String) exts.next(); | |
| 264 f = new File(dirs[j].getDir(), fnx + s); | |
| 265 // if the file exists, add to the ImageFileset | |
| 266 if (f.canRead()) { | |
| 267 add(new ImageFile(f.getName(), this, dirs[j])); | |
| 268 scalext = s; | |
| 269 break; | |
| 270 } | |
| 271 } | |
| 272 } | |
| 273 } | |
| 274 } | |
| 275 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
276 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
277 * Checks metadata and sets resolution in resX and resY. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
278 * |
| 159 | 279 */ |
| 280 public void checkMeta() { | |
| 281 if (metaChecked) { | |
| 282 return; | |
| 283 } | |
| 284 if (fileMeta == null) { | |
| 285 // try to read metadata file | |
| 286 readMeta(); | |
| 287 if (fileMeta == null) { | |
| 288 // try directory metadata | |
| 289 if (((DocuDirectory) parent).getDirMeta() != null) { | |
| 290 fileMeta = ((DocuDirectory) parent).getDirMeta(); | |
| 291 } else { | |
| 292 // no metadata available | |
| 293 metaChecked = true; | |
| 294 return; | |
| 295 } | |
| 296 } | |
| 297 } | |
| 298 metaChecked = true; | |
| 299 String s; | |
| 300 double dpi = 0; | |
| 301 double dpix = 0; | |
| 302 double dpiy = 0; | |
| 303 double sizex = 0; | |
| 304 double sizey = 0; | |
| 305 double pixx = 0; | |
| 306 double pixy = 0; | |
| 307 // DPI is valid for X and Y | |
| 308 if (fileMeta.containsKey("original-dpi")) { | |
| 309 try { | |
| 310 dpi = Double.parseDouble((String) fileMeta.get("original-dpi")); | |
| 311 } catch (NumberFormatException e) { | |
| 312 } | |
| 313 if (dpi != 0) { | |
| 314 resX = dpi; | |
| 315 resY = dpi; | |
| 316 return; | |
| 317 } | |
| 318 } | |
| 319 // DPI-X and DPI-Y | |
| 320 if (fileMeta.containsKey("original-dpi-x") | |
| 321 && fileMeta.containsKey("original-dpi-y")) { | |
| 322 try { | |
| 323 dpix = | |
| 324 Double.parseDouble((String) fileMeta.get("original-dpi-x")); | |
| 325 dpiy = | |
| 326 Double.parseDouble((String) fileMeta.get("original-dpi-y")); | |
| 327 } catch (NumberFormatException e) { | |
| 328 } | |
| 329 if ((dpix != 0) && (dpiy != 0)) { | |
| 330 resX = dpix; | |
| 331 resY = dpiy; | |
| 332 return; | |
| 333 } | |
| 334 } | |
| 335 // SIZE-X and SIZE-Y and PIXEL-X and PIXEL-Y | |
| 336 if (fileMeta.containsKey("original-size-x") | |
| 337 && fileMeta.containsKey("original-size-y") | |
| 338 && fileMeta.containsKey("original-pixel-x") | |
| 339 && fileMeta.containsKey("original-pixel-y")) { | |
| 340 try { | |
| 341 sizex = | |
| 342 Double.parseDouble( | |
| 343 (String) fileMeta.get("original-size-x")); | |
| 344 sizey = | |
| 345 Double.parseDouble( | |
| 346 (String) fileMeta.get("original-size-y")); | |
| 347 pixx = | |
| 348 Double.parseDouble( | |
| 349 (String) fileMeta.get("original-pixel-x")); | |
| 350 pixy = | |
| 351 Double.parseDouble( | |
| 352 (String) fileMeta.get("original-pixel-y")); | |
| 353 } catch (NumberFormatException e) { | |
| 354 } | |
| 355 if ((sizex != 0) && (sizey != 0) && (pixx != 0) && (pixy != 0)) { | |
| 356 resX = pixx / (sizex * 100 / 2.54); | |
| 357 resY = pixy / (sizey * 100 / 2.54); | |
| 358 return; | |
| 359 } | |
| 360 } | |
| 361 } | |
| 362 | |
| 363 /** | |
| 364 * @return | |
| 365 */ | |
| 366 public double getResX() { | |
| 367 return resX; | |
| 368 } | |
| 369 | |
| 370 /** | |
| 371 * @return | |
| 372 */ | |
| 373 public double getResY() { | |
| 374 return resY; | |
| 375 } | |
| 376 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
377 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
378 * Sets the aspect ratio from an ImageSize. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
379 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
380 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
381 * @param f |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
382 */ |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
383 public void setAspect(ImageSize s) { |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
384 aspect = s.getAspect(); |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
385 } |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
386 |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
387 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
388 * Returns the aspect ratio. |
|
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 * Aspect ratio is (width/height). So it's <1 for portrait and >1 for |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
391 * landscape. |
|
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 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
394 * @return |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
395 */ |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
396 public double getAspect() { |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
397 return aspect; |
|
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 |
| 159 | 400 } |
