# HG changeset patch
# User robcast
# Date 1293008074 -3600
# Node ID 68d91d23d7f69193fa78e7cd8410b5e7f430c1ff
# Parent a43dcac4163c7425ae42ff7cab3fdc63cc13386c# Parent 8dfa2d88ba3edfad2e35f2edb1983dad20b8ec45
Merge from HEAD
fd2ef7e461198ef4a9d9a02459be2057038d600d
diff -r 8dfa2d88ba3e -r 68d91d23d7f6 servlet/src/digilib/image/DocuImage.java
--- a/servlet/src/digilib/image/DocuImage.java Tue Dec 21 20:24:09 2010 +0100
+++ b/servlet/src/digilib/image/DocuImage.java Wed Dec 22 09:54:34 2010 +0100
@@ -29,6 +29,7 @@
import digilib.io.ImageFile;
import digilib.io.FileOpException;
+import digilib.io.ImageInput;
/** The basic class for the representation of a digilib image.
*
@@ -46,7 +47,7 @@
*/
public void loadImage(ImageFile f) throws FileOpException;
- /** This DocuImage support the loadSubImage operation.
+ /** This DocuImage supports the loadSubImage operation.
*
* @return boolean
*/
@@ -223,7 +224,7 @@
/**
* Check image size and type and store in ImageFile f
*/
- public ImageFile identify(ImageFile imgf) throws IOException;
+ public ImageInput identify(ImageFile imgf) throws IOException;
/**
* Returns a list of supported image formats
diff -r 8dfa2d88ba3e -r 68d91d23d7f6 servlet/src/digilib/image/DocuImageImpl.java
--- a/servlet/src/digilib/image/DocuImageImpl.java Tue Dec 21 20:24:09 2010 +0100
+++ b/servlet/src/digilib/image/DocuImageImpl.java Wed Dec 22 09:54:34 2010 +0100
@@ -34,6 +34,7 @@
import digilib.io.FileOpException;
import digilib.io.ImageFile;
+import digilib.io.ImageInput;
/** Simple abstract implementation of the DocuImage
interface.
*
@@ -106,7 +107,7 @@
/* (non-Javadoc)
* @see digilib.image.DocuImage#identify(digilib.io.ImageFile)
*/
- public ImageFile identify(ImageFile imgf) throws IOException {
+ public ImageInput identify(ImageFile imgf) throws IOException {
// just a do-nothing implementation
return null;
}
diff -r 8dfa2d88ba3e -r 68d91d23d7f6 servlet/src/digilib/image/ImageInfoDocuImage.java
--- a/servlet/src/digilib/image/ImageInfoDocuImage.java Tue Dec 21 20:24:09 2010 +0100
+++ b/servlet/src/digilib/image/ImageInfoDocuImage.java Wed Dec 22 09:54:34 2010 +0100
@@ -10,6 +10,7 @@
import org.marcoschmidt.image.ImageInfo;
import digilib.io.ImageFile;
+import digilib.io.ImageInput;
/** Simple abstract implementation of the DocuImage
interface.
* Implements only the identify method using the ImageInfo class.
@@ -19,7 +20,7 @@
public abstract class ImageInfoDocuImage extends DocuImageImpl {
/** Check image size and type and store in ImageFile f */
- public ImageFile identify(ImageFile imgf) throws IOException {
+ public ImageInput identify(ImageFile imgf) throws IOException {
// fileset to store the information
File f = imgf.getFile();
if (f == null) {
diff -r 8dfa2d88ba3e -r 68d91d23d7f6 servlet/src/digilib/image/ImageLoaderDocuImage.java
--- a/servlet/src/digilib/image/ImageLoaderDocuImage.java Tue Dec 21 20:24:09 2010 +0100
+++ b/servlet/src/digilib/image/ImageLoaderDocuImage.java Wed Dec 22 09:54:34 2010 +0100
@@ -51,6 +51,7 @@
import digilib.io.FileOps;
import digilib.io.ImageFile;
import digilib.io.ImageFileset;
+import digilib.io.ImageInput;
/** Implementation of DocuImage using the ImageLoader API of Java 1.4 and Java2D. */
public class ImageLoaderDocuImage extends ImageInfoDocuImage {
@@ -119,9 +120,9 @@
}
/** Check image size and type and store in ImageFile f */
- public ImageFile identify(ImageFile imageFile) throws IOException {
+ public ImageInput identify(ImageFile imageFile) throws IOException {
// try parent method first
- ImageFile imf = super.identify(imageFile);
+ ImageInput imf = super.identify(imageFile);
if (imf != null) {
return imf;
}
diff -r 8dfa2d88ba3e -r 68d91d23d7f6 servlet/src/digilib/image/JAIDocuImage.java
--- a/servlet/src/digilib/image/JAIDocuImage.java Tue Dec 21 20:24:09 2010 +0100
+++ b/servlet/src/digilib/image/JAIDocuImage.java Wed Dec 22 09:54:34 2010 +0100
@@ -48,6 +48,7 @@
import digilib.io.FileOps;
import digilib.io.ImageFile;
import digilib.io.ImageFileset;
+import digilib.io.ImageInput;
/** A DocuImage implementation using Java Advanced Imaging Library. */
/**
@@ -104,9 +105,9 @@
}
/* Check image size and type and store in ImageFile f */
- public ImageFile identify(ImageFile imageFile) throws IOException {
+ public ImageInput identify(ImageFile imageFile) throws IOException {
// try parent method first
- ImageFile imf = super.identify(imageFile);
+ ImageInput imf = super.identify(imageFile);
if (imf != null) {
return imf;
}
diff -r 8dfa2d88ba3e -r 68d91d23d7f6 servlet/src/digilib/io/ImageFile.java
--- a/servlet/src/digilib/io/ImageFile.java Tue Dec 21 20:24:09 2010 +0100
+++ b/servlet/src/digilib/io/ImageFile.java Wed Dec 22 09:54:34 2010 +0100
@@ -22,13 +22,14 @@
package digilib.io;
import java.io.File;
+import java.io.InputStream;
import digilib.image.ImageSize;
/**
* @author casties
*/
-public class ImageFile {
+public class ImageFile extends ImageInput {
// file name
private String filename = null;
@@ -36,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;
@@ -53,6 +50,13 @@
this.filename = f.getName();
}
+
+ @Override
+ public boolean hasFile() {
+ // this is File-based
+ return true;
+ }
+
/** Returns the file name (without path).
*
* @return
@@ -65,6 +69,7 @@
/**
* @return File
*/
+ @Override
public File getFile() {
if (dir == null) {
return null;
@@ -74,40 +79,6 @@
}
/**
- * @return ImageSize
- */
- public ImageSize getSize() {
- return pixelSize;
- }
-
- /**
- * @return String
- */
- public String getMimetype() {
- return mimetype;
- }
-
- /**
- * Sets the imageSize.
- * @param imageSize The imageSize to set
- */
- public void setSize(ImageSize imageSize) {
- this.pixelSize = imageSize;
- // pass on to parent
- if (this.parent != null) {
- this.parent.setAspect(imageSize);
- }
- }
-
- /**
- * Sets the mimetype.
- * @param mimetype The mimetype to set
- */
- public void setMimetype(String filetype) {
- this.mimetype = filetype;
- }
-
- /**
* @return ImageFileset
*/
public ImageFileset getParent() {
@@ -122,19 +93,15 @@
this.parent = parent;
}
- /**
- * @return boolean
+ /* (non-Javadoc)
+ * @see digilib.io.ImageInput#setSize(digilib.image.ImageSize)
*/
- public boolean isChecked() {
- return (pixelSize != null);
- }
-
- /** Returns the aspect ratio of the image (width/height).
- *
- * @return
- */
- public float getAspect() {
- return (pixelSize != null) ? pixelSize.getAspect() : 0;
+ public void setSize(ImageSize imageSize) {
+ this.pixelSize = imageSize;
+ // pass on to parent
+ if (this.parent != null) {
+ this.parent.setAspect(imageSize);
+ }
}
}
diff -r 8dfa2d88ba3e -r 68d91d23d7f6 servlet/src/digilib/io/ImageInput.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/servlet/src/digilib/io/ImageInput.java Wed Dec 22 09:54:34 2010 +0100
@@ -0,0 +1,112 @@
+/* ImageInput-- digilib image input interface.
+
+ Digital Image Library servlet components
+
+ Copyright (C) 2010 Robert Casties (robcast@mail.berlios.de)
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ Please read license.txt for the full details. A copy of the GPL
+ may be found at http://www.gnu.org/copyleft/lgpl.html
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ * Created on 20.12.2010
+ */
+
+package digilib.io;
+
+import java.io.File;
+import java.io.InputStream;
+
+import digilib.image.ImageSize;
+
+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 ImageSize getSize() {
+ return pixelSize;
+ }
+
+ /**
+ * Sets the imageSize.
+ * @param imageSize The imageSize to set
+ */
+ 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 void setMimetype(String filetype) {
+ this.mimetype = filetype;
+ }
+
+ /** returns if this image has been checked
+ * (i.e. has size and mimetype)
+ * @return boolean
+ */
+ public boolean isChecked() {
+ return (pixelSize != null);
+ }
+
+ /** Returns the aspect ratio of the image (width/height).
+ *
+ * @return
+ */
+ public float getAspect() {
+ return (pixelSize != null) ? pixelSize.getAspect() : 0;
+ }
+
+}
\ No newline at end of file
diff -r 8dfa2d88ba3e -r 68d91d23d7f6 servlet/src/digilib/servlet/DigilibConfiguration.java
--- a/servlet/src/digilib/servlet/DigilibConfiguration.java Tue Dec 21 20:24:09 2010 +0100
+++ b/servlet/src/digilib/servlet/DigilibConfiguration.java Wed Dec 22 09:54:34 2010 +0100
@@ -36,6 +36,7 @@
import digilib.image.DocuImageImpl;
import digilib.io.FileOps;
import digilib.io.ImageFile;
+import digilib.io.ImageInput;
import digilib.io.XMLListLoader;
import digilib.util.Parameter;
import digilib.util.ParameterMap;
@@ -277,7 +278,7 @@
* @return
* @throws IOException
*/
- public static ImageFile docuImageIdentify(ImageFile imgf) throws IOException {
+ public static ImageInput docuImageIdentify(ImageFile imgf) throws IOException {
// use fresh DocuImage instance
DocuImage di = getDocuImageInstance();
return di.identify(imgf);
diff -r 8dfa2d88ba3e -r 68d91d23d7f6 servlet/src/digilib/servlet/Scaler.java
--- a/servlet/src/digilib/servlet/Scaler.java Tue Dec 21 20:24:09 2010 +0100
+++ b/servlet/src/digilib/servlet/Scaler.java Wed Dec 22 09:54:34 2010 +0100
@@ -32,7 +32,7 @@
public class Scaler extends HttpServlet {
/** digilib servlet version (for all components) */
- public static final String version = "1.8.2a";
+ public static final String version = "1.9.0a";
/** servlet error codes */
public static enum Error {UNKNOWN, AUTH, FILE, IMAGE};