Mercurial > hg > digilib-old
annotate servlet/src/digilib/io/ImageFile.java @ 567:70c135bd17aa stream
Starting 'stream' branch
| author | robcast |
|---|---|
| date | Tue, 21 Dec 2010 10:05:54 +0100 |
| parents | 50f291d808b1 |
| children | 34701340922e |
| 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; | |
| 566 | 25 import java.io.InputStream; |
| 159 | 26 |
| 27 import digilib.image.ImageSize; | |
| 28 | |
| 29 /** | |
| 30 * @author casties | |
| 31 */ | |
| 566 | 32 public class ImageFile implements ImageInput { |
| 159 | 33 |
| 34 // file name | |
| 35 private String filename = null; | |
| 36 // parent ImageFileset | |
| 37 private ImageFileset parent = null; | |
| 38 // parent directory | |
| 39 private Directory dir = null; | |
| 40 // mime file type | |
| 41 private String mimetype = null; | |
| 42 // image size in pixels | |
| 43 private ImageSize pixelSize = null; | |
| 44 | |
| 45 public ImageFile(String fn, ImageFileset parent, Directory dir) { | |
| 46 this.filename = fn; | |
| 47 this.parent = parent; | |
| 48 this.dir = dir; | |
| 49 } | |
| 50 | |
| 51 public ImageFile(String fn) { | |
| 52 File f = new File(fn); | |
| 53 this.dir = new Directory(f.getParentFile()); | |
| 54 this.filename = f.getName(); | |
| 55 } | |
| 56 | |
| 566 | 57 |
| 58 @Override | |
| 59 public boolean hasFile() { | |
| 60 // this is File-based | |
| 61 return true; | |
| 62 } | |
| 63 | |
| 64 @Override | |
| 65 public boolean hasStream() { | |
| 66 return false; | |
| 67 } | |
| 68 | |
| 159 | 69 /** Returns the file name (without path). |
| 70 * | |
| 71 * @return | |
| 72 */ | |
| 73 public String getName() { | |
| 74 return filename; | |
| 75 } | |
| 76 | |
| 77 | |
| 78 /** | |
| 79 * @return File | |
| 80 */ | |
| 566 | 81 @Override |
| 159 | 82 public File getFile() { |
| 83 if (dir == null) { | |
| 84 return null; | |
| 85 } | |
| 86 File f = new File(dir.getDir(), filename); | |
| 87 return f; | |
| 88 } | |
| 89 | |
| 566 | 90 /* (non-Javadoc) |
| 91 * @see digilib.io.ImageInput#getSize() | |
| 159 | 92 */ |
| 566 | 93 @Override |
| 159 | 94 public ImageSize getSize() { |
| 95 return pixelSize; | |
| 96 } | |
| 97 | |
| 566 | 98 /* (non-Javadoc) |
| 99 * @see digilib.io.ImageInput#getMimetype() | |
| 159 | 100 */ |
| 566 | 101 @Override |
| 159 | 102 public String getMimetype() { |
| 103 return mimetype; | |
| 104 } | |
| 105 | |
| 566 | 106 /* (non-Javadoc) |
| 107 * @see digilib.io.ImageInput#setSize(digilib.image.ImageSize) | |
| 159 | 108 */ |
| 566 | 109 @Override |
| 159 | 110 public void setSize(ImageSize imageSize) { |
| 111 this.pixelSize = imageSize; | |
| 463 | 112 // pass on to parent |
| 113 if (this.parent != null) { | |
| 114 this.parent.setAspect(imageSize); | |
| 115 } | |
| 159 | 116 } |
| 117 | |
| 566 | 118 /* (non-Javadoc) |
| 119 * @see digilib.io.ImageInput#setMimetype(java.lang.String) | |
| 159 | 120 */ |
| 566 | 121 @Override |
| 284 | 122 public void setMimetype(String filetype) { |
| 123 this.mimetype = filetype; | |
| 159 | 124 } |
| 125 | |
| 126 /** | |
| 127 * @return ImageFileset | |
| 128 */ | |
| 129 public ImageFileset getParent() { | |
| 130 return parent; | |
| 131 } | |
| 132 | |
| 133 /** | |
| 134 * Sets the parent. | |
| 135 * @param parent The parent to set | |
| 136 */ | |
| 137 public void setParent(ImageFileset parent) { | |
| 138 this.parent = parent; | |
| 139 } | |
| 140 | |
| 566 | 141 /* (non-Javadoc) |
| 142 * @see digilib.io.ImageInput#isChecked() | |
| 159 | 143 */ |
| 566 | 144 @Override |
| 159 | 145 public boolean isChecked() { |
| 146 return (pixelSize != null); | |
| 147 } | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
148 |
| 566 | 149 /* (non-Javadoc) |
| 150 * @see digilib.io.ImageInput#getAspect() | |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
151 */ |
| 566 | 152 @Override |
|
295
90bab835fc25
Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents:
284
diff
changeset
|
153 public float getAspect() { |
|
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
154 return (pixelSize != null) ? pixelSize.getAspect() : 0; |
|
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
155 } |
| 159 | 156 |
| 566 | 157 @Override |
| 158 public InputStream getStream() { | |
| 159 return null; | |
| 160 } | |
| 161 | |
| 159 | 162 } |
