Mercurial > hg > digilib-old
changeset 568:34701340922e stream
more starting stream support
author | robcast |
---|---|
date | Tue, 21 Dec 2010 12:16:33 +0100 |
parents | 70c135bd17aa |
children | beeedf90cb81 |
files | servlet/src/digilib/io/ImageFile.java servlet/src/digilib/io/ImageInput.java |
diffstat | 2 files changed, 67 insertions(+), 97 deletions(-) [+] |
line wrap: on
line diff
--- 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); + } } }
--- 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