Mercurial > hg > digilib-old
changeset 570:fd2ef7e46119
more cleanup, set version to 1.8.2
author | robcast |
---|---|
date | Tue, 21 Dec 2010 20:24:09 +0100 |
parents | 1f666c2b4578 |
children | 6e8488acb499 beeedf90cb81 |
files | client/digitallibrary/WEB-INF/classes/info.txt client/digitallibrary/contexto/contexto.jsp client/digitallibrary/digilib-new.html client/digitallibrary/dlContext-xml.jsp client/digitallibrary/modules/cm_separator.gif client/digitallibrary/modules/imago.js client/digitallibrary/modules/newReferences.js client/digitallibrary/relato/astro.xml client/digitallibrary/relato/blank.html client/digitallibrary/relato/compare.xml client/digitallibrary/relato/digicat-digilib.xml client/digitallibrary/relato/digilib-digilib.xml client/digitallibrary/relato/neugebauer.xml client/digitallibrary/relato/picture.xml client/digitallibrary/relato/relato.js client/digitallibrary/relato/relato.xsl client/digitallibrary/relato/type.xml client/digitallibrary/relato/work.xml client/digitallibrary/xul/alcatraz.xpi client/digitallibrary/xul/install.html servlet/src/digilib/image/DocuImage.java servlet/src/digilib/image/DocuImageImpl.java servlet/src/digilib/image/ImageLoaderDocuImage.java servlet/src/digilib/image/ImageWorker.java servlet/src/digilib/image/JAIDocuImage.java servlet/src/digilib/image/JAIImageLoaderDocuImage.java servlet/src/digilib/pdf/PDFFileWorker.java servlet/src/digilib/servlet/PDFCache.java servlet/src/digilib/servlet/Scaler.java servlet/src/digilib/servlet/ServletOps.java servlet/src/digilib/servlet/Texter.java servlet/src/digilib/util/DigilibJobCenter.java |
diffstat | 32 files changed, 189 insertions(+), 2148 deletions(-) [+] |
line wrap: on
line diff
--- a/client/digitallibrary/WEB-INF/classes/info.txt Tue Dec 21 09:52:16 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -# hier zusaetzliche klassen zum kompilieren, diese muessen im laufenden -# tomcat system in WEB-INF/lib sein. - -export CLASSPATH=$CLASSPATH:/opt/javalibs/xerces/xercesImpl.jar:/opt/javalibs/xerces/xml-apis.jar:/opt/javalibs/xalan/bin/xalan.jar:/opt/tomcat/common/lib/servlet-api.jar
--- a/client/digitallibrary/contexto/contexto.jsp Tue Dec 21 09:52:16 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -<%@ page language="java" %> -<%@ page import="java.io.*" %> -<%@ page import="java.net.*" %> - -<% - digilib.servlet.DigilibRequest dlRequest = new digilib.servlet.DigilibRequest(); - dlRequest.setWithRequest(request); - -%> - -<% - // Possible parameters - String htmlPage = request.getParameter("htmlPage"); - // neu eingebaut - christian - // @beat: kannst du das zeugs bitte checken und mir sagen, ob du - // dagegen bist oder nicht. es ist ein uebler hack, der keine - // kontrollmechanismen hat, aber im moment halt meinen anspruechen - // genuegt. (den import von java.net.* ist auch von mir) - String htmlURL = request.getParameter("htmlURL"); - String xmlURL = request.getParameter("xmlURL"); - String xslURL = request.getParameter("xslURL"); - String fileName = request.getParameter("fn"); - String pageNumber = request.getParameter("pn"); - - // funcktioniert leider nicht - christian - //System.setProperty("http.proxyHost", "proxy.unibe.ch"); - //System.setProperty("http.proxyPort", "8080"); - - if(htmlPage != null) { - response.getWriter().println(htmlPage); - // neue parameterart eingebaut - christian - } else if(htmlURL != null) { - try { - URL u = new URL(htmlURL); - String content_type = u.openConnection().getContentType(); - InputStream is = u.openStream(); - InputStreamReader isr = new InputStreamReader(is); - BufferedReader br = new BufferedReader(isr); - //response.setContentType(content_type); - String aLine; - while ((aLine = br.readLine()) != null) { - response.getWriter().println(aLine); - } - } catch (Exception e) { - response.getWriter().println(e); - } - } else if((xmlURL != null) && (xslURL != null)) { - out.println("xsl"); - response.sendRedirect("http://sophia.unibe.ch:8080/xslt/ApplyXSLT?URL="+ xmlURL + "&xslURL=" + xslURL); - } else if(fileName != null && pageNumber != null) { - response.sendRedirect("http://hera.unibe.ch:8080/alcatraz/servlet/Texter?fn=" + fileName + "&pn=" + pageNumber); - } -%>
--- a/client/digitallibrary/digilib-new.html Tue Dec 21 09:52:16 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,366 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/transitional.dtd"> - -<html xmlns="http://www.w3.org/1999/xhtml"> - -<head> - <title>The new digilib</title> - <meta name="author" content="Martin Raspe" /> - <meta name="date" content="07.12.2005, 19:14 h" /> - <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1" /> - - <style type="text/css"> - body { background-color: #E0E0E0; color: black; font-size: 8pt } - code { font-family: monospace; color: blue; } - pre { color: #006060; } - img.png { border: none; } - a.icon { margin: 0px; padding: 0px; } - div.button { margin: -4px; padding: 0px; } - - </style> - - <script language="JavaScript" src="baselib.js"></script> - - <script language="JavaScript" src="dllib.js"></script> - - <script language="JavaScript"> - - function highlightPNG(id, on) { - var elem = document.getElementById(id); - //var div = elem.parentNode.parentNode; - elem.style.backgroundImage = on - ? "url('corona.png')" - : null; - } - - </script> -</head> - -<body> - -<div id="buttons"> - <div class="button"> - <a - class="icon" - href="javascript:showOptions(0);setMark()" - > - - <img - class="png" - id="mark" - onmouseover="highlightPNG('mark', 1)" - onmouseout="highlightPNG('mark', 0)" - title="set a mark" - src="greyskin\mark.png" - > - </a> - </div> - - <div class="button"> - <a - class="icon" - href="javascript:removeMark()" - > - - <img - class="png" - id="delmark" - onmouseover="highlightPNG('delmark', 1)" - onmouseout="highlightPNG('delmark', 0)" - title="delete the last mark" - src="greyskin\delmark.png" - > - </a> - </div> - - <div class="button"> - <a - class="icon" - href="javascript:getRefWin()" - > - - <img - class="png" - id="reference" - onmouseover="highlightPNG('reference', 1)" - onmouseout="highlightPNG('reference', 0)" - title="get a reference URL" - src="greyskin\reference.png" - > - </a> - </div> - - <div class="button"> - <a - class="icon" - href="javascript:zoomBy(1.4)" - > - - <img - class="png" - id="zoom-in" - onmouseover="highlightPNG('zoom-in', 1)" - onmouseout="highlightPNG('zoom-in', 0)" - title="zoom in" - src="greyskin\zoom-in.png" - > - </a> - </div> - - <div class="button"> - <a - class="icon" - href="javascript:zoomBy(0.7)" - > - - <img - class="png" - id="zoom-out" - onmouseover="highlightPNG('zoom-out', 1)" - onmouseout="highlightPNG('zoom-out', 0)" - title="zoom out" - src="greyskin\zoom-out.png" - > - </a> - </div> - - <div class="button"> - <a - class="icon" - href="javascript:showOptions(0);zoomArea()" - > - - <img - class="png" - id="zoom-area" - onmouseover="highlightPNG('zoom-area', 1)" - onmouseout="highlightPNG('zoom-area', 0)" - title="zoom area" - src="greyskin\zoom-area.png" - > - </a> - </div> - - <div class="button"> - <a - class="icon" - href="javascript:zoomFullpage()" - > - - <img - class="png" - id="zoom-full" - onmouseover="highlightPNG('zoom-full', 1)" - onmouseout="highlightPNG('zoom-full', 0)" - title="view the whole image" - src="greyskin\zoom-full.png" - > - </a> - </div> - - <div class="button"> - <a - class="icon" - href="javascript:mirror('h')" - > - - <img - class="png" - id="mirror-h" - onmouseover="highlightPNG('mirror-h', 1)" - onmouseout="highlightPNG('mirror-h', 0)" - title="mirror horizontally" - src="greyskin\mirror-horizontal.png" - > - </a> - </div> - - <div class="button"> - <a - class="icon" - href="javascript:mirror('v')" - > - - <img - class="png" - id="mirror-v" - onmouseover="highlightPNG('mirror-v', 1)" - onmouseout="highlightPNG('mirror-v', 0)" - title="mirror vertically" - src="greyskin\mirror-vertical.png" - > - </a> - </div> - - <div class="button"> - <a - class="icon" - href="javascript:setParamWin('rot', 'Rotate (0..360) clockwise')" - > - - <img - class="png" - id="rotate" - onmouseover="highlightPNG('rotate', 1)" - onmouseout="highlightPNG('rotate', 0)" - title="rotate image" - src="greyskin\rotate.png" - > - </a> - </div> - - <div class="button"> - <a - class="icon" - href="javascript:setParamWin('brgt', 'Brightness (-255..255)')" - > - - <img - class="png" - id="brightness" - onmouseover="highlightPNG('brightness', 1)" - onmouseout="highlightPNG('brightness', 0)" - title="set brightness" - src="greyskin\brightness.png" - > - </a> - </div> - - <div class="button"> - <a - class="icon" - href="javascript:setParamWin('cont', 'Contrast (0..8)')" - > - - <img - class="png" - id="contrast" - onmouseover="highlightPNG('contrast', 1)" - onmouseout="highlightPNG('contrast', 0)" - title="set contrast" - src="greyskin\contrast.png" - > - </a> - </div> - - <div class="button"> - <a - class="icon" - href="javascript:setParamWin('rgb', '...')" - > - - <img - class="png" - id="rgb" - onmouseover="highlightPNG('rgb', 1)" - onmouseout="highlightPNG('rgb', 0)" - title="set rgb values" - src="greyskin\rgb.png" - > - </a> - </div> - - <div class="button"> - <a - class="icon" - href="javascript:setParamWin('size', '...')" - > - - <img - class="png" - id="size" - onmouseover="highlightPNG('size', 1)" - onmouseout="highlightPNG('size', 0)" - title="resize page" - src="greyskin\size.png" - > - </a> - </div> - - <div class="button"> - <a - class="icon" - href="javascript:setQualityWin('Quality (0..2)')" - > - - <img - class="png" - id="quality" - onmouseover="highlightPNG('quality', 1)" - onmouseout="highlightPNG('quality', 0)" - title="set image quality" - src="greyskin\quality.png" - > - </a> - </div> - - <div class="button"> - <a - class="icon" - href="javascript:gotoPage('-1')" - > - - <img - class="png" - id="back" - onmouseover="highlightPNG('back', 1)" - onmouseout="highlightPNG('back', 0)" - title="goto previous image" - src="greyskin\back.png" - > - </a> - </div> - - <div class="button"> - <a - class="icon" - href="javascript:gotoPage('+1')" - > - - <img - class="png" - id="fwd" - onmouseover="highlightPNG('fwd', 1)" - onmouseout="highlightPNG('fwd', 0)" - title="goto next image" - src="greyskin\fwd.png" - > - </a> - </div> - - <div class="button"> - <a - class="icon" - href="javascript:gotoPageWin()" - > - - <img - class="png" - id="page" - onmouseover="highlightPNG('page', 1)" - onmouseout="highlightPNG('page', 0)" - title="specify image" - src="greyskin\page.png" - > - </a> - </div> - - <div class="button"> - <a - class="icon" - href="javascript:help()" - > - - <img - class="png" - id="help" - onmouseover="highlightPNG('help', 1)" - onmouseout="highlightPNG('help', 0)" - title="help" - src="greyskin\help.png" - > - </a> - </div> - -</div> - -</body> \ No newline at end of file
--- a/client/digitallibrary/dlContext-xml.jsp Tue Dec 21 09:52:16 2010 +0100 +++ b/client/digitallibrary/dlContext-xml.jsp Tue Dec 21 20:24:09 2010 +0100 @@ -27,7 +27,7 @@ int pn = dlRequest.getAsInt("pn"); String fn = dlRequest.getFilePath(); String ctx = ""; -digilib.io.DocuDirent f = dirCache.getFile(fn, pn, digilib.io.FileOps.CLASS_IMAGE); +digilib.io.DocuDirent f = dirCache.getFile(fn, pn, digilib.io.FileOps.FileClass.IMAGE); if (f != null) { //ctx = "hasfile:"+f.getName(); f.checkMeta();
--- a/client/digitallibrary/modules/imago.js Tue Dec 21 09:52:16 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,441 +0,0 @@ -/* - -Copyright (C) 2003 WTWG, Uni Bern - -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. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -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 - -Author: Christian Luginbuehl, 22.05.2003 , Version Alcatraz 0.4 - -*/ - -/************************************************************************* - * imago.js : digilib-module * - * * - * desc: adds different image manipulation functions. * - * * - *************************************************************************/ - - -/** - * brightness (value of brightness between -255 - +255) - */ -function brightness(value) { - - if ( (value >= -255) && (value <= 255) ) { - - dlParams.brgt.value = value; - display(3); - - } - -} - - -/** - * contrast (value of contrast - range?) - */ -function contrast(value) { - - dlParams.cont.value = parseFloat(value); - display(3); - -} - - -/** - * brightness/contrast in one call - */ -function brightnessContrast(brightness, contrast) { - - dlParams.cont.value = parseFloat(contrast); - - if ( (brightness >= -255) && (brightness <= 255) ) { - - dlParams.brgt.value = parseFloat(brightness); - display(3); - - } - -} - - -/** - * mirror (horizontal or vertical) - */ -function mirror(direction) { - - if ( direction == 'v' ) { - if ( dlParams.mo.value.indexOf('vmir') > -1 ) { - removeMoFlag('vmir'); - } else { - addMoFlag('vmir'); - } - } - - if ( direction == 'h' ) { - if ( dlParams.mo.value.indexOf('hmir') > -1 ) { - removeMoFlag('hmir'); - } else { - addMoFlag('hmir'); - } - } - - display(3); - -} - - -/** - * rotation - */ -function rotation(value) { - - value = parseFloat(value) % 360; - - if ( value < 0 ) { - value += 360; - } - - dlParams.rot.value = value; - display(3); - -} - - -/** - * rgb add (r/g/b, each value from -255 to +255) - */ -function rgba(value) { - - values = value.split("/"); - - if ( values.length != 3 ) { - alert ("Illegal parameter format (r/g/b)"); - } else if ( (values[0] < -255) || (values[0] > 255) ) { - alert ("Illegal red additioner (-255 to 255)"); - } else if ( (values[1] < -255) || (values[1] > 255) ) { - alert ("Illegal green additioner (-255 to 255)"); - } else if ( (values[2] < -255) || (values[2] > 255) ) { - alert ("Illegal blue additioner (-255 to 255)"); - } else { - - dlParams.rgba.value = value; - display(3); - - } -} - - -/** - * rgb mutiply (r/g/b, range?) - */ -function rgbm(value) { - - values = value.split("/"); - - if ( values.length != 3 ) { - alert ("Illegal parameter format (r/g/b)"); - } else if ( !isFinite(values[0]) ) { - alert ("Illegal red exponent"); - } else if ( !isFinite(values[1]) ) { - alert ("Illegal green exponent"); - } else if ( !isFinite(values[2]) ) { - alert ("Illegal blue exponent"); - } else { - - dlParams.rgbm.value = value; - display(3); - - } -} - - -/** - * rgba/rgbm in one call - */ -function colors(rgba, rgbm) { - - add = rgba.split("/"); - mult = rgba.split("/"); - - if ( (add.length) == 3 && (mult.length == 3) && - (add[0] >= -255) && (add[0] <= 255) && - (add[1] >= -255) && (add[1] <= 255) && - (add[2] >= -255) && (add[2] <= 255) && - (isFinite(mult[0])) && - (isFinite(mult[1])) && - (isFinite(mult[2])) ) { - - dlParams.rgba.value = rgba; - dlParams.rgbm.value = rgbm; - - display(3); - - } -} - - -/** - * pixel by pixel view of images - */ -function pixelByPixel() { - - removeMoFlag('osize'); - - addMoFlag('clip'); - - // change scale to 1 - dlParams.ws.value = 1.0; - - display(3); - -} - - -/** - * original size view of images - */ -function originalSize(dpi_v, dpi_h) { - - removeMoFlag('clip'); - - addMoFlag('osize'); - - // change scale to 1 - dlParams.ws.value = 1.0; - - dlParams.ddpix.value = cropFloat(dpi_h); - dlParams.ddpiy.value = cropFloat(dpi_v); - - display(3); - -} - - -/** - * scale (overriding old one) - * as pixel by pixel is some kind of scale, it does turn scale factor to 1 - * if chosen. also if a scale factor is chosen, - * then pixel by pixel is turned off. - */ -function scale(factor) { - - dlParams.ws.value = factor; - - removeMoFlag('clip'); - removeMoFlag('osize'); - - display(3); - -} - - -/** - * placeMarks (overriding old one) - * take care of rotation and mirroring when placing marks - */ -function placeMarks() { - - if ( dlParams.mk.value != '' ) { - - var mark = dlParams.mk.value.split(";"); - var mark_count = mark.length; - - // maximum of marks is 8 - // we do not report this error because this is already done in function 'mark' - if ( mark_count > 8 ) mark_count = 8; - - var picWidth = (document.all) ? parseInt(document.all.lay1.offsetWidth) : (typeof(document.getElementById) == "function") ? parseInt(document.pic.offsetWidth) : parseInt(document.lay1.clip.width); - var picHeight = (document.all) ? parseInt(document.all.lay1.offsetHeight) : (typeof(document.getElementById) == "function") ? parseInt(document.pic.offsetHeight) : parseInt(document.lay1.clip.height); - - // catch the cases where the picture had not been loaded already and - // make a timeout so that the coordinates are calculated with the real dimensions - if ( (picWidth > 30) || (document.pic.complete) ) { - - var xOffset = (document.all) ? parseInt(document.all.lay1.style.left) : (typeof(document.getElementById) == "function") ? parseInt(document.getElementById('lay1').style.left) : document.lay1.left; - var yOffset = (document.all) ? parseInt(document.all.lay1.style.top) : (typeof(document.getElementById) == "function") ? parseInt(document.getElementById('lay1').style.top) : document.lay1.top; - - for (var i = 0; i < mark_count; i++) { - mark[i] = mark[i].split("/"); - - if ( (parseFloat(mark[i][0]) >= parseFloat(dlParams.wx.value)) && - (parseFloat(mark[i][1]) >= parseFloat(dlParams.wy.value)) && - (parseFloat(mark[i][0]) <= (parseFloat(dlParams.wx.value) + parseFloat(dlParams.ww.value))) && - (parseFloat(mark[i][1]) <= (parseFloat(dlParams.wy.value) + parseFloat(dlParams.wh.value))) ) { - - mark[i][0] = (mark[i][0] - dlParams.wx.value)/dlParams.ww.value; - mark[i][1] = (mark[i][1] - dlParams.wy.value)/dlParams.wh.value; - - // mirror - if ( dlParams.mo.value.indexOf('hmir') > -1 ) { - mark[i][0] = 1 - mark[i][0]; - } - if ( dlParams.mo.value.indexOf('vmir') > -1 ) { - mark[i][1] = 1 - mark[i][1]; - } - - // just the beginning - not working currently - var ang_rad = dlParams.rot.value*2*3.1415926/360; - - var ws = Math.sin(ang_rad)/(Math.cos(ang_rad)*dlParams.ww.value/dlParams.wh.value+Math.sin(ang_rad)) * picWidth; - var wc = (Math.cos(ang_rad)*dlParams.ww.value/dlParams.wh.value)/(Math.cos(ang_rad)*dlParams.ww.value/dlParams.wh.value+Math.sin(ang_rad)) * picWidth; - - var hs = (Math.sin(ang_rad)*dlParams.ww.value/dlParams.wh.value)/(Math.sin(ang_rad)*dlParams.ww.value/dlParams.wh.value+Math.cos(ang_rad)) * picHeight; - var hc = Math.cos(ang_rad)/(Math.sin(ang_rad)*dlParams.ww.value/dlParams.wh.value+Math.cos(ang_rad)) * picHeight; - - var origPicWidth = Math.sqrt(Math.pow(wc, 2) + Math.pow(hs, 2)); - var origPicHeight = Math.sqrt(Math.pow(ws, 2) + Math.pow(hc, 2)); - // end of the beginning ;-) - - mark[i][0] = parseInt(xOffset + picWidth * mark[i][0]); - mark[i][1] = parseInt(yOffset + picHeight * mark[i][1]); - - if ( (document.all) || (typeof(document.getElementById) == "function") ) { - // suboptimal to place -5 pixels and not half size of mark-image - // should be changed in the future - document.getElementById("dot" + i).style.left = mark[i][0]-5; - document.getElementById("dot" + i).style.top = mark[i][1]-5; - document.getElementById("dot" + i).style.visibility = "visible"; - } else { - document.layers[i+1].moveTo(mark[i][0]-5, mark[i][1]-5); - document.layers[i+1].visibility = "show"; - } - } - } - - } else { - setTimeout("placeMarks()", 100); - } - } -} - - -/**** - * helper functions - ****/ - -/** - * Point (overriding old one) - * constructor holding different values of a point - * depending also on mirror or rotation - */ -function Point(evt) { - - if ( document.all ) { - - this.pageX = parseInt(document.body.scrollLeft+event.clientX); - this.pageY = parseInt(document.body.scrollLeft+event.clientY); - - this.x = this.pageX-parseInt(document.all.lay1.style.left); - this.y = this.pageY-parseInt(document.all.lay1.style.top); - - // mirror - if ( dlParams.mo.value.indexOf('hmir') > -1 ) { - this.relX = cropFloat(parseFloat(parseFloat(dlParams.wx.value)+parseFloat(dlParams.ww.value))-(dlParams.ww.value*this.x/document.all.lay1.offsetWidth)); - } else { - this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.all.lay1.offsetWidth)); - } - if ( dlParams.mo.value.indexOf('vmir') > -1 ) { - this.relY = cropFloat(parseFloat(parseFloat(dlParams.wy.value)+parseFloat(dlParams.wh.value))-(dlParams.wh.value*this.y/document.all.lay1.offsetHeight)); - } else { - this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.all.lay1.offsetHeight)); - } - - } else { - - this.pageX = parseInt(evt.pageX); - this.pageY = parseInt(evt.pageY); - - if ( typeof(document.getElementById) == "function" ) { - - this.x = this.pageX-parseInt(document.getElementById("lay1").style.left); - this.y = this.pageY-parseInt(document.getElementById("lay1").style.top); - - // mirror - if ( dlParams.mo.value.indexOf('hmir') > -1 ) { - this.relX = cropFloat(parseFloat(parseFloat(dlParams.wx.value)+parseFloat(dlParams.ww.value))-(dlParams.ww.value*this.x/document.pic.offsetWidth)); - } else { - this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.pic.offsetWidth)); - } - if ( dlParams.mo.value.indexOf('vmir') > -1 ) { - this.relY = cropFloat(parseFloat(parseFloat(dlParams.wy.value)+parseFloat(dlParams.wh.value))-(dlParams.wh.value*this.y/document.pic.offsetHeight)); - } else { - this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.pic.offsetHeight)); - } - - } else { - - this.x = this.pageX-document.lay1.left; - this.y = this.pageY-document.lay1.top; - - // mirror - if ( dlParams.mo.value.indexOf('hmir') > -1 ) { - this.relX = cropFloat(parseFloat(parseFloat(dlParams.wx.value)+parseFloat(dlParams.ww.value))-(dlParams.ww.value*this.x/document.lay1.clip.width)); - } else { - this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.lay1.clip.width)); - } - if ( dlParams.mo.value.indexOf('vmir') > -1 ) { - this.relY = cropFloat(parseFloat(parseFloat(dlParams.wy.value)+parseFloat(dlParams.wh.value))-(dlParams.wh.value*this.y/document.lay1.clip.height)); - } else { - this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.lay1.clip.height)); - } - - } - - } - - return this; - -} - - -/** - * removeMoFlag from mo parameter - */ -function removeMoFlag(name) { - - if ( dlParams.mo.value != '' ) { - - var idx_comma_after = dlParams.mo.value.indexOf(name + ','); - var idx_comma_before = dlParams.mo.value.indexOf(',' + name); - var idx_nocomma = dlParams.mo.value.indexOf(name); - - if ( idx_comma_after > -1 ) { - dlParams.mo.value = dlParams.mo.value.slice(0, idx_comma_after) + dlParams.mo.value.slice(idx_comma_after+name.length+1); - }else if ( idx_comma_before > -1 ) { - dlParams.mo.value = dlParams.mo.value.slice(0, idx_comma_before) + dlParams.mo.value.slice(idx_comma_before+name.length+1); - } else if ( idx_nocomma > -1 ) { - dlParams.mo.value = dlParams.mo.value.slice(0, idx_nocomma) + dlParams.mo.value.slice(idx_nocomma+name.length); - } - } - -} - - -/** - * addMoFlag from mo parameter - */ -function addMoFlag(name) { - - if ( dlParams.mo.value.indexOf(name) == -1 ) { - - if ( dlParams.mo.value.length > 0 ) { - dlParams.mo.value += ',' + name; - } else { - dlParams.mo.value = name; - } - } - -}
--- a/client/digitallibrary/modules/newReferences.js Tue Dec 21 09:52:16 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -/* - -Copyright (C) 2003 WTWG, Uni Bern - -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. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -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 - -Author: Christian Luginbuehl, 22.05.2003 , Version Alcatraz 0.4 - -*/ - -/************************************************************************* - * newReferences.js : digilib-module * - * * - * desc: creates references in the new parameter format (key-value) * - * * - *************************************************************************/ - - -/** - * ref, overriding original one - */ -function ref(select) { - - var hyperlinkRef = baseUrl + "/digilib.jsp?"; - - if ( select >= 2 ) { - - // no original size is referenced at the moment, - // because the dpi values are not constant from user to user - removeMoFlag('osize'); - - var parameterString = ''; - - for ( param in dlParams ) { - if ( (dlParams[param].detail < 9) && (dlParams[param].defaultValue != dlParams[param].value) ) { - parameterString += "&" + param + "=" + dlParams[param].value; - } - } - - if (select == 2) { - parameterString += "&lv=3"; // level three - parameterString = parameterString.slice(1); - prompt("Alcatraz-style HTML link", hyperlinkRef + parameterString); - } else { - parameterString += "&lv=1"; // i just really want the image - parameterString = parameterString.slice(1); - return hyperlinkRef + parameterString; - } - - } else { - - var parameterString = ''; - - parameterString += dlParams.fn.value + "+" + dlParams.pn.value + "+" + dlParams.ws.value + "+"; - parameterString += dlParams.mo.value + "+" + dlParams.mk.value; - - if ( (dlParams.wx.value != 0) || (dlParams.wy.value != 0) || (dlParams.ww.value != 1) || (dlParams.wh.value != 1) ) { - parameterString += "+" + dlParams.wx.value + "+" + dlParams.wy.value + "+" + dlParams.ww.value; - parameterString += "+" + dlParams.wh.value; - } - - if ( select == 1 ) { - prompt("Link for HTML-documents", hyperlinkRef + parameterString); - } - - if ( select == 0 ) { - prompt("Link for LaTeX-documents", "\\href{" + hyperlinkRef + parameterString + "}{TEXT}"); - } - } -}
--- a/client/digitallibrary/relato/astro.xml Tue Dec 21 09:52:16 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> - -<relato> - - <frames> - <frameset cols="0,100%" border="0" frameborder="0" framespacing="0"> - <frame name="navigation" src="http://pythia2.unibe.ch:8080/docuserver/digitallibrary/contexto/contexto.jsp?htmlURL=http://www.philoscience.unibe.ch/docuserver/echo/projekte/compago/navigation.html" /> - <frame name="mainFrame" /> - <noframes> - In order to use <i>relato</i> you need to have a frame capable browser. - </noframes> - </frameset> - </frames> - - <functions> - <function name="getParameter" quiet="true"> - <validInFrame name="mainFrame" /> - </function> - <function name="listParameters" quiet="true"> - <validInFrame name="mainFrame" /> - </function> - <function name="listParametersAsString" quiet="true"> - <validInFrame name="mainFrame" /> - </function> - <function name="page"> - <validInFrame name="mainFrame" /> - </function> - <function name="zoomPoint"> - <validInFrame name="mainFrame" /> - </function> - <function name="zoomArea"> - <validInFrame name="mainFrame" /> - </function> - <function name="mark"> - <validInFrame name="mainFrame" /> - </function> - <function name="ref"> - <validInFrame name="mainFrame" /> - </function> - <function name="zoomOut"> - <validInFrame name="mainFrame" /> - </function> - <function name="zoomExtends"> - <validInFrame name="mainFrame" /> - </function> - <function name="moveTo"> - <validInFrame name="mainFrame" /> - </function> - <function name="scale"> - <validInFrame name="mainFrame" /> - </function> - <function name="brightnessContrast"> - <validInFrame name="mainFrame" /> - </function> - <function name="mirror"> - <validInFrame name="mainFrame" /> - </function> - <function name="rotation"> - <validInFrame name="mainFrame" /> - </function> - <function name="colors"> - <validInFrame name="mainFrame" /> - </function> - <function name="pixelByPixel"> - <validInFrame name="mainFrame" /> - </function> - <function name="originalSize"> - <validInFrame name="mainFrame" /> - </function> - </functions> - - <buttons> - <button name="home" command="navigation.home()" /> - <button name="e-publications" command="navigation.publications()" /> - </buttons> - - <protected> - <frame name="navigation" /> - </protected> - -</relato>
--- a/client/digitallibrary/relato/blank.html Tue Dec 21 09:52:16 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> -<html> -<head> -</head> - -<body bgcolor="#666666"> -</body> -</html>
--- a/client/digitallibrary/relato/compare.xml Tue Dec 21 09:52:16 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> - -<relato> - - <frames> - <frameset rows="0,33,*,15%" border="0" frameborder="0" framespacing="0"> - <frame name="navigation" /> - <frame name="title" /> - <frameset cols="50%,50%" border="0" frameborder="0" framespacing="0"> - <frame name="mainFrameLeft" /> - <frame name="mainFrameRight" /> - </frameset> - <frameset cols="16%,38%,46%" border="0" frameborder="0" framespacing="0"> - <frame name="motiv" /> - <frame name="kriterium" /> - <frame name="krittext" /> - </frameset> - <noframes> - In order to use <i>relato</i> you need to have a frame capable browser. - </noframes> - </frameset> - </frames> - - <functions> - <function name="getParameter" quiet="true"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="listParameters" quiet="true"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="listParametersAsString" quiet="true"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="page"> - </function> - <function name="zoomPoint"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="zoomArea"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="mark"> - </function> - <function name="ref"> - </function> - <function name="zoomOut"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="zoomExtends"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="moveTo"> - </function> - <function name="scale"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="brightnessContrast"> - </function> - <function name="mirror"> - </function> - <function name="rotation"> - </function> - <function name="colors"> - </function> - <function name="pixelByPixel"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="originalSize"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - </functions> - - <buttons> - <button name="home" command="navigation.home()" /> - <button name="relation" command="navigation.relation()" /> - <button name="description" command="navigation.description()" /> - <!-- - <button name="new window" command="navigation.newwindow()" /> - --> - </buttons> - - <protected> - <frame name="navigation" /> - <frame name="title" /> - <frame name="motiv" /> - <frame name="kriterium" /> - <frame name="krittext" /> - </protected> - - <default> - </default> - -</relato>
--- a/client/digitallibrary/relato/digicat-digilib.xml Tue Dec 21 09:52:16 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> - -<relato> - - <frames> - <frameset cols="0,256,*" border="1" frameborder="1" framespacing="0"> - <frame name="navigation" src="http://pythia2.unibe.ch:8080/docuserver/digitallibrary/contexto/contexto.jsp?htmlURL=http://www.philoscience.unibe.ch/docuserver/echo/projekte/neugebauer/navigation.html" /> - <frame name="digicat" /> - <frame name="mainFrame" /> - <noframes> - In order to use <i>relato</i> you need to have a frame capable browser. - </noframes> - </frameset> - </frames> - - <functions> - <function name="getParameter" quiet="true"> - <validInFrame name="digicat" /> - <validInFrame name="mainFrame" /> - </function> - <function name="listParameters" quiet="true"> - <validInFrame name="digicat" /> - <validInFrame name="mainFrame" /> - </function> - <function name="listParametersAsString" quiet="true"> - <validInFrame name="digicat" /> - <validInFrame name="mainFrame" /> - </function> - <function name="page"> - <validInFrame name="digicat" /> - <validInFrame name="mainFrame" /> - </function> - <function name="zoomPoint"> - <validInFrame name="mainFrame" /> - </function> - <function name="zoomArea"> - <validInFrame name="mainFrame" /> - </function> - <function name="mark"> - <validInFrame name="mainFrame" /> - </function> - <function name="ref"> - <validInFrame name="mainFrame" /> - </function> - <function name="zoomOut"> - <validInFrame name="mainFrame" /> - </function> - <function name="zoomExtends"> - <validInFrame name="mainFrame" /> - </function> - <function name="moveTo"> - <validInFrame name="mainFrame" /> - </function> - <function name="scale"> - <validInFrame name="mainFrame" /> - </function> - <function name="brightnessContrast"> - <validInFrame name="mainFrame" /> - </function> - <function name="mirror"> - <validInFrame name="mainFrame" /> - </function> - <function name="rotation"> - <validInFrame name="mainFrame" /> - </function> - <function name="colors"> - <validInFrame name="mainFrame" /> - </function> - <function name="pixelByPixel"> - <validInFrame name="mainFrame" /> - </function> - <function name="originalSize"> - <validInFrame name="mainFrame" /> - </function> - </functions> - - <protected> - <frame name="digicat" /> - </protected> - - <default> - <frame name="mainFrame" /> - </default> - -</relato>
--- a/client/digitallibrary/relato/digilib-digilib.xml Tue Dec 21 09:52:16 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> - -<relato> - - <frames> - <frameset cols="50%,50%" border="1" frameborder="1" framespacing="0"> - <frame name="mainFrameLeft" /> - <frame name="mainFrameRight" /> - <noframes> - In order to use <i>relato</i> you need to have a frame capable browser. - </noframes> - </frameset> - </frames> - - <functions> - <function name="getParameter" quiet="true"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="listParameters" quiet="true"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="listParametersAsString" quiet="true"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="page"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="zoomPoint"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="zoomArea"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="mark"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="ref"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="zoomOut"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="zoomExtends"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="moveTo"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="scale"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="brightnessContrast"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="mirror"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="rotation"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="colors"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="pixelByPixel"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - <function name="originalSize"> - <validInFrame name="mainFrameLeft" /> - <validInFrame name="mainFrameRight" /> - </function> - </functions> - - <protected> - </protected> - - <default> - <frame name="mainFrameRight" /> - </default> - -</relato>
--- a/client/digitallibrary/relato/neugebauer.xml Tue Dec 21 09:52:16 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> - -<relato> - - <frames> - <frameset cols="0,100%" border="0" frameborder="0" framespacing="0"> - <frame name="navigation" src="http://pythia2.unibe.ch:8080/docuserver/digitallibrary/contexto/contexto.jsp?htmlURL=http://www.philoscience.unibe.ch/docuserver/echo/projekte/neugebauer/navigation.html" /> - <frame name="mainFrame" /> - <noframes> - In order to use <i>relato</i> you need to have a frame capable browser. - </noframes> - </frameset> - </frames> - - <functions> - <function name="getParameter" quiet="true"> - <validInFrame name="mainFrame" /> - </function> - <function name="listParameters" quiet="true"> - <validInFrame name="mainFrame" /> - </function> - <function name="listParametersAsString" quiet="true"> - <validInFrame name="mainFrame" /> - </function> - <function name="page"> - <validInFrame name="mainFrame" /> - </function> - <function name="zoomPoint"> - <validInFrame name="mainFrame" /> - </function> - <function name="zoomArea"> - <validInFrame name="mainFrame" /> - </function> - <function name="mark"> - <validInFrame name="mainFrame" /> - </function> - <function name="ref"> - <validInFrame name="mainFrame" /> - </function> - <function name="zoomOut"> - <validInFrame name="mainFrame" /> - </function> - <function name="zoomExtends"> - <validInFrame name="mainFrame" /> - </function> - <function name="moveTo"> - <validInFrame name="mainFrame" /> - </function> - <function name="scale"> - <validInFrame name="mainFrame" /> - </function> - <function name="brightnessContrast"> - <validInFrame name="mainFrame" /> - </function> - <function name="mirror"> - <validInFrame name="mainFrame" /> - </function> - <function name="rotation"> - <validInFrame name="mainFrame" /> - </function> - <function name="colors"> - <validInFrame name="mainFrame" /> - </function> - <function name="pixelByPixel"> - <validInFrame name="mainFrame" /> - </function> - <function name="originalSize"> - <validInFrame name="mainFrame" /> - </function> - </functions> - - <buttons> - <button name="home" command="navigation.home()" /> - <button name="database" command="navigation.database()" /> - </buttons> - - <protected> - <frame name="navigation" /> - </protected> - - <default> - <frame name="mainFrame" /> - </default> - -</relato>
--- a/client/digitallibrary/relato/picture.xml Tue Dec 21 09:52:16 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> - -<relato> - - <frames> - <frameset cols="0,50%,50%" border="0" frameborder="0" framespacing="0"> - <frame name="navigation" /> - <frameset rows="25,*" border="0" frameborder="0" framespacing="0"> - <frame name="picturelabel" /> - <frame name="mainFrame" /> - </frameset> - <frameset rows="15%,85%" border="0" frameborder="0" framespacing="0"> - <frame name="title" /> - <frame name="text" /> - </frameset> - <noframes> - In order to use <i>relato</i> you need to have a frame capable browser. - </noframes> - </frameset> - </frames> - - <functions> - <function name="getParameter" quiet="true"> - <validInFrame name="mainFrame" /> - </function> - <function name="listParameters" quiet="true"> - <validInFrame name="mainFrame" /> - </function> - <function name="listParametersAsString" quiet="true"> - <validInFrame name="mainFrame" /> - </function> - <function name="page"> - </function> - <function name="zoomPoint"> - <validInFrame name="mainFrame" /> - </function> - <function name="zoomArea"> - <validInFrame name="mainFrame" /> - </function> - <function name="mark"> - </function> - <function name="ref"> - </function> - <function name="zoomOut"> - <validInFrame name="mainFrame" /> - </function> - <function name="zoomExtends"> - <validInFrame name="mainFrame" /> - </function> - <function name="moveTo"> - </function> - <function name="scale"> - <validInFrame name="mainFrame" /> - </function> - <function name="brightnessContrast"> - </function> - <function name="mirror"> - </function> - <function name="rotation"> - </function> - <function name="colors"> - </function> - <function name="pixelByPixel"> - <validInFrame name="mainFrame" /> - </function> - <function name="originalSize"> - <validInFrame name="mainFrame" /> - </function> - </functions> - - <buttons> - <button name="home" command="navigation.home()" /> - <button name="work" command="navigation.work()" /> - <button name="type" command="navigation.type()" /> - <button name="relation" command="navigation.relation()" /> - <!--<button name="new window" command="navigation.newwindow()" />--> - </buttons> - - <protected> - <frame name="navigation" /> - <frame name="picturelabel" /> - <frame name="title" /> - <frame name="text" /> - </protected> - - <default> - <frame name="mainFrame" /> - </default> - -</relato>
--- a/client/digitallibrary/relato/relato.js Tue Dec 21 09:52:16 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,193 +0,0 @@ -top.name = 'f'; - -if ( !top.focused ) - top.focused = new Object(); - - -function identify() { - return 'Relato v0.1'; -} - - -function frameSelected() { - return top.focused != ''; -} - - -function frameSelectable(name) { - // created by xls - var frames = protectedFrames(); - var selectable = true; - for (var i=0; i<frames.length; i++) { - if (frames[i] == name) { - selectable = false; - } - } - return selectable; -} - - -function noFrameSelected() { - alert( "No frame activated at the moment - click on the desired frame to activate it!" ); -} - - -function nameOfSelectedFrame() { - return top.focused.name; -} - - -function selectedFrameObject() { - return top.focused; -} - - -function init() { - // do the initialisation just if it is top-level relato - if ( top == window ) { - init_rec( top, top.name ); - } - return true; -} - - -function init_rec( current, name ) { - - if (current.frames.length > 0) { - for ( i=0; i < current.frames.length; i++ ) { - if (!current.frames[i].name) { - current.frames[i].name = name + i; - } - if (frameSelectable(current.frames[i].name)) { - current.frames[i].addEventListener( 'click', focusListener, true ); - if (current.frames[i].name == nameOfSelectedFrame()) { - top.focused = current.frames[i]; - } - } else { - if (current.frames[i] == selectedFrameObject()) { - top.focused = ''; - } - } - current.frames[i].addEventListener( 'unload', unloadListener, true ); - init_rec( current.frames[i], current.frames[i].name ); - } - } -} - - -function listFrames() { - - var frames = new Array(); - - function listFrames_rec( current ) { - - if (current.frames.length > 0) { - for (var i=0; i < current.frames.length; i++) { - listFrames_rec(current.frames[i]); - } - } else { - frames.push(current); - } - } - - listFrames_rec(top); - - return frames; - -} - - -function getXML() { - query_string = location.search; - query_string.search(/xml=([^\&]*)\&/); - return RegExp.$1; -} - - -function blink() { - orig_color = top.focused.document.bgColor; - top.focused.document.bgColor="black"; - setTimeout('top.focused.document.bgColor="' + orig_color + '"', 100); -} - - -function focusListener( event ) { - - var active = this; - - if ( event.ctrlKey ) { - active = this.parent; - } - - // can be used in future to mark several frames - // markActiveFrame_rec( top, active ); - - top.focused = active; - - blink(); - - // just debug information - window.status = top.focused.name; -} - - -function unloadListener( event ) { - setTimeout('init()', 250); -} - - -function markActiveFrame_rec(current, active) { - - if ( current.frames.length > 0 ) { - for ( i=0; i < current.frames.length; i++ ) { - markActiveFrame_rec( current.frames[i], active ); - } - } else { - if ( current.name.indexOf(active.name) == 0 ) { - current.document.bgColor = '#444444'; - } else { - current.document.bgColor = '#666666'; - } - } -} - - -function loadFocusedFrame(url) { - - if (frameSelected()) { - top.focused.location.href = url; - setTimeout( 'top.init()', 1000 ); - } else { - noFrameSelected(); - } -} - - -function loadNamedFrame(url, framename) { - - desired = loadNamedFrame_rec(top, framename); - if ( desired ) { - desired.location.href = url; - setTimeout( 'top.init()', 1000 ); - } else { - alert( "Error - a frame with this name does not exist!" ); - } -} - -function loadNamedFrame_rec(current, framename) { - - if ( current.frames.length > 0 ) { - for ( i=0; i < current.frames.length; i++ ) { - thisone = loadNamedFrame_rec(current.frames[i], framename); - if (thisone) { - return thisone; - } - } - } else { - if (current.name == framename) { - return current; - } else { - return null; - } - } -}
--- a/client/digitallibrary/relato/relato.xsl Tue Dec 21 09:52:16 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> - - <xsl:output method="xml" indent="yes" encoding="iso-8859-1" - doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" - doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" /> - - <!-- the start --> - <xsl:template match="relato"> - <html xmlns="http://www.w3.org/1999/xhtml"> - <head> - <script type="text/javascript" src="relato/relato.js"> - // this comment has to be here, otherwise xerces translates this - // empty tag to a self-closing one, which is bad for HTML that - // needs a closing script-tag - </script> - <script type="text/javascript"> - <xsl:apply-templates select="functions" /> - <xsl:apply-templates select="buttons" /> - <xsl:apply-templates select="protected" /> - <xsl:apply-templates select="default" /> - </script> - </head> - <xsl:apply-templates select="frames" /> - </html> - </xsl:template> - - <xsl:template match="frames"> - <xsl:copy-of select="frameset" /> - </xsl:template> - - <xsl:template match="functions"> - <xsl:for-each select="function"> - function <xsl:value-of select="@name" />() { - if (frameSelected()) { - <xsl:for-each select="validInFrame"> - if (nameOfSelectedFrame() == "<xsl:value-of select="@name" />") { - id = selectedFrameObject(); - if (typeof(id.<xsl:value-of select="../@name" />) == 'function') { - return id.<xsl:value-of select="../@name" />(<xsl:value-of select="../@name" />.arguments[0], <xsl:value-of select="../@name" />.arguments[1], <xsl:value-of select="../@name" />.arguments[2], <xsl:value-of select="../@name" />.arguments[3]); - } - } - </xsl:for-each> - } else { - <xsl:choose> - <xsl:when test="not(@quiet = 'true')"> - // alert message - noFrameSelected(); - </xsl:when> - <xsl:otherwise> - // be quiet - return false; - </xsl:otherwise> - </xsl:choose> - } - } - </xsl:for-each> - </xsl:template> - - <xsl:template match="buttons"> - function dynamicButtons() { - var btns = ''; - <xsl:for-each select="button"> - btns += '#<xsl:value-of select="@name" />|<xsl:value-of select="@command" />';</xsl:for-each> - return btns.slice(1); - } - </xsl:template> - - <xsl:template match="protected"> - function protectedFrames() { - var frames = new Array (); - <xsl:for-each select="frame"> - frames.push('<xsl:value-of select="@name" />');</xsl:for-each> - return frames; - } - </xsl:template> - - <xsl:template match="default"> - top.focused.name = '<xsl:value-of select="frame/@name" />'; - </xsl:template> - -</xsl:stylesheet>
--- a/client/digitallibrary/relato/type.xml Tue Dec 21 09:52:16 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> - -<relato> - - <frames> - <frameset cols="0,50%,50%" border="0" frameborder="0" framespacing="0"> - <frame name="navigation" /> - <frameset rows="70%,30%" border="0" frameborder="0" framespacing="0"> - <frame name="mainFrame" /> - <frame name="links" /> - </frameset> - <frame name="text" /> - <noframes> - In order to use <i>relato</i> you need to have a frame capable browser. - </noframes> - </frameset> - </frames> - - <functions> - <function name="getParameter" quiet="true"> - <validInFrame name="mainFrame" /> - </function> - <function name="listParameters" quiet="true"> - <validInFrame name="mainFrame" /> - </function> - <function name="listParametersAsString" quiet="true"> - <validInFrame name="mainFrame" /> - </function> - <function name="page"> - </function> - <function name="zoomPoint"> - <validInFrame name="mainFrame" /> - </function> - <function name="zoomArea"> - <validInFrame name="mainFrame" /> - </function> - <function name="mark"> - </function> - <function name="ref"> - </function> - <function name="zoomOut"> - <validInFrame name="mainFrame" /> - </function> - <function name="zoomExtends"> - <validInFrame name="mainFrame" /> - </function> - <function name="moveTo"> - </function> - <function name="scale"> - <validInFrame name="mainFrame" /> - </function> - <function name="brightnessContrast"> - </function> - <function name="mirror"> - </function> - <function name="rotation"> - </function> - <function name="colors"> - </function> - <function name="pixelByPixel"> - <validInFrame name="mainFrame" /> - </function> - <function name="originalSize"> - <validInFrame name="mainFrame" /> - </function> - </functions> - - <buttons> - <button name="home" command="navigation.home()" /> - <button name="relation" command="navigation.relation()" /> - </buttons> - - <protected> - <frame name="navigation" /> - <frame name="links" /> - <frame name="text" /> - </protected> - - <default> - <frame name="mainFrame" /> - </default> - -</relato>
--- a/client/digitallibrary/relato/work.xml Tue Dec 21 09:52:16 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> - -<relato> - - <frames> - <frameset cols="0,50%,50%" border="0" frameborder="0" framespacing="0"> - <frame name="navigation" /> - <frameset rows="70%,30%" border="0" frameborder="0" framespacing="0"> - <frame name="mainFrame" /> - <frame name="links" /> - </frameset> - <frameset rows="15%,85%" border="0" frameborder="0" framespacing="0"> - <frame name="title" /> - <frame name="text" /> - </frameset> - <noframes> - In order to use <i>relato</i> you need to have a frame capable browser. - </noframes> - </frameset> - </frames> - - <functions> - <function name="getParameter" quiet="true"> - <validInFrame name="mainFrame" /> - </function> - <function name="listParameters" quiet="true"> - <validInFrame name="mainFrame" /> - </function> - <function name="listParametersAsString" quiet="true"> - <validInFrame name="mainFrame" /> - </function> - <function name="page"> - </function> - <function name="zoomPoint"> - <validInFrame name="mainFrame" /> - </function> - <function name="zoomArea"> - <validInFrame name="mainFrame" /> - </function> - <function name="mark"> - </function> - <function name="ref"> - </function> - <function name="zoomOut"> - <validInFrame name="mainFrame" /> - </function> - <function name="zoomExtends"> - <validInFrame name="mainFrame" /> - </function> - <function name="moveTo"> - </function> - <function name="scale"> - <validInFrame name="mainFrame" /> - </function> - <function name="brightnessContrast"> - </function> - <function name="mirror"> - </function> - <function name="rotation"> - </function> - <function name="colors"> - </function> - <function name="pixelByPixel"> - <validInFrame name="mainFrame" /> - </function> - <function name="originalSize"> - <validInFrame name="mainFrame" /> - </function> - </functions> - - <buttons> - <button name="home" command="navigation.home()" /> - <!-- - <button name="description" command="navigation.description()" /> - --> - <!-- - <button name="new window" command="navigation.newwindow()" /> - --> - </buttons> - - <protected> - <frame name="navigation" /> - <frame name="links" /> - <frame name="title" /> - <frame name="text" /> - </protected> - - <default> - <frame name="mainFrame" /> - </default> - -</relato>
--- a/client/digitallibrary/xul/install.html Tue Dec 21 09:52:16 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -<html> -<head> - -<title>Install Alcatraz for Firefox</title> - -<script type="application/x-javascript"> - -function dynamicButtons() { - return "google|google()"; -} - -function google() { - top.location = "http://www.google.com"; -} - -function install() { - InstallTrigger.install ( {'alcatraz' : 'alcatraz.xpi'} ); - InstallTrigger.install ( {'jslib' : 'http://downloads.mozdev.org/jslib/xpi/jslib_current.xpi'} ); -} - -</script> - -</head> -<body> - - <h3>Alcatraz XUL Package for Firefox</h3> -<p>Contains a sidebar, a toolbar and the <a href="http://jslib.mozdev.org">jslib-package</a> from mozdev</p> -<h4>Installation:</h4> -<ul> - <li>press the "install alcatraz" button - <input type="button" name="install alcatraz" value="install alcatraz" onClick="install();"> - </li> - - <li>Restart Firefox and you will find the new toolbar installed. The sidebar can be enabled anytime under View -> Sidebar or with the shortcut [Ctrl]-[a].</li> - -</ul> - -<hr> - -<address><a href="mailto:luginbuehl@student.unibe.ch">Christian Luginbuehl</a></address> -<script type="text/javascript"> -<!-- - document.write("Last modified: " + document.lastModified) ---> -</script> -</body> -</html>
--- a/servlet/src/digilib/image/DocuImage.java Tue Dec 21 09:52:16 2010 +0100 +++ b/servlet/src/digilib/image/DocuImage.java Tue Dec 21 20:24:09 2010 +0100 @@ -25,6 +25,8 @@ import java.io.OutputStream; import java.util.Iterator; +import javax.servlet.ServletException; + import digilib.io.ImageFile; import digilib.io.FileOpException; @@ -69,10 +71,11 @@ * * @param mt mime-type of the image to be sent. * @param res ServletResponse where the image is sent. - * @throws FileOpException Exception thrown on any error. + * @throws ServletException Exception thrown on sending data. + * @throws ImageOpException Exception in other cases. */ public void writeImage(String mt, OutputStream ostream) - throws FileOpException; + throws ServletException, ImageOpException; /** The width of the current image in pixel. * @@ -85,6 +88,12 @@ * @return Image height in pixels. */ public int getHeight(); + + /** The size of the current image in pixel. + * + * @return + */ + public ImageSize getSize(); /** The mime-type of the current image. *
--- a/servlet/src/digilib/image/DocuImageImpl.java Tue Dec 21 09:52:16 2010 +0100 +++ b/servlet/src/digilib/image/DocuImageImpl.java Tue Dec 21 20:24:09 2010 +0100 @@ -28,6 +28,8 @@ import java.util.LinkedList; import java.util.List; +import javax.servlet.ServletException; + import org.apache.log4j.Logger; import digilib.io.FileOpException; @@ -55,6 +57,9 @@ /** image mime-type */ protected String mimeType = null; + /** image size */ + protected ImageSize imgSize = null; + /** * Returns the quality. * @return int @@ -153,15 +158,25 @@ } public int getHeight() { - // TODO Auto-generated method stub + ImageSize is = getSize(); + if (is != null) { + return is.getHeight(); + } return 0; } public int getWidth() { - // TODO Auto-generated method stub + ImageSize is = getSize(); + if (is != null) { + return is.getWidth(); + } return 0; } + public ImageSize getSize() { + return imgSize; + } + public void loadImage(ImageFile f) throws FileOpException { // TODO Auto-generated method stub @@ -173,7 +188,7 @@ } public void writeImage(String mt, OutputStream ostream) - throws FileOpException { + throws ServletException, ImageOpException { // TODO Auto-generated method stub }
--- a/servlet/src/digilib/image/ImageLoaderDocuImage.java Tue Dec 21 09:52:16 2010 +0100 +++ b/servlet/src/digilib/image/ImageLoaderDocuImage.java Tue Dec 21 20:24:09 2010 +0100 @@ -45,6 +45,7 @@ import javax.imageio.stream.FileImageInputStream; import javax.imageio.stream.ImageInputStream; import javax.imageio.stream.ImageOutputStream; +import javax.servlet.ServletException; import digilib.io.FileOpException; import digilib.io.FileOps; @@ -56,7 +57,7 @@ /** image object */ protected BufferedImage img; - + /** interpolation type */ protected RenderingHints renderHint; @@ -88,33 +89,28 @@ } } - public int getHeight() { - int h = 0; - try { - if (img == null) { - h = reader.getHeight(0); - } else { - h = img.getHeight(); - } - } catch (IOException e) { - logger.debug("error in getHeight", e); - } - return h; - } - - public int getWidth() { - int w = 0; - try { - if (img == null) { - w = reader.getWidth(0); - } else { - w = img.getWidth(); - } - } catch (IOException e) { - logger.debug("error in getHeight", e); - } - return w; - } + /* returns the size of the current image */ + public ImageSize getSize() { + ImageSize is = null; + // TODO: do we want to cache imageSize? + int h = 0; + int w = 0; + try { + if (img == null) { + // get size from ImageReader + h = reader.getHeight(0); + w = reader.getWidth(0); + } else { + // get size from image + h = img.getHeight(); + w = img.getWidth(); + } + is = new ImageSize(w, h); + } catch (IOException e) { + logger.debug("error in getSize:", e); + } + return is; + } /* returns a list of supported image formats */ public Iterator<String> getSupportedFormats() { @@ -229,7 +225,7 @@ /* write image of type mt to Stream */ public void writeImage(String mt, OutputStream ostream) - throws FileOpException { + throws ImageOpException, ServletException { logger.debug("writeImage"); // setup output ImageWriter writer = null; @@ -255,7 +251,7 @@ writer = (ImageWriter) ImageIO.getImageWritersByFormatName( "jpeg").next(); if (writer == null) { - throw new FileOpException("Unable to get JPEG writer"); + throw new ImageOpException("Unable to get JPEG writer"); } ImageWriteParam param = writer.getDefaultWriteParam(); if (quality > 1) { @@ -276,18 +272,19 @@ writer = (ImageWriter) ImageIO.getImageWritersByFormatName( "png").next(); if (writer == null) { - throw new FileOpException("Unable to get PNG writer"); + throw new ImageOpException("Unable to get PNG writer"); } writer.setOutput(imgout); logger.debug("writing"); writer.write(img); } else { // unknown mime type - throw new FileOpException("Unknown mime type: " + mt); + throw new ImageOpException("Unknown mime type: " + mt); } } catch (IOException e) { - throw new FileOpException("Error writing image."); + logger.error("Error writing image:", e); + throw new ServletException("Error writing image:", e); } finally { // clean up if (writer != null) {
--- a/servlet/src/digilib/image/ImageWorker.java Tue Dec 21 09:52:16 2010 +0100 +++ b/servlet/src/digilib/image/ImageWorker.java Tue Dec 21 20:24:09 2010 +0100 @@ -33,7 +33,6 @@ /** * render and return the image */ - @Override public DocuImage call() throws FileOpException, IOException, ImageOpException { logger.debug("image worker starting"); @@ -73,8 +72,7 @@ docuImage.loadSubimage(jobinfo.getFileToLoad(), loadRect, (int) subsamp); - logger.debug("SUBSAMP: " + subsamp + " -> " + docuImage.getWidth() - + "x" + docuImage.getHeight()); + logger.debug("SUBSAMP: " + subsamp + " -> " + docuImage.getSize()); docuImage.scale(scaleXY, scaleXY);
--- a/servlet/src/digilib/image/JAIDocuImage.java Tue Dec 21 09:52:16 2010 +0100 +++ b/servlet/src/digilib/image/JAIDocuImage.java Tue Dec 21 20:24:09 2010 +0100 @@ -40,6 +40,7 @@ import javax.media.jai.RenderedOp; import javax.media.jai.operator.TransposeDescriptor; import javax.media.jai.operator.TransposeType; +import javax.servlet.ServletException; import com.sun.media.jai.codec.ImageCodec; @@ -49,6 +50,10 @@ import digilib.io.ImageFileset; /** A DocuImage implementation using Java Advanced Imaging Library. */ +/** + * @author casties + * + */ public class JAIDocuImage extends ImageInfoDocuImage { protected RenderedImage img; @@ -174,8 +179,7 @@ } /* Write the current image to an OutputStream. */ - public void writeImage(String mt, OutputStream ostream) - throws FileOpException { + public void writeImage(String mt, OutputStream ostream) throws ServletException, ImageOpException { try { // setup output ParameterBlock pb3 = new ParameterBlock(); @@ -187,39 +191,33 @@ pb3.add("PNG"); } else { // unknown mime type - throw new FileOpException("Unknown mime type: " + mt); + throw new ImageOpException("Unknown mime type: " + mt); } // render output JAI.create("encode", pb3); - } catch (IOException e) { - throw new FileOpException("Error writing image."); + } catch (RuntimeException e) { + // JAI likes to throw RuntimeExceptions + throw new ServletException("Error writing image:", e); } } - /** - * The width of the curent image in pixel. - * - * @return Image width in pixels. - */ - public int getWidth() { - if (img != null) { - return img.getWidth(); - } - return 0; - } - - /** - * The height of the curent image in pixel. - * - * @return Image height in pixels. - */ - public int getHeight() { - if (img != null) { - return img.getHeight(); - } - return 0; - } + /* returns the current image size + * @see digilib.image.DocuImageImpl#getSize() + */ + public ImageSize getSize() { + ImageSize is = null; + // TODO: do we want to cache imgSize? + int h = 0; + int w = 0; + if (img != null) { + // get size from image + h = img.getHeight(); + w = img.getWidth(); + is = new ImageSize(w, h); + } + return is; + } /* scales the current image */ public void scale(double scale, double scaleY) throws ImageOpException {
--- a/servlet/src/digilib/image/JAIImageLoaderDocuImage.java Tue Dec 21 09:52:16 2010 +0100 +++ b/servlet/src/digilib/image/JAIImageLoaderDocuImage.java Tue Dec 21 20:24:09 2010 +0100 @@ -35,6 +35,7 @@ import javax.imageio.stream.FileImageInputStream; import javax.imageio.stream.ImageInputStream; import javax.media.jai.JAI; +import javax.servlet.ServletException; import digilib.io.FileOpException; import digilib.io.ImageFile; @@ -54,33 +55,29 @@ return true; } - public int getHeight() { - int h = 0; - try { - if (img == null) { - h = reader.getHeight(0); - } else { - h = img.getHeight(); - } - } catch (IOException e) { - logger.debug("error in getHeight", e); - } - return h; - } + /* returns the size of the current image */ + public ImageSize getSize() { + ImageSize is = null; + // TODO: can we cache imageSize? + int h = 0; + int w = 0; + try { + if (img == null) { + // get size from ImageReader + h = reader.getHeight(0); + w = reader.getWidth(0); + } else { + // get size from image + h = img.getHeight(); + w = img.getWidth(); + } + is = new ImageSize(w, h); + } catch (IOException e) { + logger.debug("error in getSize:", e); + } + return is; + } - public int getWidth() { - int w = 0; - try { - if (img == null) { - w = reader.getWidth(0); - } else { - w = img.getWidth(); - } - } catch (IOException e) { - logger.debug("error in getHeight", e); - } - return w; - } /* Load an image file into the Object. */ public void loadImage(ImageFile f) throws FileOpException { @@ -147,7 +144,7 @@ /* Write the current image to an OutputStream. */ public void writeImage(String mt, OutputStream ostream) - throws FileOpException { + throws ImageOpException, ServletException { logger.debug("writeImage"); try { // setup output @@ -160,12 +157,12 @@ pb3.add("PNG"); } else { // unknown mime type - throw new FileOpException("Unknown mime type: " + mt); + throw new ImageOpException("Unknown mime type: " + mt); } // render output JAI.create("ImageWrite", pb3); - } catch (IOException e) { - throw new FileOpException("Error writing image."); + } catch (RuntimeException e) { + throw new ServletException("Error writing image."); } }
--- a/servlet/src/digilib/pdf/PDFFileWorker.java Tue Dec 21 09:52:16 2010 +0100 +++ b/servlet/src/digilib/pdf/PDFFileWorker.java Tue Dec 21 20:24:09 2010 +0100 @@ -45,7 +45,6 @@ this.streamWorker = new PDFStreamWorker(dlConfig, outstream, job_info, imageJobCenter); } - @Override public File call() throws Exception { OutputStream outstream = streamWorker.call(); outstream.flush();
--- a/servlet/src/digilib/servlet/PDFCache.java Tue Dec 21 09:52:16 2010 +0100 +++ b/servlet/src/digilib/servlet/PDFCache.java Tue Dec 21 20:24:09 2010 +0100 @@ -184,7 +184,7 @@ try { ServletOps.sendFile(getCacheFile(docid), "application/pdf", getDownloadFilename(pdfji), response); //sendFile(docid, getDownloadFilename(pdfji), response); - } catch (IOException e) { + } catch (Exception e) { // sending didn't work logger.error(e.getMessage()); }
--- a/servlet/src/digilib/servlet/Scaler.java Tue Dec 21 09:52:16 2010 +0100 +++ b/servlet/src/digilib/servlet/Scaler.java Tue Dec 21 20:24:09 2010 +0100 @@ -19,6 +19,7 @@ import digilib.auth.AuthOps; import digilib.image.DocuImage; import digilib.image.ImageJobDescription; +import digilib.image.ImageOpException; import digilib.image.ImageWorker; import digilib.io.DocuDirCache; import digilib.io.DocuDirectory; @@ -31,7 +32,7 @@ public class Scaler extends HttpServlet { /** digilib servlet version (for all components) */ - public static final String version = "1.9.0a"; + public static final String version = "1.8.2a"; /** servlet error codes */ public static enum Error {UNKNOWN, AUTH, FILE, IMAGE}; @@ -249,6 +250,9 @@ logger.debug("Job Processing Time: " + (System.currentTimeMillis() - startTime) + "ms"); + } catch (ImageOpException e) { + logger.error(e.getClass() + ": " + e.getMessage()); + digilibError(errMsgType, Error.IMAGE, null, response); } catch (IOException e) { logger.error(e.getClass() + ": " + e.getMessage()); digilibError(errMsgType, Error.FILE, null, response); @@ -306,7 +310,7 @@ // default: image ServletOps.sendFile(img, null, null, response); } - } catch (IOException e) { + } catch (Exception e) { logger.error("Error sending error!", e); }
--- a/servlet/src/digilib/servlet/ServletOps.java Tue Dec 21 09:52:16 2010 +0100 +++ b/servlet/src/digilib/servlet/ServletOps.java Tue Dec 21 20:24:09 2010 +0100 @@ -23,17 +23,20 @@ import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import javax.servlet.ServletConfig; +import javax.servlet.ServletException; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; import digilib.image.DocuImage; +import digilib.image.ImageOpException; import digilib.io.FileOpException; import digilib.io.FileOps; @@ -187,19 +190,17 @@ * name of the download file (for application/x) * @param res * ServletResponse where the image file will be sent. - * - * @throws FileOpException - * Exception is thrown for a IOException. - * @throws IOException + * @throws ImageOpException + * @throws ServletException Exception on sending data. */ public static void sendFile(File f, String mt, String name, HttpServletResponse response) - throws FileOpException, IOException { + throws ImageOpException, ServletException { logger.debug("sendRawFile(" + mt + ", " + f + ")"); if (mt == null) { // auto-detect mime-type mt = FileOps.mimeForFile(f); if (mt == null) { - throw new FileOpException("Unknown file type."); + throw new ImageOpException("Unknown file type."); } } response.setContentType(mt); @@ -211,18 +212,23 @@ } response.addHeader("Content-Disposition", "attachment; filename=\""+name+"\""); } - FileInputStream inFile = new FileInputStream(f); - OutputStream outStream = response.getOutputStream(); - response.setContentLength( (int) f.length()); - byte dataBuffer[] = new byte[4096]; - int len; - while ((len = inFile.read(dataBuffer)) != -1) { - // copy out file - outStream.write(dataBuffer, 0, len); - outStream.flush(); + try { + FileInputStream inFile = new FileInputStream(f); + OutputStream outStream = response.getOutputStream(); + response.setContentLength( (int) f.length()); + byte dataBuffer[] = new byte[4096]; + int len; + while ((len = inFile.read(dataBuffer)) != -1) { + // copy out file + outStream.write(dataBuffer, 0, len); + outStream.flush(); + } + response.flushBuffer(); + inFile.close(); + } catch (IOException e) { + logger.error("Error sending file:", e); + throw new ServletException("Error sending file:", e); } - response.flushBuffer(); - inFile.close(); } /** @@ -231,28 +237,35 @@ * @param img * @param mimeType * @param response - * @throws FileOpException - * @throws IOException + * @throws ImageOpException + * @throws ServletException Exception on sending data. */ public static void sendImage(DocuImage img, String mimeType, - HttpServletResponse response) throws FileOpException, IOException { - OutputStream outstream = response.getOutputStream(); - // setup output -- if mime type is set use that otherwise - // if source is JPG then dest will be JPG else it's PNG - if (mimeType == null) { - mimeType = img.getMimetype(); + HttpServletResponse response) throws ImageOpException, + ServletException { + try { + OutputStream outstream = response.getOutputStream(); + // setup output -- if mime type is set use that otherwise + // if source is JPG then dest will be JPG else it's PNG + if (mimeType == null) { + mimeType = img.getMimetype(); + } + if ((mimeType.equals("image/jpeg") || mimeType.equals("image/jp2") || mimeType + .equals("image/fpx"))) { + mimeType = "image/jpeg"; + } else { + mimeType = "image/png"; + } + // write the image + response.setContentType(mimeType); + img.writeImage(mimeType, outstream); + outstream.flush(); + } catch (IOException e) { + logger.error("Error sending image:", e); + throw new ServletException("Error sending image:", e); + } finally { + img.dispose(); } - if ((mimeType.equals("image/jpeg") || mimeType.equals("image/jp2") || mimeType - .equals("image/fpx"))) { - mimeType = "image/jpeg"; - } else { - mimeType = "image/png"; - } - - // write the image - img.writeImage(mimeType, outstream); - outstream.flush(); - img.dispose(); } } \ No newline at end of file
--- a/servlet/src/digilib/servlet/Texter.java Tue Dec 21 09:52:16 2010 +0100 +++ b/servlet/src/digilib/servlet/Texter.java Tue Dec 21 20:24:09 2010 +0100 @@ -28,6 +28,7 @@ import org.apache.log4j.Logger; import digilib.auth.AuthOps; +import digilib.image.ImageOpException; import digilib.io.DocuDirCache; import digilib.io.FileOpException; import digilib.io.FileOps; @@ -150,7 +151,7 @@ } } - } catch (FileOpException e) { + } catch (ImageOpException e) { logger.error("ERROR: File IO Error: ", e); try { ServletOps.htmlMessage("ERROR: File IO Error: " + e, response);
--- a/servlet/src/digilib/util/DigilibJobCenter.java Tue Dec 21 09:52:16 2010 +0100 +++ b/servlet/src/digilib/util/DigilibJobCenter.java Tue Dec 21 20:24:09 2010 +0100 @@ -13,8 +13,6 @@ import org.apache.log4j.Logger; -import digilib.image.DocuImage; - /** Wrapper around ExecutionService. * * @author casties @@ -32,10 +30,13 @@ /** label for this job center */ private String label = ""; - /** + /** Create a DigilibJobcenter with the given number of threads and queue length. + * If prestart=true it starts the threads in the thread pool. + * * @param maxThreads - * @param label TODO - * @param maxQueueLength + * @param maxQueueLen + * @param prestart + * @param label */ public DigilibJobCenter(int maxThreads, int maxQueueLen, boolean prestart, String label) { super(); @@ -59,17 +60,6 @@ return executor.submit(job); } - /** Returns if the service is not overloaded. - * - * @return - */ - public boolean canRun() { - int jql = getWaitingJobs(); - int jrl = getRunningJobs(); - logger.debug(label+" canRun: waiting jobs="+jql+" running jobs="+jrl); - return (jql <= maxQueueLen); - } - /** Returns if the service is overloaded. * * @return @@ -81,10 +71,16 @@ return (jql > maxQueueLen); } + /** Returns the number of currently running jobs. + * @return + */ public int getRunningJobs() { return ((ThreadPoolExecutor)executor).getActiveCount(); } + /** Returns the number of currently waiting jobs. + * @return + */ public int getWaitingJobs() { BlockingQueue<Runnable> jq = ((ThreadPoolExecutor)executor).getQueue(); int jql = jq.size(); @@ -107,6 +103,11 @@ return maxQueueLen; } + /** Shuts down the Executor. + * Tries to stop running threads and returns a list of waiting threads. + * + * @return + */ public List<Runnable> shutdownNow() { return executor.shutdownNow(); }