Mercurial > hg > digilib-old
annotate servlet/src/digilib/io/ImageFileset.java @ 273:d4c0c4d858a9
Servlet version 1.21b3
- searching in directories got faster (real binarySearch now!)
- cached file lists get disposed
- some code cleaning (Map types instead of HashMap)
| author | robcast |
|---|---|
| date | Tue, 12 Oct 2004 16:06:43 +0200 |
| parents | beed92ee6022 |
| children | c633e97cac12 |
| 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 |
| 28 import digilib.image.DocuInfo; | |
| 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; |
| 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) */ |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
43 private double 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) */ |
| 159 | 46 private double 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) */ |
| 159 | 49 private double resY = 0; |
| 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]; | |
| 259 | 74 fill(dirs, file, hints); |
| 159 | 75 } |
| 259 | 76 |
| 77 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
78 /** |
| 176 | 79 * Adds an ImageFile to this Fileset. |
| 159 | 80 * |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
81 * 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
|
82 * The first file is considered the hires "original". |
| 159 | 83 * |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
84 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
85 * @param f |
| 233 | 86 * file to add |
| 159 | 87 * @return true (always) |
| 88 */ | |
| 89 public boolean add(ImageFile f) { | |
| 90 f.setParent(this); | |
| 91 return list.add(f); | |
| 92 } | |
| 93 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
94 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
95 * The number of image files in this Fileset. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
96 * |
| 159 | 97 * |
| 98 * @return number of image files | |
| 99 */ | |
| 100 public int size() { | |
| 101 return (list != null) ? list.size() : 0; | |
| 102 } | |
| 103 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
104 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
105 * Gets the default File. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
106 * |
| 159 | 107 */ |
| 108 public File getFile() { | |
| 109 return (list != null) ? ((ImageFile) list.get(0)).getFile() : null; | |
| 110 } | |
| 111 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
112 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
113 * Get the ImageFile at the index. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
114 * |
| 159 | 115 * |
| 116 * @param index | |
| 117 * @return | |
| 118 */ | |
| 119 public ImageFile get(int index) { | |
| 120 return (ImageFile) list.get(index); | |
| 121 } | |
| 122 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
123 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
124 * Get the next smaller ImageFile than the given size. |
| 159 | 125 * |
| 233 | 126 * Returns the ImageFile from the set that has a width and height smaller or |
| 127 * equal the given size. Returns null if there isn't any smaller image. | |
| 159 | 128 * Needs DocuInfo instance to checkFile(). |
| 129 * | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
130 * |
| 159 | 131 * @param size |
| 132 * @param info | |
| 133 * @return | |
| 134 */ | |
| 135 public ImageFile getNextSmaller(ImageSize size, DocuInfo info) { | |
| 136 for (Iterator i = getHiresIterator(); i.hasNext();) { | |
| 137 ImageFile f = (ImageFile) i.next(); | |
| 138 try { | |
| 139 if (!f.isChecked()) { | |
| 140 info.checkFile(f); | |
| 141 } | |
| 142 if (f.getSize().isTotallySmallerThan(size)) { | |
| 143 return f; | |
| 144 } | |
| 145 } catch (IOException e) { | |
| 146 } | |
| 147 } | |
| 148 return null; | |
| 149 } | |
| 150 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
151 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
152 * Get the next bigger ImageFile than the given size. |
| 159 | 153 * |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
154 * Returns the ImageFile from the set that has a width or height bigger or |
| 233 | 155 * equal the given size. Returns null if there isn't any bigger image. Needs |
| 156 * DocuInfo instance to checkFile(). | |
| 159 | 157 * |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
158 * |
| 159 | 159 * @param size |
| 160 * @param info | |
| 161 * @return | |
| 162 */ | |
| 163 public ImageFile getNextBigger(ImageSize size, DocuInfo info) { | |
| 164 for (ListIterator i = getLoresIterator(); i.hasPrevious();) { | |
| 165 ImageFile f = (ImageFile) i.previous(); | |
| 166 try { | |
| 167 if (!f.isChecked()) { | |
| 168 info.checkFile(f); | |
| 169 } | |
| 170 if (f.getSize().isBiggerThan(size)) { | |
| 171 return f; | |
| 172 } | |
| 173 } catch (IOException e) { | |
| 174 } | |
| 175 } | |
| 176 return null; | |
| 177 } | |
| 178 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
179 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
180 * Returns the biggest ImageFile in the set. |
|
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 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
183 * @return |
|
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 public ImageFile getBiggest() { |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
186 return this.get(0); |
|
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 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
190 * Returns the biggest ImageFile in the set. |
|
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 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
193 * @return |
|
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 public ImageFile getSmallest() { |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
196 return this.get(this.size() - 1); |
|
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 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
200 * Get an Iterator for this Fileset starting at the highest resolution |
| 159 | 201 * images. |
| 202 * | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
203 * |
| 159 | 204 * @return |
| 205 */ | |
| 206 public ListIterator getHiresIterator() { | |
| 207 return list.listIterator(); | |
| 208 } | |
| 209 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
210 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
211 * Get an Iterator for this Fileset starting at the lowest resolution |
| 159 | 212 * images. |
| 213 * | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
214 * The Iterator starts at the last element, so you have to use it backwards |
| 159 | 215 * with hasPrevious() and previous(). |
| 216 * | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
217 * |
| 159 | 218 * @return |
| 219 */ | |
| 220 public ListIterator getLoresIterator() { | |
| 221 return list.listIterator(list.size()); | |
| 222 } | |
| 223 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
224 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
225 * Fill the ImageFileset with files from different base directories. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
226 * |
| 159 | 227 * |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
228 * @param dirs |
| 233 | 229 * list of base directories |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
230 * @param fl |
| 233 | 231 * file (from first base dir) |
| 259 | 232 * @param hints |
| 233 * | |
| 159 | 234 */ |
| 259 | 235 void fill(Directory[] dirs, File fl, Map hints) { |
| 236 String scalext = (String) hints.get(FileOps.HINT_FILEEXT); | |
| 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 | |
| 243 for (int j = 1; j < nb; j++) { | |
| 244 if (dirs[j] == null) { | |
| 245 continue; | |
| 246 } | |
| 259 | 247 // read the directories |
| 248 if (dirs[j].getFilenames() == null) { | |
| 249 dirs[j].readDir(); | |
| 250 } | |
| 251 File f = null; | |
| 252 String[] dirFiles = dirs[j].getFilenames(); | |
| 159 | 253 if (scalext != null) { |
| 254 // use the last extension | |
| 259 | 255 int i = Arrays.binarySearch(dirFiles, baseFn + scalext); |
| 256 if (i >= 0) { | |
| 257 f = new File(dirs[j].getDir(), dirFiles[i]); | |
| 258 } | |
| 159 | 259 } else { |
| 260 // try the same filename as the original | |
| 259 | 261 int i = Arrays.binarySearch(dirFiles, fn); |
| 262 if (i >= 0) { | |
| 263 f = new File(dirs[j].getDir(), dirFiles[i]); | |
| 264 } | |
| 159 | 265 } |
| 259 | 266 // if the file doesn't exists, try other file extensions |
| 267 if (f == null) { | |
| 159 | 268 // try other file extensions |
| 259 | 269 for (Iterator exts = FileOps.getImageExtensionIterator(); exts.hasNext();) { |
| 159 | 270 String s = (String) exts.next(); |
| 259 | 271 int i = Arrays.binarySearch(dirFiles, baseFn + s); |
| 272 if (i >= 0) { | |
| 273 hints.put(FileOps.HINT_FILEEXT, s); | |
| 274 f = new File(dirs[j].getDir(), dirFiles[i]); | |
| 159 | 275 break; |
| 276 } | |
| 277 } | |
| 278 } | |
| 259 | 279 if (f != null) { |
| 280 add(new ImageFile(f.getName(), this, dirs[j])); | |
| 281 } | |
| 159 | 282 } |
| 283 } | |
| 284 | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
285 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
286 * Checks metadata and sets resolution in resX and resY. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
287 * |
| 159 | 288 */ |
| 289 public void checkMeta() { | |
| 290 if (metaChecked) { | |
| 291 return; | |
| 292 } | |
| 293 if (fileMeta == null) { | |
| 294 // try to read metadata file | |
| 295 readMeta(); | |
| 296 if (fileMeta == null) { | |
| 297 // try directory metadata | |
| 233 | 298 ((DocuDirectory) parent).checkMeta(); |
| 159 | 299 if (((DocuDirectory) parent).getDirMeta() != null) { |
| 300 fileMeta = ((DocuDirectory) parent).getDirMeta(); | |
| 301 } else { | |
| 233 | 302 // try parent directory metadata |
| 303 DocuDirectory gp = (DocuDirectory) parent.getParent(); | |
| 304 if (gp != null) { | |
| 305 gp.checkMeta(); | |
| 306 if (gp.getDirMeta() != null) { | |
| 307 fileMeta = gp.getDirMeta(); | |
| 308 } else { | |
| 309 // no metadata available | |
| 310 metaChecked = true; | |
| 311 return; | |
| 312 } | |
| 313 } | |
| 159 | 314 } |
| 315 } | |
| 316 } | |
| 317 metaChecked = true; | |
| 318 String s; | |
| 319 double dpi = 0; | |
| 320 double dpix = 0; | |
| 321 double dpiy = 0; | |
| 322 double sizex = 0; | |
| 323 double sizey = 0; | |
| 324 double pixx = 0; | |
| 325 double pixy = 0; | |
| 326 // DPI is valid for X and Y | |
| 327 if (fileMeta.containsKey("original-dpi")) { | |
| 328 try { | |
| 329 dpi = Double.parseDouble((String) fileMeta.get("original-dpi")); | |
| 330 } catch (NumberFormatException e) { | |
| 331 } | |
| 332 if (dpi != 0) { | |
| 333 resX = dpi; | |
| 334 resY = dpi; | |
| 335 return; | |
| 336 } | |
| 337 } | |
| 338 // DPI-X and DPI-Y | |
| 339 if (fileMeta.containsKey("original-dpi-x") | |
| 233 | 340 && fileMeta.containsKey("original-dpi-y")) { |
| 159 | 341 try { |
| 233 | 342 dpix = Double.parseDouble((String) fileMeta |
| 343 .get("original-dpi-x")); | |
| 344 dpiy = Double.parseDouble((String) fileMeta | |
| 345 .get("original-dpi-y")); | |
| 159 | 346 } catch (NumberFormatException e) { |
| 347 } | |
| 348 if ((dpix != 0) && (dpiy != 0)) { | |
| 349 resX = dpix; | |
| 350 resY = dpiy; | |
| 351 return; | |
| 352 } | |
| 353 } | |
| 354 // SIZE-X and SIZE-Y and PIXEL-X and PIXEL-Y | |
| 355 if (fileMeta.containsKey("original-size-x") | |
| 233 | 356 && fileMeta.containsKey("original-size-y") |
| 357 && fileMeta.containsKey("original-pixel-x") | |
| 358 && fileMeta.containsKey("original-pixel-y")) { | |
| 159 | 359 try { |
| 233 | 360 sizex = Double.parseDouble((String) fileMeta |
| 361 .get("original-size-x")); | |
| 362 sizey = Double.parseDouble((String) fileMeta | |
| 363 .get("original-size-y")); | |
| 364 pixx = Double.parseDouble((String) fileMeta | |
| 365 .get("original-pixel-x")); | |
| 366 pixy = Double.parseDouble((String) fileMeta | |
| 367 .get("original-pixel-y")); | |
| 159 | 368 } catch (NumberFormatException e) { |
| 369 } | |
| 370 if ((sizex != 0) && (sizey != 0) && (pixx != 0) && (pixy != 0)) { | |
| 371 resX = pixx / (sizex * 100 / 2.54); | |
| 372 resY = pixy / (sizey * 100 / 2.54); | |
| 373 return; | |
| 374 } | |
| 375 } | |
| 376 } | |
| 377 | |
| 378 /** | |
| 379 * @return | |
| 380 */ | |
| 381 public double getResX() { | |
| 382 return resX; | |
| 383 } | |
| 384 | |
| 385 /** | |
| 386 * @return | |
| 387 */ | |
| 388 public double getResY() { | |
| 389 return resY; | |
| 390 } | |
| 391 | |
|
170
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 * Sets the aspect ratio from an ImageSize. |
|
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 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
396 * @param f |
|
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 public void setAspect(ImageSize s) { |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
399 aspect = s.getAspect(); |
|
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 /** |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
403 * Returns the aspect ratio. |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
404 * |
| 233 | 405 * 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
|
406 * landscape. |
|
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 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
409 * @return |
|
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 public double getAspect() { |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
412 return aspect; |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
413 } |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
414 |
| 233 | 415 } |
