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