annotate servlet/src/digilib/io/ImageFile.java @ 339:6d2032b6121d gen2_1

new directory and cache work
author robcast
date Wed, 17 Nov 2004 18:17:34 +0100
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
339
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
1 /* ImageFile.java -- digilib image file class.
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
2
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
3 Digital Image Library servlet components
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
4
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
5 Copyright (C) 2003 Robert Casties (robcast@mail.berlios.de)
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
6
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
7 This program is free software; you can redistribute it and/or modify it
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
9 Free Software Foundation; either version 2 of the License, or (at your
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
10 option) any later version.
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
11
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
12 Please read license.txt for the full details. A copy of the GPL
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
13 may be found at http://www.gnu.org/copyleft/lgpl.html
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
14
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
16 along with this program; if not, write to the Free Software
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
18
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
19 * Created on 25.02.2003
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
20 */
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
21
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
22 package digilib.io;
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
23
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
24 import java.io.File;
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
25 import java.io.IOException;
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
26
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
27 import digilib.image.ImageOps;
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
28 import digilib.image.ImageSize;
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
29
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
30 /**
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
31 * @author casties
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
32 */
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
33 public class ImageFile extends File {
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
34
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
35 private static final long serialVersionUID = 1L;
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
36
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
37 /** file mime-type */
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
38 private String mimetype = null;
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
39
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
40 /** image size in pixels */
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
41 private ImageSize pixelSize = null;
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
42
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
43 /**
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
44 * @param pathname
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
45 */
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
46 public ImageFile(String pathname) {
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
47 super(pathname);
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
48 }
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
49
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
50 /**
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
51 * @param file
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
52 */
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
53 public ImageFile(File file) {
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
54 super(file.getPath());
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
55 }
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
56
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
57 /**
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
58 * @return ImageSize
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
59 */
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
60 public ImageSize getSize() {
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
61 return pixelSize;
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
62 }
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
63
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
64 /**
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
65 * Sets the imageSize.
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
66 * @param imageSize The imageSize to set
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
67 */
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
68 public void setSize(ImageSize imageSize) {
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
69 this.pixelSize = imageSize;
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
70 }
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
71
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
72 /**
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
73 * @return String
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
74 */
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
75 public String getMimetype() {
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
76 return mimetype;
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
77 }
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
78
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
79 /**
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
80 * Sets the mimetype.
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
81 * @param mimetype The mimetype to set
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
82 */
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
83 public void setMimetype(String filetype) {
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
84 this.mimetype = filetype;
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
85 }
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
86
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
87 /**
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
88 * Checks image size.
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
89 * @throws IOException
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
90 *
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
91 */
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
92 public void check() throws IOException {
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
93 if (pixelSize != null) {
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
94 return;
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
95 }
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
96 ImageOps.checkFile(this);
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
97 }
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
98
6d2032b6121d new directory and cache work
robcast
parents:
diff changeset
99 }