Mercurial > hg > digilib-old
comparison webapp/src/main/webapp/jquery/jquery.digilib.annotator.js @ 1143:c2b8f777979f
first step to new shapes based annotations.
author | robcast |
---|---|
date | Thu, 22 Nov 2012 18:09:00 +0100 |
parents | e05b101f7790 |
children | dc66ab520dae |
comparison
equal
deleted
inserted
replaced
1142:e05b101f7790 | 1143:c2b8f777979f |
---|---|
235 | 235 |
236 /** | 236 /** |
237 * place single annotation on the image | 237 * place single annotation on the image |
238 */ | 238 */ |
239 var renderAnnotation = function (data, annot) { | 239 var renderAnnotation = function (data, annot) { |
240 if (annot == null || annot.annotation == null || annot.annotation.areas == null | 240 if (annot == null || annot.annotation == null || data.$img == null || data.imgTrafo == null) |
241 || data.$img == null || data.imgTrafo == null) | |
242 return; | 241 return; |
243 if (!data.settings.isAnnotationsVisible) return; | 242 if (!data.settings.isAnnotationsVisible) return; |
244 var cssPrefix = data.settings.cssPrefix; | 243 var cssPrefix = data.settings.cssPrefix; |
245 var $elem = data.$elem; | 244 var $elem = data.$elem; |
246 var annotator = data.annotator; | 245 var annotator = data.annotator; |
247 var annotation = annot.annotation; | 246 var annotation = annot.annotation; |
248 var idx = annot.idx ? annot.idx : '?'; | 247 var idx = annot.idx ? annot.idx : '?'; |
249 var area = geom.rectangle(annotation.areas[0]); | 248 var area = null; |
249 var type = null; | |
250 if (annotation.shapes != null) { | |
251 // annotation shape | |
252 var shape = annotation.shapes[0]; | |
253 type = shape.type; | |
254 if (type === "point") { | |
255 area = geom.position(shape.geometry); | |
256 } else if (type === "rectangle") { | |
257 area = geom.rectangle(shape.geometry); | |
258 } else { | |
259 console.error("Unsupported shape type="+type); | |
260 return; | |
261 } | |
262 } else if (annotation.areas != null) { | |
263 // legacy annotation areas | |
264 area = geom.rectangle(annotation.areas[0]); | |
265 if (area.isRectangle()) { | |
266 type = 'rectangle'; | |
267 } else { | |
268 type = 'point'; | |
269 } | |
270 } else { | |
271 console.error("Unable to render this annotation!"); | |
272 return; | |
273 } | |
250 var screenRect = null; | 274 var screenRect = null; |
251 var $annotation = null; | 275 var $annotation = null; |
252 if (area.isRectangle()) { | 276 if (type === 'rectangle') { |
277 // render rectangle | |
253 var clippedArea = data.zoomArea.intersect(area); | 278 var clippedArea = data.zoomArea.intersect(area); |
254 if (clippedArea == null) return; | 279 if (clippedArea == null) return; |
255 screenRect = data.imgTrafo.transform(clippedArea); | 280 screenRect = data.imgTrafo.transform(clippedArea); |
256 // console.debug("renderRegion: pos=",geom.position(screenRect)); | 281 // console.debug("renderRegion: pos=",geom.position(screenRect)); |
257 $annotation = $('<div class="'+cssPrefix+'annotationregion '+cssPrefix+'overlay annotator-hl">'+idx+'</div>'); | 282 $annotation = $('<div class="'+cssPrefix+'annotationregion '+cssPrefix+'overlay annotator-hl">'+idx+'</div>'); |
258 } else { | 283 } else { |
284 // render point | |
259 var pos = area.getPosition(); | 285 var pos = area.getPosition(); |
260 if (!data.zoomArea.containsPosition(pos)) return; | 286 if (!data.zoomArea.containsPosition(pos)) return; |
261 var screenRect = data.imgTrafo.transform(pos); | 287 var screenRect = data.imgTrafo.transform(pos); |
262 // create annotation | 288 // create annotation |
263 var html = '<div class="'+cssPrefix+'annotationmark '+cssPrefix+'overlay annotator-hl">'+idx+'</div>'; | 289 var html = '<div class="'+cssPrefix+'annotationmark '+cssPrefix+'overlay annotator-hl">'+idx+'</div>'; |