comparison servlet/src/digilib/io/ImageFile.java @ 585:95417c4615b8 stream

more cleanup for ImageFileSet
author robcast
date Wed, 05 Jan 2011 14:41:28 +0100
parents 7357ad8f9f42
children aee436f0549d
comparison
equal deleted inserted replaced
583:7357ad8f9f42 585:95417c4615b8
20 */ 20 */
21 21
22 package digilib.io; 22 package digilib.io;
23 23
24 import java.io.File; 24 import java.io.File;
25 import java.io.IOException;
25 26
26 import digilib.image.ImageSize; 27 import digilib.image.ImageSize;
28 import digilib.servlet.DigilibConfiguration;
27 29
28 /** 30 /**
29 * @author casties 31 * @author casties
30 */ 32 */
31 public class ImageFile extends ImageInput { 33 public class ImageFile extends ImageInput {
62 this.dir = dir; 64 this.dir = dir;
63 this.file = new File(this.dir.getDir(), fn); 65 this.file = new File(this.dir.getDir(), fn);
64 this.parent = parent; 66 this.parent = parent;
65 } 67 }
66 68
67 /** Returns the file name (without path). 69
70 /** Checks the image and sets size and type.
71 *
72 */
73 public void check() {
74 if (pixelSize == null) {
75 try {
76 // use the configured toolkit to identify the image
77 DigilibConfiguration.identifyDocuImage(this);
78 } catch (IOException e) {
79 // nothing much to do...
80 }
81 }
82 }
83
84 /* (non-Javadoc)
85 * @see digilib.io.ImageInput#getSize()
86 */
87 @Override
88 public ImageSize getSize() {
89 check();
90 return pixelSize;
91 }
92
93 /* (non-Javadoc)
94 * @see digilib.io.ImageInput#getMimetype()
95 */
96 @Override
97 public String getMimetype() {
98 check();
99 return mimetype;
100 }
101
102 /* (non-Javadoc)
103 * @see digilib.io.ImageInput#getAspect()
104 */
105 @Override
106 public float getAspect() {
107 check();
108 return (pixelSize != null) ? pixelSize.getAspect() : 0f;
109 }
110
111 /** Returns the file name (without path).
68 * 112 *
69 * @return 113 * @return
70 */ 114 */
71 public String getName() { 115 public String getName() {
72 return name; 116 return name;
73 } 117 }
74
75 118
76 /** 119 /**
77 * @return File 120 * @return File
78 */ 121 */
79 public File getFile() { 122 public File getFile() {