Mercurial > hg > digilib-old
annotate 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 |
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 */ | |
579
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
31 public class ImageFile extends DocuDirent implements 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; | |
579
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
39 // mime file type |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
40 protected String mimetype = null; |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
41 // image size in pixels |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
42 protected ImageSize pixelSize = null; |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
43 |
159 | 44 |
574 | 45 public ImageFile(String fn, ImageSet parent, Directory dir) { |
159 | 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 |
159 | 58 /** Returns the file name (without path). |
59 * | |
60 * @return | |
61 */ | |
62 public String getName() { | |
63 return filename; | |
64 } | |
65 | |
66 | |
67 /** | |
68 * @return File | |
69 */ | |
70 public File getFile() { | |
71 if (dir == null) { | |
72 return null; | |
73 } | |
74 File f = new File(dir.getDir(), filename); | |
75 return f; | |
76 } | |
77 | |
566 | 78 /* (non-Javadoc) |
568 | 79 * @see digilib.io.ImageInput#setSize(digilib.image.ImageSize) |
159 | 80 */ |
568 | 81 public void setSize(ImageSize imageSize) { |
82 this.pixelSize = imageSize; | |
83 // pass on to parent | |
84 if (this.parent != null) { | |
85 this.parent.setAspect(imageSize); | |
86 } | |
566 | 87 } |
579
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
88 /* (non-Javadoc) |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
89 * @see digilib.io.ImageInput#getSize() |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
90 */ |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
91 public ImageSize getSize() { |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
92 return pixelSize; |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
93 } |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
94 |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
95 /* (non-Javadoc) |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
96 * @see digilib.io.ImageInput#getMimetype() |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
97 */ |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
98 public String getMimetype() { |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
99 return mimetype; |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
100 } |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
101 |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
102 /* (non-Javadoc) |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
103 * @see digilib.io.ImageInput#setMimetype(java.lang.String) |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
104 */ |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
105 public void setMimetype(String filetype) { |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
106 this.mimetype = filetype; |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
107 } |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
108 |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
109 /* (non-Javadoc) |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
110 * @see digilib.io.ImageInput#isChecked() |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
111 */ |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
112 public boolean isChecked() { |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
113 return (pixelSize != null); |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
114 } |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
115 |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
116 /* (non-Javadoc) |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
117 * @see digilib.io.ImageInput#getAspect() |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
118 */ |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
119 public float getAspect() { |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
120 return (pixelSize != null) ? pixelSize.getAspect() : 0; |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
121 } |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
122 |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
123 @Override |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
124 public ImageSet getParentSet() { |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
125 // TODO Auto-generated method stub |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
126 return null; |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
127 } |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
128 |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
129 @Override |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
130 public void setParentSet(ImageSet parent) { |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
131 // TODO Auto-generated method stub |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
132 |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
133 } |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
134 |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
135 @Override |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
136 public void checkMeta() { |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
137 // TODO Auto-generated method stub |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
138 |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
139 } |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
140 |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
141 @Override |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
142 public File getInput() { |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
143 // TODO Auto-generated method stub |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
144 return null; |
efd7a223f819
try: ImageInput as interface, ImageFile inherits from Dirent and implements ImageInput
robcast
parents:
574
diff
changeset
|
145 } |
566 | 146 |
159 | 147 } |