changeset 243:4dbff786ff50

new digimage with red triangles for moving the zoomed area (can be switched off with "clop=noarrows")
author robcast
date Wed, 04 Aug 2004 20:35:35 +0200
parents e2c455c2a0d0
children a945d4d5f8cd
files client/digitallibrary/digimage.jsp client/digitallibrary/digimage_img_inc.jsp client/digitallibrary/digimage_tbl_inc.jsp client/digitallibrary/dllib.js
diffstat 4 files changed, 111 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/client/digitallibrary/digimage.jsp	Wed Aug 04 20:35:35 2004 +0200
+++ b/client/digitallibrary/digimage.jsp	Wed Aug 04 20:35:35 2004 +0200
@@ -20,11 +20,13 @@
 // parsing the query
 // -----------------
 digilib.servlet.DigilibRequest dlRequest = new digilib.servlet.DigilibRequest(request);
+docBean.setRequest(dlRequest);
 // check if authentication is needed and redirect if necessary
-docBean.doAuthentication(dlRequest, response);
+docBean.doAuthentication(response);
 // add number of pages
-dlRequest.setValue("pt", docBean.getNumPages(dlRequest));
-String imageLocation = dlRequest.getAsString("base.url") + "/servlet/Scaler?" + dlRequest.getAsString();
+dlRequest.setValue("pt", docBean.getNumPages());
+// store objects for jsp:include
+pageContext.setAttribute("docBean", docBean, pageContext.REQUEST_SCOPE);
 %><html>
 <head>
     <title>Digital Document Library (L1)</title>
@@ -56,13 +58,12 @@
 </script>
 </head>
 <body bgcolor="#666666" onload="dl_init();">
-
-<div id="scaler" style="position:absolute; left:10px; top:10px; visibility:visible">
-<script type="text/javascript">
-var ps = bestPicSize(getElement('scaler'), 10);
-document.write('<img id="pic" src="<%= imageLocation %>&dw='+ps.width+'&dh='+ps.height+'" />');
-</script>
-</div>
+<% if (dlRequest.hasOption("clop", "noarrows")) {
+%><jsp:include page="digimage_img_inc.jsp" /><%
+} else {
+%><jsp:include page="digimage_tbl_inc.jsp" /><%
+}
+%>
 
  <div id="dot0" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="mark1.gif" border="0"></div>
  <div id="dot1" style="position:absolute; left:-20; top:100; visibility:hidden"><img src="mark2.gif" border="0"></div>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/client/digitallibrary/digimage_img_inc.jsp	Wed Aug 04 20:35:35 2004 +0200
@@ -0,0 +1,13 @@
+<%@ page language="java" %><%
+// retrieve objects from context
+digilib.servlet.DocumentBean docBean = (digilib.servlet.DocumentBean) pageContext.getAttribute("docBean", pageContext.REQUEST_SCOPE);
+digilib.servlet.DigilibRequest dlRequest = docBean.getRequest();
+%>
+<div id="scaler" style="position:absolute; left:10px; top:10px; visibility:visible">
+<script type="text/javascript">
+var ps = bestPicSize(getElement('scaler'), 10);
+document.write('<img id="pic" src="<%=
+  dlRequest.getAsString("base.url") + "/servlet/Scaler?" + dlRequest.getAsString()
+%>&dw='+ps.width+'&dh='+ps.height+'" />');
+</script>
+</div>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/client/digitallibrary/digimage_tbl_inc.jsp	Wed Aug 04 20:35:35 2004 +0200
@@ -0,0 +1,47 @@
+<%@ page language="java" %><%
+// retrieve objects from context
+digilib.servlet.DocumentBean docBean = (digilib.servlet.DocumentBean) pageContext.getAttribute("docBean", pageContext.REQUEST_SCOPE);
+digilib.servlet.DigilibRequest dlRequest = docBean.getRequest();
+%>
+<table border="0"  cellpadding="0" cellspacing="0">
+  <tr>
+    <td></td>
+    <td align="center"><%
+      if (docBean.canMoveUp()) {
+        %><a href="javascript:moveBy(0, -0.5)"><img src="img/up.gif" border="0" /></a><%
+      }
+      %></td>
+      <td></td>
+  </tr>
+  <tr>
+    <td valign="center"><%
+      if (docBean.canMoveLeft()) {
+        %><a href="javascript:moveBy(-0.5, 0)"><img src="img/left.gif" border="0" /></a><%
+      }
+      %></td>
+      <td>
+<div id="scaler" style="visibility:visible">
+<script type="text/javascript">
+var ps = bestPicSize(getElement('scaler'), 10);
+document.write('<img id="pic" src="<%=
+  dlRequest.getAsString("base.url") + "/servlet/Scaler?" + dlRequest.getAsString()
+%>&dw='+ps.width+'&dh='+ps.height+'" />');
+</script>
+</div>
+    </td>
+    <td valign="center"><%
+      if (docBean.canMoveRight()) {
+        %><a href="javascript:moveBy(0.5, 0)"><img src="img/right.gif" border="0" /></a><%
+      }
+      %></td>
+  </tr>
+  <tr>
+    <td></td>
+    <td align="center"><%
+      if (docBean.canMoveDown()) {
+        %><a href="javascript:moveBy(0, 0.5)"><img src="img/down.gif" border="0" /></a><%
+      }
+      %></td>
+    <td></td>
+  </tr>
+</table>
--- a/client/digitallibrary/dllib.js	Wed Aug 04 20:35:35 2004 +0200
+++ b/client/digitallibrary/dllib.js	Wed Aug 04 20:35:35 2004 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003,2004 WTWG Uni Bern and others
+/* Copyright (C) 2003,2004 IT-Group MPIWG, WTWG Uni Bern and others
  
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
@@ -14,15 +14,16 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
  
-Authors: ROC 20.7.2004
-  first version by Christian Luginbuehl, 01.05.2003
-  Changed for digiLib in Zope by DW 24.03.2004
+Authors:
+  Christian Luginbuehl, 01.05.2003 (first version)
+  DW 24.03.2004 (Changed for digiLib in Zope)
+  Robert Casties, 04.08.2004
 
-Requires baselib.js !
+  ! Requires baselib.js !
 
 */
 
-var dlScriptVersion = "1.0b1";
+var dlScriptVersion = "1.0b2";
 
 /*
  * more parameter handling
@@ -293,7 +294,7 @@
 
     function markEvent(evt) {
 	// event handler adding a new mark
-	unregisterMouseDown(elemScaler, markEvent);
+	unregisterEvent("mousedown", elemScaler, markEvent);
 	var p = dlTrafo.invtransform(evtPosition(evt));
 	addMark(p);
 	if (defined(reload)&&(!reload)) {
@@ -305,7 +306,7 @@
     }
 
     // starting event capture
-    registerMouseDown(elemScaler, markEvent);
+    registerEvent("mousedown", elemScaler, markEvent);
 }
 
 
@@ -350,8 +351,12 @@
 	    showElement(eck2, true);
 	    showElement(eck3, true);
 	    showElement(eck4, true);
-	    registerMouseMove(elemScaler, zoomMove);
-	    registerMouseMove(eck4, zoomMove);
+	    // show moving
+	    registerEvent("mousemove", elemScaler, zoomMove);
+	    registerEvent("mousemove", eck4, zoomMove);
+	    // enable drag-to-zoom
+	    registerEvent("mouseup", elemScaler, zoomClick);
+	    registerEvent("mouseup", eck4, zoomClick);
 	} else {
 	    // second click -- end moving
 	    pt2 = evtPosition(evt);
@@ -359,10 +364,10 @@
 	    showElement(eck2, false);
 	    showElement(eck3, false);
 	    showElement(eck4, false);
-	    unregisterMouseMove(elemScaler, zoomMove);
-	    unregisterMouseMove(eck4, zoomMove);
-	    unregisterMouseDown(elemScaler, zoomClick);
-	    unregisterMouseDown(eck4, zoomClick);
+	    unregisterEvent("mousemove", elemScaler, zoomMove);
+	    unregisterEvent("mousemove", eck4, zoomMove);
+	    unregisterEvent("mousedown", elemScaler, zoomClick);
+	    unregisterEvent("mousedown", eck4, zoomClick);
 	    var p1 = dlTrafo.invtransform(pt1);
 	    var p2 = dlTrafo.invtransform(pt2);
 	    var ww = p2.x-p1.x;
@@ -395,8 +400,8 @@
     }
 
     // starting event capture
-    registerMouseDown(elemScaler, zoomClick);
-    registerMouseDown(eck4, zoomClick);
+    registerEvent("mousedown", elemScaler, zoomClick);
+    registerEvent("mousedown", eck4, zoomClick);
 }
 
 var ZOOMFACTOR = Math.sqrt(2);
@@ -434,7 +439,7 @@
 
     function moveCenterEvent(evt) {
 	// move to handler
-	unregisterMouseDown(elemScaler, moveCenterEvent);
+	unregisterEvent("mousedown", elemScaler, moveCenterEvent);
 	var pt = dlTrafo.invtransform(evtPosition(evt));
 	var newarea = new Rectangle(pt.x-0.5*dlArea.width, pt.y-0.5*dlArea.height, dlArea.width, dlArea.height);
 	newarea = dlMaxArea.fit(newarea);
@@ -445,9 +450,26 @@
     }
 
     // starting event capture
-    registerMouseDown(elemScaler, moveCenterEvent);
+    registerEvent("mousedown", elemScaler, moveCenterEvent);
 }
 
+function moveBy(movx, movy) {
+    // move visible area by movx and movy (in units of dw, dh)
+    if ((dlArea.width == 1.0)&&(dlArea.height == 1.0)) {
+	// nothing to do
+	return;
+    }
+    var newarea = dlArea.copy();
+    newarea.x += parseFloat(movx)*dlArea.width;
+    newarea.y += parseFloat(movy)*dlArea.height;
+    newarea = dlMaxArea.fit(newarea);
+    // set parameters
+    setParamFromArea(newarea);
+    parseArea();
+    display();
+}
+
+    
 
 
 function getRef() {