@abi-software/flatmap-viewer 2.3.1-b.1 → 2.3.2-b.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.rst +1 -1
- package/package.json +1 -1
- package/src/annotation.js +14 -9
- package/src/controls/controls.js +133 -229
- package/src/controls/info.js +2 -0
- package/src/controls/paths.js +143 -0
- package/src/controls/systems.js +18 -9
- package/src/flatmap-viewer.js +14 -11
- package/src/interactions.js +110 -91
- package/src/layers.js +2 -2
- package/src/pathways.js +108 -91
- package/src/styling.js +62 -43
- package/src/systems.js +53 -36
- package/src/utils.js +18 -0
package/README.rst
CHANGED
|
@@ -38,7 +38,7 @@ The map server endpoint is specified as ``MAP_ENDPOINT`` in ``src/main.js``. It
|
|
|
38
38
|
Package Installation
|
|
39
39
|
====================
|
|
40
40
|
|
|
41
|
-
* ``npm install @abi-software/flatmap-viewer@2.3.
|
|
41
|
+
* ``npm install @abi-software/flatmap-viewer@2.3.2-b.1``
|
|
42
42
|
|
|
43
43
|
Documentation
|
|
44
44
|
-------------
|
package/package.json
CHANGED
package/src/annotation.js
CHANGED
|
@@ -639,16 +639,21 @@ export class Annotator
|
|
|
639
639
|
//========================
|
|
640
640
|
{
|
|
641
641
|
const url = this.__flatmap.makeServerUrl('', 'annotator/');
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
642
|
+
try {
|
|
643
|
+
const response = await fetch(url, {
|
|
644
|
+
headers: {
|
|
645
|
+
"Accept": "application/json; charset=utf-8",
|
|
646
|
+
"Cache-Control": "no-store"
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
if (response.ok) {
|
|
650
|
+
return response.json();
|
|
651
|
+
} else {
|
|
652
|
+
console.error(`Annotated features: ${response.status} ${response.statusText}`);
|
|
653
|
+
return Promise.resolve([]);
|
|
646
654
|
}
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
return response.json();
|
|
650
|
-
} else {
|
|
651
|
-
console.error(`Annotated features: ${response.status} ${response.statusText}`);
|
|
655
|
+
} catch {
|
|
656
|
+
console.error(`Fetch failed -- is annotator available at ${this.__flatmap._baseUrl} ?`);
|
|
652
657
|
return Promise.resolve([]);
|
|
653
658
|
}
|
|
654
659
|
}
|
package/src/controls/controls.js
CHANGED
|
@@ -32,12 +32,15 @@ function standardise_color(str){
|
|
|
32
32
|
|
|
33
33
|
//==============================================================================
|
|
34
34
|
|
|
35
|
-
export class
|
|
35
|
+
export class Control
|
|
36
36
|
{
|
|
37
|
-
constructor(flatmap)
|
|
37
|
+
constructor(flatmap, id, name)
|
|
38
38
|
{
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
39
|
+
this.__flatmap = flatmap;
|
|
40
|
+
this.__id = id;
|
|
41
|
+
this.__name = name;
|
|
42
|
+
this.__map = undefined;
|
|
43
|
+
this.__prefix = `${this.__id}-`
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
getDefaultPosition()
|
|
@@ -46,48 +49,140 @@ export class NavigationControl
|
|
|
46
49
|
return 'top-right';
|
|
47
50
|
}
|
|
48
51
|
|
|
52
|
+
_addControlDetails()
|
|
53
|
+
//==================
|
|
54
|
+
{
|
|
55
|
+
return {
|
|
56
|
+
enabled: 0,
|
|
57
|
+
total: 0
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
_enableAll(enable)
|
|
62
|
+
//================
|
|
63
|
+
{
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
__setAllCheckedState()
|
|
67
|
+
//====================
|
|
68
|
+
{
|
|
69
|
+
if (this.__checkedCount === 0) {
|
|
70
|
+
this.__allCheckbox.checked = false;
|
|
71
|
+
this.__allCheckbox.indeterminate = false;
|
|
72
|
+
} else if (this.__checkedCount === this.__totalCount) {
|
|
73
|
+
this.__allCheckbox.checked = true;
|
|
74
|
+
this.__allCheckbox.indeterminate = false;
|
|
75
|
+
} else {
|
|
76
|
+
this.__allCheckbox.indeterminate = true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
_addControlLine(id, name, style=null)
|
|
81
|
+
//===================================
|
|
82
|
+
{
|
|
83
|
+
const label = document.createElement('label');
|
|
84
|
+
label.setAttribute('for', id);
|
|
85
|
+
if (style !== null) {
|
|
86
|
+
label.setAttribute('style', style);
|
|
87
|
+
}
|
|
88
|
+
label.textContent = name;
|
|
89
|
+
this.__control.appendChild(label);
|
|
90
|
+
const input = document.createElement('input');
|
|
91
|
+
input.setAttribute('type', 'checkbox');
|
|
92
|
+
input.id = id;
|
|
93
|
+
this.__control.appendChild(input);
|
|
94
|
+
return input;
|
|
95
|
+
}
|
|
96
|
+
|
|
49
97
|
onAdd(map)
|
|
50
98
|
//========
|
|
51
99
|
{
|
|
52
|
-
this.
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this.
|
|
59
|
-
|
|
100
|
+
this.__map = map;
|
|
101
|
+
this.__container = document.createElement('div');
|
|
102
|
+
this.__container.className = 'maplibregl-ctrl flatmap-control';
|
|
103
|
+
this.__control = document.createElement('div');
|
|
104
|
+
this.__control.className = 'flatmap-control-grid';
|
|
105
|
+
|
|
106
|
+
this.__allCheckbox = this._addControlLine(`control-all-${this.__id}`, `ALL ${this.__name.toUpperCase()}:`);
|
|
107
|
+
const controlDetails = this._addControlDetails();
|
|
108
|
+
this.__totalCount = controlDetails.total;
|
|
109
|
+
this.__halfCount = Math.trunc(this.__totalCount/2);
|
|
110
|
+
this.__checkedCount = controlDetails.enabled;
|
|
111
|
+
this.__setAllCheckedState();
|
|
112
|
+
|
|
113
|
+
/*
|
|
114
|
+
const innerDetails = this._innerLinesHTML();
|
|
115
|
+
const innerHTML = innerDetails.html;
|
|
116
|
+
innerHTML.splice(0, 0, `<label for="control-all-${this.__id}">ALL ${this.__name.toUpperCase()}:</label><input id="control-all-${this.__id}" type="checkbox"/>`);
|
|
117
|
+
this.__control.innerHTML = innerHTML.join('\n');
|
|
118
|
+
|
|
119
|
+
this.__totalCount = innerHTML.length;
|
|
120
|
+
this.__halfCount = Math.trunc(this.__totalCount/2);
|
|
121
|
+
this.__checkedCount = innerDetails.enabled;
|
|
122
|
+
this.__allCheckbox = document.getElementById(`control-all-${this.__id}`);
|
|
123
|
+
this.__setAllCheckedState();
|
|
124
|
+
*/
|
|
125
|
+
|
|
126
|
+
this.__button = document.createElement('button');
|
|
127
|
+
this.__button.id = `flatmap-${this.__id}-button`;
|
|
128
|
+
this.__button.className = 'control-button text-button';
|
|
129
|
+
this.__button.setAttribute('type', 'button');
|
|
130
|
+
this.__button.setAttribute('aria-label', `Show/hide map's ${this.__name}`);
|
|
131
|
+
this.__button.setAttribute('control-visible', 'false');
|
|
132
|
+
this.__button.textContent = this.__name.toUpperCase().substring(0, 6);
|
|
133
|
+
this.__button.title = `Show/hide map's ${this.__name}`;
|
|
134
|
+
this.__container.appendChild(this.__button);
|
|
135
|
+
|
|
136
|
+
this.__container.addEventListener('click', this.onClick_.bind(this));
|
|
137
|
+
return this.__container;
|
|
60
138
|
}
|
|
61
139
|
|
|
62
140
|
onRemove()
|
|
63
141
|
//========
|
|
64
142
|
{
|
|
65
|
-
this.
|
|
66
|
-
this.
|
|
143
|
+
this.__container.parentNode.removeChild(this.__container);
|
|
144
|
+
this.__map = undefined;
|
|
67
145
|
}
|
|
68
146
|
|
|
69
|
-
onClick_(
|
|
70
|
-
|
|
147
|
+
onClick_(event)
|
|
148
|
+
//=============
|
|
71
149
|
{
|
|
72
|
-
if
|
|
73
|
-
this.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
150
|
+
if (event.target.id === `flatmap-${this.__id}-button`) {
|
|
151
|
+
if (this.__button.getAttribute('control-visible') === 'false') {
|
|
152
|
+
this.__container.appendChild(this.__control);
|
|
153
|
+
this.__button.setAttribute('control-visible', 'true');
|
|
154
|
+
this.__control.focus();
|
|
155
|
+
} else {
|
|
156
|
+
this.__control = this.__container.removeChild(this.__control);
|
|
157
|
+
this.__button.setAttribute('control-visible', 'false');
|
|
158
|
+
}
|
|
159
|
+
} else if (event.target.tagName === 'INPUT') {
|
|
160
|
+
if (event.target.id === `control-all-${this.__id}`) {
|
|
161
|
+
if (event.target.indeterminate) {
|
|
162
|
+
event.target.checked = (this.__checkedCount >= this.__halfCount);
|
|
163
|
+
event.target.indeterminate = false;
|
|
164
|
+
}
|
|
165
|
+
this.__checkedCount = event.target.checked ? this.__totalCount : 0;
|
|
166
|
+
this._enableAll(event.target.checked);
|
|
167
|
+
} else if (event.target.id.startsWith(`${this.__id}-`)) {
|
|
168
|
+
this.__enableControl(event.target.id.substring(this.__prefix.length),
|
|
169
|
+
event.target.checked);
|
|
170
|
+
this.__checkedCount += (event.target.checked ? 1 : -1);
|
|
171
|
+
this.__setAllCheckedState();
|
|
172
|
+
}
|
|
78
173
|
}
|
|
174
|
+
event.stopPropagation();
|
|
79
175
|
}
|
|
80
176
|
}
|
|
81
177
|
|
|
82
178
|
//==============================================================================
|
|
83
179
|
|
|
84
|
-
export class
|
|
180
|
+
export class NavigationControl
|
|
85
181
|
{
|
|
86
|
-
constructor(flatmap
|
|
182
|
+
constructor(flatmap)
|
|
87
183
|
{
|
|
88
184
|
this._flatmap = flatmap;
|
|
89
185
|
this._map = undefined;
|
|
90
|
-
this.__pathTypes = pathTypes;
|
|
91
186
|
}
|
|
92
187
|
|
|
93
188
|
getDefaultPosition()
|
|
@@ -101,41 +196,11 @@ export class PathControl
|
|
|
101
196
|
{
|
|
102
197
|
this._map = map;
|
|
103
198
|
this._container = document.createElement('div');
|
|
104
|
-
this._container.className = 'maplibregl-ctrl';
|
|
105
|
-
this._container.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
this.
|
|
109
|
-
this._legend.className = 'flatmap-nerve-grid';
|
|
110
|
-
|
|
111
|
-
const innerHTML = [];
|
|
112
|
-
innerHTML.push(`<label for="path-all-paths">ALL PATHS:</label><div class="nerve-line"></div><input id="path-all-paths" type="checkbox" checked/>`);
|
|
113
|
-
this.__checkedCount = 0;
|
|
114
|
-
for (const path of this.__pathTypes) {
|
|
115
|
-
const checked = !('enabled' in path) || path.enabled ? 'checked' : '';
|
|
116
|
-
if (checked != '') {
|
|
117
|
-
this.__checkedCount += 1;
|
|
118
|
-
}
|
|
119
|
-
const colour = path.colour || '#440';
|
|
120
|
-
const style = path.dashed ? `background: repeating-linear-gradient(to right,${colour} 0,${colour} 6px,transparent 6px,transparent 9px);`
|
|
121
|
-
: `background: ${colour};`;
|
|
122
|
-
|
|
123
|
-
innerHTML.push(`<label for="path-${path.type}">${path.label}</label><div class="nerve-line" style="${style}"></div><input id="path-${path.type}" type="checkbox" ${checked}/>`);
|
|
124
|
-
}
|
|
125
|
-
this._legend.innerHTML = innerHTML.join('\n');
|
|
126
|
-
this.__halfCount = Math.trunc(this.__pathTypes.length/2);
|
|
127
|
-
|
|
128
|
-
this._button = document.createElement('button');
|
|
129
|
-
this._button.id = 'nerve-key-button';
|
|
130
|
-
this._button.className = 'control-button text-button';
|
|
131
|
-
this._button.setAttribute('type', 'button');
|
|
132
|
-
this._button.setAttribute('aria-label', 'Nerve paths legend');
|
|
133
|
-
this._button.setAttribute('control-visible', 'false');
|
|
134
|
-
this._button.textContent = 'PATHS';
|
|
135
|
-
this._button.title = 'Show/hide neuron paths';
|
|
136
|
-
this._container.appendChild(this._button);
|
|
137
|
-
|
|
138
|
-
this._container.addEventListener('click', this.onClick_.bind(this));
|
|
199
|
+
this._container.className = 'maplibregl-ctrl navigation-group';
|
|
200
|
+
this._container.innerHTML = `<button id="flatmap-zoom-in" class="navigation-zoom-in" type="button" title="Zoom in" aria-label="Zoom in"></button>
|
|
201
|
+
<button id="flatmap-zoom-out" class="navigation-zoom-out" type="button" title="Zoom out" aria-label="Zoom out"></button>
|
|
202
|
+
<button id="flatmap-reset" class="navigation-reset" type="button" title="Reset" aria-label="Reset"></button>`;
|
|
203
|
+
this._container.onclick = this.onClick_.bind(this);
|
|
139
204
|
return this._container;
|
|
140
205
|
}
|
|
141
206
|
|
|
@@ -146,60 +211,16 @@ export class PathControl
|
|
|
146
211
|
this._map = undefined;
|
|
147
212
|
}
|
|
148
213
|
|
|
149
|
-
onClick_(
|
|
150
|
-
|
|
214
|
+
onClick_(e)
|
|
215
|
+
//=========
|
|
151
216
|
{
|
|
152
|
-
if
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
&& this.__checkedCount > 0;
|
|
159
|
-
this._legend.focus();
|
|
160
|
-
} else {
|
|
161
|
-
this._legend = this._container.removeChild(this._legend);
|
|
162
|
-
this._button.setAttribute('control-visible', 'false');
|
|
163
|
-
}
|
|
164
|
-
} else if (event.target.tagName === 'INPUT') {
|
|
165
|
-
if (event.target.id === 'path-all-paths') {
|
|
166
|
-
if (event.target.indeterminate) {
|
|
167
|
-
event.target.checked = (this.__checkedCount >= this.__halfCount);
|
|
168
|
-
event.target.indeterminate = false;
|
|
169
|
-
}
|
|
170
|
-
if (event.target.checked) {
|
|
171
|
-
this.__checkedCount = this.__pathTypes.length;
|
|
172
|
-
} else {
|
|
173
|
-
this.__checkedCount = 0;
|
|
174
|
-
}
|
|
175
|
-
for (const path of this.__pathTypes) {
|
|
176
|
-
const pathCheckbox = document.getElementById(`path-${path.type}`);
|
|
177
|
-
if (pathCheckbox) {
|
|
178
|
-
pathCheckbox.checked = event.target.checked;
|
|
179
|
-
this._flatmap.enablePath(path.type, event.target.checked);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
} else if (event.target.id.startsWith('path-')) {
|
|
183
|
-
const pathType = event.target.id.substring(5);
|
|
184
|
-
this._flatmap.enablePath(pathType, event.target.checked);
|
|
185
|
-
if (event.target.checked) {
|
|
186
|
-
this.__checkedCount += 1;
|
|
187
|
-
} else {
|
|
188
|
-
this.__checkedCount -= 1;
|
|
189
|
-
}
|
|
190
|
-
const allPathsCheckbox = document.getElementById('path-all-paths');
|
|
191
|
-
if (this.__checkedCount === 0) {
|
|
192
|
-
allPathsCheckbox.checked = false;
|
|
193
|
-
allPathsCheckbox.indeterminate = false;
|
|
194
|
-
} else if (this.__checkedCount === this.__pathTypes.length) {
|
|
195
|
-
allPathsCheckbox.checked = true;
|
|
196
|
-
allPathsCheckbox.indeterminate = false;
|
|
197
|
-
} else {
|
|
198
|
-
allPathsCheckbox.indeterminate = true;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
217
|
+
if (e.target.id === 'flatmap-zoom-in') {
|
|
218
|
+
this._flatmap.zoomIn();
|
|
219
|
+
} else if (e.target.id === 'flatmap-zoom-out') {
|
|
220
|
+
this._flatmap.zoomOut();
|
|
221
|
+
} else if (e.target.id === 'flatmap-reset') {
|
|
222
|
+
this._flatmap.resetMap();
|
|
201
223
|
}
|
|
202
|
-
event.stopPropagation();
|
|
203
224
|
}
|
|
204
225
|
}
|
|
205
226
|
|
|
@@ -317,123 +338,6 @@ export class LayerControl
|
|
|
317
338
|
|
|
318
339
|
//==============================================================================
|
|
319
340
|
|
|
320
|
-
export class Control
|
|
321
|
-
{
|
|
322
|
-
constructor(flatmap, id, name)
|
|
323
|
-
{
|
|
324
|
-
this.__flatmap = flatmap;
|
|
325
|
-
this.__id = id;
|
|
326
|
-
this.__name = name;
|
|
327
|
-
this.__map = undefined;
|
|
328
|
-
this.__prefix = `${this.__id}-`
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
getDefaultPosition()
|
|
332
|
-
//==================
|
|
333
|
-
{
|
|
334
|
-
return 'top-right';
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
__innerLinesHTML()
|
|
338
|
-
//================
|
|
339
|
-
{
|
|
340
|
-
return [];
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
__enableAll(enable)
|
|
344
|
-
//=================
|
|
345
|
-
{
|
|
346
|
-
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
onAdd(map)
|
|
350
|
-
//========
|
|
351
|
-
{
|
|
352
|
-
this.__map = map;
|
|
353
|
-
this.__container = document.createElement('div');
|
|
354
|
-
this.__container.className = 'maplibregl-ctrl flatmap-control';
|
|
355
|
-
this.__control = document.createElement('div');
|
|
356
|
-
this.__control.className = 'flatmap-control-grid';
|
|
357
|
-
|
|
358
|
-
const innerHTML = this.__innerLinesHTML();
|
|
359
|
-
this.__totalCount = innerHTML.length;
|
|
360
|
-
innerHTML.splice(0, 0, `<label for="control-all-${this.__id}">ALL ${this.__name.toUpperCase()}:</label><input id="control-all-${this.__id}" type="checkbox" checked/>`);
|
|
361
|
-
this.__control.innerHTML = innerHTML.join('\n');
|
|
362
|
-
|
|
363
|
-
this.__checkedCount = this.__totalCount;
|
|
364
|
-
this.__halfCount = Math.trunc(this.__checkedCount/2);
|
|
365
|
-
|
|
366
|
-
this.__button = document.createElement('button');
|
|
367
|
-
this.__button.id = `flatmap-${this.__id}-button`;
|
|
368
|
-
this.__button.className = 'control-button text-button';
|
|
369
|
-
this.__button.setAttribute('type', 'button');
|
|
370
|
-
this.__button.setAttribute('aria-label', `Show/hide map's ${this.__name}`);
|
|
371
|
-
this.__button.setAttribute('control-visible', 'false');
|
|
372
|
-
this.__button.textContent = this.__name.toUpperCase().substring(0, 6);
|
|
373
|
-
this.__button.title = `Show/hide map's ${this.__name}`;
|
|
374
|
-
this.__container.appendChild(this.__button);
|
|
375
|
-
|
|
376
|
-
this.__container.addEventListener('click', this.onClick_.bind(this));
|
|
377
|
-
return this.__container;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
onRemove()
|
|
381
|
-
//========
|
|
382
|
-
{
|
|
383
|
-
this.__container.parentNode.removeChild(this.__container);
|
|
384
|
-
this.__map = undefined;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
onClick_(event)
|
|
388
|
-
//=============
|
|
389
|
-
{
|
|
390
|
-
if (event.target.id === `flatmap-${this.__id}-button`) {
|
|
391
|
-
if (this.__button.getAttribute('control-visible') === 'false') {
|
|
392
|
-
this.__container.appendChild(this.__control);
|
|
393
|
-
this.__button.setAttribute('control-visible', 'true');
|
|
394
|
-
this.__control.focus();
|
|
395
|
-
} else {
|
|
396
|
-
this.__control = this.__container.removeChild(this.__control);
|
|
397
|
-
this.__button.setAttribute('control-visible', 'false');
|
|
398
|
-
}
|
|
399
|
-
} else if (event.target.tagName === 'INPUT') {
|
|
400
|
-
if (event.target.id === `control-all-${this.__id}`) {
|
|
401
|
-
if (event.target.indeterminate) {
|
|
402
|
-
event.target.checked = (this.__checkedCount >= this.__halfCount);
|
|
403
|
-
event.target.indeterminate = false;
|
|
404
|
-
}
|
|
405
|
-
if (event.target.checked) {
|
|
406
|
-
this.__checkedCount = this.__totalCount;
|
|
407
|
-
} else {
|
|
408
|
-
this.__checkedCount = 0;
|
|
409
|
-
}
|
|
410
|
-
this.__enableAll(event.target.checked);
|
|
411
|
-
} else if (event.target.id.startsWith(`${this.__id}-`)) {
|
|
412
|
-
this.__enableControl(event.target.id.substring(this.__prefix.length),
|
|
413
|
-
event.target.checked);
|
|
414
|
-
if (event.target.checked) {
|
|
415
|
-
this.__checkedCount += 1;
|
|
416
|
-
} else {
|
|
417
|
-
this.__checkedCount -= 1;
|
|
418
|
-
}
|
|
419
|
-
const allCheckbox = document.getElementById(`control-all-${this.__id}`);
|
|
420
|
-
if (this.__checkedCount === 0) {
|
|
421
|
-
allCheckbox.checked = false;
|
|
422
|
-
allCheckbox.indeterminate = false;
|
|
423
|
-
} else if (this.__checkedCount === this.__totalCount) {
|
|
424
|
-
allCheckbox.checked = true;
|
|
425
|
-
allCheckbox.indeterminate = false;
|
|
426
|
-
} else {
|
|
427
|
-
allCheckbox.indeterminate = true;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
event.stopPropagation();
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
//==============================================================================
|
|
436
|
-
|
|
437
341
|
const SCKAN_STATES = [
|
|
438
342
|
{
|
|
439
343
|
'id': 'VALID',
|
package/src/controls/info.js
CHANGED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
|
|
3
|
+
Flatmap viewer and annotation tool
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2019 - 2023 David Brooks
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
|
|
19
|
+
******************************************************************************/
|
|
20
|
+
|
|
21
|
+
export class PathControl
|
|
22
|
+
{
|
|
23
|
+
constructor(flatmap, pathTypes)
|
|
24
|
+
{
|
|
25
|
+
this._flatmap = flatmap;
|
|
26
|
+
this._map = undefined;
|
|
27
|
+
this.__pathTypes = pathTypes;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getDefaultPosition()
|
|
31
|
+
//==================
|
|
32
|
+
{
|
|
33
|
+
return 'top-right';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
onAdd(map)
|
|
37
|
+
//========
|
|
38
|
+
{
|
|
39
|
+
this._map = map;
|
|
40
|
+
this._container = document.createElement('div');
|
|
41
|
+
this._container.className = 'maplibregl-ctrl';
|
|
42
|
+
this._container.id = 'flatmap-nerve-key';
|
|
43
|
+
|
|
44
|
+
this._legend = document.createElement('div');
|
|
45
|
+
this._legend.id = 'nerve-key-text';
|
|
46
|
+
this._legend.className = 'flatmap-nerve-grid';
|
|
47
|
+
|
|
48
|
+
const innerHTML = [];
|
|
49
|
+
innerHTML.push(`<label for="path-all-paths">ALL PATHS:</label><div class="nerve-line"></div><input id="path-all-paths" type="checkbox" checked/>`);
|
|
50
|
+
this.__checkedCount = 0;
|
|
51
|
+
for (const path of this.__pathTypes) {
|
|
52
|
+
const checked = !('enabled' in path) || path.enabled ? 'checked' : '';
|
|
53
|
+
if (checked != '') {
|
|
54
|
+
this.__checkedCount += 1;
|
|
55
|
+
}
|
|
56
|
+
const colour = path.colour || '#440';
|
|
57
|
+
const style = path.dashed ? `background: repeating-linear-gradient(to right,${colour} 0,${colour} 6px,transparent 6px,transparent 9px);`
|
|
58
|
+
: `background: ${colour};`;
|
|
59
|
+
|
|
60
|
+
innerHTML.push(`<label for="path-${path.type}">${path.label}</label><div class="nerve-line" style="${style}"></div><input id="path-${path.type}" type="checkbox" ${checked}/>`);
|
|
61
|
+
}
|
|
62
|
+
this._legend.innerHTML = innerHTML.join('\n');
|
|
63
|
+
this.__halfCount = Math.trunc(this.__pathTypes.length/2);
|
|
64
|
+
|
|
65
|
+
this._button = document.createElement('button');
|
|
66
|
+
this._button.id = 'nerve-key-button';
|
|
67
|
+
this._button.className = 'control-button text-button';
|
|
68
|
+
this._button.setAttribute('type', 'button');
|
|
69
|
+
this._button.setAttribute('aria-label', 'Nerve paths legend');
|
|
70
|
+
this._button.setAttribute('control-visible', 'false');
|
|
71
|
+
this._button.textContent = 'PATHS';
|
|
72
|
+
this._button.title = 'Show/hide neuron paths';
|
|
73
|
+
this._container.appendChild(this._button);
|
|
74
|
+
|
|
75
|
+
this._container.addEventListener('click', this.onClick_.bind(this));
|
|
76
|
+
return this._container;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
onRemove()
|
|
80
|
+
//========
|
|
81
|
+
{
|
|
82
|
+
this._container.parentNode.removeChild(this._container);
|
|
83
|
+
this._map = undefined;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
onClick_(event)
|
|
87
|
+
//=============
|
|
88
|
+
{
|
|
89
|
+
if (event.target.id === 'nerve-key-button') {
|
|
90
|
+
if (this._button.getAttribute('control-visible') === 'false') {
|
|
91
|
+
this._container.appendChild(this._legend);
|
|
92
|
+
this._button.setAttribute('control-visible', 'true');
|
|
93
|
+
const allPathsCheckbox = document.getElementById('path-all-paths');
|
|
94
|
+
allPathsCheckbox.indeterminate = this.__checkedCount < this.__pathTypes.length
|
|
95
|
+
&& this.__checkedCount > 0;
|
|
96
|
+
this._legend.focus();
|
|
97
|
+
} else {
|
|
98
|
+
this._legend = this._container.removeChild(this._legend);
|
|
99
|
+
this._button.setAttribute('control-visible', 'false');
|
|
100
|
+
}
|
|
101
|
+
} else if (event.target.tagName === 'INPUT') {
|
|
102
|
+
if (event.target.id === 'path-all-paths') {
|
|
103
|
+
if (event.target.indeterminate) {
|
|
104
|
+
event.target.checked = (this.__checkedCount >= this.__halfCount);
|
|
105
|
+
event.target.indeterminate = false;
|
|
106
|
+
}
|
|
107
|
+
if (event.target.checked) {
|
|
108
|
+
this.__checkedCount = this.__pathTypes.length;
|
|
109
|
+
} else {
|
|
110
|
+
this.__checkedCount = 0;
|
|
111
|
+
}
|
|
112
|
+
for (const path of this.__pathTypes) {
|
|
113
|
+
const pathCheckbox = document.getElementById(`path-${path.type}`);
|
|
114
|
+
if (pathCheckbox) {
|
|
115
|
+
pathCheckbox.checked = event.target.checked;
|
|
116
|
+
this._flatmap.enablePath(path.type, event.target.checked);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
} else if (event.target.id.startsWith('path-')) {
|
|
120
|
+
const pathType = event.target.id.substring(5);
|
|
121
|
+
this._flatmap.enablePath(pathType, event.target.checked);
|
|
122
|
+
if (event.target.checked) {
|
|
123
|
+
this.__checkedCount += 1;
|
|
124
|
+
} else {
|
|
125
|
+
this.__checkedCount -= 1;
|
|
126
|
+
}
|
|
127
|
+
const allPathsCheckbox = document.getElementById('path-all-paths');
|
|
128
|
+
if (this.__checkedCount === 0) {
|
|
129
|
+
allPathsCheckbox.checked = false;
|
|
130
|
+
allPathsCheckbox.indeterminate = false;
|
|
131
|
+
} else if (this.__checkedCount === this.__pathTypes.length) {
|
|
132
|
+
allPathsCheckbox.checked = true;
|
|
133
|
+
allPathsCheckbox.indeterminate = false;
|
|
134
|
+
} else {
|
|
135
|
+
allPathsCheckbox.indeterminate = true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
event.stopPropagation();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
//==============================================================================
|
package/src/controls/systems.js
CHANGED
|
@@ -31,24 +31,33 @@ export class SystemsControl extends Control
|
|
|
31
31
|
this.__systems = systems;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
_addControlDetails()
|
|
35
|
+
//===============
|
|
36
36
|
{
|
|
37
|
-
|
|
37
|
+
let lines = 0;
|
|
38
|
+
let enabled = 0;
|
|
38
39
|
for (const system of this.__systems) {
|
|
39
|
-
|
|
40
|
+
const input = this._addControlLine(`${this.__prefix}${system.id}`, system.name, `background: ${system.colour};`);
|
|
41
|
+
if (system.enabled) {
|
|
42
|
+
input.checked = true;
|
|
43
|
+
enabled += 1;
|
|
44
|
+
}
|
|
45
|
+
lines += 1;
|
|
40
46
|
}
|
|
41
|
-
return
|
|
47
|
+
return {
|
|
48
|
+
enabled: enabled,
|
|
49
|
+
total: lines
|
|
50
|
+
};
|
|
42
51
|
}
|
|
43
52
|
|
|
44
|
-
|
|
45
|
-
|
|
53
|
+
_enableAll(enable)
|
|
54
|
+
//================
|
|
46
55
|
{
|
|
47
56
|
for (const system of this.__systems) {
|
|
48
57
|
const checkbox = document.getElementById(`${this.__prefix}${system.id}`);
|
|
49
58
|
if (checkbox) {
|
|
50
59
|
checkbox.checked = enable;
|
|
51
|
-
this.__flatmap.enableSystem(system.
|
|
60
|
+
this.__flatmap.enableSystem(system.id, enable);
|
|
52
61
|
}
|
|
53
62
|
}
|
|
54
63
|
}
|
|
@@ -58,7 +67,7 @@ export class SystemsControl extends Control
|
|
|
58
67
|
{
|
|
59
68
|
for (const system of this.__systems) {
|
|
60
69
|
if (id === system.id) {
|
|
61
|
-
this.__flatmap.enableSystem(system.
|
|
70
|
+
this.__flatmap.enableSystem(system.id, enable);
|
|
62
71
|
}
|
|
63
72
|
}
|
|
64
73
|
}
|