Code Monkey home page Code Monkey logo

annotorious-openseadragon's Introduction



A plugin for OpenSeadragon that integrates Annotorious to enable creation and display of annotations on high-resolution zoomable images. See the project website for details and live demos.

Installing

Download the latest release and include it in your web page after the OpenSeadragon script.

<link rel="stylesheet" href="annotorious.min.css">
<script src="openseadragon/openseadragon.2.4.2.min.js"></script>
<script src="openseadragon-annotorious.min.js"></script>

Using

<script>
  window.onload = function() {
    var viewer = OpenSeadragon({
      id: "openseadragon1",
      prefixUrl: "openseadragon/images/",
      tileSources: {
        type: "image",
        url: "1280px-Hallstatt.jpg"
      }
    });

    // Initialize the Annotorious plugin
    var anno = OpenSeadragon.Annotorious(viewer);

    // Load annotations in W3C WebAnnotation format
    anno.loadAnnotations('annotations.w3c.json');

    // Attach handlers to listen to events
    anno.on('createAnnotation', function(a) {
      // Do something
    });
  }
</script>

Full documentation is on the project website. Questions? Feedack? Feature requests? Join the Annotorious chat on Gitter.

Join the chat at https://gitter.im/recogito/annotorious

License

BSD 3-Clause (= feel free to use this code in whatever way you wish. But keep the attribution/license file, and if this code breaks something, don't complain to us :-)

Who's Using Annotorious OpenSeadragon

Archipelago Open Source Digital Object Repository Software

annotorious-openseadragon's People

Contributors

akshaytoraskar avatar ananthparimi avatar architrixs avatar atomotic avatar blms avatar dependabot[bot] avatar dzeri96 avatar rainyday321 avatar rsimon avatar umesh-timalsina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

annotorious-openseadragon's Issues

Bug after polygon drawing

There is a bug after the polygon drawing while clicking the cancel button on the editor panel. I draw a polygon then the editor panel appears and when I click the cancel button the editor panel disappears but the polygon does not. The polygon still appears even if clicking the cancel button. The same steps work while drawing a rectangle, but it doesn't work by drawing a polygon.

Could you fix this bug, please?

(tested with chrome browser)

Bundle size

The recent release made the bundle importable via NPM. In order to make this happen, it was necessary to import the MouseTracker and Point classes from the openseadragon NPM package.

The problem now, is that the annotorious-openseadragon build bundles all of OpenSeadragon into the distribution. Not a problem per se, but it inflates the size of the plugin to >500kB. I wonder what the best way would be to import just MouseTracker and Point, and not all of OpenSeadragon.

Un-Select Annotation

Can you create an unselectAnnotation event, so we can change control state of the previously selected annotation. i.e. unhighlight an annotation that was previously highlighted through the selectAnnotation event.

Annotation ID's

When you create an annotation through the UI, the new annotation is assigned an id, this takes the form #GUID.

Is the # part of some standard that needs to be there? I'll have to strip this out in order to save the annotation to a database with a column type of GUID.

Looks like I can add annotation without the #, so it's just an issue through the UI created ones.

Touch support

Standard Annotorious now has touch support. Port the feature to the OSD plugin.

Formatter not called

I switched from using "plain" plugin to the openseadragon plugin and it seems like the formatter callback is not called, in the plain plugin i used this callback to add a class to thr annotation g element
Is it a bug ?
Thanks

fitBounds API method

Similar to the one that comes with OpenSeadragon, but taking an annotation (id) as an argument. Also take an immediate argument (and forward to OSD).

Getting error for .addAnnotation()

I am having trouble loading annotations after they are created. I can create the annotations fine but once I refresh the page, they are gone. I think it has something to do with this error I am getting
Screen Shot 2021-05-28 at 3 13 20 PM
Screen Shot 2021-05-28 at 3 12 56 PM

Openseadragon editor popup location

Hi,
While adding a new polygon, the editor popup shows out of the div, and sometimes we cannot see the popup because of that.
While adding a new rectangle, the editor popup shows inside of the div, so there is no problem for the rectangle.

Can you fix this problem for the polygon?

osd1

Headless mode for AnnotoriousOSD

Can we prevent the default Editor/CommentWidget from showing.

Something like

var anno = AnnotoriousOSD.init(openSeadragonViewer, { showEditor: true/false } );

Then using the selectAnnotation and createAnnotation events a dev can popup there own Editor.

Cancel Annotation

If you cancel an annotation through the UI, it leaves the draw rect on the canvas.

To reproduce ~ Draw new annotation, Editor Shows, Press Cancel button, annotation remains on screen.

Delete Annotation

I'm getting an error message when I delete an annotation.

openseadragon-annotorious.min.js:1 Uncaught ReferenceError: annotation is not defined
    at Object.onAnnotationDeleted (openseadragon-annotorious.min.js:1)
    at Object.u [as click] (openseadragon-annotorious.min.js:1)
    at HTMLButtonElement.b (openseadragon-annotorious.min.js:1)

Possibility to start the annotation on click of a button

Is it possible add another event to start an annotation?
To start an annotation it is now required hold the shift key. For a not expert user it can be not easy to use.
So it can be helpful add an event listener to start the tracking on click on a DOM element with a certain id.
For example, in OSDAnnotationLayer.js, add the following lines:

document.getElementById("annotorious-start-selection").addEventListener("click", () => { this.mouseTracker.setTracking(true); });

Formatters for AnnotoriousOSD

How can we add annotation with style options such as line colour, width etc.

Looked at Web Annotation Model and came up with this

        var annotation = [
            {
                "type": "Annotation",
                "stylesheet": {
                    "type": "CssStylesheet",
                    "value": ".red { color: red }"
                },
                "body": [{ "type": "TextualBody", "value": "Logo", "purpose": "commenting" }],
                "target": { "selector": { "type": "FragmentSelector", "conformsTo": "http://www.w3.org/TR/media-frags/", "value": "xywh=pixel:4529.12646484375,1530.34130859375,871.17236328125,131.33251953125" }, "styleClass": "red" },
                "@context": "http://www.w3.org/ns/anno.jsonld", "id": "#3e4502d0-923a-11ea-95ff-25ef2ceeaad8"
            }]

but it did not display annotation in a red colour.

Setters for readOnly and disableEditor are async operations

Outside of readOnly mode, I am able to create, edit, and delete annotations with no issues, but as soon as I set readOnly to true and attempt to create an annotation, this happens:
annotation_issue
Also, when I am logging anno.readOnly I am getting that it is undefined even though I am setting it on the previous line.
Here is my init code:

var perms = drupalSettings.recogito_integration.permissions;
  var user_data = drupalSettings.recogito_integration.user_data;
  var readOnly1 = (!perms['recogito create annotations'] &&
      !perms['recogito edit annotations'] &&
      !perms['recogito delete annotations'] &&
      !perms['recogito edit own annotations'] &&
      !perms['recogito delete own annotations']);

  var image_anno = OpenSeadragon.Annotorious(viewer);
  image_anno.readOnly = (readOnly1 || window.location.search !== "?mode=annotation");
  image_anno.disableEditor = image_anno.readOnly;
  image_anno.setAuthInfo({'id': user_data.id, 'displayName': user_data.displayName});

  var page_url = window.location.pathname;

  jQuery.ajax({
    type: "GET",
    url: "/recogito_integration/get",
    dataType: 'json',
    headers: {
      'pageurl': page_url,
    },

    success: function (data) {
      console.log(data);
      for (annotation in data) {

        w3c = convert_annotation_w3c(data[annotation]);
        if(w3c.type != "Annotation")
        {
          image_anno.addAnnotation(w3c);
        }
      }
    },
    error: function (xhr, status, error) {
      alert(xhr.responseText);
    }
  });


  image_anno.on('selectAnnotation', function (annotation) {

    highlightAnnotatedContent(annotation);

  });

  image_anno.on('createAnnotation', function (annotation) {

    console.log("createAnnotation: " + typeof annotation);
    create_annotation(annotation);
  });

  image_anno.on('updateAnnotation', function (annotation, previous) {

    console.log(annotation);
    console.log(previous);
    update_annotation(annotation, previous);
  });

  image_anno.on('deleteAnnotation', function (annotation) {
    delete_annotation(annotation);
  });

Add vite build config

For some reason, vite produces a significantly larger bundle (600+kB vs. ~400kB).

fitBounds Padding

Would it be possible to pass a padding value with the fitBound method.

anno.fitBounds(annotation.id, false, 20);

where 20 is 20px.

All the other functionality just released works beautifully!!

clear all annotations (≠ anno.destroy() )

i'm playing with webview to make a desktop app with annotorius that persists annotations locally into an sqlite file.

i will publish in github soon, meanwhile 👇
Screenshot 2020-06-29 at 17 40 32

the problem: i'm opening new canvases from IIIF manifest with viewer.open(), but when changing the tile the annotation layer persists. i'm wondering if can be useful an api method to clear all annotations (not actually the current destroy() method)

this new clear() method could be sticked inside osd open event.

or maybe i can use anno.getAnnotations() and then looping and remove every annotation?

PS/ right now .getAnnotations() seems missing
o.annotationLayer.getAnnotations is not a function. (In 'o.annotationLayer.getAnnotations()', 'o.annotationLayer.getAnnotations' is undefined)

Fullscreen annotations disappear

Good day,

I have integrated the annotrious-openseadragon into my project and overall it's working quite well! Although I noticed that when the application goes into full screen mode, all of the annotations seem to disappear. Any thoughts on why this is happening and how to remedy? I am using a bleeding edge head revision of the base annotrious library because I require the annotation editability so that may be a factor.

Again, thanks for all the great work! This project saved my bacon!

Thanks!
Brian

Thumbnail/ToDataURL

Would it be possible to get a thumbnail of the image within the bounds of the annotations rectangle? This could then be saved and used to show an index of the available annotations for example.
The image data would be posted back in the created event as 64bit data string?
This might be achievable via open seadraggon all ready??

Disable Annotorious Plugin (Editor + Draw)

I see headless mode (and disableEditor) allows for just the drawing aspect of the plugin... is there a way to disable the draw and the editor programatically? End goal here is to allow users to toggle annotorious on and off as needed.

Drawing Annotation Over OSD's Navigator

I have the OSD Nagivator control in the BOTTOM_RIGHT position. When you draw an anotation which might touch it, the draw rectangle inverts and jumps to the top left position.

I attach two screen shots of this behaviour.
Annotation1
Annotation2

getAnnotations method throws an error when called from selectAnnotation event handler

While trying to get all the current annotations in the selectAnnotation event handler, the following error is thrown:

OpenSeadragonAnnotator.jsx:241 Uncaught (in promise) TypeError: Cannot read property 'clone' of undefined
    at OpenSeadragonAnnotator.jsx:241
    at Array.map (<anonymous>)
    at p.getAnnotations (OpenSeadragonAnnotator.jsx:241)
    at e.getAnnotations (index.js:131)
    at (index):101
    at n.emit (index.js:36)
    at Object.onAnnotationSelected (index.js:73)
    at p.<anonymous> (OpenSeadragonAnnotator.jsx:83)
    at index.js:271
    at Array.some (<anonymous>)

Fullscreen mode

Need to figure out what‘s going on there. Currently doesn’t work at all. Z-index is only one part of the issue.

readonly mode

Just like in standard Annotorious. Should by mostly a bit of extra plumbing.

Touch navigation breaks after starting pinch/pan gesture on annotation

It looks like touch navigation breaks when starting a touch gesture on an annotation. Once this was done once, touch navigation remains broken! As long as you just select an annotation (with a single tap), or do pan/pinch gestures outside of annotation shapes, things work just fine.

Note: this is almost certainly related to OSD's weird ways of handling touch/mouse events, and might (hopefully) go away with the release of OSD 3.0, for which event handling was thoroughly revised.

panTo API method

Similar to the one that comes with OpenSeadragon, but taking an annotation (id) as an argument. Also take an immediate argument (and forward to OSD).

selectAnnotation Method

Can there be a selectAnnotation method.

var selectedAnnotation = anno.selectAnnotation('#GUID');

Pass annotation id to select, return annotation object if found.

destroy()

There does not appear to be a .destroy() method. Subsequent .init() methods seem to work though, so switch between different images with .init() works, but previous versions have had .destroy() method.

Annotorious icons are not visible and state remains as promise

I'm trying to use the plug-in.
I'm calling:
var anno = OpenSeadragon.Annotorious(myViewer);
This creates an object
Afterwards, I call:
anno.loadAnnotations('annotations.w3c.json');
But this Promise object remains pending

I don't see any icons to use for annotation.
I'm missing something and would really appreciate some guidance.
Regards

Port startSelection event

Added recently to Annotorious standard version. A bit of plumbing is needed to make it work in OSD, too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.