# HG changeset patch # User robcast # Date 1292930193 -3600 # Node ID 34701340922e0f28434aec88c2199a36deacd4e4 # Parent 70c135bd17aaa9e67243c6e1ffb735157f101c03 more starting stream support diff -r 70c135bd17aa -r 34701340922e servlet/src/digilib/io/ImageFile.java --- a/servlet/src/digilib/io/ImageFile.java Tue Dec 21 10:05:54 2010 +0100 +++ b/servlet/src/digilib/io/ImageFile.java Tue Dec 21 12:16:33 2010 +0100 @@ -29,7 +29,7 @@ /** * @author casties */ -public class ImageFile implements ImageInput { +public class ImageFile extends ImageInput { // file name private String filename = null; @@ -37,10 +37,6 @@ private ImageFileset parent = null; // parent directory private Directory dir = null; - // mime file type - private String mimetype = null; - // image size in pixels - private ImageSize pixelSize = null; public ImageFile(String fn, ImageFileset parent, Directory dir) { this.filename = fn; @@ -61,11 +57,6 @@ return true; } - @Override - public boolean hasStream() { - return false; - } - /** Returns the file name (without path). * * @return @@ -87,42 +78,6 @@ return f; } - /* (non-Javadoc) - * @see digilib.io.ImageInput#getSize() - */ - @Override - public ImageSize getSize() { - return pixelSize; - } - - /* (non-Javadoc) - * @see digilib.io.ImageInput#getMimetype() - */ - @Override - public String getMimetype() { - return mimetype; - } - - /* (non-Javadoc) - * @see digilib.io.ImageInput#setSize(digilib.image.ImageSize) - */ - @Override - public void setSize(ImageSize imageSize) { - this.pixelSize = imageSize; - // pass on to parent - if (this.parent != null) { - this.parent.setAspect(imageSize); - } - } - - /* (non-Javadoc) - * @see digilib.io.ImageInput#setMimetype(java.lang.String) - */ - @Override - public void setMimetype(String filetype) { - this.mimetype = filetype; - } - /** * @return ImageFileset */ @@ -139,24 +94,14 @@ } /* (non-Javadoc) - * @see digilib.io.ImageInput#isChecked() + * @see digilib.io.ImageInput#setSize(digilib.image.ImageSize) */ - @Override - public boolean isChecked() { - return (pixelSize != null); - } - - /* (non-Javadoc) - * @see digilib.io.ImageInput#getAspect() - */ - @Override - public float getAspect() { - return (pixelSize != null) ? pixelSize.getAspect() : 0; - } - - @Override - public InputStream getStream() { - return null; + public void setSize(ImageSize imageSize) { + this.pixelSize = imageSize; + // pass on to parent + if (this.parent != null) { + this.parent.setAspect(imageSize); + } } } diff -r 70c135bd17aa -r 34701340922e servlet/src/digilib/io/ImageInput.java --- a/servlet/src/digilib/io/ImageInput.java Tue Dec 21 10:05:54 2010 +0100 +++ b/servlet/src/digilib/io/ImageInput.java Tue Dec 21 12:16:33 2010 +0100 @@ -26,62 +26,87 @@ import digilib.image.ImageSize; -public interface ImageInput { +public abstract class ImageInput { + + // mime file type + protected String mimetype = null; + // image size in pixels + protected ImageSize pixelSize = null; + + /** Returns if this ImageInput is File-based. + * @return + */ + public boolean hasFile() { + return false; + } + + /** Returns the underlying File (if applicable) + * + * @return + */ + public File getFile() { + return null; + } + + /** Returns if this ImageInput is Stream-based. + * @return + */ + public boolean hasStream() { + return false; + } + + /** Returns the underlying Stream (if applicable) + * + * @return + */ + public InputStream getStream() { + return null; + } /** * @return ImageSize */ - public abstract ImageSize getSize(); - - /** - * @return String - */ - public abstract String getMimetype(); + public ImageSize getSize() { + return pixelSize; + } /** * Sets the imageSize. * @param imageSize The imageSize to set */ - public abstract void setSize(ImageSize imageSize); + public void setSize(ImageSize imageSize) { + this.pixelSize = imageSize; + } + + /** + * @return String + */ + public String getMimetype() { + return mimetype; + } /** * Sets the mimetype. * @param mimetype The mimetype to set */ - public abstract void setMimetype(String filetype); + public void setMimetype(String filetype) { + this.mimetype = filetype; + } /** returns if this image has been checked * (i.e. has size and mimetype) * @return boolean */ - public abstract boolean isChecked(); - + public boolean isChecked() { + return (pixelSize != null); + } + /** Returns the aspect ratio of the image (width/height). * * @return */ - public abstract float getAspect(); - - /** Returns if this ImageInput is File-based. - * @return - */ - public abstract boolean hasFile(); - - /** Returns the underlying File (if applicable) - * - * @return - */ - public abstract File getFile(); - - /** Returns the underlying Stream (if applicable) - * - * @return - */ - public abstract InputStream getStream(); - - /** Returns if this ImageInput is Stream-based. - * @return - */ - public abstract boolean hasStream(); + public float getAspect() { + return (pixelSize != null) ? pixelSize.getAspect() : 0; + } } \ No newline at end of file