Mercurial > hg > digilib-old
annotate servlet/src/digilib/io/ImageFile.java @ 196:8125a068af80
Servlet version 1.18b5
- fix for config file names on non-unix systems
author | robcast |
---|---|
date | Mon, 08 Dec 2003 16:50:59 +0100 |
parents | d40922628e4a |
children | c633e97cac12 |
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 */ | |
31 public class ImageFile { | |
32 | |
33 // file name | |
34 private String filename = null; | |
35 // parent ImageFileset | |
36 private ImageFileset parent = null; | |
37 // parent directory | |
38 private Directory dir = null; | |
39 // mime file type | |
40 private String mimetype = null; | |
41 // image size in pixels | |
42 private ImageSize pixelSize = null; | |
43 | |
44 public ImageFile(String fn, ImageFileset parent, Directory dir) { | |
45 this.filename = fn; | |
46 this.parent = parent; | |
47 this.dir = dir; | |
48 } | |
49 | |
50 public ImageFile(String fn) { | |
51 File f = new File(fn); | |
52 this.dir = new Directory(f.getParentFile()); | |
53 this.filename = f.getName(); | |
54 } | |
55 | |
56 /** Returns the file name (without path). | |
57 * | |
58 * @return | |
59 */ | |
60 public String getName() { | |
61 return filename; | |
62 } | |
63 | |
64 | |
65 /** | |
66 * @return File | |
67 */ | |
68 public File getFile() { | |
69 if (dir == null) { | |
70 return null; | |
71 } | |
72 File f = new File(dir.getDir(), filename); | |
73 return f; | |
74 } | |
75 | |
76 /** | |
77 * @return ImageSize | |
78 */ | |
79 public ImageSize getSize() { | |
80 return pixelSize; | |
81 } | |
82 | |
83 /** | |
84 * @return String | |
85 */ | |
86 public String getMimetype() { | |
87 return mimetype; | |
88 } | |
89 | |
90 /** | |
91 * Sets the imageSize. | |
92 * @param imageSize The imageSize to set | |
93 */ | |
94 public void setSize(ImageSize imageSize) { | |
95 this.pixelSize = imageSize; | |
96 } | |
97 | |
98 /** | |
99 * Sets the mimetype. | |
100 * @param mimetype The mimetype to set | |
101 */ | |
102 public void setMimetype(String mimetype) { | |
103 this.mimetype = mimetype; | |
104 } | |
105 | |
106 /** | |
107 * @return ImageFileset | |
108 */ | |
109 public ImageFileset getParent() { | |
110 return parent; | |
111 } | |
112 | |
113 /** | |
114 * Sets the parent. | |
115 * @param parent The parent to set | |
116 */ | |
117 public void setParent(ImageFileset parent) { | |
118 this.parent = parent; | |
119 } | |
120 | |
121 /** | |
122 * @return boolean | |
123 */ | |
124 public boolean isChecked() { | |
125 return (pixelSize != null); | |
126 } | |
170
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
127 |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
128 /** Returns the aspect ratio of the image (width/height). |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
129 * |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
130 * @return |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
131 */ |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
132 public double getAspect() { |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
133 return (pixelSize != null) ? pixelSize.getAspect() : 0; |
d40922628e4a
Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents:
159
diff
changeset
|
134 } |
159 | 135 |
136 } |