# HG changeset patch
# User robcast
# Date 1293046361 -3600
# Node ID 9267cb4745f71852bcc71aa36d2da84e7d4c95ff
# Parent d3485985ea181ed762ec57757d3bedef3be89b5f# Parent 0c93c829e9fdb4d1b48a2e51c9c8c9178c45e731
Merge from HEAD
5d80f333828a2305ea0cee84f70ad42b3847249b
diff -r 0c93c829e9fd -r 9267cb4745f7 servlet/src/digilib/image/DocuImage.java
--- a/servlet/src/digilib/image/DocuImage.java Wed Dec 22 18:47:03 2010 +0100
+++ b/servlet/src/digilib/image/DocuImage.java Wed Dec 22 20:32:41 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 0c93c829e9fd -r 9267cb4745f7 servlet/src/digilib/image/DocuImageImpl.java
--- a/servlet/src/digilib/image/DocuImageImpl.java Wed Dec 22 18:47:03 2010 +0100
+++ b/servlet/src/digilib/image/DocuImageImpl.java Wed Dec 22 20:32:41 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 0c93c829e9fd -r 9267cb4745f7 servlet/src/digilib/image/ImageInfoDocuImage.java
--- a/servlet/src/digilib/image/ImageInfoDocuImage.java Wed Dec 22 18:47:03 2010 +0100
+++ b/servlet/src/digilib/image/ImageInfoDocuImage.java Wed Dec 22 20:32:41 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 0c93c829e9fd -r 9267cb4745f7 servlet/src/digilib/image/ImageJobDescription.java
--- a/servlet/src/digilib/image/ImageJobDescription.java Wed Dec 22 18:47:03 2010 +0100
+++ b/servlet/src/digilib/image/ImageJobDescription.java Wed Dec 22 20:32:41 2010 +0100
@@ -12,7 +12,8 @@
import digilib.io.FileOps;
import digilib.io.FileOps.FileClass;
import digilib.io.ImageFile;
-import digilib.io.ImageFileset;
+import digilib.io.ImageInput;
+import digilib.io.ImageSet;
import digilib.servlet.DigilibConfiguration;
import digilib.util.OptionsSet;
import digilib.util.Parameter;
@@ -36,8 +37,8 @@
DigilibConfiguration dlConfig = null;
protected static Logger logger = Logger.getLogger("digilib.servlet");
- ImageFile fileToLoad = null;
- ImageFileset fileset = null;
+ ImageInput fileToLoad = null;
+ ImageSet fileset = null;
DocuDirectory fileDir = null;
String filePath = null;
ImageSize expectedSourceSize = null;
@@ -132,14 +133,14 @@
if (mimeType == null) {
fileToLoad = getFileToLoad();
if(! fileToLoad.isChecked()){
- DigilibConfiguration.docuImageIdentify(fileToLoad);
+ DigilibConfiguration.docuImageIdentify((ImageFile) fileToLoad); //FIXME: cast to file?
}
mimeType = fileToLoad.getMimetype();
}
return mimeType;
}
- public ImageFile getFileToLoad() throws IOException {
+ public ImageInput getFileToLoad() throws IOException {
if(fileToLoad == null){
fileset = getFileset();
@@ -163,7 +164,7 @@
fileToLoad = fileset.getBiggest();
}
}
- logger.info("Planning to load: " + fileToLoad.getFile());
+ logger.info("Planning to load: " + fileToLoad);
}
return fileToLoad;
@@ -182,11 +183,11 @@
return fileDir;
}
- public ImageFileset getFileset() throws FileOpException {
+ public ImageSet getFileset() throws FileOpException {
if(fileset==null){
DocuDirCache dirCache = (DocuDirCache) dlConfig.getValue("servlet.dir.cache");
- fileset = (ImageFileset) dirCache.getFile(getFilePath(), getAsInt("pn"), FileClass.IMAGE);
+ fileset = (ImageSet) dirCache.getFile(getFilePath(), getAsInt("pn"), FileClass.IMAGE);
if (fileset == null) {
throw new FileOpException("File " + getFilePath() + "("
+ getAsInt("pn") + ") not found.");
@@ -245,11 +246,11 @@
logger.debug("get_hiresSize()");
ImageSize hiresSize = null;
- ImageFileset fileset = getFileset();
+ ImageSet fileset = getFileset();
if (getAbsoluteScale()) {
- ImageFile hiresFile = fileset.getBiggest();
+ ImageInput hiresFile = fileset.getBiggest();
if (!hiresFile.isChecked()) {
- DigilibConfiguration.docuImageIdentify(hiresFile);
+ DigilibConfiguration.docuImageIdentify((ImageFile) hiresFile); //FIXME: cast to file?
}
hiresSize = hiresFile.getSize();
}
diff -r 0c93c829e9fd -r 9267cb4745f7 servlet/src/digilib/image/ImageLoaderDocuImage.java
--- a/servlet/src/digilib/image/ImageLoaderDocuImage.java Wed Dec 22 18:47:03 2010 +0100
+++ b/servlet/src/digilib/image/ImageLoaderDocuImage.java Wed Dec 22 20:32:41 2010 +0100
@@ -50,7 +50,8 @@
import digilib.io.FileOpException;
import digilib.io.FileOps;
import digilib.io.ImageFile;
-import digilib.io.ImageFileset;
+import digilib.io.ImageSet;
+import digilib.io.ImageInput;
/** Implementation of DocuImage using the ImageLoader API of Java 1.4 and Java2D. */
public class ImageLoaderDocuImage extends ImageInfoDocuImage {
@@ -119,14 +120,14 @@
}
/** 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;
}
// fileset to store the information
- ImageFileset imgfs = imageFile.getParent();
+ ImageSet imgfs = imageFile.getParent();
File f = imageFile.getFile();
if (f == null) {
throw new IOException("File not found!");
diff -r 0c93c829e9fd -r 9267cb4745f7 servlet/src/digilib/image/ImageWorker.java
--- a/servlet/src/digilib/image/ImageWorker.java Wed Dec 22 18:47:03 2010 +0100
+++ b/servlet/src/digilib/image/ImageWorker.java Wed Dec 22 20:32:41 2010 +0100
@@ -10,6 +10,7 @@
import org.apache.log4j.Logger;
import digilib.io.FileOpException;
+import digilib.io.ImageFile;
import digilib.servlet.DigilibConfiguration;
/** Worker that renders an image.
@@ -70,7 +71,7 @@
+ scaleXY);
}
- docuImage.loadSubimage(jobinfo.getFileToLoad(), loadRect, (int) subsamp);
+ docuImage.loadSubimage((ImageFile) jobinfo.getFileToLoad(), loadRect, (int) subsamp); //FIXME: cast to file
logger.debug("SUBSAMP: " + subsamp + " -> " + docuImage.getSize());
@@ -78,7 +79,7 @@
} else {
// else load and crop the whole file
- docuImage.loadImage(jobinfo.getFileToLoad());
+ docuImage.loadImage((ImageFile) jobinfo.getFileToLoad()); //FIXME: cast to file
docuImage.crop((int) loadRect.getX(), (int) loadRect.getY(),
(int) loadRect.getWidth(), (int) loadRect.getHeight());
diff -r 0c93c829e9fd -r 9267cb4745f7 servlet/src/digilib/image/JAIDocuImage.java
--- a/servlet/src/digilib/image/JAIDocuImage.java Wed Dec 22 18:47:03 2010 +0100
+++ b/servlet/src/digilib/image/JAIDocuImage.java Wed Dec 22 20:32:41 2010 +0100
@@ -47,7 +47,8 @@
import digilib.io.FileOpException;
import digilib.io.FileOps;
import digilib.io.ImageFile;
-import digilib.io.ImageFileset;
+import digilib.io.ImageSet;
+import digilib.io.ImageInput;
/** A DocuImage implementation using Java Advanced Imaging Library. */
/**
@@ -104,14 +105,14 @@
}
/* 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;
}
// fileset to store the information
- ImageFileset imgfs = imageFile.getParent();
+ ImageSet imgfs = imageFile.getParent();
File f = imageFile.getFile();
if (f == null) {
throw new IOException("File not found!");
diff -r 0c93c829e9fd -r 9267cb4745f7 servlet/src/digilib/io/DocuDirectory.java
--- a/servlet/src/digilib/io/DocuDirectory.java Wed Dec 22 18:47:03 2010 +0100
+++ b/servlet/src/digilib/io/DocuDirectory.java Wed Dec 22 20:32:41 2010 +0100
@@ -40,9 +40,6 @@
/** list of files (DocuDirent) */
private List> list = null;
- /** default FileClass for unspecified calls */
- public static FileClass defaultFileClass = FileClass.IMAGE;
-
/** directory object is valid (exists on disk) */
private boolean isValid = false;
@@ -111,7 +108,7 @@
*
*/
public int size() {
- return size(defaultFileClass);
+ return ((list != null) && (list.get(0) != null)) ? list.get(0).size() : 0;
}
/**
@@ -121,13 +118,7 @@
* fileClass
*/
public int size(FileClass fc) {
- if (list != null) {
- List l = list.get(fc.ordinal());
- if (l != null) {
- return l.size();
- }
- }
- return 0;
+ return ((list != null) && (list.get(fc.ordinal()) != null)) ? list.get(fc.ordinal()).size() : 0;
}
/**
@@ -136,8 +127,11 @@
* @param index
* @return
*/
- public ImageFileset get(int index) {
- return (ImageFileset) get(index, defaultFileClass);
+ public ImageSet get(int index) {
+ if ((list == null) || (list.get(0) == null) || (index >= list.get(0).size())) {
+ return null;
+ }
+ return (ImageSet) list.get(0).get(index);
}
/**
@@ -456,8 +450,8 @@
return -1;
}
- private boolean isBasenameInList(List fl, int idx, String fn) {
- String dfn = FileOps.basename((fl.get(idx))
+ private boolean isBasenameInList(List fileList, int idx, String fn) {
+ String dfn = FileOps.basename((fileList.get(idx))
.getName());
return (dfn.equals(fn)||dfn.equals(FileOps.basename(fn)));
}
@@ -474,7 +468,12 @@
* @return DocuDirent
*/
public DocuDirent find(String fn) {
- return find(fn, defaultFileClass);
+ FileClass fc = FileOps.classForFilename(fn);
+ int i = indexOf(fn, fc);
+ if (i >= 0) {
+ return (DocuDirent) list.get(0).get(i);
+ }
+ return null;
}
/**
diff -r 0c93c829e9fd -r 9267cb4745f7 servlet/src/digilib/io/DocuDirent.java
--- a/servlet/src/digilib/io/DocuDirent.java Wed Dec 22 18:47:03 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,169 +0,0 @@
-/*
- * DocuDirent.java -- Abstract directory entry in a DocuDirectory
- *
- * Digital Image Library servlet components
- *
- * Copyright (C) 2003 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 15.09.2003 by casties
- *
- */
-package digilib.io;
-
-import java.io.File;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-
-import digilib.io.FileOps.FileClass;
-
-/**
- * Abstract directory entry in a DocuDirectory.
- *
- * @author casties
- *
- */
-public abstract class DocuDirent implements Comparable