Mercurial > hg > digilib-old
comparison servlet/src/digilib/io/ImageFile.java @ 579:efd7a223f819 stream
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
author | robcast |
---|---|
date | Wed, 22 Dec 2010 19:17:52 +0100 |
parents | 790cbfb58b52 |
children | f210731dc6cc |
comparison
equal
deleted
inserted
replaced
574:790cbfb58b52 | 579:efd7a223f819 |
---|---|
26 import digilib.image.ImageSize; | 26 import digilib.image.ImageSize; |
27 | 27 |
28 /** | 28 /** |
29 * @author casties | 29 * @author casties |
30 */ | 30 */ |
31 public class ImageFile extends ImageInput { | 31 public class ImageFile extends DocuDirent implements ImageInput { |
32 | 32 |
33 // file name | 33 // file name |
34 private String filename = null; | 34 private String filename = null; |
35 // parent ImageSet | 35 // parent ImageSet |
36 private ImageSet parent = null; | 36 private ImageSet parent = null; |
37 // parent directory | 37 // parent directory |
38 private Directory dir = null; | 38 private Directory dir = null; |
39 // mime file type | |
40 protected String mimetype = null; | |
41 // image size in pixels | |
42 protected ImageSize pixelSize = null; | |
43 | |
39 | 44 |
40 public ImageFile(String fn, ImageSet parent, Directory dir) { | 45 public ImageFile(String fn, ImageSet parent, Directory dir) { |
41 this.filename = fn; | 46 this.filename = fn; |
42 this.parent = parent; | 47 this.parent = parent; |
43 this.dir = dir; | 48 this.dir = dir; |
48 this.dir = new Directory(f.getParentFile()); | 53 this.dir = new Directory(f.getParentFile()); |
49 this.filename = f.getName(); | 54 this.filename = f.getName(); |
50 } | 55 } |
51 | 56 |
52 | 57 |
53 @Override | |
54 public boolean hasFile() { | |
55 // this is File-based | |
56 return true; | |
57 } | |
58 | |
59 /** Returns the file name (without path). | 58 /** Returns the file name (without path). |
60 * | 59 * |
61 * @return | 60 * @return |
62 */ | 61 */ |
63 public String getName() { | 62 public String getName() { |
66 | 65 |
67 | 66 |
68 /** | 67 /** |
69 * @return File | 68 * @return File |
70 */ | 69 */ |
71 @Override | |
72 public File getFile() { | 70 public File getFile() { |
73 if (dir == null) { | 71 if (dir == null) { |
74 return null; | 72 return null; |
75 } | 73 } |
76 File f = new File(dir.getDir(), filename); | 74 File f = new File(dir.getDir(), filename); |
77 return f; | 75 return f; |
78 } | |
79 | |
80 /** | |
81 * @return ImageSet | |
82 */ | |
83 public ImageSet getParent() { | |
84 return parent; | |
85 } | |
86 | |
87 /** | |
88 * Sets the parent. | |
89 * @param parent The parent to set | |
90 */ | |
91 public void setParent(ImageSet parent) { | |
92 this.parent = parent; | |
93 } | 76 } |
94 | 77 |
95 /* (non-Javadoc) | 78 /* (non-Javadoc) |
96 * @see digilib.io.ImageInput#setSize(digilib.image.ImageSize) | 79 * @see digilib.io.ImageInput#setSize(digilib.image.ImageSize) |
97 */ | 80 */ |
100 // pass on to parent | 83 // pass on to parent |
101 if (this.parent != null) { | 84 if (this.parent != null) { |
102 this.parent.setAspect(imageSize); | 85 this.parent.setAspect(imageSize); |
103 } | 86 } |
104 } | 87 } |
88 /* (non-Javadoc) | |
89 * @see digilib.io.ImageInput#getSize() | |
90 */ | |
91 public ImageSize getSize() { | |
92 return pixelSize; | |
93 } | |
94 | |
95 /* (non-Javadoc) | |
96 * @see digilib.io.ImageInput#getMimetype() | |
97 */ | |
98 public String getMimetype() { | |
99 return mimetype; | |
100 } | |
101 | |
102 /* (non-Javadoc) | |
103 * @see digilib.io.ImageInput#setMimetype(java.lang.String) | |
104 */ | |
105 public void setMimetype(String filetype) { | |
106 this.mimetype = filetype; | |
107 } | |
108 | |
109 /* (non-Javadoc) | |
110 * @see digilib.io.ImageInput#isChecked() | |
111 */ | |
112 public boolean isChecked() { | |
113 return (pixelSize != null); | |
114 } | |
115 | |
116 /* (non-Javadoc) | |
117 * @see digilib.io.ImageInput#getAspect() | |
118 */ | |
119 public float getAspect() { | |
120 return (pixelSize != null) ? pixelSize.getAspect() : 0; | |
121 } | |
122 | |
123 @Override | |
124 public ImageSet getParentSet() { | |
125 // TODO Auto-generated method stub | |
126 return null; | |
127 } | |
128 | |
129 @Override | |
130 public void setParentSet(ImageSet parent) { | |
131 // TODO Auto-generated method stub | |
132 | |
133 } | |
134 | |
135 @Override | |
136 public void checkMeta() { | |
137 // TODO Auto-generated method stub | |
138 | |
139 } | |
140 | |
141 @Override | |
142 public File getInput() { | |
143 // TODO Auto-generated method stub | |
144 return null; | |
145 } | |
105 | 146 |
106 } | 147 } |