changeset 1326:08fffd540a75

add linestring/polyline annotations.
author robcast
date Mon, 26 Jan 2015 19:23:27 +0100
parents dc94ed3f60ff
children f50d5517ea52
files webapp/src/main/webapp/jquery/img/fullscreen/32/annotation-polyline.png webapp/src/main/webapp/jquery/img/fullscreen3.svg webapp/src/main/webapp/jquery/jquery.digilib.annotator.js
diffstat 3 files changed, 84 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
Binary file webapp/src/main/webapp/jquery/img/fullscreen/32/annotation-polyline.png has changed
--- a/webapp/src/main/webapp/jquery/img/fullscreen3.svg	Mon Jan 26 01:29:34 2015 +0100
+++ b/webapp/src/main/webapp/jquery/img/fullscreen3.svg	Mon Jan 26 19:23:27 2015 +0100
@@ -141,16 +141,16 @@
      inkscape:pageopacity="0.0"
      inkscape:pageshadow="2"
      inkscape:zoom="16"
-     inkscape:cx="16.28845"
+     inkscape:cx="2.41345"
      inkscape:cy="15.609701"
-     inkscape:current-layer="g3539"
+     inkscape:current-layer="g3545"
      showgrid="true"
      inkscape:grid-bbox="true"
      inkscape:document-units="px"
-     inkscape:window-width="1298"
-     inkscape:window-height="723"
-     inkscape:window-x="0"
-     inkscape:window-y="0"
+     inkscape:window-width="1851"
+     inkscape:window-height="1156"
+     inkscape:window-x="69"
+     inkscape:window-y="22"
      inkscape:window-maximized="1"
      showguides="true"
      inkscape:guide-bbox="true"
@@ -706,10 +706,11 @@
   </g>
   <g
      transform="translate(-7.8129058,-7.9934033)"
-     style="display:inline"
+     style="display:none"
      inkscape:label="annotation-polygon"
      id="g3539"
-     inkscape:groupmode="layer">
+     inkscape:groupmode="layer"
+     sodipodi:insensitive="true">
     <path
        inkscape:connector-curvature="0"
        id="path3541"
@@ -724,6 +725,30 @@
        sodipodi:nodetypes="ccccc" />
   </g>
   <g
+     inkscape:groupmode="layer"
+     id="g3545"
+     inkscape:label="annotation-polyline"
+     style="display:none"
+     transform="translate(-7.8129058,-7.9934033)"
+     sodipodi:insensitive="true">
+    <path
+       style="fill:none;stroke:#4d4d4d;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       d="M 5.25,8.125 8,16.006596 16,16 l 4.5625,-7.875 5.75,1.319096"
+       id="path4319"
+       inkscape:connector-curvature="0"
+       transform="translate(7.8129058,7.9934033)"
+       sodipodi:nodetypes="ccccc"
+       inkscape:export-filename="/Volumes/User/Users/casties/Documents/Eclipse/digilib/webapp/src/main/webapp/jquery/img/fullscreen/32/annotation-polyline.png"
+       inkscape:export-xdpi="90"
+       inkscape:export-ydpi="90" />
+    <path
+       sodipodi:nodetypes="ccccc"
+       inkscape:connector-curvature="0"
+       id="path3549"
+       d="m 21.765939,21.488404 11.278998,0 c -1.773025,8.409248 3.823753,4.013599 2.050729,12.004999 l -11.343086,0 C 25.482882,25.40112 19.907466,29.975104 21.765939,21.488404 z"
+       style="fill:#ffff00;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+  </g>
+  <g
      transform="translate(-7.8129058,-7.9934033)"
      style="display:none"
      inkscape:label="addregion"
--- a/webapp/src/main/webapp/jquery/jquery.digilib.annotator.js	Mon Jan 26 01:29:34 2015 +0100
+++ b/webapp/src/main/webapp/jquery/jquery.digilib.annotator.js	Mon Jan 26 19:23:27 2015 +0100
@@ -31,7 +31,7 @@
  */
 (function($) {
     // version of this plugin
-    var version = 'jquery.digilib.annotator.js 1.3.3';
+    var version = 'jquery.digilib.annotator.js 1.3.4';
 
     // affine geometry
     var geom = null;
@@ -65,8 +65,13 @@
         },
         annotationpolygon : {
             onclick : "setAnnotationPolygon",
-            tooltip : "create an annotation for a polygon region",
+            tooltip : "create an annotation for a polygon region (end with doubleclick)",
             icon : "annotation-polygon.png"
+        },
+        annotationpolyline : {
+            onclick : "setAnnotationPolyline",
+            tooltip : "create an annotation for a polyline (end with doubleclick)",
+            icon : "annotation-polyline.png"
         }
     };
 
@@ -160,6 +165,23 @@
                 // use position and text (and user-id)
                 console.error("Sorry, currently only interactive annotations!");
             }
+        },
+
+        /**
+         * set a polyline-annotation by clicking (or giving a position and a text)
+         *
+         * @param data
+         * @param poly
+         * @param text
+         */
+        setAnnotationPolyline : function (data, poly, text) {
+            if (poly == null) {
+                // interactive
+                setAnnotationShape(data, 'LineString');
+            } else {
+                // use position and text (and user-id)
+                console.error("Sorry, currently only interactive annotations!");
+            }
         }
 
     };
@@ -255,17 +277,25 @@
         	if (type === 'Point') {
         		pos = geom.position(newshape.geometry.coordinates[0]);
                 // create annotation shape
-                annoShape = {'type': 'point', 'units': 'fraction', 'geometry': pos};
+                annoShape = {'type': 'point', 'geometry': pos};
+                annoshape.geometry['units'] = 'fraction'; 
         	} else if (type === 'Rectangle') {
         		pos = geom.position(newshape.geometry.coordinates[0]);
         		var pt2 = geom.position(newshape.geometry.coordinates[1]);
         		var rect = geom.rectangle(pos, pt2);
                 // create annotation shape
-                annoShape = {'type': 'rectangle', 'units': 'fraction', 'geometry': rect};
+                annoShape = {'type': 'rectangle', 'geometry': rect};
+                annoshape.geometry['units'] = 'fraction'; 
         	} else if (type === 'Polygon') {
         		pos = geom.position(newshape.geometry.coordinates[0]);
         		// create annotation shape
-                annoShape = {'type': 'polygon', 'units': 'fraction', 'geometry': {'coordinates': newshape.geometry.coordinates}};
+                annoShape = {'type': 'polygon', 'geometry': {'coordinates': newshape.geometry.coordinates}};
+                annoshape.geometry['units'] = 'fraction'; 
+        	} else if (type === 'LineString') {
+        		pos = geom.position(newshape.geometry.coordinates[0]);
+        		// create annotation shape
+                annoShape = {'type': 'linestring', 'geometry': {'coordinates': newshape.geometry.coordinates}};
+                annoshape.geometry['units'] = 'fraction'; 
         	} else {
         		console.error("Unsupported annotation shape="+type);
         		return;
@@ -407,6 +437,21 @@
                     	},
                     	'annotation': annotation
             	};
+            } else if (type === "linestring") {
+                // render polyline
+            	shape = {
+            			'id': id,
+            			'geometry': {
+            				'type' : 'LineString',
+            				'coordinates' : annoShape.geometry.coordinates
+            			},
+            			'properties' : {
+                            'stroke' : 'yellow',
+                            'cssclass' : cssPrefix+'svg-annotation annotator-hl',
+                            'style' : 'pointer-events:visiblePainted'
+                    	},
+                    	'annotation': annotation
+            	};
             } else {
                 console.error("Unsupported annotation shape type: "+type);
                 return;
@@ -576,7 +621,7 @@
         // are annotations active?
         'isAnnotationsVisible' : true,
         // buttonset of this plugin
-        'annotationSet' : ['annotations', 'annotationuser', 'annotationmark', 'annotationrect', 'annotationpolygon', 'lessoptions'],
+        'annotationSet' : ['annotations', 'annotationuser', 'annotationmark', 'annotationrect', 'annotationpolygon', 'annotationpolyline', 'lessoptions'],
         'annotationReadOnlySet' : ['annotations', 'lessoptions'],
         // URL of annotation server .e.g. 'http://tuxserve03.mpiwg-berlin.mpg.de/AnnotationManager/annotator'
         'annotationServerUrl' : null,