landscape-widget 0.2.0 → 0.3.0-alpha

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.
@@ -0,0 +1,155 @@
1
+ import { forceSimulation, forceManyBody, forceCenter, forceCollide, } from 'd3-force';
2
+ import { NODE_X, NODE_Y, PPN } from './enum/layout';
3
+ import { polygonHull, polygonCentroid } from 'd3-polygon';
4
+ function circle_pack_components(components, nodes, numIterations) {
5
+ const node2componentID = {};
6
+ components.forEach((component, index) => {
7
+ component.forEach((node_id) => {
8
+ const n = Number(node_id);
9
+ node2componentID[n] = index;
10
+ });
11
+ });
12
+ // componentPositions is an array of positions of each point
13
+ const componentPositions = components.map((component) => component.map((node_id) => {
14
+ const j = Number(node_id) * PPN;
15
+ return [nodes[j + NODE_X], nodes[j + NODE_Y]];
16
+ }));
17
+ const polygons = componentPositions.map((component) => polygonHull(component));
18
+ const polygonCentroids = polygons.map((shape, i) => {
19
+ if (shape === null) {
20
+ // if shape == null.
21
+ // CASE 1 componentPosition.length == 1
22
+ // CASE 2 componentPosition.length == 2.
23
+ const componentPosition = componentPositions[i];
24
+ if (componentPosition.length === 1) {
25
+ return componentPosition[0];
26
+ }
27
+ const pt1x = componentPosition[0][0];
28
+ const pt2x = componentPosition[1][0];
29
+ const pt1y = componentPosition[0][1];
30
+ const pt2y = componentPosition[1][1];
31
+ return [(pt1x + pt2x) / 2, (pt1y + pt2y) / 2];
32
+ }
33
+ return polygonCentroid(shape);
34
+ });
35
+ const componentRadiuses = polygons.map((polygon, i) => {
36
+ const center = polygonCentroids[i];
37
+ let maxRadius = 0;
38
+ if (polygon === null) {
39
+ const component = componentPositions[i];
40
+ if (component.length === 1) {
41
+ // Singleton radius
42
+ maxRadius = 5;
43
+ }
44
+ else {
45
+ const dx = component[1][0] - component[0][0];
46
+ const dy = component[1][1] - component[0][1];
47
+ maxRadius = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)) / 2;
48
+ }
49
+ }
50
+ else {
51
+ // Find the max distance from center to edge.
52
+ for (let j = 0; j < polygon.length; j += 1) {
53
+ const pos = polygon[j];
54
+ const dx = pos[0] - center[0];
55
+ const dy = pos[1] - center[1];
56
+ const dist = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
57
+ maxRadius = Math.max(dist, maxRadius);
58
+ }
59
+ }
60
+ return maxRadius;
61
+ });
62
+ // This i is the index in the map.
63
+ // Little bit weird if you're not used to js.
64
+ const componentsToCirclePack = components.map((d, i) => {
65
+ const cp = Object.create(d);
66
+ cp.radius = componentRadiuses[i];
67
+ return cp;
68
+ });
69
+ const simulation = forceSimulation(componentsToCirclePack)
70
+ .force('charge', forceManyBody())
71
+ .force('center', forceCenter(0, 0))
72
+ .force('collision', forceCollide().radius((d) => d.radius));
73
+ simulation.stop();
74
+ simulation.tick(numIterations);
75
+ const verticesInComponents = components
76
+ .map((component) => component.map((node_id) => Number(node_id)))
77
+ .flat();
78
+ return {
79
+ vertices: verticesInComponents,
80
+ node_to_component_id: node2componentID,
81
+ components_to_circle_pack: componentsToCirclePack,
82
+ polygon_centroids_initial: polygonCentroids,
83
+ };
84
+ }
85
+ // eslint-disable-next-line no-restricted-globals
86
+ export const explicitComponentLayout = (node_matrix, components, iterations) => {
87
+ const nonSingletonComponents = components.filter((component) => component.length > 1);
88
+ const singletonComponents = components.filter((component) => component.length === 1);
89
+ const out = circle_pack_components(nonSingletonComponents, node_matrix, iterations);
90
+ let minX = Number.MAX_VALUE;
91
+ let maxX = Number.MIN_VALUE;
92
+ let minY = Number.MAX_VALUE;
93
+ let maxY = Number.MIN_VALUE;
94
+ out.vertices.forEach((i) => {
95
+ const componentID = out.node_to_component_id[i];
96
+ const componentCentroid = out.polygon_centroids_initial[componentID];
97
+ const xPosition = out.components_to_circle_pack[componentID].x +
98
+ node_matrix[i * PPN + NODE_X] -
99
+ componentCentroid[0];
100
+ const yPosition = out.components_to_circle_pack[componentID].y +
101
+ node_matrix[i * PPN + NODE_Y] -
102
+ componentCentroid[1];
103
+ node_matrix[i * PPN + NODE_X] = xPosition;
104
+ node_matrix[i * PPN + NODE_Y] = yPosition;
105
+ maxX = Math.max(maxX, xPosition);
106
+ minX = Math.min(minX, xPosition);
107
+ maxY = Math.max(maxY, yPosition);
108
+ minY = Math.min(minY, yPosition);
109
+ });
110
+ const singletonInfo = circle_pack_components(singletonComponents, node_matrix, iterations);
111
+ let minXS = Number.MAX_VALUE;
112
+ let maxXS = Number.MIN_VALUE;
113
+ let minYS = Number.MAX_VALUE;
114
+ let maxYS = Number.MIN_VALUE;
115
+ const numNonSingletonNodes = nonSingletonComponents.reduce((acc, x) => acc + x.length, 0);
116
+ // scale by number of nodes
117
+ const ratio = singletonComponents.length / numNonSingletonNodes;
118
+ singletonInfo.vertices.forEach((i) => {
119
+ const componentID = singletonInfo.node_to_component_id[i];
120
+ const xPosition = singletonInfo.components_to_circle_pack[componentID].x;
121
+ const yPosition = singletonInfo.components_to_circle_pack[componentID].y;
122
+ maxXS = Math.max(xPosition, maxXS);
123
+ minXS = Math.min(xPosition, minXS);
124
+ maxYS = Math.max(yPosition, maxYS);
125
+ minYS = Math.min(yPosition, minYS);
126
+ });
127
+ const widthSingletonsRegion = maxXS - minXS;
128
+ const heightSingletonsRegion = maxYS - minYS;
129
+ const widthNonSingletonsRegion = maxX - minX;
130
+ const heightNonSingletonsRegion = maxY - minY;
131
+ const areaNonSingletonRegion = widthNonSingletonsRegion * heightNonSingletonsRegion;
132
+ const areaSingletonRegion = widthSingletonsRegion * heightSingletonsRegion;
133
+ const midY = (maxY + minY) / 2;
134
+ const scaleFactor = Math.sqrt((ratio * areaNonSingletonRegion) / areaSingletonRegion);
135
+ // Reset check again.
136
+ minXS = Number.MAX_VALUE;
137
+ maxXS = Number.MIN_VALUE;
138
+ singletonInfo.vertices.forEach((i) => {
139
+ const componentID = singletonInfo.node_to_component_id[i];
140
+ const xPosition = singletonInfo.components_to_circle_pack[componentID].x;
141
+ const yPosition = singletonInfo.components_to_circle_pack[componentID].y;
142
+ // Set Node.x position to to be the minimum x value in the nonSingletonComponent area.
143
+ node_matrix[i * PPN + NODE_X] = minX - xPosition * scaleFactor;
144
+ // Set Node.y position to be the middle y value the nonSingletonComponent area.
145
+ node_matrix[i * PPN + NODE_Y] = midY + yPosition * scaleFactor;
146
+ maxXS = Math.max(minX - xPosition * scaleFactor, maxXS);
147
+ minXS = Math.min(minX - xPosition * scaleFactor, minXS);
148
+ });
149
+ const horizontalOverlap = Math.max(maxXS - minX, 0) * 1.2;
150
+ singletonInfo.vertices.forEach((i) => {
151
+ // Offset here by horizontal overlap.
152
+ node_matrix[i * PPN + NODE_X] -= horizontalOverlap;
153
+ });
154
+ };
155
+ //# sourceMappingURL=explicitComponentLayout.js.map
@@ -0,0 +1,18 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ // Entry point for the notebook bundle containing custom model definitions.
4
+ //
5
+ // Setup notebook base URL
6
+ //
7
+ // Some static assets may be required by the custom widget javascript. The base
8
+ // url for the notebook is not known at build time and is therefore computed
9
+ // dynamically.
10
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
11
+ // (window as any).__webpack_public_path__ =
12
+ // document.querySelector('body')!.getAttribute('data-base-url') + 'nbextensions/landscape_widget';
13
+ // declare let __webpack_public_path__: string;
14
+ // __webpack_public_path__ =
15
+ // document.querySelector('body')!.getAttribute('data-base-url') + 'nbextensions/landscape_widget';
16
+ import './public-path';
17
+ export * from './index';
18
+ //# sourceMappingURL=extension.js.map
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export const AnalysisIcon = ({ width = 32, height = 32 }) => (React.createElement("svg", { xmlns: 'http://www.w3.org/2000/svg', width: width, height: height, viewBox: '0 0 24 24', fill: 'currentColor', strokeLinecap: 'round', strokeLinejoin: 'round' },
3
+ React.createElement("path", { d: 'M19 15c-.712.004-1.41.2-2.019.567l-1.548-1.548a3.916 3.916 0 0 0-.484-4.7l.933-2.332c.04 0 .078.012.118.012a3.03 3.03 0 1 0-1.974-.757l-.789 1.973a3.791 3.791 0 0 0-3.256.351L6.707 5.293 6.7 5.287a2.957 2.957 0 0 0-.206-2.954A3 3 0 1 0 4 7a2.96 2.96 0 0 0 1.287-.3l.006.009 3.274 3.272a3.908 3.908 0 0 0 .443 4.649L6.17 18.1a2.53 2.53 0 1 0 1.548 1.269l2.955-3.613a3.82 3.82 0 0 0 3.346-.323l1.548 1.548A3.947 3.947 0 0 0 15 19a4 4 0 1 0 4-4ZM4 5a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm6 7a2 2 0 1 1 4 0 2 2 0 0 1-4 0Zm9 9a2 2 0 1 1 0-4 2 2 0 0 1 0 4Z' })));
4
+ //# sourceMappingURL=AnalysisIcon.js.map
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export const ChevronSolid = ({ width = 32, height = 32 }) => (React.createElement("svg", { xmlns: 'http://www.w3.org/2000/svg', width: width, height: height, viewBox: '0 0 24 24', fill: 'currentColor', strokeLinecap: 'round', strokeLinejoin: 'round' },
3
+ React.createElement("path", { d: 'M8.29833 18.7022C7.9078 18.3117 8.00523 17.9951 8.0057 17.4951V11.9951V6.49512C8.0057 5.99512 7.9078 5.67853 8.29833 5.28801C8.68885 4.89749 9.32202 4.89749 9.71254 5.28801L15.7125 11.288C16.1031 11.6785 16.1031 12.3117 15.7125 12.7022L9.71254 18.7022C9.32202 19.0927 8.68885 19.0927 8.29833 18.7022Z' })));
4
+ //# sourceMappingURL=ChevronSolid.js.map
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export const ClearSelection = ({ width = 32, height = 32 }) => (React.createElement("svg", { width: width, height: height, viewBox: '0 0 32 32', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
3
+ React.createElement("path", { d: 'M6 17.6667V14.3333C6 14.1123 6.0878 13.9004 6.24408 13.7441C6.40036 13.5878 6.61232 13.5 6.83333 13.5C7.05435 13.5 7.26631 13.5878 7.42259 13.7441C7.57887 13.9004 7.66667 14.1123 7.66667 14.3333V17.6667C7.66667 17.8877 7.57887 18.0996 7.42259 18.2559C7.26631 18.4122 7.05435 18.5 6.83333 18.5C6.61232 18.5 6.40036 18.4122 6.24408 18.2559C6.0878 18.0996 6 17.8877 6 17.6667ZM10.1667 6H7.66667C7.22464 6 6.80072 6.17559 6.48816 6.48816C6.17559 6.80072 6 7.22464 6 7.66667V10.1667C6 10.3877 6.0878 10.5996 6.24408 10.7559C6.40036 10.9122 6.61232 11 6.83333 11C7.05435 11 7.26631 10.9122 7.42259 10.7559C7.57887 10.5996 7.66667 10.3877 7.66667 10.1667V7.66667H10.1667C10.3877 7.66667 10.5996 7.57887 10.7559 7.42259C10.9122 7.26631 11 7.05435 11 6.83333C11 6.61232 10.9122 6.40036 10.7559 6.24408C10.5996 6.0878 10.3877 6 10.1667 6ZM10.1667 24.3333H7.66667V21.8333C7.66667 21.6123 7.57887 21.4004 7.42259 21.2441C7.26631 21.0878 7.05435 21 6.83333 21C6.61232 21 6.40036 21.0878 6.24408 21.2441C6.0878 21.4004 6 21.6123 6 21.8333V24.3333C6 24.7754 6.17559 25.1993 6.48816 25.5118C6.80072 25.8244 7.22464 26 7.66667 26H10.1667C10.3877 26 10.5996 25.9122 10.7559 25.7559C10.9122 25.5996 11 25.3877 11 25.1667C11 24.9457 10.9122 24.7337 10.7559 24.5774C10.5996 24.4211 10.3877 24.3333 10.1667 24.3333ZM17.6667 24.3333H14.3333C14.1123 24.3333 13.9004 24.4211 13.7441 24.5774C13.5878 24.7337 13.5 24.9457 13.5 25.1667C13.5 25.3877 13.5878 25.5996 13.7441 25.7559C13.9004 25.9122 14.1123 26 14.3333 26H17.6667C17.8877 26 18.0996 25.9122 18.2559 25.7559C18.4122 25.5996 18.5 25.3877 18.5 25.1667C18.5 24.9457 18.4122 24.7337 18.2559 24.5774C18.0996 24.4211 17.8877 24.3333 17.6667 24.3333ZM25.1667 13.5C24.9457 13.5 24.7337 13.5878 24.5774 13.7441C24.4211 13.9004 24.3333 14.1123 24.3333 14.3333V17.6667C24.3333 17.8877 24.4211 18.0996 24.5774 18.2559C24.7337 18.4122 24.9457 18.5 25.1667 18.5C25.3877 18.5 25.5996 18.4122 25.7559 18.2559C25.9122 18.0996 26 17.8877 26 17.6667V14.3333C26 14.1123 25.9122 13.9004 25.7559 13.7441C25.5996 13.5878 25.3877 13.5 25.1667 13.5ZM24.3333 6H21.8333C21.6123 6 21.4004 6.0878 21.2441 6.24408C21.0878 6.40036 21 6.61232 21 6.83333C21 7.05435 21.0878 7.26631 21.2441 7.42259C21.4004 7.57887 21.6123 7.66667 21.8333 7.66667H24.3333V10.1667C24.3333 10.3877 24.4211 10.5996 24.5774 10.7559C24.7337 10.9122 24.9457 11 25.1667 11C25.3877 11 25.5996 10.9122 25.7559 10.7559C25.9122 10.5996 26 10.3877 26 10.1667V7.66667C26 7.22464 25.8244 6.80072 25.5118 6.48816C25.1993 6.17559 24.7754 6 24.3333 6ZM17.6667 6H14.3333C14.1123 6 13.9004 6.0878 13.7441 6.24408C13.5878 6.40036 13.5 6.61232 13.5 6.83333C13.5 7.05435 13.5878 7.26631 13.7441 7.42259C13.9004 7.57887 14.1123 7.66667 14.3333 7.66667H17.6667C17.8877 7.66667 18.0996 7.57887 18.2559 7.42259C18.4122 7.26631 18.5 7.05435 18.5 6.83333C18.5 6.61232 18.4122 6.40036 18.2559 6.24408C18.0996 6.0878 17.8877 6 17.6667 6ZM25.1667 21C24.9457 21 24.7337 21.0878 24.5774 21.2441C24.4211 21.4004 24.3333 21.6123 24.3333 21.8333V24.3333H21.8333C21.6123 24.3333 21.4004 24.4211 21.2441 24.5774C21.0878 24.7337 21 24.9457 21 25.1667C21 25.3877 21.0878 25.5996 21.2441 25.7559C21.4004 25.9122 21.6123 26 21.8333 26H24.3333C24.7754 26 25.1993 25.8244 25.5118 25.5118C25.8244 25.1993 26 24.7754 26 24.3333V21.8333C26 21.6123 25.9122 21.4004 25.7559 21.2441C25.5996 21.0878 25.3877 21 25.1667 21Z', fill: '#122239', stroke: '#122239', strokeWidth: '0.5' }),
4
+ React.createElement("path", { d: 'M19.8225 12.1835C19.5859 11.9469 19.2036 11.9469 18.967 12.1835L16 15.1445L13.033 12.1775C12.7964 11.9408 12.4141 11.9408 12.1775 12.1775C11.9408 12.4141 11.9408 12.7964 12.1775 13.033L15.1445 16L12.1775 18.967C11.9408 19.2036 11.9408 19.5859 12.1775 19.8225C12.4141 20.0592 12.7964 20.0592 13.033 19.8225L16 16.8555L18.967 19.8225C19.2036 20.0592 19.5859 20.0592 19.8225 19.8225C20.0592 19.5859 20.0592 19.2036 19.8225 18.967L16.8555 16L19.8225 13.033C20.0531 12.8024 20.0531 12.4141 19.8225 12.1835V12.1835Z', fill: '#122239', stroke: '#122239', strokeWidth: '0.5' })));
5
+ //# sourceMappingURL=ClearSelection.js.map
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export const FullScreenEnter = ({ width = 32, height = 32 }) => (React.createElement("svg", { width: width, height: height, viewBox: '0 0 32 32', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
3
+ React.createElement("g", { clipPath: 'url(#clip0_9590_459383)' },
4
+ React.createElement("path", { d: 'M13.793 16.793C13.973 16.6137 14.2144 16.5095 14.4684 16.5018C14.7223 16.494 14.9697 16.5832 15.1603 16.7512C15.3508 16.9193 15.4703 17.1536 15.4944 17.4065C15.5185 17.6594 15.4454 17.912 15.29 18.113L15.207 18.207L10.414 23H13C13.2549 23.0003 13.5 23.0979 13.6854 23.2728C13.8707 23.4478 13.9822 23.687 13.9972 23.9414C14.0121 24.1958 13.9293 24.4464 13.7657 24.6418C13.6021 24.8373 13.3701 24.9629 13.117 24.993L13 25H8C7.75507 25 7.51866 24.91 7.33563 24.7473C7.15259 24.5845 7.03566 24.3603 7.007 24.117L7 24V19C7.00028 18.7451 7.09788 18.5 7.27285 18.3146C7.44782 18.1293 7.68695 18.0178 7.94139 18.0028C8.19584 17.9879 8.44638 18.0707 8.64183 18.2343C8.83729 18.3979 8.9629 18.6299 8.993 18.883L9 19V21.586L13.793 16.793ZM24 7C24.2449 7.00003 24.4813 7.08996 24.6644 7.25272C24.8474 7.41547 24.9643 7.63975 24.993 7.883L25 8V13C24.9997 13.2549 24.9021 13.5 24.7272 13.6854C24.5522 13.8707 24.313 13.9822 24.0586 13.9972C23.8042 14.0121 23.5536 13.9293 23.3582 13.7657C23.1627 13.6021 23.0371 13.3701 23.007 13.117L23 13V10.414L18.207 15.207C18.027 15.3863 17.7856 15.4905 17.5316 15.4982C17.2777 15.506 17.0303 15.4168 16.8397 15.2488C16.6492 15.0807 16.5297 14.8464 16.5056 14.5935C16.4815 14.3406 16.5546 14.088 16.71 13.887L16.793 13.793L21.586 9H19C18.7451 8.99972 18.5 8.90212 18.3146 8.72715C18.1293 8.55218 18.0178 8.31305 18.0028 8.05861C17.9879 7.80416 18.0707 7.55362 18.2343 7.35817C18.3979 7.16271 18.6299 7.0371 18.883 7.007L19 7H24Z', fill: 'black' })),
5
+ React.createElement("defs", null,
6
+ React.createElement("clipPath", { id: 'clip0_9590_459383' },
7
+ React.createElement("rect", { width: '24', height: '24', fill: 'white', transform: 'translate(4 4)' })))));
8
+ //# sourceMappingURL=FullScreenEnter.js.map
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export const FullScreenExit = ({ width = 32, height = 32 }) => (React.createElement("svg", { width: width, height: height, viewBox: '0 0 32 32', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
3
+ React.createElement("g", { clipPath: 'url(#clip0_9590_459423)' },
4
+ React.createElement("path", { d: 'M14.9999 15.9987C15.2448 15.9987 15.4812 16.0887 15.6643 16.2514C15.8473 16.4142 15.9642 16.6384 15.9929 16.8817L15.9999 16.9987V21.9987C15.9996 22.2536 15.902 22.4987 15.727 22.6841C15.5521 22.8694 15.3129 22.9809 15.0585 22.9959C14.804 23.0108 14.5535 22.928 14.3581 22.7644C14.1626 22.6008 14.037 22.3688 14.0069 22.1157L13.9999 21.9987V19.4127L8.70688 24.7057C8.52693 24.885 8.28545 24.9892 8.0315 24.9969C7.77755 25.0047 7.53017 24.9155 7.33961 24.7474C7.14904 24.5794 7.02958 24.3451 7.00549 24.0922C6.98139 23.8393 7.05447 23.5867 7.20988 23.3857L7.29288 23.2917L12.5859 17.9987H9.99988C9.745 17.9984 9.49985 17.9008 9.31452 17.7258C9.12918 17.5509 9.01765 17.3117 9.00271 17.0573C8.98778 16.8029 9.07056 16.5523 9.23415 16.3569C9.39774 16.1614 9.62979 16.0358 9.88288 16.0057L9.99988 15.9987H14.9999ZM23.2929 7.29169C23.4728 7.11235 23.7143 7.00822 23.9683 7.00047C24.2222 6.99271 24.4696 7.08191 24.6602 7.24994C24.8507 7.41798 24.9702 7.65225 24.9943 7.90517C25.0184 8.15809 24.9453 8.4107 24.7899 8.61169L24.7069 8.70569L19.4139 13.9987H21.9999C22.2548 13.999 22.4999 14.0966 22.6853 14.2715C22.8706 14.4465 22.9821 14.6856 22.9971 14.9401C23.012 15.1945 22.9292 15.4451 22.7656 15.6405C22.602 15.836 22.37 15.9616 22.1169 15.9917L21.9999 15.9987H16.9999C16.755 15.9987 16.5185 15.9087 16.3355 15.746C16.1525 15.5832 16.0355 15.3589 16.0069 15.1157L15.9999 14.9987V9.99869C16.0002 9.74381 16.0978 9.49866 16.2727 9.31333C16.4477 9.12799 16.6868 9.01646 16.9413 9.00152C17.1957 8.98659 17.4463 9.06937 17.6417 9.23296C17.8372 9.39655 17.9628 9.6286 17.9929 9.88169L17.9999 9.99869V12.5847L23.2929 7.29169Z', fill: 'black' })),
5
+ React.createElement("defs", null,
6
+ React.createElement("clipPath", { id: 'clip0_9590_459423' },
7
+ React.createElement("rect", { width: '24', height: '24', fill: 'white', transform: 'translate(4 4)' })))));
8
+ //# sourceMappingURL=FullScreenExit.js.map
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export const SvgGradient = () => (React.createElement("svg", { width: '0', height: '0', className: 'test', version: '1.1', xmlns: 'http://www.w3.org/2000/svg' },
3
+ React.createElement("linearGradient", { id: 'svgGradient', x1: '0', y1: '0', x2: '0', y2: '26.6666', gradientUnits: 'userSpaceOnUse' },
4
+ React.createElement("stop", { offset: '0%', stopColor: '#122839' }),
5
+ React.createElement("stop", { offset: '60%', stopColor: '#1EB0E9' }))));
6
+ //# sourceMappingURL=Gradient.js.map
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export const Grid = () => (React.createElement("svg", { width: '32', height: '32', viewBox: '0 0 28 28', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
3
+ React.createElement("path", { fillRule: 'evenodd', clipRule: 'evenodd', d: 'M14.8334 6.49999C14.8334 6.03975 15.2065 5.66666 15.6667 5.66666H21.5C21.9603 5.66666 22.3334 6.03975 22.3334 6.49999V12.3333C22.3334 12.7936 21.9603 13.1667 21.5 13.1667H15.6667C15.2065 13.1667 14.8334 12.7936 14.8334 12.3333V6.49999ZM16.5 7.33332V11.5H20.6667V7.33332H16.5ZM6.50002 14.8333C6.03978 14.8333 5.66669 15.2064 5.66669 15.6667V21.5C5.66669 21.9602 6.03978 22.3333 6.50002 22.3333H12.3334C12.7936 22.3333 13.1667 21.9602 13.1667 21.5V15.6667C13.1667 15.2064 12.7936 14.8333 12.3334 14.8333H6.50002ZM7.33335 20.6667V16.5H11.5V20.6667H7.33335ZM15.6667 14.8333C15.2065 14.8333 14.8334 15.2064 14.8334 15.6667V21.5C14.8334 21.9602 15.2065 22.3333 15.6667 22.3333H21.5C21.9603 22.3333 22.3334 21.9602 22.3334 21.5V15.6667C22.3334 15.2064 21.9603 14.8333 21.5 14.8333H15.6667ZM16.5 20.6667V16.5H20.6667V20.6667H16.5ZM6.50002 5.66666C6.03978 5.66666 5.66669 6.03975 5.66669 6.49999V12.3333C5.66669 12.7936 6.03978 13.1667 6.50002 13.1667H12.3334C12.7936 13.1667 13.1667 12.7936 13.1667 12.3333V6.49999C13.1667 6.03975 12.7936 5.66666 12.3334 5.66666H6.50002ZM7.33335 11.5V7.33332H11.5V11.5H7.33335Z', fill: '#122239' })));
4
+ //# sourceMappingURL=Grid.js.map
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export const Invert = ({ width = 32, height = 32 }) => (React.createElement("svg", { width: width, height: height, viewBox: '0 0 32 32', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
3
+ React.createElement("path", { fillRule: 'evenodd', clipRule: 'evenodd', d: 'M16 6C10.4772 6 6 10.4772 6 16C6 21.5228 10.4772 26 16 26C21.5228 26 26 21.5228 26 16C26 10.4772 21.5228 6 16 6ZM7.53846 16C7.53846 11.3268 11.3268 7.53846 16 7.53846C16.0002 7.53846 15.9998 7.53846 16 7.53846L16.0006 12.4497C15.059 12.4497 14.156 12.8238 13.4902 13.4896C12.8244 14.1554 12.4503 15.0584 12.4503 16C12.4503 16.9416 12.8244 17.8446 13.4902 18.5104C14.156 19.1762 15.059 19.5503 16.0006 19.5503V24.4615C16.0004 24.4615 16.0008 24.4615 16.0006 24.4615C11.3274 24.4615 7.53846 20.6732 7.53846 16ZM16.0006 19.5503C16.9422 19.5503 17.8452 19.1762 18.5111 18.5104C19.1769 17.8446 19.5509 16.9416 19.5509 16C19.5509 15.0584 19.1769 14.1554 18.5111 13.4896C17.8452 12.8238 16.9422 12.4497 16.0006 12.4497V19.5503Z', fill: '#122239' }),
4
+ React.createElement("path", { d: 'M16 7.53846C11.3268 7.53846 7.53846 11.3268 7.53846 16C7.53846 20.6732 11.3274 24.4615 16.0006 24.4615M16 7.53846C15.9998 7.53846 16.0002 7.53846 16 7.53846ZM16 7.53846L16.0006 12.4497M16.0006 12.4497C15.059 12.4497 14.156 12.8238 13.4902 13.4896C12.8244 14.1554 12.4503 15.0584 12.4503 16C12.4503 16.9416 12.8244 17.8446 13.4902 18.5104C14.156 19.1762 15.059 19.5503 16.0006 19.5503M16.0006 12.4497C16.9422 12.4497 17.8452 12.8238 18.5111 13.4896C19.1769 14.1554 19.5509 15.0584 19.5509 16C19.5509 16.9416 19.1769 17.8446 18.5111 18.5104C17.8452 19.1762 16.9422 19.5503 16.0006 19.5503M16.0006 12.4497V19.5503M16.0006 19.5503V24.4615M16.0006 24.4615C16.0008 24.4615 16.0004 24.4615 16.0006 24.4615ZM6 16C6 10.4772 10.4772 6 16 6C21.5228 6 26 10.4772 26 16C26 21.5228 21.5228 26 16 26C10.4772 26 6 21.5228 6 16Z', stroke: '#122239', strokeWidth: '0.5' })));
5
+ //# sourceMappingURL=Invert.js.map
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export const Lasso = ({ width = 32, height = 32 }) => (React.createElement("svg", { width: width, height: height, viewBox: '0 0 32 32', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
3
+ React.createElement("path", { d: 'M11 26C10.379 25.5343 9.875 24.9303 9.52786 24.2361C9.18073 23.5418 9 22.7762 9 22M7.3 18C6.45485 16.8376 5.99974 15.4372 6 14C6 9.6 10.5 6 16 6C21.5 6 26 9.6 26 14C26 18.4 21.5 22 16 22C14.2809 22.0287 12.5758 21.6877 11 21', stroke: '#122239', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' }),
4
+ React.createElement("path", { d: 'M9 22C9.53043 22 10.0391 21.7893 10.4142 21.4142C10.7893 21.0391 11 20.5304 11 20C11 19.4696 10.7893 18.9609 10.4142 18.5858C10.0391 18.2107 9.53043 18 9 18C8.46957 18 7.96086 18.2107 7.58579 18.5858C7.21071 18.9609 7 19.4696 7 20C7 20.5304 7.21071 21.0391 7.58579 21.4142C7.96086 21.7893 8.46957 22 9 22V22Z', stroke: '#122239', strokeWidth: '1.5', strokeLinecap: 'round', strokeLinejoin: 'round' })));
5
+ //# sourceMappingURL=Lasso.js.map
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export const List = () => (React.createElement("svg", { width: '32', height: '32', viewBox: '0 0 32 32', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
3
+ React.createElement("path", { fillRule: 'evenodd', clipRule: 'evenodd', d: 'M11.8333 21C11.8333 20.5397 12.2064 20.1666 12.6666 20.1666H23.5C23.9602 20.1666 24.3333 20.5397 24.3333 21C24.3333 21.4602 23.9602 21.8333 23.5 21.8333H12.6666C12.2064 21.8333 11.8333 21.4602 11.8333 21Z', fill: '#122239' }),
4
+ React.createElement("path", { fillRule: 'evenodd', clipRule: 'evenodd', d: 'M7.66669 21C7.66669 20.5397 8.03978 20.1666 8.50002 20.1666H8.50835C8.96859 20.1666 9.34169 20.5397 9.34169 21C9.34169 21.4602 8.96859 21.8333 8.50835 21.8333H8.50002C8.03978 21.8333 7.66669 21.4602 7.66669 21Z', fill: '#122239' }),
5
+ React.createElement("path", { fillRule: 'evenodd', clipRule: 'evenodd', d: 'M11.8333 16C11.8333 15.5397 12.2064 15.1666 12.6666 15.1666H23.5C23.9602 15.1666 24.3333 15.5397 24.3333 16C24.3333 16.4602 23.9602 16.8333 23.5 16.8333H12.6666C12.2064 16.8333 11.8333 16.4602 11.8333 16Z', fill: '#122239' }),
6
+ React.createElement("path", { fillRule: 'evenodd', clipRule: 'evenodd', d: 'M7.66669 16C7.66669 15.5397 8.03978 15.1666 8.50002 15.1666H8.50835C8.96859 15.1666 9.34169 15.5397 9.34169 16C9.34169 16.4602 8.96859 16.8333 8.50835 16.8333H8.50002C8.03978 16.8333 7.66669 16.4602 7.66669 16Z', fill: '#122239' }),
7
+ React.createElement("path", { fillRule: 'evenodd', clipRule: 'evenodd', d: 'M11.8333 11C11.8333 10.5397 12.2064 10.1666 12.6666 10.1666H23.5C23.9602 10.1666 24.3333 10.5397 24.3333 11C24.3333 11.4602 23.9602 11.8333 23.5 11.8333H12.6666C12.2064 11.8333 11.8333 11.4602 11.8333 11Z', fill: '#122239' }),
8
+ React.createElement("path", { fillRule: 'evenodd', clipRule: 'evenodd', d: 'M7.66669 11C7.66669 10.5397 8.03978 10.1666 8.50002 10.1666H8.50835C8.96859 10.1666 9.34169 10.5397 9.34169 11C9.34169 11.4602 8.96859 11.8333 8.50835 11.8333H8.50002C8.03978 11.8333 7.66669 11.4602 7.66669 11Z', fill: '#122239' })));
9
+ //# sourceMappingURL=List.js.map
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export const Minus = ({ width = 32, height = 32 }) => (React.createElement("svg", { width: width, height: height, viewBox: '0 0 32 32', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
3
+ React.createElement("path", { d: 'M9 16H23', stroke: '#122239', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' })));
4
+ //# sourceMappingURL=Minus.js.map
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export const Plus = ({ width = 32, height = 32 }) => (React.createElement("svg", { width: width, height: height, viewBox: '0 0 32 32', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
3
+ React.createElement("path", { d: 'M9 16H23', stroke: '#122239', strokeWidth: '2', strokeLinecap: 'round' }),
4
+ React.createElement("path", { d: 'M16 9L16 23', stroke: '#122239', strokeWidth: '2', strokeLinecap: 'round' })));
5
+ //# sourceMappingURL=Plus.js.map
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export const Reset = ({ width = 32, height = 32 }) => (React.createElement("svg", { width: width, height: height, viewBox: '0 0 32 32', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
3
+ React.createElement("path", { d: 'M25.295 18C25.388 17.9999 25.48 18.0181 25.5659 18.0538C25.6517 18.0894 25.7297 18.1417 25.7952 18.2076C25.8608 18.2735 25.9126 18.3518 25.9478 18.4378C25.9829 18.5239 26.0007 18.616 26 18.709V21.913C26.0007 22.0055 25.9831 22.0973 25.9482 22.183C25.9134 22.2688 25.862 22.3468 25.797 22.4126C25.732 22.4785 25.6546 22.5309 25.5694 22.5668C25.4841 22.6027 25.3925 22.6215 25.3 22.622C25.2075 22.6215 25.116 22.6027 25.0307 22.5668C24.9454 22.5309 24.868 22.4785 24.803 22.4126C24.738 22.3468 24.6866 22.2688 24.6518 22.183C24.6169 22.0973 24.5994 22.0055 24.6 21.913V20.788C22.779 23.844 19.399 26 15.757 26C11.347 26 7.65102 23.279 6.04802 19.085C5.98071 18.9103 5.98495 18.716 6.05982 18.5444C6.13469 18.3728 6.27416 18.2375 6.44802 18.168C6.80802 18.027 7.21402 18.208 7.35402 18.573C8.75402 22.235 11.942 24.583 15.757 24.583C19.128 24.583 22.277 22.401 23.744 19.429L22.273 19.439C22.1805 19.4391 22.0888 19.421 22.0033 19.3857C21.9178 19.3504 21.84 19.2985 21.7746 19.2332C21.7091 19.1678 21.6571 19.0901 21.6217 19.0046C21.5863 18.9192 21.568 18.8275 21.568 18.735C21.5656 18.5482 21.6375 18.3681 21.7678 18.2342C21.8981 18.1003 22.0762 18.0236 22.263 18.021L25.295 18ZM16.245 6C20.653 6 24.35 8.721 25.953 12.915C26.0203 13.0897 26.0161 13.284 25.9412 13.4556C25.8663 13.6272 25.7269 13.7625 25.553 13.832C25.467 13.8655 25.3752 13.8817 25.2829 13.8794C25.1906 13.8772 25.0996 13.8566 25.0153 13.8189C24.931 13.7813 24.8551 13.7272 24.7918 13.6599C24.7286 13.5926 24.6794 13.5135 24.647 13.427C23.247 9.765 20.059 7.417 16.244 7.417C12.873 7.417 9.72402 9.599 8.25702 12.571L9.72802 12.561C9.82055 12.5609 9.9122 12.579 9.99773 12.6143C10.0833 12.6496 10.161 12.7015 10.2265 12.7668C10.2919 12.8322 10.3439 12.9099 10.3793 12.9954C10.4148 13.0808 10.433 13.1725 10.433 13.265C10.4354 13.4518 10.3636 13.6319 10.2333 13.7658C10.1029 13.8997 9.92483 13.9764 9.73802 13.979L6.70502 14C6.61206 14.0001 6.52 13.9819 6.43414 13.9462C6.34828 13.9106 6.27033 13.8583 6.20479 13.7924C6.13925 13.7265 6.08741 13.6482 6.05226 13.5622C6.01711 13.4761 5.99936 13.384 6.00002 13.291V10.087C6.00002 9.695 6.31302 9.378 6.70002 9.378C7.08602 9.378 7.40002 9.695 7.40002 10.087V11.212C9.22102 8.156 12.601 6 16.243 6H16.245Z', fill: '#122239', stroke: '#122239', strokeWidth: '0.5' }),
4
+ React.createElement("circle", { cx: '16', cy: '16', r: '3', fill: '#122239' })));
5
+ //# sourceMappingURL=Reset.js.map
@@ -0,0 +1,13 @@
1
+ export { Grid } from './Grid';
2
+ export { List } from './List';
3
+ export { SvgGradient } from './Gradient';
4
+ export { ChevronSolid } from './ChevronSolid';
5
+ export { Minus } from './Minus';
6
+ export { Plus } from './Plus';
7
+ export { FullScreenEnter } from './FullScreenEnter';
8
+ export { FullScreenExit } from './FullScreenExit';
9
+ export { ClearSelection } from './ClearSelection';
10
+ export { Reset } from './Reset';
11
+ export { Invert } from './Invert';
12
+ export { AnalysisIcon } from './AnalysisIcon';
13
+ //# sourceMappingURL=index.js.map
package/lib/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './version';
2
+ export * from './landscape';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,226 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { DOMWidgetModel, DOMWidgetView } from '@jupyter-widgets/base';
11
+ import { MODULE_NAME, MODULE_VERSION } from './version';
12
+ // Import the CSS
13
+ import '../css/widget.css';
14
+ import { MultiResolutionGraph } from 'blai-graph-widget';
15
+ import 'blai-graph-widget/styles.css';
16
+ import Rand from 'rand-seed';
17
+ const defaultGraph = {
18
+ 0: {
19
+ nodes: [
20
+ { points: [1, 2], size: 5 },
21
+ { points: [3], size: 5 },
22
+ ],
23
+ edges: [{ s: 0, t: 1 }],
24
+ },
25
+ 1: { nodes: [{ points: [1, 2, 3], size: 5 }], edges: [] },
26
+ };
27
+ const defaultColors = null;
28
+ const defaultLabels = Object();
29
+ const defaultSigmaSettings = {
30
+ allowInvalidContainer: true,
31
+ };
32
+ export class LandscapeModel extends DOMWidgetModel {
33
+ initialize(attributes, options) {
34
+ super.initialize(attributes, options);
35
+ this.on('change:colors', this.updateNodeColors, this);
36
+ this.on('change:node_labels', this.updateNodeLabels, this);
37
+ this.on('change:node_hover_labels', this.updateNodeHoverLabels, this);
38
+ this.on('change:selected_level', this.updateSelectedLevel, this);
39
+ this.on('change:avg_degree', this.updateAvgDegree, this);
40
+ this.on('change:selected_nodes', this.updateSelectedNodes, this);
41
+ this.on('msg:custom', this.handleCustomMessage, this);
42
+ this.loadGraph();
43
+ }
44
+ loadGraph() {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const sourceData = this.get('graph');
47
+ const sliderValues = Object.keys(sourceData).map(Number);
48
+ const minSliderValue = Math.min(...sliderValues);
49
+ const maxSliderValue = Math.max(...sliderValues);
50
+ const initialSliderValue = this.get('selected_level') || Math.floor((minSliderValue + maxSliderValue) / 2);
51
+ const sliderConfig = {
52
+ coarseness: {
53
+ label: 'Coarseness',
54
+ minValue: minSliderValue,
55
+ maxValue: maxSliderValue,
56
+ initialValue: initialSliderValue,
57
+ step: 1,
58
+ },
59
+ connectivity: {
60
+ label: 'Connectivity',
61
+ minValue: 0,
62
+ maxValue: 20,
63
+ initialValue: this.get('avg_degree') || 6,
64
+ step: 0.1,
65
+ },
66
+ selectedLevel: initialSliderValue.toString(),
67
+ };
68
+ this.multiResolutionGraph = new MultiResolutionGraph({
69
+ graphData: sourceData,
70
+ sliderConfig: sliderConfig,
71
+ sigmaSettings: Object.assign(Object.assign({}, defaultSigmaSettings), (this.get('sigma_settings') || {})),
72
+ onSelectedNodesChange: this.setSelectedNodes.bind(this),
73
+ onFullScreenChange: this.toggleExpandedLayout.bind(this),
74
+ onCoarsenessChange: this.setCoarsenessLevel.bind(this),
75
+ onConnectivityChange: this.setConnectivityLevel.bind(this),
76
+ layoutConfig: this.get('layout_config'),
77
+ });
78
+ this.updateNodeProperties();
79
+ });
80
+ }
81
+ updateNodeProperties() {
82
+ // this.updateNodeSizes();
83
+ this.updateNodeColors();
84
+ this.updateNodeLabels();
85
+ this.updateNodeHoverLabels();
86
+ }
87
+ setSelectedNodes(nodes) {
88
+ this.set('selected_nodes', nodes);
89
+ this.save_changes();
90
+ }
91
+ toggleExpandedLayout(isFullScreen) {
92
+ this.set('is_expanded_layout', isFullScreen);
93
+ this.save_changes();
94
+ }
95
+ setCoarsenessLevel(coarsenessLevel) {
96
+ this.set('selected_level', coarsenessLevel);
97
+ this.save_changes();
98
+ }
99
+ setConnectivityLevel(connectivityLevel) {
100
+ this.set('avg_degree', connectivityLevel);
101
+ this.save_changes();
102
+ }
103
+ updateNodeColors() {
104
+ if (!this.multiResolutionGraph) {
105
+ return;
106
+ }
107
+ const nodeColors = this.get('colors');
108
+ if (!nodeColors) {
109
+ return;
110
+ }
111
+ this.multiResolutionGraph.setNodeColors(nodeColors);
112
+ }
113
+ updateNodeLabels() {
114
+ if (!this.multiResolutionGraph) {
115
+ return;
116
+ }
117
+ const nodeLabels = this.get('node_labels');
118
+ if (!nodeLabels) {
119
+ return;
120
+ }
121
+ this.multiResolutionGraph.setNodeLabels(nodeLabels);
122
+ }
123
+ updateNodeHoverLabels() {
124
+ if (!this.multiResolutionGraph) {
125
+ return;
126
+ }
127
+ const nodeHoverLabels = this.get('node_hover_labels');
128
+ if (!nodeHoverLabels) {
129
+ return;
130
+ }
131
+ this.multiResolutionGraph.setNodeHoverLabels(nodeHoverLabels);
132
+ }
133
+ updateSelectedLevel() {
134
+ if (!this.multiResolutionGraph) {
135
+ return;
136
+ }
137
+ const level = this.get('selected_level');
138
+ if (!level) {
139
+ return;
140
+ }
141
+ this.multiResolutionGraph.setCoarsenessLevel(level);
142
+ this.multiResolutionGraph.sliderManager.setSliderValue('Coarseness', level);
143
+ }
144
+ updateAvgDegree() {
145
+ if (!this.multiResolutionGraph) {
146
+ return;
147
+ }
148
+ const avgDegree = this.get('avg_degree');
149
+ if (!avgDegree && avgDegree !== 0) {
150
+ return;
151
+ }
152
+ this.multiResolutionGraph.setConnectivityLevel(avgDegree);
153
+ this.multiResolutionGraph.sliderManager.setSliderValue('Connectivity', avgDegree);
154
+ }
155
+ updateSelectedNodes() {
156
+ if (!this.multiResolutionGraph) {
157
+ return;
158
+ }
159
+ const selectedNodes = this.get('selected_nodes');
160
+ if (!selectedNodes) {
161
+ return;
162
+ }
163
+ this.multiResolutionGraph.setSelectedNodes(selectedNodes);
164
+ }
165
+ disposeGraph() {
166
+ this.multiResolutionGraph.cleanup();
167
+ this.multiResolutionGraph.dispose();
168
+ }
169
+ handleCustomMessage(content) {
170
+ if (content.event_type === 'dispose_graph') {
171
+ this.disposeGraph();
172
+ }
173
+ }
174
+ defaults() {
175
+ return Object.assign(Object.assign({}, super.defaults()), { _model_name: LandscapeModel.model_name, _model_module: LandscapeModel.model_module, _model_module_version: LandscapeModel.model_module_version, _view_name: LandscapeModel.view_name, _view_module: LandscapeModel.view_module, _view_module_version: LandscapeModel.view_module_version, graph: defaultGraph, colors: defaultColors, node_labels: defaultLabels, node_hover_labels: null, node_sizes: null, selected_nodes: [], sigma_settings: defaultSigmaSettings, background_color: null, is_expanded_layout: false });
176
+ }
177
+ }
178
+ LandscapeModel.serializers = Object.assign({}, DOMWidgetModel.serializers);
179
+ LandscapeModel.model_name = 'LandscapeModel';
180
+ LandscapeModel.model_module = MODULE_NAME;
181
+ LandscapeModel.model_module_version = MODULE_VERSION;
182
+ LandscapeModel.view_name = 'LandscapeView'; // Set to null if no view
183
+ LandscapeModel.view_module = MODULE_NAME; // Set to null if no view
184
+ LandscapeModel.view_module_version = MODULE_VERSION;
185
+ export class LandscapeView extends DOMWidgetView {
186
+ constructor(options) {
187
+ super(options);
188
+ this.view = null;
189
+ const rand = new Rand();
190
+ this.containerId = `landscape-container-${rand.next().toString(36).substring(2)}`;
191
+ }
192
+ render() {
193
+ this.createLandscapeContainer();
194
+ this.setupGraphManager();
195
+ this.model.on('change:background_color', this.setBackgroundColor, this);
196
+ }
197
+ createLandscapeContainer() {
198
+ this._landscapeContainer = document.createElement('div');
199
+ this._landscapeContainer.id = this.containerId;
200
+ this._landscapeContainer.classList.add('landscape-container');
201
+ this.setBackgroundColor();
202
+ this.el.appendChild(this._landscapeContainer);
203
+ this.el.classList.add('custom-widget');
204
+ }
205
+ setupGraphManager() {
206
+ const container = document.getElementById(this.containerId);
207
+ if (container && this.model.multiResolutionGraph) {
208
+ this.view = this.model.multiResolutionGraph.getView(container);
209
+ // Using `zoomInAndOut` fixes WebGL context in Jupyter Notebook, triggering a refresh
210
+ this.view.graphManager.zoomInAndOut();
211
+ }
212
+ else {
213
+ setTimeout(() => this.setupGraphManager(), 100);
214
+ }
215
+ }
216
+ setBackgroundColor() {
217
+ const backgroundColor = this.model.get('background_color');
218
+ if (!backgroundColor) {
219
+ return;
220
+ }
221
+ this.el.style.backgroundColor = backgroundColor;
222
+ this._landscapeContainer.style.backgroundColor = backgroundColor;
223
+ this._landscapeContainer.style.setProperty('--sigma-background-color', backgroundColor);
224
+ }
225
+ }
226
+ //# sourceMappingURL=landscape.js.map
@@ -0,0 +1,30 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import React from 'react';
13
+ import { styled } from '@mui/material/styles';
14
+ import Tooltip, { tooltipClasses } from '@mui/material/Tooltip';
15
+ const HtmlTooltip = styled((_a) => {
16
+ var { className } = _a, props = __rest(_a, ["className"]);
17
+ return (React.createElement(Tooltip, Object.assign({ placement: 'right' }, props, { classes: { popper: className } }), props.children));
18
+ })(({ theme }) => ({
19
+ [`& .${tooltipClasses.tooltip}`]: {
20
+ backgroundColor: theme.palette.secondary.main,
21
+ color: theme.palette.primary.contrastText,
22
+ fontSize: '1rem',
23
+ lineHeight: '1.4',
24
+ '.MuiTooltip-arrow': {
25
+ color: theme.palette.secondary.main,
26
+ },
27
+ },
28
+ }));
29
+ export { HtmlTooltip as Tooltip };
30
+ //# sourceMappingURL=Tooltip.js.map
package/lib/plugin.js ADDED
@@ -0,0 +1,27 @@
1
+ import { IJupyterWidgetRegistry } from '@jupyter-widgets/base';
2
+ import * as widgetExports from './landscape';
3
+ import { MODULE_NAME, MODULE_VERSION } from './version';
4
+ const EXTENSION_ID = 'landscape-widget:plugin';
5
+ /**
6
+ * The example plugin.
7
+ */
8
+ const examplePlugin = {
9
+ id: EXTENSION_ID,
10
+ requires: [IJupyterWidgetRegistry],
11
+ activate: activateWidgetExtension,
12
+ autoStart: true,
13
+ };
14
+ // the "as unknown as ..." typecast above is solely to support JupyterLab 1
15
+ // and 2 in the same codebase and should be removed when we migrate to Lumino.
16
+ export default examplePlugin;
17
+ /**
18
+ * Activate the widget extension.
19
+ */
20
+ function activateWidgetExtension(app, registry) {
21
+ registry.registerWidget({
22
+ name: MODULE_NAME,
23
+ version: MODULE_VERSION,
24
+ exports: widgetExports,
25
+ });
26
+ }
27
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ __webpack_public_path__ =
3
+ document.querySelector('body').getAttribute('data-base-url') + 'nbextensions/landscape_widget/';
4
+ //# sourceMappingURL=public-path.js.map
package/lib/version.js ADDED
@@ -0,0 +1,16 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-ignore
3
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
4
+ const data = require('../package.json');
5
+ /**
6
+ * The _model_module_version/_view_module_version this package implements.
7
+ *
8
+ * The html widget manager assumes that this is the same as the npm package
9
+ * version number.
10
+ */
11
+ export const MODULE_VERSION = data.version;
12
+ /*
13
+ * The current package name.
14
+ */
15
+ export const MODULE_NAME = data.name;
16
+ //# sourceMappingURL=version.js.map