@abi-software/flatmap-viewer 2.3.0-b.2 → 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 +137 -17
- 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 -25
- package/src/interactions.js +150 -165
- package/src/layers.js +2 -2
- package/src/pathways.js +110 -93
- package/src/styling.js +71 -48
- package/src/systems.js +54 -31
- package/src/utils.js +18 -0
- package/static/css/flatmap-viewer.css +12 -0
- package/src/controls/newcontrols.js +0 -617
- package/src/editor.js +0 -198
package/src/systems.js
CHANGED
|
@@ -21,45 +21,50 @@ limitations under the License.
|
|
|
21
21
|
|
|
22
22
|
export class SystemsManager
|
|
23
23
|
{
|
|
24
|
-
constructor(flatmap, ui, enabled=
|
|
24
|
+
constructor(flatmap, ui, enabled=false)
|
|
25
25
|
{
|
|
26
26
|
this.__ui = ui;
|
|
27
27
|
this.__systems = new Map();
|
|
28
28
|
this.__enabledChildren = new Map();
|
|
29
29
|
for (const [id, ann] of flatmap.annotations) {
|
|
30
30
|
if (ann['fc-class'] === 'fc-class:System') {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const systemId = ann.name.replaceAll(' ', '_');
|
|
32
|
+
if (this.__systems.has(systemId)) {
|
|
33
|
+
this.__systems.get(systemId).featureIds.push(ann.featureId)
|
|
33
34
|
} else {
|
|
34
|
-
this.__systems.set(
|
|
35
|
-
|
|
35
|
+
this.__systems.set(systemId, {
|
|
36
|
+
name: ann.name,
|
|
36
37
|
colour: ann.colour,
|
|
37
38
|
featureIds: [ ann.featureId ],
|
|
38
|
-
enabled:
|
|
39
|
+
enabled: false,
|
|
40
|
+
pathIds: ('path-ids' in ann) ? ann['path-ids'] : []
|
|
39
41
|
});
|
|
42
|
+
this.__ui.enableFeature(ann.featureId, false, true);
|
|
40
43
|
}
|
|
41
44
|
for (const childId of ann['children']) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
? this.__enabledChildren.get(childId)
|
|
45
|
-
: 0;
|
|
46
|
-
this.__enabledChildren.set(childId, enabledCount + 1);
|
|
47
|
-
} else {
|
|
48
|
-
this.__enabledChildren.set(childId, 0);
|
|
49
|
-
}
|
|
45
|
+
this.__enabledChildren.set(childId, 0);
|
|
46
|
+
this.__ui.enableFeatureWithChildren(childId, false, true);
|
|
50
47
|
}
|
|
51
48
|
}
|
|
52
49
|
}
|
|
50
|
+
for (const system of this.__systems.values()) {
|
|
51
|
+
if (enabled) {
|
|
52
|
+
this.__enableSystem(system, true);
|
|
53
|
+
} else {
|
|
54
|
+
// Disable all paths associated with the disabled system
|
|
55
|
+
this.__ui.enablePathsBySystem(system, false, true);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
get systems()
|
|
56
61
|
//===========
|
|
57
62
|
{
|
|
58
63
|
const systems = [];
|
|
59
|
-
for (const [
|
|
64
|
+
for (const [systemId, system] of this.__systems.entries()) {
|
|
60
65
|
systems.push({
|
|
61
|
-
|
|
62
|
-
|
|
66
|
+
id: systemId,
|
|
67
|
+
name: system.name,
|
|
63
68
|
colour: system.colour,
|
|
64
69
|
enabled: system.enabled
|
|
65
70
|
});
|
|
@@ -67,26 +72,44 @@ export class SystemsManager
|
|
|
67
72
|
return systems;
|
|
68
73
|
}
|
|
69
74
|
|
|
70
|
-
enable(
|
|
71
|
-
|
|
75
|
+
enable(systemId, enable=true)
|
|
76
|
+
//===========================
|
|
72
77
|
{
|
|
73
|
-
const system = this.__systems.get(
|
|
78
|
+
const system = this.__systems.get(systemId);
|
|
74
79
|
if (system !== undefined && enable !== system.enabled) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
this.__enableSystem(system, enable);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
__enableSystem(system, enable=true)
|
|
85
|
+
//=================================
|
|
86
|
+
{
|
|
87
|
+
for (const featureId of system.featureIds) {
|
|
88
|
+
const feature = this.__ui.mapFeature(featureId);
|
|
89
|
+
if (feature !== undefined) {
|
|
90
|
+
this.__ui.enableMapFeature(feature, enable);
|
|
91
|
+
for (const childFeatureId of feature.children) {
|
|
92
|
+
const enabledCount = this.__enabledChildren.get(childFeatureId);
|
|
93
|
+
if (enable && enabledCount === 0 || !enable && enabledCount == 1) {
|
|
94
|
+
this.__ui.enableFeatureWithChildren(childFeatureId, enable);
|
|
85
95
|
}
|
|
96
|
+
this.__enabledChildren.set(childFeatureId, enabledCount + (enable ? 1 : -1));
|
|
86
97
|
}
|
|
87
98
|
}
|
|
88
|
-
system.enabled = enable;
|
|
89
99
|
}
|
|
100
|
+
|
|
101
|
+
// Enable/disable all paths associated with the system
|
|
102
|
+
this.__ui.enablePathsBySystem(system, enable);
|
|
103
|
+
|
|
104
|
+
// Save system state
|
|
105
|
+
system.enabled = enable;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
systemEnabled(systemId)
|
|
109
|
+
//=====================
|
|
110
|
+
{
|
|
111
|
+
const system = this.__systems.get(systemId);
|
|
112
|
+
return (system !== undefined && system.enabled);
|
|
90
113
|
}
|
|
91
114
|
}
|
|
92
115
|
|
package/src/utils.js
CHANGED
|
@@ -124,3 +124,21 @@ export function setDefaults(options, defaultOptions)
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
//==============================================================================
|
|
127
|
+
|
|
128
|
+
export function reverseMap(mapping)
|
|
129
|
+
//=================================
|
|
130
|
+
{
|
|
131
|
+
const reverse = {};
|
|
132
|
+
for (const [key, values] of Object.entries(mapping)) {
|
|
133
|
+
for (const value of values) {
|
|
134
|
+
if (value in reverse) {
|
|
135
|
+
reverse[value].add(key);
|
|
136
|
+
} else {
|
|
137
|
+
reverse[value] = new Set([key]);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return reverse;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
//==============================================================================
|
|
@@ -342,6 +342,18 @@ label[for=layer-all-layers] {
|
|
|
342
342
|
background-color: #BBB;
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
+
#annotation-feature-selection
|
|
346
|
+
{
|
|
347
|
+
display: flex;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
#annotation-feature-buttons
|
|
351
|
+
{
|
|
352
|
+
float: right;
|
|
353
|
+
padding-top: 10px;
|
|
354
|
+
padding-bottom: 10px;
|
|
355
|
+
}
|
|
356
|
+
|
|
345
357
|
.jsPanel-title {
|
|
346
358
|
font-size: 1.4em !important;
|
|
347
359
|
font-weight: bold !important;
|