mascot-vis 3.0.0 → 3.0.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/package.json +1 -2
- package/js/depGraphVis.js +0 -66
- package/src-new-ts/action/createElement.ts +0 -91
- package/src-new-ts/action/encode.js +0 -20
- package/src-new-ts/action/repeat.js +0 -128
- package/src-new-ts/action/traverseScene.js +0 -41
- package/src-new-ts/data/Network.js +0 -2
- package/src-new-ts/data/Scope.js +0 -135
- package/src-new-ts/data/Table.js +0 -263
- package/src-new-ts/data/Tree.js +0 -3
- package/src-new-ts/data/field.ts +0 -115
- package/src-new-ts/data/import.ts +0 -96
- package/src-new-ts/data/predicate.ts +0 -82
- package/src-new-ts/depgraph/DepGraph.js +0 -178
- package/src-new-ts/depgraph/Edge.js +0 -9
- package/src-new-ts/depgraph/SceneGraph2DepGraph.js +0 -110
- package/src-new-ts/depgraph/Signal.js +0 -12
- package/src-new-ts/depgraph/operator/BoundsEvaluator.js +0 -30
- package/src-new-ts/depgraph/operator/Dataflow.js +0 -41
- package/src-new-ts/depgraph/operator/DomainBuilder.js +0 -50
- package/src-new-ts/depgraph/updateDepGraph.js +0 -45
- package/src-new-ts/depgraph/variable/BoundsVar.js +0 -81
- package/src-new-ts/depgraph/variable/ChannelVar.js +0 -17
- package/src-new-ts/depgraph/variable/DataScopeVar.js +0 -12
- package/src-new-ts/depgraph/variable/DomainVar.js +0 -15
- package/src-new-ts/depgraph/variable/FieldVar.js +0 -17
- package/src-new-ts/depgraph/variable/LayoutParameter.js +0 -8
- package/src-new-ts/depgraph/variable/ScaleVar.js +0 -13
- package/src-new-ts/depgraph/variable/Variable.js +0 -39
- package/src-new-ts/element/gradient/LinearGradient.js +0 -37
- package/src-new-ts/element/group/Collection.js +0 -109
- package/src-new-ts/element/group/Group.js +0 -307
- package/src-new-ts/element/group/Scene.js +0 -98
- package/src-new-ts/element/mark/CircleMark.ts +0 -85
- package/src-new-ts/element/mark/Mark.ts +0 -233
- package/src-new-ts/element/mark/PathMark.js +0 -483
- package/src-new-ts/element/mark/Segment.js +0 -29
- package/src-new-ts/element/mark/Vertex.js +0 -118
- package/src-new-ts/encode/Scale.ts +0 -115
- package/src-new-ts/index.ts +0 -19
- package/src-new-ts/layout/Layout.ts +0 -3
- package/src-new-ts/render/CanvasRenderer.ts +0 -24
- package/src-new-ts/render/SVGRenderer.js +0 -316
- package/src-new-ts/util.ts +0 -3
- package/src-old/action/Classify.js +0 -53
- package/src-old/action/Densify.js +0 -199
- package/src-old/action/Partition.js +0 -531
- package/src-old/action/Repeat.js +0 -106
- package/src-old/action/Repopulate.js +0 -44
- package/src-old/action/Stratify.js +0 -156
- package/src-old/basic/Gradient.js +0 -37
- package/src-old/basic/Point.js +0 -51
- package/src-old/basic/Rectangle.js +0 -63
- package/src-old/bind/bindToAngle.js +0 -56
- package/src-old/bind/bindToAreaMark.js +0 -360
- package/src-old/bind/bindToColor.js +0 -114
- package/src-old/bind/bindToLink.js +0 -81
- package/src-old/bind/bindToPosition.js +0 -283
- package/src-old/bind/bindToRadialDistance.js +0 -62
- package/src-old/bind/bindToSize.js +0 -235
- package/src-old/bind/bindToText.js +0 -60
- package/src-old/bind/bindToThickness.js +0 -100
- package/src-old/constraint/AffixConstraint.js +0 -129
- package/src-old/constraint/AlignConstraint.js +0 -58
- package/src-old/core/Encoding.js +0 -336
- package/src-old/core/Scale.js +0 -322
- package/src-old/core/SceneLoader.js +0 -290
- package/src-old/core/SceneValidator.js +0 -232
- package/src-old/core/SpecExecutor.js +0 -113
- package/src-old/core/SpecGenerator.js +0 -350
- package/src-old/data/DataImporter.js +0 -64
- package/src-old/data/DataScope.js +0 -124
- package/src-old/data/DataTable.js +0 -338
- package/src-old/data/Network.js +0 -106
- package/src-old/data/Tree.js +0 -251
- package/src-old/data/transform/Bin.js +0 -46
- package/src-old/data/transform/Filter.js +0 -48
- package/src-old/data/transform/Groupby.js +0 -18
- package/src-old/data/transform/KDE.js +0 -58
- package/src-old/data/transform/Sort.js +0 -14
- package/src-old/data/transform/Split.js +0 -5
- package/src-old/data/transform/partition.js +0 -46
- package/src-old/history/UndoRedoStack +0 -0
- package/src-old/index.js +0 -271
- package/src-old/indexSVG.js +0 -259
- package/src-old/interaction/Interaction.js +0 -91
- package/src-old/interaction/MouseEvent.js +0 -8
- package/src-old/interaction/Selection.js +0 -9
- package/src-old/interaction/brush.js +0 -362
- package/src-old/item/Segment.js +0 -29
- package/src-old/item/Vertex.js +0 -118
- package/src-old/item/composite/Collection.js +0 -106
- package/src-old/item/composite/Glyph.js +0 -19
- package/src-old/item/composite/Group.js +0 -310
- package/src-old/item/composite/Scene.js +0 -1251
- package/src-old/item/mark/ArcPath.js +0 -181
- package/src-old/item/mark/AreaPath.js +0 -78
- package/src-old/item/mark/CirclePath.js +0 -102
- package/src-old/item/mark/EllipsePath.js +0 -5
- package/src-old/item/mark/Image.js +0 -101
- package/src-old/item/mark/LinkPath.js +0 -118
- package/src-old/item/mark/Mark.js +0 -163
- package/src-old/item/mark/Path.js +0 -494
- package/src-old/item/mark/PointText.js +0 -201
- package/src-old/item/mark/PolygonPath.js +0 -64
- package/src-old/item/mark/RectPath.js +0 -88
- package/src-old/item/mark/RingPath.js +0 -92
- package/src-old/item/refs/Axis.js +0 -362
- package/src-old/item/refs/EncodingAxis.js +0 -515
- package/src-old/item/refs/Gridlines.js +0 -144
- package/src-old/item/refs/LayoutAxis.js +0 -316
- package/src-old/item/refs/Legend.js +0 -273
- package/src-old/layout/Circular.js +0 -95
- package/src-old/layout/Force.js +0 -52
- package/src-old/layout/Grid.js +0 -423
- package/src-old/layout/Layout.js +0 -13
- package/src-old/layout/Packing.js +0 -56
- package/src-old/layout/Stack.js +0 -264
- package/src-old/layout/Strata.js +0 -88
- package/src-old/layout/Sugiyama.js +0 -59
- package/src-old/layout/TidyTree.js +0 -105
- package/src-old/layout/Treemap.js +0 -87
- package/src-old/renderer/SVGInteractionHandler.js +0 -241
- package/src-old/renderer/SVGRenderer.js +0 -325
- package/src-old/renderer/WebGLRenderer.js +0 -1097
- package/src-old/renderer/WebGLRenderer2.js +0 -249
- package/src-old/renderer/threejs/Line2.js +0 -18
- package/src-old/renderer/threejs/LineGeometry.js +0 -77
- package/src-old/renderer/threejs/LineMaterial.js +0 -605
- package/src-old/renderer/threejs/LineSegments2.js +0 -281
- package/src-old/renderer/threejs/LineSegmentsGeometry.js +0 -226
- package/src-old/renderer/threejs/Wireframe.js +0 -51
- package/src-old/renderer/threejs/WireframeGeometry2.js +0 -16
- package/src-old/scale/areaSize.js +0 -0
- package/src-old/scale/domain.js +0 -38
- package/src-old/util/Constants.js +0 -180
- package/src-old/util/DataUtil.js +0 -35
- package/src-old/util/ItemUtil.js +0 -586
- package/src-old/util/Numerical.js +0 -33
- package/tests/demo-tests/README.md +0 -80
- package/tests/demo-tests/SVG2PNG.js +0 -56
- package/tests/demo-tests/demos2CanvasPNGs.js +0 -69
- package/tests/demo-tests/demos2ScenesSVGs.js +0 -100
- package/tests/demo-tests/pathElementWorker.js +0 -91
- package/tests/demo-tests/pixelTest.js +0 -62
- package/tests/demo-tests/renderDemos.html +0 -132
- package/tests/demo-tests/serializationTest.js +0 -36
- package/tests/demo-tests/serializeDemos.html +0 -134
- package/tests/unit-tests/README.md +0 -4
- package/tests/unit-tests/jasmine-browser.json +0 -21
- package/tests/unit-tests/jasmine.json +0 -14
- package/tests/unit-tests/testSpec.js +0 -274
package/src-old/index.js
DELETED
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import * as d3 from "d3";
|
|
2
|
-
import Scene from "./item/composite/Scene";
|
|
3
|
-
import SVGRenderer from "./renderer/SVGRenderer";
|
|
4
|
-
import DataTable from "./data/DataTable";
|
|
5
|
-
import Scale from "./core/Scale";
|
|
6
|
-
import {ItemType} from "./util/Constants";
|
|
7
|
-
import {CanvasProvider, cartesian2Polar, getLayout, getLeafItems, getLeafMarks, getPeers, isGuide, isMark, polar2Cartesian} from "./util/ItemUtil";
|
|
8
|
-
import LinearGradient from "./basic/Gradient";
|
|
9
|
-
import SpecGenerator from "./core/SpecGenerator";
|
|
10
|
-
import SceneLoader from "./core/SceneLoader";
|
|
11
|
-
import SpecExecutor from "./core/SpecExecutor";
|
|
12
|
-
import Rectangle from "./basic/Rectangle";
|
|
13
|
-
import WebGLRenderer from "./renderer/WebGLRenderer";
|
|
14
|
-
import Path from "./item/mark/Path";
|
|
15
|
-
import { classifiable } from "./action/Classify";
|
|
16
|
-
import { densifiable } from "./action/Densify";
|
|
17
|
-
import { dividable } from "./action/Partition";
|
|
18
|
-
import { repeatable } from "./action/Repeat";
|
|
19
|
-
import { importCSV, importGraphjson, importTreejson } from "./data/DataImporter";
|
|
20
|
-
|
|
21
|
-
var pixiRenderers = {};
|
|
22
|
-
|
|
23
|
-
export function scene(args) {
|
|
24
|
-
return new Scene(args);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function renderer(type, id) {
|
|
28
|
-
switch (type) {
|
|
29
|
-
case "svg":
|
|
30
|
-
return new SVGRenderer(id);
|
|
31
|
-
case "webgl":
|
|
32
|
-
if (!(id in pixiRenderers))
|
|
33
|
-
pixiRenderers[id] = new WebGLRenderer(id);
|
|
34
|
-
return pixiRenderers[id];
|
|
35
|
-
// case "three":
|
|
36
|
-
// return new WebGLRenderer2(id);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function createScale(type, args) {
|
|
41
|
-
return new Scale(type, args);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function layout(type, params) {
|
|
45
|
-
return getLayout(type, params);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function linearGradient(params) {
|
|
49
|
-
return new LinearGradient(params);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function sceneLoader() {
|
|
53
|
-
return new SceneLoader();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function specGenerator() {
|
|
57
|
-
return new SpecGenerator();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function specExecutor() {
|
|
61
|
-
return new SpecExecutor();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
export async function csv(url) {
|
|
68
|
-
return importCSV(url);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export async function csvFromFile(data) {
|
|
72
|
-
let parsed = d3.csvParse(data.trim(), d3.autoType);
|
|
73
|
-
return new DataTable(parsed, "");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function csvFromString(data, name) {
|
|
77
|
-
let parsed = d3.csvParse(data.trim(), d3.autoType);
|
|
78
|
-
return new DataTable(parsed, name);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export async function treejson(url) {
|
|
82
|
-
return importTreejson(url);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export async function graphjson(url) {
|
|
86
|
-
return importGraphjson(url);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function cartesianToPolar(x, y, cx, cy){
|
|
90
|
-
return cartesian2Polar(x, y, cx, cy);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function polarToCartesian(cx, cy, r, deg){
|
|
94
|
-
return polar2Cartesian(cx, cy, r, deg);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function inMarkRectHitTest(item, rect, tolerance) {
|
|
98
|
-
let t = tolerance ? tolerance : 2;
|
|
99
|
-
if (isMark(item)) {
|
|
100
|
-
let list = [];
|
|
101
|
-
for (let v of item.vertices) {
|
|
102
|
-
let wd = Math.max(t, v.width, v.radius * 2), ht = Math.max(t, v.height, v.radius * 2);
|
|
103
|
-
list.push({i: v, b: new Rectangle(v.x - wd/2, v.y - ht/2, wd, ht)});
|
|
104
|
-
}
|
|
105
|
-
if (item.type === ItemType.Rect) {
|
|
106
|
-
for (let s of item.segments) {
|
|
107
|
-
let tk = Math.max(item.strokeWidth, t), orientation = s.vertex1.x === s.vertex2.x ? "v" : "h";
|
|
108
|
-
if (orientation === "v")
|
|
109
|
-
list.push({i: s, b: new Rectangle(s.vertex1.x - tk/2, Math.min(s.vertex1.y, s.vertex2.y) - tk/2, tk, Math.abs(s.vertex1.y - s.vertex2.y))});
|
|
110
|
-
else
|
|
111
|
-
list.push({i: s, b: new Rectangle(Math.min(s.vertex1.x, s.vertex2.x) - tk/2, s.vertex1.y - tk/2, Math.abs(s.vertex1.x - s.vertex2.x), tk)});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
for (let l of list) {
|
|
116
|
-
if (l.b.overlap(rect))
|
|
117
|
-
return l.i;
|
|
118
|
-
}
|
|
119
|
-
return null;
|
|
120
|
-
} else if (!isGuide(item) && item.children && item.children.length > 0) {
|
|
121
|
-
for (let c of item.children) {
|
|
122
|
-
if (c.bounds.overlap(rect)) {
|
|
123
|
-
let r = inMarkRectHitTest(c, rect, t);
|
|
124
|
-
if (r) return r;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export function inMarkHitTest(item, x, y, tolerance) {
|
|
133
|
-
// let itm = item, found = false, t = tolerance ? tolerance : 2;
|
|
134
|
-
// while (itm.children && itm.children.length > 0) {
|
|
135
|
-
// for (let c of itm.children) {
|
|
136
|
-
// if (c.contains(x, y) && !isGuide(c)) {
|
|
137
|
-
// itm = c;
|
|
138
|
-
// found = true;
|
|
139
|
-
// break;
|
|
140
|
-
// }
|
|
141
|
-
// }
|
|
142
|
-
// if (found) {
|
|
143
|
-
// found = false;
|
|
144
|
-
// } else {
|
|
145
|
-
// break;
|
|
146
|
-
// }
|
|
147
|
-
// }
|
|
148
|
-
// if (!isMark(itm)) return null;
|
|
149
|
-
let leafMarks = getLeafMarks(item);
|
|
150
|
-
let itm, t = tolerance ? tolerance : 2;
|
|
151
|
-
let ctx = CanvasProvider.getContext();
|
|
152
|
-
|
|
153
|
-
for (let m of leafMarks) {
|
|
154
|
-
if (!(m instanceof Path)) continue;
|
|
155
|
-
let p = new Path2D(m.getSVGPathData());
|
|
156
|
-
ctx.lineWidth = Math.max(m.strokeWidth, t * 2);
|
|
157
|
-
ctx.stroke(p);
|
|
158
|
-
if (ctx.isPointInStroke(p, x, y)) {
|
|
159
|
-
itm = m;
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (!itm) return null;
|
|
165
|
-
|
|
166
|
-
let list = [];
|
|
167
|
-
for (let v of itm.vertices) {
|
|
168
|
-
let wd = Math.max(t, v.width, v.radius * 2), ht = Math.max(t, v.height, v.radius * 2);
|
|
169
|
-
list.push({i: v, b: new Rectangle(v.x - wd/2, v.y - ht/2, wd, ht)});
|
|
170
|
-
}
|
|
171
|
-
for (let l of list) {
|
|
172
|
-
if (l.b.contains(x, y))
|
|
173
|
-
return l.i;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (itm.segments && itm.segments.length > 0) {
|
|
177
|
-
for (let s of itm.segments) {
|
|
178
|
-
let p = new Path2D();
|
|
179
|
-
p.moveTo(s.vertex1.x, s.vertex1.y);
|
|
180
|
-
p.lineTo(s.vertex2.x, s.vertex2.y);
|
|
181
|
-
ctx.lineWidth = Math.max(itm.strokeWidth, t);
|
|
182
|
-
ctx.stroke(p);
|
|
183
|
-
if (ctx.isPointInStroke(p, x, y))
|
|
184
|
-
return s;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
// if (itm.type === ItemType.Rect) {
|
|
188
|
-
// for (let s of itm.segments) {
|
|
189
|
-
// let tk = Math.max(itm.strokeWidth, t), orientation = s.vertex1.x === s.vertex2.x ? "v" : "h";
|
|
190
|
-
// if (orientation === "v")
|
|
191
|
-
// list.push({i: s, b: new Rectangle(s.vertex1.x - tk/2, Math.min(s.vertex1.y, s.vertex2.y) - tk/2, tk, Math.abs(s.vertex1.y - s.vertex2.y))});
|
|
192
|
-
// else
|
|
193
|
-
// list.push({i: s, b: new Rectangle(Math.min(s.vertex1.x, s.vertex2.x) - tk/2, s.vertex1.y - tk/2, Math.abs(s.vertex1.x - s.vertex2.x), tk)});
|
|
194
|
-
// }
|
|
195
|
-
// }
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
return null;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
export function rectHitTest(item, rect) {
|
|
202
|
-
let result = [];
|
|
203
|
-
if (!item.children || item.children.length == 0) {
|
|
204
|
-
return item.bounds.overlap(rect) && item.type !== ItemType.Scene ? [item] : [];
|
|
205
|
-
}
|
|
206
|
-
for (let i = item.children.length - 1; i >= 0; i--) {
|
|
207
|
-
let c = item.children[i];
|
|
208
|
-
if (c.bounds.overlap(rect))
|
|
209
|
-
result.push(c);
|
|
210
|
-
}
|
|
211
|
-
return result;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export function hitTest(item, x, y) {
|
|
215
|
-
if (!item.children || item.children.length == 0) {
|
|
216
|
-
return item.contains(x, y) && item.type !== ItemType.Scene ? item : null
|
|
217
|
-
}
|
|
218
|
-
let children = item.children;
|
|
219
|
-
if (item.type === ItemType.Scene) {
|
|
220
|
-
children = children.slice();
|
|
221
|
-
children.sort((a,b) => isGuide(a) ? 1 : isGuide(b) ? -1 : 0 );
|
|
222
|
-
}
|
|
223
|
-
for (let i = children.length - 1; i >= 0; i--) {
|
|
224
|
-
let c = children[i];
|
|
225
|
-
if (c.contains(x, y))
|
|
226
|
-
return c;
|
|
227
|
-
}
|
|
228
|
-
return null;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
export function hitTestAll(item, x, y) {
|
|
232
|
-
let items = getLeafItems(item);
|
|
233
|
-
for (let i = items.length - 1; i >= 0; i--) {
|
|
234
|
-
let c = items[i];
|
|
235
|
-
if (c.contains(x, y))
|
|
236
|
-
return c;
|
|
237
|
-
}
|
|
238
|
-
return null;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
export function canRepeat(compnt) {
|
|
242
|
-
return repeatable(compnt);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
export function canDivide(compnt) {
|
|
246
|
-
return dividable(compnt);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export function canDensify(compnt) {
|
|
250
|
-
return densifiable(compnt);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
export function canFormGlyph(args) {
|
|
254
|
-
for (let itm of args) {
|
|
255
|
-
if (!isMark(itm))
|
|
256
|
-
return false;
|
|
257
|
-
}
|
|
258
|
-
return true;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export function canClassify(item) {
|
|
262
|
-
return classifiable(item);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
export function getPeersInScene(item) {
|
|
266
|
-
if (item.type == "vertex" || item.type == "segment") {
|
|
267
|
-
return getPeers(item, item.parent.getScene());
|
|
268
|
-
} else {
|
|
269
|
-
return getPeers(item, item.getScene());
|
|
270
|
-
}
|
|
271
|
-
}
|
package/src-old/indexSVG.js
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import * as d3 from "d3";
|
|
2
|
-
import Scene from "./item/composite/Scene";
|
|
3
|
-
import SVGRenderer from "./renderer/SVGRenderer";
|
|
4
|
-
import DataTable from "./data/DataTable";
|
|
5
|
-
import Scale from "./core/Scale";
|
|
6
|
-
import {ItemType} from "./util/Constants";
|
|
7
|
-
import {CanvasProvider, cartesian2Polar, getLayout, getLeafItems, getLeafMarks, getPeers, isGuide, isMark, polar2Cartesian} from "./util/ItemUtil";
|
|
8
|
-
import LinearGradient from "./basic/Gradient";
|
|
9
|
-
import SpecGenerator from "./core/SpecGenerator";
|
|
10
|
-
import SceneLoader from "./core/SceneLoader";
|
|
11
|
-
import SpecExecutor from "./core/SpecExecutor";
|
|
12
|
-
import Rectangle from "./basic/Rectangle";
|
|
13
|
-
import Path from "./item/mark/Path";
|
|
14
|
-
import { classifiable } from "./action/Classify";
|
|
15
|
-
import { densifiable } from "./action/Densify";
|
|
16
|
-
import { dividable } from "./action/Partition";
|
|
17
|
-
import { repeatable } from "./action/Repeat";
|
|
18
|
-
import { importCSV, importGraphjson, importTreejson } from "./data/DataImporter";
|
|
19
|
-
|
|
20
|
-
export function scene(args) {
|
|
21
|
-
return new Scene(args);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function renderer(type, id) {
|
|
25
|
-
return new SVGRenderer(id);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function createScale(type, args) {
|
|
29
|
-
return new Scale(type, args);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function layout(type, params) {
|
|
33
|
-
return getLayout(type, params);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function linearGradient(params) {
|
|
37
|
-
return new LinearGradient(params);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function sceneLoader() {
|
|
41
|
-
return new SceneLoader();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function specGenerator() {
|
|
45
|
-
return new SpecGenerator();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function specExecutor() {
|
|
49
|
-
return new SpecExecutor();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
export async function csv(url) {
|
|
56
|
-
return importCSV(url);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export async function csvFromFile(data) {
|
|
60
|
-
let parsed = d3.csvParse(data.trim(), d3.autoType);
|
|
61
|
-
return new DataTable(parsed, "");
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function csvFromString(data, name) {
|
|
65
|
-
let parsed = d3.csvParse(data.trim(), d3.autoType);
|
|
66
|
-
return new DataTable(parsed, name);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export async function treejson(url) {
|
|
70
|
-
return importTreejson(url);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export async function graphjson(url) {
|
|
74
|
-
return importGraphjson(url);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function cartesianToPolar(x, y, cx, cy){
|
|
78
|
-
return cartesian2Polar(x, y, cx, cy);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function polarToCartesian(cx, cy, r, deg){
|
|
82
|
-
return polar2Cartesian(cx, cy, r, deg);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function inMarkRectHitTest(item, rect, tolerance) {
|
|
86
|
-
let t = tolerance ? tolerance : 2;
|
|
87
|
-
if (isMark(item)) {
|
|
88
|
-
let list = [];
|
|
89
|
-
for (let v of item.vertices) {
|
|
90
|
-
let wd = Math.max(t, v.width, v.radius * 2), ht = Math.max(t, v.height, v.radius * 2);
|
|
91
|
-
list.push({i: v, b: new Rectangle(v.x - wd/2, v.y - ht/2, wd, ht)});
|
|
92
|
-
}
|
|
93
|
-
if (item.type === ItemType.Rect) {
|
|
94
|
-
for (let s of item.segments) {
|
|
95
|
-
let tk = Math.max(item.strokeWidth, t), orientation = s.vertex1.x === s.vertex2.x ? "v" : "h";
|
|
96
|
-
if (orientation === "v")
|
|
97
|
-
list.push({i: s, b: new Rectangle(s.vertex1.x - tk/2, Math.min(s.vertex1.y, s.vertex2.y) - tk/2, tk, Math.abs(s.vertex1.y - s.vertex2.y))});
|
|
98
|
-
else
|
|
99
|
-
list.push({i: s, b: new Rectangle(Math.min(s.vertex1.x, s.vertex2.x) - tk/2, s.vertex1.y - tk/2, Math.abs(s.vertex1.x - s.vertex2.x), tk)});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
for (let l of list) {
|
|
104
|
-
if (l.b.overlap(rect))
|
|
105
|
-
return l.i;
|
|
106
|
-
}
|
|
107
|
-
return null;
|
|
108
|
-
} else if (!isGuide(item) && item.children && item.children.length > 0) {
|
|
109
|
-
for (let c of item.children) {
|
|
110
|
-
if (c.bounds.overlap(rect)) {
|
|
111
|
-
let r = inMarkRectHitTest(c, rect, t);
|
|
112
|
-
if (r) return r;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export function inMarkHitTest(item, x, y, tolerance) {
|
|
121
|
-
// let itm = item, found = false, t = tolerance ? tolerance : 2;
|
|
122
|
-
// while (itm.children && itm.children.length > 0) {
|
|
123
|
-
// for (let c of itm.children) {
|
|
124
|
-
// if (c.contains(x, y) && !isGuide(c)) {
|
|
125
|
-
// itm = c;
|
|
126
|
-
// found = true;
|
|
127
|
-
// break;
|
|
128
|
-
// }
|
|
129
|
-
// }
|
|
130
|
-
// if (found) {
|
|
131
|
-
// found = false;
|
|
132
|
-
// } else {
|
|
133
|
-
// break;
|
|
134
|
-
// }
|
|
135
|
-
// }
|
|
136
|
-
// if (!isMark(itm)) return null;
|
|
137
|
-
let leafMarks = getLeafMarks(item);
|
|
138
|
-
let itm, t = tolerance ? tolerance : 2;
|
|
139
|
-
let ctx = CanvasProvider.getContext();
|
|
140
|
-
|
|
141
|
-
for (let m of leafMarks) {
|
|
142
|
-
if (!(m instanceof Path)) continue;
|
|
143
|
-
let p = new Path2D(m.getSVGPathData());
|
|
144
|
-
ctx.lineWidth = Math.max(m.strokeWidth, t * 2);
|
|
145
|
-
ctx.stroke(p);
|
|
146
|
-
if (ctx.isPointInStroke(p, x, y)) {
|
|
147
|
-
itm = m;
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (!itm) return null;
|
|
153
|
-
|
|
154
|
-
let list = [];
|
|
155
|
-
for (let v of itm.vertices) {
|
|
156
|
-
let wd = Math.max(t, v.width, v.radius * 2), ht = Math.max(t, v.height, v.radius * 2);
|
|
157
|
-
list.push({i: v, b: new Rectangle(v.x - wd/2, v.y - ht/2, wd, ht)});
|
|
158
|
-
}
|
|
159
|
-
for (let l of list) {
|
|
160
|
-
if (l.b.contains(x, y))
|
|
161
|
-
return l.i;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (itm.segments && itm.segments.length > 0) {
|
|
165
|
-
for (let s of itm.segments) {
|
|
166
|
-
let p = new Path2D();
|
|
167
|
-
p.moveTo(s.vertex1.x, s.vertex1.y);
|
|
168
|
-
p.lineTo(s.vertex2.x, s.vertex2.y);
|
|
169
|
-
ctx.lineWidth = Math.max(itm.strokeWidth, t);
|
|
170
|
-
ctx.stroke(p);
|
|
171
|
-
if (ctx.isPointInStroke(p, x, y))
|
|
172
|
-
return s;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
// if (itm.type === ItemType.Rect) {
|
|
176
|
-
// for (let s of itm.segments) {
|
|
177
|
-
// let tk = Math.max(itm.strokeWidth, t), orientation = s.vertex1.x === s.vertex2.x ? "v" : "h";
|
|
178
|
-
// if (orientation === "v")
|
|
179
|
-
// list.push({i: s, b: new Rectangle(s.vertex1.x - tk/2, Math.min(s.vertex1.y, s.vertex2.y) - tk/2, tk, Math.abs(s.vertex1.y - s.vertex2.y))});
|
|
180
|
-
// else
|
|
181
|
-
// list.push({i: s, b: new Rectangle(Math.min(s.vertex1.x, s.vertex2.x) - tk/2, s.vertex1.y - tk/2, Math.abs(s.vertex1.x - s.vertex2.x), tk)});
|
|
182
|
-
// }
|
|
183
|
-
// }
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
return null;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export function rectHitTest(item, rect) {
|
|
190
|
-
let result = [];
|
|
191
|
-
if (!item.children || item.children.length == 0) {
|
|
192
|
-
return item.bounds.overlap(rect) && item.type !== ItemType.Scene ? [item] : [];
|
|
193
|
-
}
|
|
194
|
-
for (let i = item.children.length - 1; i >= 0; i--) {
|
|
195
|
-
let c = item.children[i];
|
|
196
|
-
if (c.bounds.overlap(rect))
|
|
197
|
-
result.push(c);
|
|
198
|
-
}
|
|
199
|
-
return result;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export function hitTest(item, x, y) {
|
|
203
|
-
if (!item.children || item.children.length == 0) {
|
|
204
|
-
return item.contains(x, y) && item.type !== ItemType.Scene ? item : null
|
|
205
|
-
}
|
|
206
|
-
let children = item.children;
|
|
207
|
-
if (item.type === ItemType.Scene) {
|
|
208
|
-
children = children.slice();
|
|
209
|
-
children.sort((a,b) => isGuide(a) ? 1 : isGuide(b) ? -1 : 0 );
|
|
210
|
-
}
|
|
211
|
-
for (let i = children.length - 1; i >= 0; i--) {
|
|
212
|
-
let c = children[i];
|
|
213
|
-
if (c.contains(x, y))
|
|
214
|
-
return c;
|
|
215
|
-
}
|
|
216
|
-
return null;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
export function hitTestAll(item, x, y) {
|
|
220
|
-
let items = getLeafItems(item);
|
|
221
|
-
for (let i = items.length - 1; i >= 0; i--) {
|
|
222
|
-
let c = items[i];
|
|
223
|
-
if (c.contains(x, y))
|
|
224
|
-
return c;
|
|
225
|
-
}
|
|
226
|
-
return null;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export function canRepeat(compnt) {
|
|
230
|
-
return repeatable(compnt);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
export function canDivide(compnt) {
|
|
234
|
-
return dividable(compnt);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
export function canDensify(compnt) {
|
|
238
|
-
return densifiable(compnt);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
export function canFormGlyph(args) {
|
|
242
|
-
for (let itm of args) {
|
|
243
|
-
if (!isMark(itm))
|
|
244
|
-
return false;
|
|
245
|
-
}
|
|
246
|
-
return true;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export function canClassify(item) {
|
|
250
|
-
return classifiable(item);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
export function getPeersInScene(item) {
|
|
254
|
-
if (item.type == "vertex" || item.type == "segment") {
|
|
255
|
-
return getPeers(item, item.parent.getScene());
|
|
256
|
-
} else {
|
|
257
|
-
return getPeers(item, item.getScene());
|
|
258
|
-
}
|
|
259
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { evaluatePredicate, getPeers } from "../util/ItemUtil";
|
|
2
|
-
import * as d3 from 'd3';
|
|
3
|
-
|
|
4
|
-
export default class Interaction {
|
|
5
|
-
|
|
6
|
-
constructor(listener, eventType, selDef, targetDef) {
|
|
7
|
-
this._listener = listener;
|
|
8
|
-
this._eventType = eventType;
|
|
9
|
-
this._selDef = selDef;
|
|
10
|
-
this._targetDef = targetDef;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
getCallbackFunction(scene, handler) {
|
|
14
|
-
let i = this;
|
|
15
|
-
return function(e){
|
|
16
|
-
e.stopPropagation();
|
|
17
|
-
let sel = handler._getSelection(e, i.selectionDef, i._listener, scene.getItem(d3.select(this).attr("id")));
|
|
18
|
-
let targets = getPeers(i.targetDef.item, scene);
|
|
19
|
-
let predicates;
|
|
20
|
-
if (i.selectionDef.remember) {
|
|
21
|
-
handler.addGlobalPredicate(scene, sel.predicate);
|
|
22
|
-
predicates = handler.getGlobalPredicates(scene);
|
|
23
|
-
} else {
|
|
24
|
-
predicates = handler.getGlobalPredicates(scene).concat([sel.predicate])
|
|
25
|
-
}
|
|
26
|
-
for (let t of targets) {
|
|
27
|
-
let selected = true;
|
|
28
|
-
for (let p of predicates) {
|
|
29
|
-
if (!evaluatePredicate(t, p)) {
|
|
30
|
-
selected = false;
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
for (let c in i.targetDef.effect) {
|
|
35
|
-
if (!(c in t.staticProperties))
|
|
36
|
-
t.staticProperties[c] = t[c];
|
|
37
|
-
if (selected) {
|
|
38
|
-
t[c] = i.targetDef.effect[c].selected;
|
|
39
|
-
} else if ("unselected" in i.targetDef.effect[c]) {
|
|
40
|
-
t[c] = i.targetDef.effect[c].unselected;
|
|
41
|
-
} else if (c in t.staticProperties) {
|
|
42
|
-
t[c] = t.staticProperties[c];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
// console.log(handler.getGlobalPredicates(scene));
|
|
47
|
-
handler._renderer.render(scene, {visualOnly: true});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
getRestoreFunction(scene, handler, clearGlobalPredicates) {
|
|
52
|
-
let i = this;
|
|
53
|
-
return function(){
|
|
54
|
-
let targets = getPeers(i.targetDef.item, scene);
|
|
55
|
-
if (i.targetDef.effect) {
|
|
56
|
-
for (let t of targets) {
|
|
57
|
-
for (let c in i.targetDef.effect)
|
|
58
|
-
t[c] = t.staticProperties[c];
|
|
59
|
-
//delete t.staticProperties[c];
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
for (let t of targets) {
|
|
63
|
-
for (let c in t.staticProperties)
|
|
64
|
-
t[c] = t.staticProperties[c];
|
|
65
|
-
//t.staticProperties = {};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (clearGlobalPredicates)
|
|
70
|
-
handler._globalPredicates = {};
|
|
71
|
-
|
|
72
|
-
handler._renderer.render(scene, {visualOnly: true});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
get listener() {
|
|
77
|
-
return this._listener;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
get selectionDef() {
|
|
81
|
-
return this._selDef;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
get targetDef() {
|
|
85
|
-
return this._targetDef;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
get eventType() {
|
|
89
|
-
return this._eventType;
|
|
90
|
-
}
|
|
91
|
-
}
|