Mercurial > hg > digilib-old
annotate servlet/src/digilib/io/ImageFile.java @ 349:bafd7b503d14
Servlet version 1.5.7b
- new max-waiting-threads parameter and handling
- DocumentBean also gets real image sizes (for dlInfo-xml et al.)
| author | robcast |
|---|---|
| date | Fri, 22 Apr 2005 19:17:44 +0200 |
| parents | 90bab835fc25 |
| children | d76a9e3f1ec9 |
| rev | line source |
|---|---|
| 159 | 1 /* ImageFile.java -- digilib image file class. |
| 2 | |
| 3 Digital Image Library servlet components | |
| 4 | |
| 5 Copyright (C) 2003 Robert Casties (robcast@mail.berlios.de) | |
| 6 | |
| 7 This program is free software; you can redistribute it and/or modify it | |
| 8 under the terms of the GNU General Public License as published by the | |
| 9 Free Software Foundation; either version 2 of the License, or (at your | |
| 10 option) any later version. | |
| 11 | |
| 12 Please read license.txt for the full details. A copy of the GPL | |
| 13 may be found at http://www.gnu.org/copyleft/lgpl.html | |
| 14 | |
| 15 You should have received a copy of the GNU General Public License | |
| 16 along with this program; if not, write to the Free Software | |
| 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 18 | |
| 19 * Created on 25.02.2003 | |
| 20 */ | |
| 21 | |
| 22 package digilib.io; | |
| 23 | |
| 24 import java.io.File; | |
| 25 | |
| 26 import digilib.image.ImageSize; | |
| 27 | |
| 28 /** | |
| 29 * @author casties | |
| 30 */ | |
| 31 public class ImageFile { | |
| 32 | |
| 33 // file name | |
| 34 private String filename = null; | |
| 35 // parent ImageFileset | |
| 36 private ImageFileset parent = null; | |
| 37 // parent directory | |
| 38 private Directory dir = null; | |
| 39 // mime file type | |
| 40 private String mimetype = null; | |
| 41 // image size in pixels | |
| 42 private ImageSize pixelSize = null; | |
| 43 | |
| 44 public ImageFile(String fn, ImageFileset parent, Directory dir) { | |
| 45 this.filename = fn; | |
| 46 this.parent = parent; | |
| 47 this.dir = dir; | |
| 48 } | |
| 49 | |
| 50 public ImageFile(String fn) { | |
| 51 File f = new File(fn); | |
| 52 this.dir = new Directory(f.getParentFile()); | |
| 53 this.filename = f.getName(); | |
| 54 } | |
| 55 | |
| 56 /** Returns the file name (without path). | |
| 57 * | |
| 58 * @return | |
| 59 */ | |
| 60 public String getName() { | |
| 61 return filename; | |
| 62 } | |
| 63 | |
| 64 | |
| 65 /** | |
| 66 * @return File | |
| 67 */ | |
| 68 public File getFile() { | |
| 69 if (dir == null) { | |
| 70 return null; | |
| 71 } | |
| 72 File f = new File(dir.getDir(), filename); | |
| 73 return f; | |
| 74 } | |
| 75 | |
| 76 /** | |
| 77 * @return ImageSize | |
| 78 */ | |
| 79 public ImageSize getSize() { | |
| 80 return pixelSize; | |
| 81 } | |
| 82 | |
| 83 /** | |
| 84 * @return String | |
| 85 */ | |
| 86 public String getMimetype() { | |
| 87 return mimetype; | |
| 88 } | |
| 89 | |
| 90 /** | |
| 91 * Sets the imageSize. | |
| 92 * @param imageSize The imageSize to set | |
| 93 */ | |
| 94 public void setSize(ImageSize imageSize) { | |
| 95 this.pixelSize = imageSize; | |
| 96 } | |
| 97 | |
| 98 /** | |
| 99 * Sets the mimetype. | |
| 100 * @param mimetype The mimetype to set | |
| 101 */ | |
| 284 | 102 public void setMimetype(String filetype) { |
| 103 this.mimetype = filetype; | |
| 159 | 104 } |
| 105 | |
| 106 /** | |
| 107 * @return ImageFileset | |
| 108 */ | |
| 109 public ImageFileset getParent() { | |
| 110 return parent; | |
| 111 } | |
| 112 | |
| 113 /** | |
| 114 * Sets the parent. | |
| 115 * @param parent The parent to set | |
| 116 */ | |
| 117 public void setParent(ImageFileset parent) { | |
| 118 this.parent = parent; | |
| 119 } | |
| 120 | |
| 121 /** | |
| 122 * @return boolean | |
| 123 */ | |
| 124 public boolean isChecked() { | |
| 125 return (pixelSize != null); | |
| 126 } | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
127 |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
128 /** Returns the aspect ratio of the image (width/height). |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
129 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
130 * @return |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
131 */ |
|
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
132 public float getAspect() { |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
133 return (pixelSize != null) ? pixelSize.getAspect() : 0; |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
134 } |
| 159 | 135 |
| 136 } |
