Merge pull request 'fix:提交测试' (#1) from dengchuting into main
Reviewed-on: https://dsvision.net/git/Anyview/StructV2/pulls/1
This commit is contained in:
commit
ba6f50bf55
269
demo/Layouter/IndentedTree.js
Normal file
269
demo/Layouter/IndentedTree.js
Normal file
@ -0,0 +1,269 @@
|
||||
|
||||
//
|
||||
|
||||
SV.registerLayout('Indented', {
|
||||
|
||||
defineOptions() {
|
||||
return {
|
||||
node: {
|
||||
default: {
|
||||
type: 'indented-tree-node',//自定义节点
|
||||
label: '[data]',
|
||||
size: [60, 30],
|
||||
labelOptions: {
|
||||
style: {
|
||||
fontsize: 18,
|
||||
color: '#333'
|
||||
},
|
||||
style: {
|
||||
stroke: '#333',
|
||||
fill: '#95e1d3',
|
||||
cursor: 'pointer',
|
||||
},
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
|
||||
},
|
||||
|
||||
|
||||
link: {
|
||||
|
||||
child: {
|
||||
type: 'polyline',//折线
|
||||
sourceAnchor: 0,
|
||||
targetAnchor: 1,
|
||||
style: {
|
||||
cursor: 'pointer',
|
||||
lineAppendWidth: 4,
|
||||
stroke: '#333',
|
||||
endArrow: {
|
||||
path: G6.Arrow.triangle(8, 6, 0),
|
||||
fill: '#333'
|
||||
},
|
||||
startArrow: {
|
||||
path: G6.Arrow.circle(2, -1),
|
||||
fill: '#333'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
layout: {
|
||||
xInterval: 40,
|
||||
yInterval: 10,
|
||||
},
|
||||
|
||||
};
|
||||
},
|
||||
/**
|
||||
* 对子树进行递归布局
|
||||
*/
|
||||
//判断是否是B节点
|
||||
|
||||
layoutItem(node,elements,layoutOptions)
|
||||
{
|
||||
if (!node) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
let width = 60,
|
||||
height = 40;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//还是要分第一个节点
|
||||
if (node.child) {//如果是父节点//node==B
|
||||
let childLength = node.child.length;
|
||||
console.log(childLength);
|
||||
for (let i = 0; i < childLength; i++) {
|
||||
parent = node;
|
||||
|
||||
|
||||
// console.log(node.child[i].get('parent'));
|
||||
|
||||
node.child[i].set('x', parent.get('x') + width + layoutOptions.xInterval);
|
||||
console.log(layoutOptions.xInterval);
|
||||
if (this.isFirstChild(elements, node.child[i]))//如果是B节点{
|
||||
|
||||
{
|
||||
|
||||
node.child[i].set('y', 0 + height +layoutOptions.yInterval);
|
||||
let tempY = node.child[i].get('y')
|
||||
console.log(tempY);
|
||||
}
|
||||
else {
|
||||
node.child[i].set('y', tempY + height + layoutOptions.yInterval)
|
||||
}
|
||||
|
||||
tempY = node.child[i].get('y')
|
||||
console.log(tempY);//80
|
||||
|
||||
|
||||
|
||||
|
||||
if (node.child[i].child) {
|
||||
|
||||
|
||||
this.LayoutChild(node.child[i],layoutOptions);//node.child[i]==c
|
||||
|
||||
}
|
||||
if (!(node.child[i].child)) {
|
||||
|
||||
// tempY= node.child[i].get('y')
|
||||
|
||||
// console.log(node.get('tempY'));
|
||||
tempY = node.child[i].get('y')
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
isFirstChild(elements,node)
|
||||
{
|
||||
|
||||
console.log(elements);
|
||||
let root = elements[0];
|
||||
|
||||
for (g = 0; g < root.child.length; g++)
|
||||
{
|
||||
if (root.child[0].id === node.id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
LayoutChild(node,layoutOptions) //node.child[0]=B
|
||||
|
||||
{
|
||||
|
||||
let parent = node;//b
|
||||
|
||||
|
||||
//70
|
||||
|
||||
//当前节点的y坐标
|
||||
//140 C=140
|
||||
let xInterval = layoutOptions.xInterval,
|
||||
yInterval = layoutOptions.yInterval;
|
||||
for (let k = 0; k < node.child.length; k++) {
|
||||
|
||||
if (!(node.child[k].child))
|
||||
{
|
||||
|
||||
node.child[k].set('x', parent.get('x') + 60 + xInterval)
|
||||
console.log( node);
|
||||
node.child[k].set('y', tempY + 40 +yInterval)//D/F的坐标
|
||||
tempY = node.child[k].get('y')
|
||||
console.log(tempY);
|
||||
|
||||
|
||||
|
||||
|
||||
}//node.child[k=g]
|
||||
if (node.child[k].child) {
|
||||
node.child[k].set('x', parent.get('x') + 60 +xInterval)
|
||||
node.child[k].set('y', tempY + 40 +yInterval )//c
|
||||
tempY = node.child[k].get('y');
|
||||
console.log(node.child[k]);
|
||||
this.LayoutChild(node.child[k], layoutOptions)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
//返回第一层子节点
|
||||
// isFirstChild(elements,node) {
|
||||
// let Root = elements[0];
|
||||
// console.log(Root);
|
||||
// console.log(node.id);
|
||||
// console.log(node);
|
||||
// for (g = 0; g < Root.child.length; g++)
|
||||
// {
|
||||
|
||||
// if (Root.child[g].id === node.id) {
|
||||
// return node;
|
||||
// }
|
||||
|
||||
// }
|
||||
// },
|
||||
|
||||
layout(elements, layoutOptions) {
|
||||
|
||||
let root = elements[0];
|
||||
|
||||
root.set({
|
||||
x: 0,
|
||||
y: 0
|
||||
});
|
||||
|
||||
console.log(root.get('x'));
|
||||
console.log(root.get('y'));
|
||||
|
||||
this.layoutItem(root,elements,layoutOptions);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
505
demo/data.js
505
demo/data.js
@ -1,469 +1,68 @@
|
||||
const SOURCES_DATA = [{
|
||||
"GeneralizedList0": {
|
||||
"data": [{
|
||||
"type": "atom",
|
||||
"id": "0x1486ec0",
|
||||
"tag": 0,
|
||||
"data": "e",
|
||||
"root": true,
|
||||
"external": ["p"]
|
||||
}, {
|
||||
"type": "atom",
|
||||
"id": "0x1486ee0",
|
||||
"tag": 0,
|
||||
"data": "0",
|
||||
"root": true,
|
||||
"external": ["head"]
|
||||
}],
|
||||
"layouter": "GeneralizedList"
|
||||
},
|
||||
},
|
||||
const SOURCES_DATA = [
|
||||
{
|
||||
"GeneralizedList": {
|
||||
IndentedTree: {
|
||||
"data": [{
|
||||
"type": "atom",
|
||||
"id": "0x1486ec0",
|
||||
"tag": 0,
|
||||
"data": "e",
|
||||
"root": true,
|
||||
"external": ["p"]
|
||||
}, {
|
||||
"type": "table",
|
||||
"id": "0x1486ee0",
|
||||
"tag": 1,
|
||||
"next": null,
|
||||
"loopNext": null,
|
||||
"root": true,
|
||||
"external": ["head"]
|
||||
}],
|
||||
"layouter": "GeneralizedList"
|
||||
}
|
||||
},
|
||||
{
|
||||
"TriTree0": {
|
||||
"data": [{
|
||||
"external": [
|
||||
"T"
|
||||
],
|
||||
"parent": [
|
||||
"0x0"
|
||||
],
|
||||
"child": [
|
||||
"0xfd9ee0",
|
||||
"0xfd9f10"
|
||||
],
|
||||
"id": "0xfd9eb0",
|
||||
"name": "T",
|
||||
"data": "A",
|
||||
"root": true,
|
||||
"type": "default"
|
||||
},
|
||||
{
|
||||
"child": [
|
||||
"0x0",
|
||||
"0x0"
|
||||
],
|
||||
"id": "0xfd9ee0",
|
||||
"name": "T->lchild",
|
||||
"data": "B",
|
||||
"type": "default",
|
||||
"l_parent": [
|
||||
"0xfd9eb0"
|
||||
],
|
||||
"external": [
|
||||
"T1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"child": [
|
||||
"0x0",
|
||||
"0x0"
|
||||
],
|
||||
"id": "0xfd9f10",
|
||||
"name": "T->rchild",
|
||||
"data": "C",
|
||||
"type": "default",
|
||||
"r_parent": [
|
||||
"0xfd9eb0"
|
||||
],
|
||||
"external": [
|
||||
"T2"
|
||||
]
|
||||
}
|
||||
],
|
||||
"layouter": "TriTree"
|
||||
},
|
||||
"TriTree3": {
|
||||
"data": [{
|
||||
"external": [
|
||||
"T3"
|
||||
],
|
||||
"parent": [
|
||||
"0x0"
|
||||
],
|
||||
"child": [
|
||||
"0x0",
|
||||
"0x0"
|
||||
"0x2",
|
||||
"0x3",
|
||||
"0x5",
|
||||
],
|
||||
"id": "0xfd9f40",
|
||||
"name": "T3",
|
||||
"id": "0x1",
|
||||
"root": true,
|
||||
"data": "A",
|
||||
"type": "default",
|
||||
},
|
||||
{ "child":["0x9"],
|
||||
"id": "0x2",
|
||||
"data": "B",
|
||||
"type": "default",
|
||||
},
|
||||
{
|
||||
"child": [
|
||||
"0x4",
|
||||
"0x7"
|
||||
],
|
||||
"id": "0x3",
|
||||
"data": "C",
|
||||
"type": "default",
|
||||
},
|
||||
{
|
||||
"child": [
|
||||
"0x6",
|
||||
],
|
||||
"id": "0x4",
|
||||
"data": "D",
|
||||
"root": true,
|
||||
"type": "default"
|
||||
}],
|
||||
"layouter": "TriTree"
|
||||
},
|
||||
"TriTree4": {
|
||||
"data": [{
|
||||
"external": [
|
||||
"T4"
|
||||
],
|
||||
"parent": [
|
||||
"0x0"
|
||||
],
|
||||
"child": [
|
||||
"0x0",
|
||||
"0x0"
|
||||
],
|
||||
"id": "0xfd9f70",
|
||||
"name": "T4",
|
||||
"type": "default",
|
||||
},
|
||||
{
|
||||
"id": "0x5",
|
||||
"data": "E",
|
||||
"root": true,
|
||||
"type": "default"
|
||||
}],
|
||||
"layouter": "TriTree"
|
||||
},
|
||||
"handleUpdate": {
|
||||
"isEnterFunction": true,
|
||||
"isFirstDebug": true
|
||||
}
|
||||
}, {
|
||||
"TriTree0": {
|
||||
"data": [{
|
||||
"external": [
|
||||
"T"
|
||||
],
|
||||
"parent": [
|
||||
"0x0"
|
||||
],
|
||||
"child": [
|
||||
"0xfd9ee0",
|
||||
"0xfd9f10"
|
||||
],
|
||||
"id": "0xfd9eb0",
|
||||
"name": "T",
|
||||
"data": "A",
|
||||
"root": true,
|
||||
"type": "default"
|
||||
"type": "default",
|
||||
},
|
||||
{"child":["0x8"],
|
||||
"id": "0x6",
|
||||
"data": "F",
|
||||
"type": "default",
|
||||
},
|
||||
{
|
||||
"child": [
|
||||
"0x0",
|
||||
"0x0"
|
||||
],
|
||||
"id": "0xfd9ee0",
|
||||
"name": "T->lchild",
|
||||
"data": "B",
|
||||
"id": "0x7",
|
||||
"data": "G",
|
||||
"type": "default",
|
||||
"l_parent": [
|
||||
"0xfd9eb0"
|
||||
],
|
||||
"external": [
|
||||
"T1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"child": [
|
||||
"0x0",
|
||||
"0x0"
|
||||
],
|
||||
"id": "0xfd9f10",
|
||||
"name": "T->rchild",
|
||||
"data": "C",
|
||||
"id": "0x8",
|
||||
"data": "I",
|
||||
"type": "default",
|
||||
"r_parent": [
|
||||
"0xfd9eb0"
|
||||
],
|
||||
"external": [
|
||||
"T2"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "0x9",
|
||||
"data": "J",
|
||||
"type": "default",
|
||||
},
|
||||
|
||||
],
|
||||
"layouter": "TriTree"
|
||||
},
|
||||
"TriTree3": {
|
||||
"data": [{
|
||||
"external": [
|
||||
"T3"
|
||||
],
|
||||
"parent": [
|
||||
"0x0"
|
||||
],
|
||||
"child": [
|
||||
"0x0",
|
||||
"0x0"
|
||||
],
|
||||
"id": "0xfd9f40",
|
||||
"name": "T3",
|
||||
"data": "D",
|
||||
"root": true,
|
||||
"type": "default"
|
||||
}],
|
||||
"layouter": "TriTree"
|
||||
},
|
||||
"TriTree4": {
|
||||
"data": [{
|
||||
"external": [
|
||||
"T4"
|
||||
],
|
||||
"parent": [
|
||||
"0xfd9f40"
|
||||
],
|
||||
"child": [
|
||||
"0x0",
|
||||
"0x0"
|
||||
],
|
||||
"id": "0xfd9f70",
|
||||
"name": "T4",
|
||||
"data": "E",
|
||||
"root": true,
|
||||
"type": "default"
|
||||
}],
|
||||
"layouter": "TriTree"
|
||||
},
|
||||
"handleUpdate": {
|
||||
"isEnterFunction": false,
|
||||
"isFirstDebug": false
|
||||
}
|
||||
}, {
|
||||
"TriTree0": {
|
||||
"data": [{
|
||||
"external": [
|
||||
"T"
|
||||
],
|
||||
"parent": [
|
||||
"0x0"
|
||||
],
|
||||
"child": [
|
||||
"0xfd9ee0",
|
||||
"0xfd9f10"
|
||||
],
|
||||
"id": "0xfd9eb0",
|
||||
"name": "T",
|
||||
"data": "A",
|
||||
"root": true,
|
||||
"type": "default"
|
||||
},
|
||||
{
|
||||
"child": [
|
||||
"0x0",
|
||||
"0x0"
|
||||
],
|
||||
"id": "0xfd9ee0",
|
||||
"name": "T->lchild",
|
||||
"data": "B",
|
||||
"type": "default",
|
||||
"l_parent": [
|
||||
"0xfd9eb0"
|
||||
],
|
||||
"external": [
|
||||
"T1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"child": [
|
||||
"0x0",
|
||||
"0x0"
|
||||
],
|
||||
"id": "0xfd9f10",
|
||||
"name": "T->rchild",
|
||||
"data": "C",
|
||||
"type": "default",
|
||||
"r_parent": [
|
||||
"0xfd9eb0"
|
||||
],
|
||||
"external": [
|
||||
"T2"
|
||||
]
|
||||
}
|
||||
],
|
||||
"layouter": "TriTree"
|
||||
},
|
||||
"TriTree3": {
|
||||
"data": [{
|
||||
"external": [
|
||||
"T3"
|
||||
],
|
||||
"parent": [
|
||||
"0x0"
|
||||
],
|
||||
"child": [
|
||||
"0xfd9f70",
|
||||
"0x0"
|
||||
],
|
||||
"id": "0xfd9f40",
|
||||
"name": "T3",
|
||||
"data": "D",
|
||||
"root": true,
|
||||
"type": "default"
|
||||
},
|
||||
{
|
||||
"child": [
|
||||
"0x0",
|
||||
"0x0"
|
||||
],
|
||||
"id": "0xfd9f70",
|
||||
"name": "T3->lchild",
|
||||
"data": "E",
|
||||
"type": "default",
|
||||
"l_parent": [
|
||||
"0xfd9f40"
|
||||
],
|
||||
"external": [
|
||||
"T4"
|
||||
]
|
||||
}
|
||||
],
|
||||
"layouter": "TriTree"
|
||||
},
|
||||
"handleUpdate": {
|
||||
"isEnterFunction": false,
|
||||
"isFirstDebug": false
|
||||
}
|
||||
}, {
|
||||
"force0": {
|
||||
"data": [{
|
||||
"id": "0x617eb1",
|
||||
"data": "A",
|
||||
"next": "0x617eb2"
|
||||
},
|
||||
{
|
||||
"id": "0x617eb2",
|
||||
"data": "B",
|
||||
"next": "0x617eb3"
|
||||
},
|
||||
{
|
||||
"id": "0x617eb3",
|
||||
"data": "C",
|
||||
"next": "0x617eb5"
|
||||
},
|
||||
{
|
||||
"id": "0x617eb5",
|
||||
"data": "D",
|
||||
"next": "0x617eb3"
|
||||
},
|
||||
{
|
||||
"id": "0x617eb6",
|
||||
"data": "D",
|
||||
"next": "0x617eb5"
|
||||
},
|
||||
{
|
||||
"id": "0x617eb7",
|
||||
"data": "D",
|
||||
"next": "0x617eb6"
|
||||
},
|
||||
{
|
||||
"id": "0x617eb8",
|
||||
"data": "D",
|
||||
"next": "0x617eb7"
|
||||
},
|
||||
{
|
||||
"id": "0x617eb9",
|
||||
"data": "D",
|
||||
"next": "0x617eb8"
|
||||
},
|
||||
{
|
||||
"id": "0x617eba",
|
||||
"data": "D",
|
||||
"next": "0x617eb9"
|
||||
},
|
||||
{
|
||||
"id": "0x617ebb",
|
||||
"data": "D",
|
||||
"next": "0x617eba"
|
||||
},
|
||||
{
|
||||
"id": "0x617ebc",
|
||||
"data": "D",
|
||||
"next": "0x617ebb"
|
||||
},
|
||||
{
|
||||
"id": "0x617ebd",
|
||||
"data": "D",
|
||||
"next": "0x617ebc"
|
||||
},
|
||||
{
|
||||
"id": "0x617ebe",
|
||||
"data": "D",
|
||||
"next": "0x617ebd"
|
||||
},
|
||||
{
|
||||
"id": "0x627ebe",
|
||||
"data": "D",
|
||||
"next": "0x617ebe"
|
||||
},
|
||||
{
|
||||
"id": "0x637ebe",
|
||||
"data": "D",
|
||||
"next": "0x627ebe"
|
||||
},
|
||||
{
|
||||
"id": "0x647ebe",
|
||||
"data": "D",
|
||||
"next": "0x637ebe"
|
||||
},
|
||||
{
|
||||
"id": "0x657ebe",
|
||||
"data": "D",
|
||||
"next": "0x647ebe"
|
||||
},
|
||||
{
|
||||
"id": "0x667ebe",
|
||||
"data": "D",
|
||||
"next": "0x657ebe"
|
||||
},
|
||||
{
|
||||
"id": "0x677ebe",
|
||||
"data": "D",
|
||||
"next": "0x667ebe"
|
||||
},
|
||||
{
|
||||
"id": "0x687ebe",
|
||||
"data": "D",
|
||||
"next": "0x677ebe"
|
||||
},
|
||||
{
|
||||
"id": "0x697ebe",
|
||||
"data": "D",
|
||||
"next": "0x687ebe"
|
||||
},
|
||||
{
|
||||
"id": "0x6a7ebe",
|
||||
"data": "D",
|
||||
"next": "0x697ebe"
|
||||
},
|
||||
{
|
||||
"id": "0x6b7ebe",
|
||||
"data": "D",
|
||||
"next": "0x6a7ebe"
|
||||
},
|
||||
{
|
||||
"id": "0x6c7ebe",
|
||||
"data": "D",
|
||||
"next": "0x6b7ebe"
|
||||
},
|
||||
{
|
||||
"id": "0x6d7ebe",
|
||||
"data": "X",
|
||||
"next": "0x6c7ebe"
|
||||
},
|
||||
{
|
||||
"id": "0x6e7ebe",
|
||||
"data": "Y",
|
||||
"next": "0x6d7ebe"
|
||||
},
|
||||
],
|
||||
"layouter": "Force"
|
||||
"layouter": "Indented"
|
||||
}
|
||||
}
|
||||
|
||||
];
|
||||
@ -87,6 +87,7 @@
|
||||
<script src="./Layouter/PTree.js"></script>
|
||||
<script src="./Layouter/PCTree.js"></script>
|
||||
<script src="./Layouter/Force.js"></script>
|
||||
<script src="./Layouter/IndentedTree.js"></script>
|
||||
<script src="./data.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
15
src/RegisteredShape/intendedTreeNode.ts
Normal file
15
src/RegisteredShape/intendedTreeNode.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { Util } from '../Common/util';
|
||||
|
||||
export default Util.registerShape(
|
||||
'indented-tree-node', {
|
||||
getAnchorPoints() {
|
||||
return [
|
||||
[0.5, 1],
|
||||
[0, 0.5],
|
||||
];
|
||||
},
|
||||
|
||||
},
|
||||
'rect'
|
||||
|
||||
);
|
||||
@ -15,6 +15,7 @@ import LinkListNode from "./RegisteredShape/linkListNode";
|
||||
import BinaryTreeNode from "./RegisteredShape/binaryTreeNode";
|
||||
import ForceNode from "./RegisteredShape/force";
|
||||
import TriTreeNode from "./RegisteredShape/triTreeNode";
|
||||
import IntendedTreeNode from "./RegisteredShape/intendedTreeNode";
|
||||
import CLenQueuePointer from "./RegisteredShape/clenQueuePointer";
|
||||
import TwoCellNode from "./RegisteredShape/twoCellNode";
|
||||
import ThreeCellNode from "./RegisteredShape/threeCellNode";
|
||||
@ -73,7 +74,8 @@ SV.registeredShape = [
|
||||
Cursor,
|
||||
ArrayNode,
|
||||
CLenQueuePointer,
|
||||
ForceNode
|
||||
ForceNode,
|
||||
IntendedTreeNode
|
||||
];
|
||||
|
||||
SV.registerShape = Util.registerShape;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user