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
|
|
53 @Override
|
|
54 public boolean hasFile() {
|
|
55 // this is File-based
|
|
56 return true;
|
|
57 }
|
|
58
|
159
|
59 /** Returns the file name (without path).
|
|
60 *
|
|
61 * @return
|
|
62 */
|
|
63 public String getName() {
|
|
64 return filename;
|
|
65 }
|
|
66
|
|
67
|
|
68 /**
|
|
69 * @return File
|
|
70 */
|
566
|
71 @Override
|
159
|
72 public File getFile() {
|
|
73 if (dir == null) {
|
|
74 return null;
|
|
75 }
|
|
76 File f = new File(dir.getDir(), filename);
|
|
77 return f;
|
|
78 }
|
|
79
|
|
80 /**
|
574
|
81 * @return ImageSet
|
159
|
82 */
|
574
|
83 public ImageSet getParent() {
|
159
|
84 return parent;
|
|
85 }
|
|
86
|
|
87 /**
|
|
88 * Sets the parent.
|
|
89 * @param parent The parent to set
|
|
90 */
|
574
|
91 public void setParent(ImageSet parent) {
|
159
|
92 this.parent = parent;
|
|
93 }
|
|
94
|
566
|
95 /* (non-Javadoc)
|
568
|
96 * @see digilib.io.ImageInput#setSize(digilib.image.ImageSize)
|
159
|
97 */
|
568
|
98 public void setSize(ImageSize imageSize) {
|
|
99 this.pixelSize = imageSize;
|
|
100 // pass on to parent
|
|
101 if (this.parent != null) {
|
|
102 this.parent.setAspect(imageSize);
|
|
103 }
|
566
|
104 }
|
|
105
|
159
|
106 }
|