Skip to content

Commit cb7df65

Browse files
author
Dennis Ried
committed
Merge branch 'rel/1.0.0-beta.4'
# Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
2 parents e25730f + e808929 commit cb7df65

11 files changed

+202
-93
lines changed

add/data/xql/getAnnotationsOnPage.xql

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ declare function local:getParticipants($annoId as xs:string, $plist as xs:string
124124
for $p in $participants
125125
let $coord := local:getCoordinates($p)
126126
return map {
127-
'id': $annoId || '__' || string($p/@xml:id),
127+
'id': 'annotation__' || string($p/@xml:id),
128128
'type': string($p/@type),
129129
'ulx': $coord[1],
130130
'uly': $coord[2],

add/data/xql/getMusicInMdiv.xql

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,27 @@ xquery version "3.0";
22

33
declare namespace request="http://exist-db.org/xquery/request";
44
declare namespace mei="http://www.music-encoding.org/ns/mei";
5+
declare namespace system="http://exist-db.org/xquery/system";
6+
declare namespace transform="http://exist-db.org/xquery/transform";
57

68
let $uri := request:get-parameter('uri', '')
79
let $movementId := request:get-parameter('movementId', '')
810
let $mei := doc($uri)/root()
911
let $mdiv := if($movementId eq '')
1012
then($mei//mei:mdiv[1])
1113
else($mei/id($movementId))
14+
15+
let $base := concat(replace(system:get-module-load-path(), 'embedded-eXist-server', ''), '/../xslt/')
16+
let $data := transform:transform($mdiv, concat($base, 'edirom_prepareAnnotsForRendering.xsl'), <parameters/>)
17+
1218

1319
return
1420
<mei xmlns="http://www.music-encoding.org/ns/mei" xmlns:xlink="http://www.w3.org/1999/xlink" meiversion="4.0.0">
1521
{$mei//mei:meiHead}
1622
<music>
1723
<facsimile/>
1824
<body>
19-
{$mdiv}
25+
{$data}
2026
</body>
2127
</music>
2228
</mei>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3+
xmlns:xs="http://www.w3.org/2001/XMLSchema"
4+
xmlns:math="http://www.w3.org/2005/xpath-functions/math"
5+
xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
6+
xmlns:mei="http://www.music-encoding.org/ns/mei"
7+
exclude-result-prefixes="xs math xd mei"
8+
version="3.0">
9+
<xd:doc scope="stylesheet">
10+
<xd:desc>
11+
<xd:p><xd:b>Created on:</xd:b> Jun 25, 2022</xd:p>
12+
<xd:p><xd:b>Author:</xd:b> Johannes Kepper</xd:p>
13+
<xd:p>
14+
This XSLT massages annot elements in MEI to make it easier to pick them up for rendering annotations on top of a Verovio rendering.
15+
</xd:p>
16+
</xd:desc>
17+
</xd:doc>
18+
19+
<!-- no indentation to save bandwidth -->
20+
<xsl:output method="xml" indent="no"/>
21+
22+
<xsl:variable name="annots" as="node()*">
23+
<xsl:for-each select="//mei:annot[contains(@type,'editorialComment')][@tstamp2]">
24+
<!-- get only those annots that affect more than one measure -->
25+
<xsl:if test="not(starts-with(@tstamp2,'0m'))">
26+
<annotRef annot="{@xml:id}" class="{@class}" staff="{@staff}">
27+
<xsl:variable name="affects.num" select="xs:integer(substring-before(@tstamp2,'m+'))" as="xs:integer"/>
28+
<xsl:variable name="measure.ids" select="parent::mei:measure/following::mei:measure[position() le $affects.num]/xs:string(@xml:id)" as="xs:string+"/>
29+
<xsl:for-each select="$measure.ids">
30+
<measure ref="{.}" pos="{position()}"/>
31+
</xsl:for-each>
32+
</annotRef>
33+
</xsl:if>
34+
</xsl:for-each>
35+
</xsl:variable>
36+
37+
<xsl:template match="/">
38+
<xsl:message select="'Found ' || count($annots/descendant-or-self::annotRef) || ' annotRefs with ' || count($annots//measure) || ' measures'"/>
39+
<xsl:apply-templates select="node()"/>
40+
</xsl:template>
41+
42+
<xsl:template match="mei:measure">
43+
<xsl:variable name="measure.id" select="string(@xml:id)" as="xs:string"/>
44+
<xsl:copy>
45+
<xsl:apply-templates select="node() | @*"/>
46+
<xsl:for-each select="$annots//measure[@ref = $measure.id]">
47+
<xsl:message select="' gotcha: ' || $measure.id"/>
48+
<xsl:variable name="measureRef" select="." as="element()"/>
49+
<xsl:variable name="annotRef" select="$measureRef/parent::annotRef" as="element()"/>
50+
<annot xmlns="http://www.music-encoding.org/ns/mei">
51+
<xsl:attribute name="type" select="'annotRef ' || replace($annotRef/@class,'#','')"/>
52+
<xsl:attribute name="staff" select="$annotRef/@staff"/>
53+
<xsl:attribute name="xml:id" select="$annotRef/@annot"/>
54+
</annot>
55+
</xsl:for-each>
56+
</xsl:copy>
57+
</xsl:template>
58+
59+
<xsl:template match="mei:annot[contains(@type, 'editorialComment')]">
60+
<xsl:copy>
61+
<xsl:apply-templates select="@* except @type"/>
62+
<xsl:attribute name="type" select="xs:string(@type) || ' ' || replace(@class,'#','')"/>
63+
<xsl:apply-templates select="node()"/>
64+
</xsl:copy>
65+
</xsl:template>
66+
67+
<xsl:template match="node() | @*" mode="#all">
68+
<xsl:copy>
69+
<xsl:apply-templates select="node() | @*" mode="#current"/>
70+
</xsl:copy>
71+
</xsl:template>
72+
73+
74+
</xsl:stylesheet>

app/view/window/image/OpenSeaDragonViewer.js

+35-22
Original file line numberDiff line numberDiff line change
@@ -288,15 +288,14 @@ Ext.define('EdiromOnline.view.window.image.OpenSeaDragonViewer', {
288288

289289
annotations.each(function(annotation) {
290290

291+
var annoId = annotation.get('id');
291292
var name = annotation.get('title');
292293
var uri = annotation.get('uri');
293294
var categories = annotation.get('categories');
294295
var priority = annotation.get('priority');
295296
var fn = annotation.get('fn');
296297
var plist = Ext.Array.toArray(annotation.get('plist'));
297298

298-
Ext.Array.insert(me.shapes.get('annotations'), 0, plist);
299-
300299
Ext.Array.each(plist, function(shape) {
301300

302301
var id = shape.id;
@@ -306,33 +305,43 @@ Ext.define('EdiromOnline.view.window.image.OpenSeaDragonViewer', {
306305
var height = shape.lry - shape.uly;
307306
var partType = shape.type;
308307

309-
var anno = document.createElement("div");
310-
anno.id = me.id + '_' + id;
311-
anno.className = "annotation " + categories + ' ' + priority + ' ' + partType;
308+
var anno = me.viewer.getOverlayById(me.id + '_' + id);
309+
if(anno === null) {
310+
311+
var anno = document.createElement('div');
312+
anno.id = me.id + '_' + id;
313+
anno.className = 'annotation';
314+
315+
var annoIcon = document.createElement('div');
316+
annoIcon.id = annoId + '_' + anno.id + '_inner';
317+
annoIcon.className = 'annotIcon ' + categories + ' ' + priority + ' ' + partType;
318+
anno.append(annoIcon);
319+
320+
var point = me.viewer.viewport.imageToViewportCoordinates(x, y);
321+
var rect = me.viewer.viewport.imageToViewportRectangle(x, y, width, height);
322+
323+
me.viewer.addOverlay({element:anno, location:new OpenSeadragon.Rect(point.x, point.y, rect.width, rect.height)});
312324

313-
var annoIcon = document.createElement("div");
314-
annoIcon.id = anno.id + '_inner';
315-
annoIcon.className = "annotIcon";
316-
anno.append(annoIcon);
325+
}else {
326+
327+
var anno = me.el.getById(me.id + '_' + id);
328+
var annoIcon = document.createElement('div');
329+
annoIcon.id = annoId + '_' + anno.id + '_inner';
330+
annoIcon.className = 'annotIcon ' + categories + ' ' + priority + ' ' + partType;
331+
anno.dom.append(annoIcon);
332+
}
333+
334+
Ext.Array.push(me.shapes.get('annotations'), annoId + '_' + anno.id + '_inner');
335+
var annoIcon = me.el.getById(annoId + '_' + anno.id + '_inner');
317336

318-
var point = me.viewer.viewport.imageToViewportCoordinates(x, y);
319-
var rect = me.viewer.viewport.imageToViewportRectangle(x, y, width, height);
320-
321-
me.viewer.addOverlay({
322-
element: anno,
323-
location: new OpenSeadragon.Rect(point.x, point.y, rect.width, rect.height)
324-
});
325-
326-
var anno = me.el.getById(me.id + '_' + id);
327-
328-
anno.on('click', me.openShapeLink, me, {
337+
annoIcon.on('click', me.openShapeLink, me, {
329338
single: true,
330339
stopEvent : true,
331340
fn: fn
332341
});
333342

334343
var tip = Ext.create('Ext.tip.ToolTip', {
335-
target: me.id + '_' + id,
344+
target: annoId + '_' + anno.id + '_inner',
336345
cls: 'annotationTip',
337346
width: me.annotTipWidth,
338347
maxWidth: me.annotTipMaxWidth,
@@ -386,7 +395,11 @@ Ext.define('EdiromOnline.view.window.image.OpenSeaDragonViewer', {
386395
getShapeElem: function(shapeId) {
387396

388397
var me = this;
389-
return me.el.getById(me.id + '_' + shapeId);
398+
var elem = me.el.getById(me.id + '_' + shapeId);
399+
if(elem === null)
400+
elem = me.el.getById(shapeId);
401+
402+
return elem;
390403
},
391404

392405
listenForShapeLink: function(e, dom, args) {

app/view/window/source/MeasureBasedView.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -635,9 +635,9 @@ Ext.define('EdiromOnline.view.window.source.HorizontalMeasureViewer', {
635635
else{
636636

637637
var fn = Ext.bind(function(annotation) {
638-
var annotDiv = viewer.getShapeElem(annotation.id);
638+
var annotDiv = viewer.getShapeElem(annotation);
639639

640-
var className = annotDiv.dom.className.replace('annotation', '').trim();
640+
var className = annotDiv.dom.className.replace('annotIcon', '').trim();
641641
var classes = className.split(' ');
642642

643643
var hasCategory = false;
@@ -648,10 +648,13 @@ Ext.define('EdiromOnline.view.window.source.HorizontalMeasureViewer', {
648648
hasPriority |= Ext.Array.contains(visiblePriorities, classes[i]);
649649
}
650650

651-
annotDiv.setVisible(hasCategory & hasPriority);
651+
if(hasCategory & hasPriority)
652+
annotDiv.removeCls('hidden');
653+
else
654+
annotDiv.addCls('hidden');
652655
}, me);
653656

654-
if(annotation != undefined) {
657+
if (typeof annotations !== 'undefined') {
655658
if(annotations.each)
656659
annotations.each(fn);
657660
else

app/view/window/source/PageBasedView.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ Ext.define('EdiromOnline.view.window.source.PageBasedView', {
7979
}
8080

8181
var fn = Ext.bind(function(annotation) {
82-
var annotDiv = this.imageViewer.getShapeElem(annotation.id);
82+
var annotDiv = this.imageViewer.getShapeElem(annotation);
8383

84-
var className = annotDiv.dom.className.replace('annotation', '').trim();
84+
var className = annotDiv.dom.className.replace('annotIcon', '').trim();
8585

8686
var classes = className.split(' ');
8787

@@ -92,10 +92,12 @@ Ext.define('EdiromOnline.view.window.source.PageBasedView', {
9292
hasCategory |= Ext.Array.contains(visibleCategories, classes[i]);
9393

9494
hasPriority |= Ext.Array.contains(visiblePriorities, classes[i]);
95-
9695
}
97-
annotDiv.setVisible(true);
98-
//annotDiv.setVisible(hasCategory & hasPriority);
96+
97+
if(hasCategory & hasPriority)
98+
annotDiv.removeCls('hidden');
99+
else
100+
annotDiv.addCls('hidden');
99101
}, me);
100102

101103
if(annotations.each)

build.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<import file="${basedir}/.sencha/app/build-impl.xml"/>
55

6-
<property name="project.version" value="1.0.0-beta.3"/>
6+
<property name="project.version" value="1.0.0-beta.4"/>
77
<property name="project.app" value="Edirom-Online"/>
88
<property name="project.title" value="Edirom Online"/>
99
<property name="repo.target" value="${project.app}"/>

packages/eoTheme/sass/etc/facsimile.scss

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@
4646
@include box-shadow(0 0 20px rgba(0,0,0,0.5));
4747
}
4848

49-
&.ediromAnnotPrio1 .annotIcon {
49+
.annotIcon.ediromAnnotPrio1 {
5050
@include background(linear-gradient(top,rgba(255,48,25,0.85) 0%, rgba(207,4,4,0.85) 100%));
5151
}
5252

53-
&.ediromAnnotPrio2 .annotIcon {
53+
.annotIcon.ediromAnnotPrio2 {
5454
@include background(linear-gradient(top,rgba(255,233,91,0.85) 0%, rgba(255,107,15,0.85) 100%));
5555
}
5656

57-
&.ediromAnnotPrio3 .annotIcon {
57+
.annotIcon.ediromAnnotPrio3 {
5858
@include background(linear-gradient(top,rgba(254,252,234,0.85) 0%, rgba(241,218,54,0.85) 100%));
5959
}
6060

resources/css/todo.css

+5-2
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,12 @@ span.musicalSymbol {
9292
}
9393

9494
.ediromWindow .annotation {
95-
border: 1px solid red;
96-
background-color: rgba(255, 0, 0, 0.3);
9795
z-index: 10;
96+
display: flex !important;
97+
justify-content: center;
98+
align-items: center;
99+
flex-wrap: wrap;
100+
align-content: center;
98101
}
99102

100103

resources/css/verovio-view.css

+25
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,31 @@ body {
4545
font-size: 1.3em;
4646
}
4747

48+
.annotIcon {
49+
fill: #ff000066;
50+
}
51+
52+
.annotIcon.ediromAnnotPrio1 {
53+
fill: rgba(207, 4, 4, 0.7);
54+
}
55+
56+
.annotIcon.ediromAnnotPrio2{
57+
fill: rgba(255, 107, 15, 0.7);
58+
}
59+
60+
.annotIcon.ediromAnnotPrio3 {
61+
fill: rgba(241, 218, 54, 0.7);
62+
}
63+
64+
.lem, .lem *, .supplied, .supplied * {
65+
fill: grey;
66+
stroke: grey;
67+
}
68+
69+
.bounding-box, .bounding-box * {
70+
fill: transparent;
71+
}
72+
4873
.noselect {
4974
-webkit-touch-callout: none; /* iOS Safari */
5075
-webkit-user-select: none; /* Safari */

0 commit comments

Comments
 (0)