Mercurial > hg > digilib-old
annotate servlet/src/digilib/io/ImageFile.java @ 712:823f0050f7eb jquery
'reset' should reset fitwidth/fitheight, too
| author | hertzhaft |
|---|---|
| date | Sun, 30 Jan 2011 16:38:54 +0100 |
| parents | d76a9e3f1ec9 |
| children | 50f291d808b1 |
| 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; | |
| 463 | 96 // pass on to parent |
| 97 if (this.parent != null) { | |
| 98 this.parent.setAspect(imageSize); | |
| 99 } | |
| 159 | 100 } |
| 101 | |
| 102 /** | |
| 103 * Sets the mimetype. | |
| 104 * @param mimetype The mimetype to set | |
| 105 */ | |
| 284 | 106 public void setMimetype(String filetype) { |
| 107 this.mimetype = filetype; | |
| 159 | 108 } |
| 109 | |
| 110 /** | |
| 111 * @return ImageFileset | |
| 112 */ | |
| 113 public ImageFileset getParent() { | |
| 114 return parent; | |
| 115 } | |
| 116 | |
| 117 /** | |
| 118 * Sets the parent. | |
| 119 * @param parent The parent to set | |
| 120 */ | |
| 121 public void setParent(ImageFileset parent) { | |
| 122 this.parent = parent; | |
| 123 } | |
| 124 | |
| 125 /** | |
| 126 * @return boolean | |
| 127 */ | |
| 128 public boolean isChecked() { | |
| 129 return (pixelSize != null); | |
| 130 } | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
131 |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
132 /** Returns the aspect ratio of the image (width/height). |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
133 * |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
134 * @return |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
135 */ |
|
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
136 public float getAspect() { |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
137 return (pixelSize != null) ? pixelSize.getAspect() : 0; |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
138 } |
| 159 | 139 |
| 140 } |
