@wcardinal/wcardinal-ui 0.376.2 → 0.377.0
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/dist/types/wcardinal/ui/shape/index.d.ts +0 -2
- package/dist/wcardinal/ui/shape/e-shape-connector-edge-impl.js +5 -4
- package/dist/wcardinal/ui/shape/e-shape-connector-edge-impl.js.map +1 -1
- package/dist/wcardinal/ui/shape/index.js +0 -2
- package/dist/wcardinal/ui/shape/index.js.map +1 -1
- package/dist/wcardinal-ui-theme-dark.js +1 -1
- package/dist/wcardinal-ui-theme-dark.min.js +1 -1
- package/dist/wcardinal-ui-theme-white.js +1 -1
- package/dist/wcardinal-ui-theme-white.min.js +1 -1
- package/dist/wcardinal-ui.cjs.js +5 -330
- package/dist/wcardinal-ui.js +5 -330
- package/dist/wcardinal-ui.min.js +2 -2
- package/dist/wcardinal-ui.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/types/wcardinal/ui/shape/e-shape-deleter.d.ts +0 -7
- package/dist/types/wcardinal/ui/shape/e-shape-search.d.ts +0 -71
- package/dist/wcardinal/ui/shape/e-shape-deleter.js +0 -124
- package/dist/wcardinal/ui/shape/e-shape-deleter.js.map +0 -1
- package/dist/wcardinal/ui/shape/e-shape-search.js +0 -203
- package/dist/wcardinal/ui/shape/e-shape-search.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { EShape } from "./e-shape";
|
|
2
|
-
import { EShapeContainer } from "./e-shape-container";
|
|
3
|
-
export declare class EShapeDeleter {
|
|
4
|
-
private static EXCEPTIONS?;
|
|
5
|
-
private static addAll;
|
|
6
|
-
static delete(parent: EShape | EShapeContainer, shapes?: EShape[], generateListOfDetachedShapes?: boolean): EShape[] | null;
|
|
7
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { EShape } from "./e-shape";
|
|
2
|
-
import { EShapeContainer } from "./e-shape-container";
|
|
3
|
-
import { EShapeType } from "./e-shape-type";
|
|
4
|
-
/**
|
|
5
|
-
* {@link EShape} search utility.
|
|
6
|
-
*/
|
|
7
|
-
export declare class EShapeSearch {
|
|
8
|
-
static COMPARATOR_INDEX: (a: EShape, b: EShape) => number;
|
|
9
|
-
/**
|
|
10
|
-
* Returns indices of the given shapes.
|
|
11
|
-
*
|
|
12
|
-
* @param shapes shapes
|
|
13
|
-
* @return indices
|
|
14
|
-
*/
|
|
15
|
-
static toIndices(shapes: EShape[]): number[];
|
|
16
|
-
/**
|
|
17
|
-
* Returns a depth of the given shape.
|
|
18
|
-
*
|
|
19
|
-
* @param shape a shape
|
|
20
|
-
* @return a depth
|
|
21
|
-
*/
|
|
22
|
-
static toDepth(shape: EShape): number;
|
|
23
|
-
/**
|
|
24
|
-
* Returns a deepest shape on the path to the given shapes.
|
|
25
|
-
*
|
|
26
|
-
* @param shapeA a shape
|
|
27
|
-
* @param shapeB a shape
|
|
28
|
-
* @return a found shape
|
|
29
|
-
*/
|
|
30
|
-
static toSharedParent(shapeA: EShape, shapeB: EShape): EShape | EShapeContainer;
|
|
31
|
-
/**
|
|
32
|
-
* Returns a shape on the path to the given shape whose parent is equals to the given parent.
|
|
33
|
-
* If there is no such shape, returns a root shape on the path.
|
|
34
|
-
*
|
|
35
|
-
* @param shape a shape
|
|
36
|
-
* @param parent a parent
|
|
37
|
-
* @returns a found shape
|
|
38
|
-
*/
|
|
39
|
-
static toOfParent(shape: EShape, parent: EShape | EShapeContainer): EShape;
|
|
40
|
-
/**
|
|
41
|
-
* Returns true if the given target is on the path to the given shape.
|
|
42
|
-
*
|
|
43
|
-
* @param shape a shape
|
|
44
|
-
* @param target a check target
|
|
45
|
-
* @return true if the given target is on the path to the given shape
|
|
46
|
-
*/
|
|
47
|
-
static isParent(shape: EShape, target: EShape | null): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Returns a selected shape on the path to the given shape.
|
|
50
|
-
* If there are more than one selected shapes, returns a deepest selected shape.
|
|
51
|
-
*
|
|
52
|
-
* @param shape a shape
|
|
53
|
-
* @return a found selected shape or null
|
|
54
|
-
*/
|
|
55
|
-
static toSelected(shape: EShape): EShape | null;
|
|
56
|
-
static findChildById(shape: {
|
|
57
|
-
children: EShape[];
|
|
58
|
-
}, id: string, recursively?: boolean): EShape | null;
|
|
59
|
-
static findChildByType(shape: {
|
|
60
|
-
children: EShape[];
|
|
61
|
-
}, type: EShapeType, recursively?: boolean): EShape | null;
|
|
62
|
-
static findChild(shape: {
|
|
63
|
-
children: EShape[];
|
|
64
|
-
}, matcher: (shape: EShape) => boolean, recursively?: boolean): EShape | null;
|
|
65
|
-
static findChildrenByType(shape: {
|
|
66
|
-
children: EShape[];
|
|
67
|
-
}, type: EShapeType, recursively?: boolean, result?: EShape[]): EShape[];
|
|
68
|
-
static findChildren(shape: {
|
|
69
|
-
children: EShape[];
|
|
70
|
-
}, matcher: (shape: EShape) => boolean, recursively?: boolean, result?: EShape[]): EShape[];
|
|
71
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (C) 2019 Toshiba Corporation
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
import { EShapeSearch } from "./e-shape-search";
|
|
6
|
-
var EShapeDeleter = /** @class */ (function () {
|
|
7
|
-
function EShapeDeleter() {
|
|
8
|
-
}
|
|
9
|
-
EShapeDeleter.addAll = function (shapes, result) {
|
|
10
|
-
for (var i = 0, imax = shapes.length; i < imax; ++i) {
|
|
11
|
-
var shape = shapes[i];
|
|
12
|
-
result.add(shape);
|
|
13
|
-
this.addAll(shape.children, result);
|
|
14
|
-
}
|
|
15
|
-
return result;
|
|
16
|
-
};
|
|
17
|
-
EShapeDeleter.delete = function (parent, shapes, generateListOfDetachedShapes) {
|
|
18
|
-
var _a;
|
|
19
|
-
var children = parent.children;
|
|
20
|
-
var length = children.length;
|
|
21
|
-
// Update indices
|
|
22
|
-
var exceptions = ((_a = EShapeDeleter.EXCEPTIONS) !== null && _a !== void 0 ? _a : (EShapeDeleter.EXCEPTIONS = new Set()));
|
|
23
|
-
for (var i = 0; i < length; ++i) {
|
|
24
|
-
var child = children[i];
|
|
25
|
-
if (child.selected) {
|
|
26
|
-
child.index = length + i;
|
|
27
|
-
exceptions.add(child);
|
|
28
|
-
this.addAll(child.children, exceptions);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
child.index = i;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
// Sort
|
|
35
|
-
children.sort(EShapeSearch.COMPARATOR_INDEX);
|
|
36
|
-
// Detach
|
|
37
|
-
if (generateListOfDetachedShapes === true) {
|
|
38
|
-
for (var i = length - 1; 0 <= i; --i) {
|
|
39
|
-
var child = children[i];
|
|
40
|
-
if (child.selected) {
|
|
41
|
-
child.index -= length;
|
|
42
|
-
child.parent = null;
|
|
43
|
-
child.selected = false;
|
|
44
|
-
child.uploaded = undefined;
|
|
45
|
-
child.onDetach(exceptions);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
exceptions.clear();
|
|
49
|
-
var size = children.length - (i + 1);
|
|
50
|
-
if (0 < size) {
|
|
51
|
-
var result = children.splice(i + 1, size);
|
|
52
|
-
if (shapes != null) {
|
|
53
|
-
shapes.length = 0;
|
|
54
|
-
}
|
|
55
|
-
parent.onChildTransformChange();
|
|
56
|
-
parent.toDirty();
|
|
57
|
-
return result;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
if (shapes != null) {
|
|
61
|
-
shapes.length = 0;
|
|
62
|
-
}
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exceptions.clear();
|
|
68
|
-
if (0 < children.length) {
|
|
69
|
-
var result = children.splice(0, children.length);
|
|
70
|
-
if (shapes != null) {
|
|
71
|
-
shapes.length = 0;
|
|
72
|
-
}
|
|
73
|
-
parent.onChildTransformChange();
|
|
74
|
-
parent.toDirty();
|
|
75
|
-
return result;
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
if (shapes != null) {
|
|
79
|
-
shapes.length = 0;
|
|
80
|
-
}
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
for (var i = length - 1; 0 <= i; --i) {
|
|
86
|
-
var child = children[i];
|
|
87
|
-
if (child.selected) {
|
|
88
|
-
child.parent = null;
|
|
89
|
-
child.selected = false;
|
|
90
|
-
child.uploaded = undefined;
|
|
91
|
-
child.onDetach(exceptions);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
exceptions.clear();
|
|
95
|
-
children.length = i + 1;
|
|
96
|
-
if (shapes != null) {
|
|
97
|
-
shapes.length = 0;
|
|
98
|
-
}
|
|
99
|
-
parent.onChildTransformChange();
|
|
100
|
-
parent.toDirty();
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
exceptions.clear();
|
|
105
|
-
if (0 < children.length) {
|
|
106
|
-
children.length = 0;
|
|
107
|
-
if (shapes != null) {
|
|
108
|
-
shapes.length = 0;
|
|
109
|
-
}
|
|
110
|
-
parent.onChildTransformChange();
|
|
111
|
-
parent.toDirty();
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
if (shapes != null) {
|
|
115
|
-
shapes.length = 0;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
return EShapeDeleter;
|
|
122
|
-
}());
|
|
123
|
-
export { EShapeDeleter };
|
|
124
|
-
//# sourceMappingURL=e-shape-deleter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"e-shape-deleter.js","sourceRoot":"","sources":["../../../../src/main/typescript/wcardinal/ui/shape/e-shape-deleter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;A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sB,EAAE,CAAC;gBAChC,MAAM,CAAC,OAAO,EAAE,CAAC;aACjB;iBAAM;gBACN,IAAI,MAAM,IAAI,IAAI,EAAE;oBACnB,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;iBAClB;aACD;YACD,OAAO,IAAI,CAAC;SACZ;IACF,CAAC;IACF,oBAAC;AAAD,CAAC,AAnHD,IAmHC","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { EShape } from \"./e-shape\";\nimport { EShapeContainer } from \"./e-shape-container\";\nimport { EShapeSearch } from \"./e-shape-search\";\n\nexport class EShapeDeleter {\n\tprivate static EXCEPTIONS?: Set<EShape>;\n\n\tprivate static addAll(shapes: EShape[], result: Set<EShape>): Set<EShape> {\n\t\tfor (let i = 0, imax = shapes.length; i < imax; ++i) {\n\t\t\tconst shape = shapes[i];\n\t\t\tresult.add(shape);\n\t\t\tthis.addAll(shape.children, result);\n\t\t}\n\t\treturn result;\n\t}\n\n\tstatic delete(\n\t\tparent: EShape | EShapeContainer,\n\t\tshapes?: EShape[],\n\t\tgenerateListOfDetachedShapes?: boolean\n\t): EShape[] | null {\n\t\tconst children = parent.children;\n\t\tconst length = children.length;\n\n\t\t// Update indices\n\t\tconst exceptions = (EShapeDeleter.EXCEPTIONS ??= new Set<EShape>());\n\t\tfor (let i = 0; i < length; ++i) {\n\t\t\tconst child = children[i];\n\t\t\tif (child.selected) {\n\t\t\t\tchild.index = length + i;\n\t\t\t\texceptions.add(child);\n\t\t\t\tthis.addAll(child.children, exceptions);\n\t\t\t} else {\n\t\t\t\tchild.index = i;\n\t\t\t}\n\t\t}\n\n\t\t// Sort\n\t\tchildren.sort(EShapeSearch.COMPARATOR_INDEX);\n\n\t\t// Detach\n\t\tif (generateListOfDetachedShapes === true) {\n\t\t\tfor (let i = length - 1; 0 <= i; --i) {\n\t\t\t\tconst child = children[i];\n\t\t\t\tif (child.selected) {\n\t\t\t\t\tchild.index -= length;\n\t\t\t\t\tchild.parent = null;\n\t\t\t\t\tchild.selected = false;\n\t\t\t\t\tchild.uploaded = undefined;\n\t\t\t\t\tchild.onDetach(exceptions);\n\t\t\t\t} else {\n\t\t\t\t\texceptions.clear();\n\t\t\t\t\tconst size = children.length - (i + 1);\n\t\t\t\t\tif (0 < size) {\n\t\t\t\t\t\tconst result = children.splice(i + 1, size);\n\t\t\t\t\t\tif (shapes != null) {\n\t\t\t\t\t\t\tshapes.length = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tparent.onChildTransformChange();\n\t\t\t\t\t\tparent.toDirty();\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (shapes != null) {\n\t\t\t\t\t\t\tshapes.length = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\texceptions.clear();\n\t\t\tif (0 < children.length) {\n\t\t\t\tconst result = children.splice(0, children.length);\n\t\t\t\tif (shapes != null) {\n\t\t\t\t\tshapes.length = 0;\n\t\t\t\t}\n\t\t\t\tparent.onChildTransformChange();\n\t\t\t\tparent.toDirty();\n\t\t\t\treturn result;\n\t\t\t} else {\n\t\t\t\tif (shapes != null) {\n\t\t\t\t\tshapes.length = 0;\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t}\n\t\t} else {\n\t\t\tfor (let i = length - 1; 0 <= i; --i) {\n\t\t\t\tconst child = children[i];\n\t\t\t\tif (child.selected) {\n\t\t\t\t\tchild.parent = null;\n\t\t\t\t\tchild.selected = false;\n\t\t\t\t\tchild.uploaded = undefined;\n\t\t\t\t\tchild.onDetach(exceptions);\n\t\t\t\t} else {\n\t\t\t\t\texceptions.clear();\n\t\t\t\t\tchildren.length = i + 1;\n\t\t\t\t\tif (shapes != null) {\n\t\t\t\t\t\tshapes.length = 0;\n\t\t\t\t\t}\n\t\t\t\t\tparent.onChildTransformChange();\n\t\t\t\t\tparent.toDirty();\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t\texceptions.clear();\n\t\t\tif (0 < children.length) {\n\t\t\t\tchildren.length = 0;\n\t\t\t\tif (shapes != null) {\n\t\t\t\t\tshapes.length = 0;\n\t\t\t\t}\n\t\t\t\tparent.onChildTransformChange();\n\t\t\t\tparent.toDirty();\n\t\t\t} else {\n\t\t\t\tif (shapes != null) {\n\t\t\t\t\tshapes.length = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (C) 2019 Toshiba Corporation
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
import { EShapeBase } from "./variant/e-shape-base";
|
|
6
|
-
/**
|
|
7
|
-
* {@link EShape} search utility.
|
|
8
|
-
*/
|
|
9
|
-
var EShapeSearch = /** @class */ (function () {
|
|
10
|
-
function EShapeSearch() {
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Returns indices of the given shapes.
|
|
14
|
-
*
|
|
15
|
-
* @param shapes shapes
|
|
16
|
-
* @return indices
|
|
17
|
-
*/
|
|
18
|
-
EShapeSearch.toIndices = function (shapes) {
|
|
19
|
-
var result = [];
|
|
20
|
-
for (var i = 0, imax = shapes.length; i < imax; ++i) {
|
|
21
|
-
result.push(shapes[i].index);
|
|
22
|
-
}
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Returns a depth of the given shape.
|
|
27
|
-
*
|
|
28
|
-
* @param shape a shape
|
|
29
|
-
* @return a depth
|
|
30
|
-
*/
|
|
31
|
-
EShapeSearch.toDepth = function (shape) {
|
|
32
|
-
var result = 0;
|
|
33
|
-
var parent = shape.parent;
|
|
34
|
-
while (parent instanceof EShapeBase) {
|
|
35
|
-
result += 1;
|
|
36
|
-
parent = parent.parent;
|
|
37
|
-
}
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Returns a deepest shape on the path to the given shapes.
|
|
42
|
-
*
|
|
43
|
-
* @param shapeA a shape
|
|
44
|
-
* @param shapeB a shape
|
|
45
|
-
* @return a found shape
|
|
46
|
-
*/
|
|
47
|
-
EShapeSearch.toSharedParent = function (shapeA, shapeB) {
|
|
48
|
-
var depthA = this.toDepth(shapeA);
|
|
49
|
-
var depthB = this.toDepth(shapeB);
|
|
50
|
-
if (depthA < depthB) {
|
|
51
|
-
var parent_1 = shapeA.parent;
|
|
52
|
-
while (parent_1 instanceof EShapeBase) {
|
|
53
|
-
if (this.isParent(shapeB, parent_1)) {
|
|
54
|
-
return parent_1;
|
|
55
|
-
}
|
|
56
|
-
parent_1 = parent_1.parent;
|
|
57
|
-
}
|
|
58
|
-
return parent_1;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
var parent_2 = shapeB.parent;
|
|
62
|
-
while (parent_2 instanceof EShapeBase) {
|
|
63
|
-
if (this.isParent(shapeA, parent_2)) {
|
|
64
|
-
return parent_2;
|
|
65
|
-
}
|
|
66
|
-
parent_2 = parent_2.parent;
|
|
67
|
-
}
|
|
68
|
-
return parent_2;
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Returns a shape on the path to the given shape whose parent is equals to the given parent.
|
|
73
|
-
* If there is no such shape, returns a root shape on the path.
|
|
74
|
-
*
|
|
75
|
-
* @param shape a shape
|
|
76
|
-
* @param parent a parent
|
|
77
|
-
* @returns a found shape
|
|
78
|
-
*/
|
|
79
|
-
EShapeSearch.toOfParent = function (shape, parent) {
|
|
80
|
-
var shapeParent = shape.parent;
|
|
81
|
-
while (shapeParent !== parent && shapeParent instanceof EShapeBase) {
|
|
82
|
-
shape = shapeParent;
|
|
83
|
-
shapeParent = shapeParent.parent;
|
|
84
|
-
}
|
|
85
|
-
return shape;
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Returns true if the given target is on the path to the given shape.
|
|
89
|
-
*
|
|
90
|
-
* @param shape a shape
|
|
91
|
-
* @param target a check target
|
|
92
|
-
* @return true if the given target is on the path to the given shape
|
|
93
|
-
*/
|
|
94
|
-
EShapeSearch.isParent = function (shape, target) {
|
|
95
|
-
var parent = shape.parent;
|
|
96
|
-
while (parent instanceof EShapeBase) {
|
|
97
|
-
if (parent === target) {
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
parent = parent.parent;
|
|
101
|
-
}
|
|
102
|
-
return false;
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* Returns a selected shape on the path to the given shape.
|
|
106
|
-
* If there are more than one selected shapes, returns a deepest selected shape.
|
|
107
|
-
*
|
|
108
|
-
* @param shape a shape
|
|
109
|
-
* @return a found selected shape or null
|
|
110
|
-
*/
|
|
111
|
-
EShapeSearch.toSelected = function (shape) {
|
|
112
|
-
var target = shape;
|
|
113
|
-
while (target instanceof EShapeBase) {
|
|
114
|
-
if (target.selected) {
|
|
115
|
-
return target;
|
|
116
|
-
}
|
|
117
|
-
target = target.parent;
|
|
118
|
-
}
|
|
119
|
-
return null;
|
|
120
|
-
};
|
|
121
|
-
EShapeSearch.findChildById = function (shape, id, recursively) {
|
|
122
|
-
var children = shape.children;
|
|
123
|
-
for (var i = 0, imax = children.length; i < imax; ++i) {
|
|
124
|
-
var child = children[i];
|
|
125
|
-
if (child.id === id) {
|
|
126
|
-
return child;
|
|
127
|
-
}
|
|
128
|
-
if (recursively === true) {
|
|
129
|
-
var result = EShapeSearch.findChildById(child, id, recursively);
|
|
130
|
-
if (result != null) {
|
|
131
|
-
return result;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return null;
|
|
136
|
-
};
|
|
137
|
-
EShapeSearch.findChildByType = function (shape, type, recursively) {
|
|
138
|
-
var children = shape.children;
|
|
139
|
-
for (var i = 0, imax = children.length; i < imax; ++i) {
|
|
140
|
-
var child = children[i];
|
|
141
|
-
if (child.type === type) {
|
|
142
|
-
return child;
|
|
143
|
-
}
|
|
144
|
-
if (recursively === true) {
|
|
145
|
-
var result = EShapeSearch.findChildByType(child, type, recursively);
|
|
146
|
-
if (result != null) {
|
|
147
|
-
return result;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return null;
|
|
152
|
-
};
|
|
153
|
-
EShapeSearch.findChild = function (shape, matcher, recursively) {
|
|
154
|
-
var children = shape.children;
|
|
155
|
-
for (var i = 0, imax = children.length; i < imax; ++i) {
|
|
156
|
-
var child = children[i];
|
|
157
|
-
if (matcher(child)) {
|
|
158
|
-
return child;
|
|
159
|
-
}
|
|
160
|
-
if (recursively === true) {
|
|
161
|
-
var result = EShapeSearch.findChild(child, matcher, recursively);
|
|
162
|
-
if (result != null) {
|
|
163
|
-
return result;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return null;
|
|
168
|
-
};
|
|
169
|
-
EShapeSearch.findChildrenByType = function (shape, type, recursively, result) {
|
|
170
|
-
result = result || [];
|
|
171
|
-
var children = shape.children;
|
|
172
|
-
for (var i = 0, imax = children.length; i < imax; ++i) {
|
|
173
|
-
var child = children[i];
|
|
174
|
-
if (child.type === type) {
|
|
175
|
-
result.push(child);
|
|
176
|
-
}
|
|
177
|
-
if (recursively === true) {
|
|
178
|
-
EShapeSearch.findChildrenByType(child, type, recursively, result);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return result;
|
|
182
|
-
};
|
|
183
|
-
EShapeSearch.findChildren = function (shape, matcher, recursively, result) {
|
|
184
|
-
result = result || [];
|
|
185
|
-
var children = shape.children;
|
|
186
|
-
for (var i = 0, imax = children.length; i < imax; ++i) {
|
|
187
|
-
var child = children[i];
|
|
188
|
-
if (matcher(child)) {
|
|
189
|
-
result.push(child);
|
|
190
|
-
}
|
|
191
|
-
if (recursively === true) {
|
|
192
|
-
EShapeSearch.findChildren(child, matcher, recursively, result);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return result;
|
|
196
|
-
};
|
|
197
|
-
EShapeSearch.COMPARATOR_INDEX = function (a, b) {
|
|
198
|
-
return a.index - b.index;
|
|
199
|
-
};
|
|
200
|
-
return EShapeSearch;
|
|
201
|
-
}());
|
|
202
|
-
export { EShapeSearch };
|
|
203
|
-
//# sourceMappingURL=e-shape-search.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"e-shape-search.js","sourceRoot":"","sources":["../../../../src/main/typescript/wcardinal/ui/shape/e-shape-search.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD;;GAEG;AACH;IAAA;IA6NA,CAAC;IAxNA;;;;;OAKG;IACI,sBAAS,GAAhB,UAAiB,MAAgB;QAChC,IAAM,MAAM,GAAG,EAAE,CAAC;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,EAAE;YACpD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;SAC7B;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACI,oBAAO,GAAd,UAAe,KAAa;QAC3B,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,IAAI,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC1B,OAAO,MAAM,YAAY,UAAU,EAAE;YACpC,MAAM,IAAI,CAAC,CAAC;YACZ,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;SACvB;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;;;;OAMG;IACI,2BAAc,GAArB,UAAsB,MAAc,EAAE,MAAc;QACnD,IAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACpC,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AAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACnB;YACD,IAAI,WAAW,KAAK,IAAI,EAAE;gBACzB,YAAY,CAAC,kBAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;aAClE;SACD;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAEM,yBAAY,GAAnB,UACC,KAA6B,EAC7B,OAAmC,EACnC,WAAqB,EACrB,MAAiB;QAEjB,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC;QACtB,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,EAAE;YACtD,IAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC1B,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;gBACnB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACnB;YACD,IAAI,WAAW,KAAK,IAAI,EAAE;gBACzB,YAAY,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;aAC/D;SACD;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IA3NM,6BAAgB,GAAG,UAAC,CAAS,EAAE,CAAS;QAC9C,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;IAC1B,CAAC,CAAC;IA0NH,mBAAC;CAAA,AA7ND,IA6NC;SA7NY,YAAY","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { EShape } from \"./e-shape\";\nimport { EShapeContainer } from \"./e-shape-container\";\nimport { EShapeType } from \"./e-shape-type\";\nimport { EShapeBase } from \"./variant/e-shape-base\";\n\n/**\n * {@link EShape} search utility.\n */\nexport class EShapeSearch {\n\tstatic COMPARATOR_INDEX = (a: EShape, b: EShape): number => {\n\t\treturn a.index - b.index;\n\t};\n\n\t/**\n\t * Returns indices of the given shapes.\n\t *\n\t * @param shapes shapes\n\t * @return indices\n\t */\n\tstatic toIndices(shapes: EShape[]): number[] {\n\t\tconst result = [];\n\t\tfor (let i = 0, imax = shapes.length; i < imax; ++i) {\n\t\t\tresult.push(shapes[i].index);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Returns a depth of the given shape.\n\t *\n\t * @param shape a shape\n\t * @return a depth\n\t */\n\tstatic toDepth(shape: EShape): number {\n\t\tlet result = 0;\n\t\tlet parent = shape.parent;\n\t\twhile (parent instanceof EShapeBase) {\n\t\t\tresult += 1;\n\t\t\tparent = parent.parent;\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Returns a deepest shape on the path to the given shapes.\n\t *\n\t * @param shapeA a shape\n\t * @param shapeB a shape\n\t * @return a found shape\n\t */\n\tstatic toSharedParent(shapeA: EShape, shapeB: EShape): EShape | EShapeContainer {\n\t\tconst depthA = this.toDepth(shapeA);\n\t\tconst depthB = this.toDepth(shapeB);\n\t\tif (depthA < depthB) {\n\t\t\tlet parent = shapeA.parent;\n\t\t\twhile (parent instanceof EShapeBase) {\n\t\t\t\tif (this.isParent(shapeB, parent)) {\n\t\t\t\t\treturn parent;\n\t\t\t\t}\n\t\t\t\tparent = parent.parent;\n\t\t\t}\n\t\t\treturn parent!;\n\t\t} else {\n\t\t\tlet parent = shapeB.parent;\n\t\t\twhile (parent instanceof EShapeBase) {\n\t\t\t\tif (this.isParent(shapeA, parent)) {\n\t\t\t\t\treturn parent;\n\t\t\t\t}\n\t\t\t\tparent = parent.parent;\n\t\t\t}\n\t\t\treturn parent!;\n\t\t}\n\t}\n\n\t/**\n\t * Returns a shape on the path to the given shape whose parent is equals to the given parent.\n\t * If there is no such shape, returns a root shape on the path.\n\t *\n\t * @param shape a shape\n\t * @param parent a parent\n\t * @returns a found shape\n\t */\n\tstatic toOfParent(shape: EShape, parent: EShape | EShapeContainer): EShape {\n\t\tlet shapeParent = shape.parent;\n\t\twhile (shapeParent !== parent && shapeParent instanceof EShapeBase) {\n\t\t\tshape = shapeParent;\n\t\t\tshapeParent = shapeParent.parent;\n\t\t}\n\t\treturn shape;\n\t}\n\n\t/**\n\t * Returns true if the given target is on the path to the given shape.\n\t *\n\t * @param shape a shape\n\t * @param target a check target\n\t * @return true if the given target is on the path to the given shape\n\t */\n\tstatic isParent(shape: EShape, target: EShape | null): boolean {\n\t\tlet parent = shape.parent;\n\t\twhile (parent instanceof EShapeBase) {\n\t\t\tif (parent === target) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tparent = parent.parent;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Returns a selected shape on the path to the given shape.\n\t * If there are more than one selected shapes, returns a deepest selected shape.\n\t *\n\t * @param shape a shape\n\t * @return a found selected shape or null\n\t */\n\tstatic toSelected(shape: EShape): EShape | null {\n\t\tlet target: EShape | EShapeContainer | null = shape;\n\t\twhile (target instanceof EShapeBase) {\n\t\t\tif (target.selected) {\n\t\t\t\treturn target;\n\t\t\t}\n\t\t\ttarget = target.parent;\n\t\t}\n\t\treturn null;\n\t}\n\n\tstatic findChildById(\n\t\tshape: { children: EShape[] },\n\t\tid: string,\n\t\trecursively?: boolean\n\t): EShape | null {\n\t\tconst children = shape.children;\n\t\tfor (let i = 0, imax = children.length; i < imax; ++i) {\n\t\t\tconst child = children[i];\n\t\t\tif (child.id === id) {\n\t\t\t\treturn child;\n\t\t\t}\n\t\t\tif (recursively === true) {\n\t\t\t\tconst result = EShapeSearch.findChildById(child, id, recursively);\n\t\t\t\tif (result != null) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\tstatic findChildByType(\n\t\tshape: { children: EShape[] },\n\t\ttype: EShapeType,\n\t\trecursively?: boolean\n\t): EShape | null {\n\t\tconst children = shape.children;\n\t\tfor (let i = 0, imax = children.length; i < imax; ++i) {\n\t\t\tconst child = children[i];\n\t\t\tif (child.type === type) {\n\t\t\t\treturn child;\n\t\t\t}\n\t\t\tif (recursively === true) {\n\t\t\t\tconst result = EShapeSearch.findChildByType(child, type, recursively);\n\t\t\t\tif (result != null) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\tstatic findChild(\n\t\tshape: { children: EShape[] },\n\t\tmatcher: (shape: EShape) => boolean,\n\t\trecursively?: boolean\n\t): EShape | null {\n\t\tconst children = shape.children;\n\t\tfor (let i = 0, imax = children.length; i < imax; ++i) {\n\t\t\tconst child = children[i];\n\t\t\tif (matcher(child)) {\n\t\t\t\treturn child;\n\t\t\t}\n\t\t\tif (recursively === true) {\n\t\t\t\tconst result = EShapeSearch.findChild(child, matcher, recursively);\n\t\t\t\tif (result != null) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\tstatic findChildrenByType(\n\t\tshape: { children: EShape[] },\n\t\ttype: EShapeType,\n\t\trecursively?: boolean,\n\t\tresult?: EShape[]\n\t): EShape[] {\n\t\tresult = result || [];\n\t\tconst children = shape.children;\n\t\tfor (let i = 0, imax = children.length; i < imax; ++i) {\n\t\t\tconst child = children[i];\n\t\t\tif (child.type === type) {\n\t\t\t\tresult.push(child);\n\t\t\t}\n\t\t\tif (recursively === true) {\n\t\t\t\tEShapeSearch.findChildrenByType(child, type, recursively, result);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\tstatic findChildren(\n\t\tshape: { children: EShape[] },\n\t\tmatcher: (shape: EShape) => boolean,\n\t\trecursively?: boolean,\n\t\tresult?: EShape[]\n\t): EShape[] {\n\t\tresult = result || [];\n\t\tconst children = shape.children;\n\t\tfor (let i = 0, imax = children.length; i < imax; ++i) {\n\t\t\tconst child = children[i];\n\t\t\tif (matcher(child)) {\n\t\t\t\tresult.push(child);\n\t\t\t}\n\t\t\tif (recursively === true) {\n\t\t\t\tEShapeSearch.findChildren(child, matcher, recursively, result);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n}\n"]}
|