Mercurial > hg > digilib-old
annotate servlet/src/digilib/io/ImageFile.java @ 576:dad720e9b12b stream
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
| author | robcast |
|---|---|
| date | Wed, 22 Dec 2010 20:19:06 +0100 |
| parents | 790cbfb58b52 |
| children | 7357ad8f9f42 |
| 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 */ | |
| 568 | 31 public class ImageFile extends ImageInput { |
| 159 | 32 |
| 33 // file name | |
| 34 private String filename = null; | |
| 574 | 35 // parent ImageSet |
| 36 private ImageSet parent = null; | |
| 159 | 37 // parent directory |
| 38 private Directory dir = null; | |
| 39 | |
| 574 | 40 public ImageFile(String fn, ImageSet parent, Directory dir) { |
| 159 | 41 this.filename = fn; |
| 42 this.parent = parent; | |
| 43 this.dir = dir; | |
| 44 } | |
| 45 | |
| 46 public ImageFile(String fn) { | |
| 47 File f = new File(fn); | |
| 48 this.dir = new Directory(f.getParentFile()); | |
| 49 this.filename = f.getName(); | |
| 50 } | |
| 51 | |
| 566 | 52 |
| 159 | 53 /** Returns the file name (without path). |
| 54 * | |
| 55 * @return | |
| 56 */ | |
| 57 public String getName() { | |
| 58 return filename; | |
| 59 } | |
| 60 | |
| 61 | |
| 62 /** | |
| 63 * @return File | |
| 64 */ | |
| 65 public File getFile() { | |
| 66 if (dir == null) { | |
| 67 return null; | |
| 68 } | |
| 69 File f = new File(dir.getDir(), filename); | |
| 70 return f; | |
| 71 } | |
| 72 | |
| 73 /** | |
| 574 | 74 * @return ImageSet |
| 159 | 75 */ |
| 574 | 76 public ImageSet getParent() { |
| 159 | 77 return parent; |
| 78 } | |
| 79 | |
| 80 /** | |
| 81 * Sets the parent. | |
| 82 * @param parent The parent to set | |
| 83 */ | |
| 574 | 84 public void setParent(ImageSet parent) { |
| 159 | 85 this.parent = parent; |
| 86 } | |
| 87 | |
| 566 | 88 /* (non-Javadoc) |
| 568 | 89 * @see digilib.io.ImageInput#setSize(digilib.image.ImageSize) |
| 159 | 90 */ |
| 568 | 91 public void setSize(ImageSize imageSize) { |
| 92 this.pixelSize = imageSize; | |
| 93 // pass on to parent | |
| 94 if (this.parent != null) { | |
| 95 this.parent.setAspect(imageSize); | |
| 96 } | |
| 566 | 97 } |
| 98 | |
|
576
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
99 /* (non-Javadoc) |
|
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
100 * @see java.lang.Object#toString() |
|
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
101 */ |
|
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
102 @Override |
|
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
103 public String toString() { |
|
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
104 // try to use File.toString |
|
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
105 File f = getFile(); |
|
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
106 if (f != null) { |
|
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
107 return f.toString(); |
|
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
108 } |
|
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
109 return super.toString(); |
|
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
110 } |
|
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
111 |
|
dad720e9b12b
try: DocuDirent as interface, ImageFile inherits from ImageInput and implements DocuDirent
robcast
parents:
574
diff
changeset
|
112 |
| 159 | 113 } |
