Merge branch 'hotfix/cjc' into 'main'
修改外部指针id,增加自定义的三叉树 See merge request phenomLi/StructV2!15
This commit is contained in:
commit
1c36865547
@ -1,96 +1,100 @@
|
|||||||
/**
|
/**
|
||||||
* 三叉树
|
* 三叉树
|
||||||
*/
|
*/
|
||||||
SV.registerLayout('TriTree', {
|
SV.registerLayout('TriTree', {
|
||||||
defineOptions() {
|
defineOptions() {
|
||||||
return {
|
return {
|
||||||
/**
|
node: {
|
||||||
* 结点
|
|
||||||
*/
|
|
||||||
element: {
|
|
||||||
default: {
|
default: {
|
||||||
type: 'tri-tree-node',
|
type: 'tri-tree-node',
|
||||||
size: [60, 30],
|
size: [60, 30],
|
||||||
label: '[data]',
|
label: '[data]',
|
||||||
style: {
|
style: {
|
||||||
fill: '#ff2e63',
|
fill: '#95e1d3',
|
||||||
stroke: "#333",
|
stroke: '#333',
|
||||||
cursor: 'pointer'
|
cursor: 'pointer',
|
||||||
|
backgroundFill: '#eee'
|
||||||
|
},
|
||||||
|
labelOptions: {
|
||||||
|
style: { fontSize: 16 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* 箭头
|
|
||||||
*/
|
|
||||||
link: {
|
link: {
|
||||||
child: {
|
child: {
|
||||||
type: 'line',
|
|
||||||
sourceAnchor: index => index,
|
sourceAnchor: index => index,
|
||||||
targetAnchor: 3,
|
targetAnchor: 3,
|
||||||
|
type: 'line',
|
||||||
style: {
|
style: {
|
||||||
stroke: '#333',
|
stroke: '#333',
|
||||||
//边的响应范围
|
lineAppendWidth: 10,
|
||||||
lineAppendWidth: 6,
|
lineWidth: 1.6,
|
||||||
cursor: 'pointer',
|
|
||||||
endArrow: 'default',
|
endArrow: 'default',
|
||||||
startArrow: {
|
startArrow: {
|
||||||
//参数:半径、偏移量
|
|
||||||
path: G6.Arrow.circle(2, -1),
|
path: G6.Arrow.circle(2, -1),
|
||||||
fill: '#333'
|
fill: '#333'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
parent: {
|
r_parent: {
|
||||||
type: 'line',
|
type: 'quadratic',
|
||||||
|
sourceAnchor: 4,
|
||||||
|
targetAnchor: 5,
|
||||||
|
curveOffset: -20,
|
||||||
|
style: {
|
||||||
|
stroke: '#999',
|
||||||
|
lineAppendWidth: 10,
|
||||||
|
lineWidth: 1.6,
|
||||||
|
endArrow: 'default',
|
||||||
|
startArrow: {
|
||||||
|
path: G6.Arrow.circle(2, -1),
|
||||||
|
fill: '#999'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
l_parent: {
|
||||||
|
type: 'quadratic',
|
||||||
sourceAnchor: 4,
|
sourceAnchor: 4,
|
||||||
targetAnchor: 2,
|
targetAnchor: 2,
|
||||||
|
curveOffset: 20,
|
||||||
style: {
|
style: {
|
||||||
stroke: '#A9A9A9',
|
stroke: '#999',
|
||||||
//边的响应范围
|
lineAppendWidth: 10,
|
||||||
lineAppendWidth: 6,
|
lineWidth: 1.6,
|
||||||
cursor: 'pointer',
|
|
||||||
endArrow: 'default',
|
endArrow: 'default',
|
||||||
startArrow: {
|
startArrow: {
|
||||||
//参数:半径、偏移量
|
|
||||||
path: G6.Arrow.circle(2, -1),
|
path: G6.Arrow.circle(2, -1),
|
||||||
fill: '#333'
|
fill: '#999'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* 指针
|
|
||||||
*/
|
|
||||||
marker: {
|
marker: {
|
||||||
external: {
|
external: {
|
||||||
type: "pointer",
|
type: 'pointer',
|
||||||
anchor: 3,
|
anchor: 3,
|
||||||
offset: 14,
|
offset: 14,
|
||||||
|
labelOffset: 2,
|
||||||
style: {
|
style: {
|
||||||
fill: '#f08a5d'
|
fill: '#f08a5d'
|
||||||
},
|
},
|
||||||
labelOptions: {
|
labelOptions: {
|
||||||
style: {
|
style: {
|
||||||
// stroke:
|
fontSize: 15,
|
||||||
|
fill: '#999'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
addressLabel: {
|
||||||
* 布局
|
style: {
|
||||||
*/
|
fill: '#999'
|
||||||
|
}
|
||||||
|
},
|
||||||
layout: {
|
layout: {
|
||||||
xInterval: 40,
|
xInterval: 40,
|
||||||
yInterval: 40,
|
yInterval: 40,
|
||||||
},
|
}
|
||||||
/**
|
|
||||||
* 动画
|
|
||||||
*/
|
|
||||||
//animation: {
|
|
||||||
// enable: true,
|
|
||||||
// duration: 750,
|
|
||||||
// timingFunction: 'easePolyOut'
|
|
||||||
//}
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -99,7 +103,7 @@
|
|||||||
*/
|
*/
|
||||||
layoutItem(node, parent, index, layoutOptions) {
|
layoutItem(node, parent, index, layoutOptions) {
|
||||||
// 次双亲不进行布局
|
// 次双亲不进行布局
|
||||||
if(!node) {
|
if (!node) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,20 +113,20 @@
|
|||||||
group = new Group(node); //创建分组
|
group = new Group(node); //创建分组
|
||||||
|
|
||||||
//有双亲,设置结点的位置
|
//有双亲,设置结点的位置
|
||||||
if(parent) {
|
if (parent) {
|
||||||
// 纵坐标
|
// 纵坐标
|
||||||
node.set('y', parent.get('y') + layoutOptions.yInterval + height);
|
node.set('y', parent.get('y') + layoutOptions.yInterval + height);
|
||||||
// 左节点横坐标
|
// 左节点横坐标
|
||||||
if(index === 0) {
|
if (index === 0) {
|
||||||
node.set('x', parent.get('x') - layoutOptions.xInterval / 2 - width / 2);
|
node.set('x', parent.get('x') - layoutOptions.xInterval / 2 - width / 2);
|
||||||
}
|
}
|
||||||
// 右结点横坐标
|
// 右结点横坐标
|
||||||
if(index === 1) {
|
if (index === 1) {
|
||||||
node.set('x', parent.get('x') + layoutOptions.xInterval / 2 + width / 2);
|
node.set('x', parent.get('x') + layoutOptions.xInterval / 2 + width / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//有孩子
|
//有孩子
|
||||||
if(node.child && (node.child[0] || node.child[1])) {
|
if (node.child && (node.child[0] || node.child[1])) {
|
||||||
let leftChild = node.child[0],
|
let leftChild = node.child[0],
|
||||||
rightChild = node.child[1],
|
rightChild = node.child[1],
|
||||||
leftGroup = this.layoutItem(leftChild, node, 0, layoutOptions),
|
leftGroup = this.layoutItem(leftChild, node, 0, layoutOptions),
|
||||||
@ -131,12 +135,12 @@
|
|||||||
move = 0;
|
move = 0;
|
||||||
|
|
||||||
// 处理左子树中子树相交问题
|
// 处理左子树中子树相交问题
|
||||||
if(leftGroup && rightChild) {
|
if (leftGroup && rightChild) {
|
||||||
//求出包围盒相交部分
|
//求出包围盒相交部分
|
||||||
intersection = Bound.intersect(leftGroup.getBound(), rightGroup.getBound());
|
intersection = Bound.intersect(leftGroup.getBound(), rightGroup.getBound());
|
||||||
move = 0;
|
move = 0;
|
||||||
//处理
|
//处理
|
||||||
if(intersection && intersection.width > 0) {
|
if (intersection && intersection.width > 0) {
|
||||||
move = (intersection.width + layoutOptions.xInterval) / 2;
|
move = (intersection.width + layoutOptions.xInterval) / 2;
|
||||||
// console.log(move,intersection.width,layoutOptions.xInterval);
|
// console.log(move,intersection.width,layoutOptions.xInterval);
|
||||||
leftGroup.translate(-move, 0);
|
leftGroup.translate(-move, 0);
|
||||||
@ -145,10 +149,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//加入分组
|
//加入分组
|
||||||
if(leftGroup) {
|
if (leftGroup) {
|
||||||
group.add(leftGroup);
|
group.add(leftGroup);
|
||||||
}
|
}
|
||||||
if(rightGroup) {
|
if (rightGroup) {
|
||||||
group.add(rightGroup)
|
group.add(rightGroup)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
149
demo/data.js
149
demo/data.js
@ -1,16 +1,19 @@
|
|||||||
const SOURCES_DATA = [{
|
const SOURCES_DATA = [{
|
||||||
"BinaryTree0": {
|
"TriTree0": {
|
||||||
"data": [{
|
"data": [{
|
||||||
"external": [
|
"external": [
|
||||||
"T1"
|
"T"
|
||||||
|
],
|
||||||
|
"parent": [
|
||||||
|
"0x0"
|
||||||
],
|
],
|
||||||
"child": [
|
"child": [
|
||||||
"0x617ee0",
|
"0xb07ee0",
|
||||||
"0x617f10"
|
"0xb07f10"
|
||||||
],
|
],
|
||||||
"id": "0x617eb0",
|
"id": "0xb07eb0",
|
||||||
"name": "T1",
|
"name": "T",
|
||||||
"data": "Z",
|
"data": "A",
|
||||||
"root": true,
|
"root": true,
|
||||||
"type": "default"
|
"type": "default"
|
||||||
},
|
},
|
||||||
@ -19,19 +22,57 @@ const SOURCES_DATA = [{
|
|||||||
"0x0",
|
"0x0",
|
||||||
"0x0"
|
"0x0"
|
||||||
],
|
],
|
||||||
"id": "0x617ee0",
|
"id": "0xb07ee0",
|
||||||
"name": "T1->lchild",
|
"name": "T->lchild",
|
||||||
"data": "D",
|
"data": "B",
|
||||||
"type": "default"
|
"type": "default",
|
||||||
|
"l_parent": [
|
||||||
|
"0x0"
|
||||||
|
],
|
||||||
|
"external": [
|
||||||
|
"T1"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"child": [
|
"child": [
|
||||||
"0x617f70",
|
"0x0",
|
||||||
"0x617f40"
|
"0x0"
|
||||||
],
|
],
|
||||||
"id": "0x617f10",
|
"id": "0xb07f10",
|
||||||
"name": "T1->rchild",
|
"name": "T->rchild",
|
||||||
"data": "C",
|
"data": "C",
|
||||||
|
"type": "default",
|
||||||
|
"r_parent": [
|
||||||
|
"0x0"
|
||||||
|
],
|
||||||
|
"external": [
|
||||||
|
"T2"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"layouter": "TriTree"
|
||||||
|
},
|
||||||
|
"handleUpdate": {
|
||||||
|
"isEnterFunction": false,
|
||||||
|
"isFirstDebug": false
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"TriTree0": {
|
||||||
|
"data": [{
|
||||||
|
"external": [
|
||||||
|
"T"
|
||||||
|
],
|
||||||
|
"parent": [
|
||||||
|
"0x0"
|
||||||
|
],
|
||||||
|
"child": [
|
||||||
|
"0xb07ee0",
|
||||||
|
"0xb07f10"
|
||||||
|
],
|
||||||
|
"id": "0xb07eb0",
|
||||||
|
"name": "T",
|
||||||
|
"data": "A",
|
||||||
|
"root": true,
|
||||||
"type": "default"
|
"type": "default"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -39,39 +80,93 @@ const SOURCES_DATA = [{
|
|||||||
"0x0",
|
"0x0",
|
||||||
"0x0"
|
"0x0"
|
||||||
],
|
],
|
||||||
"id": "0x617f70",
|
"id": "0xb07ee0",
|
||||||
"name": "(T1->rchild)->lchild",
|
"name": "T->lchild",
|
||||||
|
"data": "B",
|
||||||
|
"type": "default",
|
||||||
|
"l_parent": [
|
||||||
|
"0xb07eb0"
|
||||||
|
],
|
||||||
|
"external": [
|
||||||
|
"T1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"child": [
|
||||||
|
"0x0",
|
||||||
|
"0x0"
|
||||||
|
],
|
||||||
|
"id": "0xb07f10",
|
||||||
|
"name": "T->rchild",
|
||||||
|
"data": "C",
|
||||||
|
"type": "default",
|
||||||
|
"r_parent": [
|
||||||
|
"0x0"
|
||||||
|
],
|
||||||
|
"external": [
|
||||||
|
"T2"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"layouter": "TriTree"
|
||||||
|
},
|
||||||
|
"handleUpdate": {
|
||||||
|
"isEnterFunction": false,
|
||||||
|
"isFirstDebug": false
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"TriTree0": {
|
||||||
|
"data": [{
|
||||||
|
"external": [
|
||||||
|
"T"
|
||||||
|
],
|
||||||
|
"parent": [
|
||||||
|
"0x0"
|
||||||
|
],
|
||||||
|
"child": [
|
||||||
|
"0xb07ee0",
|
||||||
|
"0xb07f10"
|
||||||
|
],
|
||||||
|
"id": "0xb07eb0",
|
||||||
|
"name": "T",
|
||||||
"data": "A",
|
"data": "A",
|
||||||
|
"root": true,
|
||||||
"type": "default"
|
"type": "default"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"child": [
|
"child": [
|
||||||
"0x0",
|
"0x0",
|
||||||
"0x617fa0"
|
"0x0"
|
||||||
],
|
],
|
||||||
"id": "0x617f40",
|
"id": "0xb07ee0",
|
||||||
"name": "(T1->rchild)->rchild",
|
"name": "T->lchild",
|
||||||
"data": "B",
|
"data": "B",
|
||||||
"type": "default",
|
"type": "default",
|
||||||
|
"l_parent": [
|
||||||
|
"0xb07eb0"
|
||||||
|
],
|
||||||
"external": [
|
"external": [
|
||||||
"t"
|
"T1"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"child": [
|
"child": [
|
||||||
"0x0",
|
"0x0",
|
||||||
"0x617f40"
|
"0x0"
|
||||||
],
|
],
|
||||||
"id": "0x617fa0",
|
"id": "0xb07f10",
|
||||||
"name": "((T1->rchild)->rchild)->rchild",
|
"name": "T->rchild",
|
||||||
"data": "E",
|
"data": "C",
|
||||||
"type": "default",
|
"type": "default",
|
||||||
|
"r_parent": [
|
||||||
|
"0xb07eb0"
|
||||||
|
],
|
||||||
"external": [
|
"external": [
|
||||||
"r"
|
"T2"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"layouter": "BinaryTree"
|
"layouter": "TriTree"
|
||||||
},
|
},
|
||||||
"handleUpdate": {
|
"handleUpdate": {
|
||||||
"isEnterFunction": false,
|
"isEnterFunction": false,
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
|
||||||
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>DEMO</title>
|
<title>DEMO</title>
|
||||||
@ -42,13 +43,13 @@
|
|||||||
transition: opacity 0.75s ease-in-out;
|
transition: opacity 0.75s ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
#leak > span {
|
#leak>span {
|
||||||
color: #000;
|
color: #000;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="container" id="container">
|
<div class="container" id="container">
|
||||||
<div id="leak">
|
<div id="leak">
|
||||||
<span>泄漏区</span>
|
<span>泄漏区</span>
|
||||||
@ -72,6 +73,7 @@
|
|||||||
</script>
|
</script>
|
||||||
<script src="./Layouter/LinkList.js"></script>
|
<script src="./Layouter/LinkList.js"></script>
|
||||||
<script src="./Layouter/BinaryTree.js"></script>
|
<script src="./Layouter/BinaryTree.js"></script>
|
||||||
|
<script src="./Layouter/TriTree.js"></script>
|
||||||
<script src="./Layouter/Stack.js"></script>
|
<script src="./Layouter/Stack.js"></script>
|
||||||
<script src="./Layouter/LinkQueue.js"></script>
|
<script src="./Layouter/LinkQueue.js"></script>
|
||||||
<script src="./Layouter/GeneralizedList.js"></script>
|
<script src="./Layouter/GeneralizedList.js"></script>
|
||||||
@ -147,5 +149,6 @@
|
|||||||
pos.innerHTML = `${x},${y}`;
|
pos.innerHTML = `${x},${y}`;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@ -49,6 +49,7 @@ export class ModelConstructor {
|
|||||||
const layoutGroupTable = new Map<string, LayoutGroup>(),
|
const layoutGroupTable = new Map<string, LayoutGroup>(),
|
||||||
layoutMap: { [key: string]: LayoutCreator } = SV.registeredLayout;
|
layoutMap: { [key: string]: LayoutCreator } = SV.registeredLayout;
|
||||||
|
|
||||||
|
|
||||||
Object.keys(sources).forEach(group => {
|
Object.keys(sources).forEach(group => {
|
||||||
let sourceGroup = sources[group],
|
let sourceGroup = sources[group],
|
||||||
layout = sourceGroup.layouter,
|
layout = sourceGroup.layouter,
|
||||||
@ -301,7 +302,8 @@ export class ModelConstructor {
|
|||||||
// 若没有指针字段的结点则跳过
|
// 若没有指针字段的结点则跳过
|
||||||
if (!markerData) continue;
|
if (!markerData) continue;
|
||||||
|
|
||||||
let id = `${group}[${name}(${Array.isArray(markerData) ? markerData.join('-') : markerData})]`,
|
let id = `[${name}(${Array.isArray(markerData) ? markerData.join('-') : markerData})]`,
|
||||||
|
|
||||||
marker = new SVMarker(id, name, group, layout, markerData, node, markerOptions[name]);
|
marker = new SVMarker(id, name, group, layout, markerData, node, markerOptions[name]);
|
||||||
|
|
||||||
markerList.push(marker);
|
markerList.push(marker);
|
||||||
@ -349,6 +351,7 @@ export class ModelConstructor {
|
|||||||
): SVNode {
|
): SVNode {
|
||||||
let label: string | string[] = this.resolveNodeLabel(options.label, sourceNode),
|
let label: string | string[] = this.resolveNodeLabel(options.label, sourceNode),
|
||||||
id = `${sourceNodeType}(${sourceNode.id.toString()})`,
|
id = `${sourceNodeType}(${sourceNode.id.toString()})`,
|
||||||
|
|
||||||
node = new SVNode(id, sourceNodeType, group, layout, sourceNode, label, options);
|
node = new SVNode(id, sourceNodeType, group, layout, sourceNode, label, options);
|
||||||
|
|
||||||
if (node.freed) {
|
if (node.freed) {
|
||||||
|
|||||||
146
src/RegisteredShape/triTreeNode.ts
Normal file
146
src/RegisteredShape/triTreeNode.ts
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
import { Util } from '../Common/util';
|
||||||
|
|
||||||
|
export default Util.registerShape(
|
||||||
|
'tri-tree-node',
|
||||||
|
{
|
||||||
|
draw(cfg, group) {
|
||||||
|
cfg.size = cfg.size;
|
||||||
|
|
||||||
|
const width = cfg.size[0],
|
||||||
|
height = cfg.size[1];
|
||||||
|
|
||||||
|
const wrapperRect = group.addShape('rect', {
|
||||||
|
attrs: {
|
||||||
|
x: width / 2,
|
||||||
|
y: height / 2,
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
|
stroke: cfg.style.stroke || '#333',
|
||||||
|
cursor: cfg.style.cursor,
|
||||||
|
fill: '#eee'
|
||||||
|
},
|
||||||
|
name: 'wrapper'
|
||||||
|
});
|
||||||
|
|
||||||
|
group.addShape('rect', {
|
||||||
|
attrs: {
|
||||||
|
x: width / 4 + width / 2,
|
||||||
|
y: height / 2,
|
||||||
|
width: width / 2,
|
||||||
|
height: height / 4,
|
||||||
|
fill: '#eee',
|
||||||
|
stroke: cfg.style.stroke || '#333',
|
||||||
|
cursor: cfg.style.cursor
|
||||||
|
},
|
||||||
|
name: 'top',
|
||||||
|
draggable: true
|
||||||
|
});
|
||||||
|
|
||||||
|
group.addShape('rect', {
|
||||||
|
attrs: {
|
||||||
|
x: width / 4 + width / 2,
|
||||||
|
y: height / 2 + height / 4,
|
||||||
|
width: width / 2,
|
||||||
|
height: height / 4 * 3,
|
||||||
|
fill: cfg.color || cfg.style.fill,
|
||||||
|
stroke: cfg.style.stroke || '#333',
|
||||||
|
cursor: cfg.style.cursor
|
||||||
|
},
|
||||||
|
name: 'bottom',
|
||||||
|
draggable: true
|
||||||
|
});
|
||||||
|
const style = (cfg.labelCfg && cfg.labelCfg.style) || {};
|
||||||
|
if (cfg.label) {
|
||||||
|
|
||||||
|
group.addShape('text', {
|
||||||
|
attrs: {
|
||||||
|
x: width, // 居中
|
||||||
|
y: height + height / 8,
|
||||||
|
textAlign: 'center',
|
||||||
|
textBaseline: 'middle',
|
||||||
|
text: cfg.label,
|
||||||
|
fill: style.fill || '#000',
|
||||||
|
fontSize: style.fontSize || 16,
|
||||||
|
cursor: cfg.style.cursor
|
||||||
|
},
|
||||||
|
name: 'text',
|
||||||
|
draggable: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const isLeftEmpty =
|
||||||
|
!cfg.child || cfg.child[0] === undefined || cfg.child[0] === undefined || cfg.child[0] == '0x0',
|
||||||
|
isRightEmpty =
|
||||||
|
!cfg.child || cfg.child[1] === undefined || cfg.child[1] === undefined || cfg.child[1] == '0x0',
|
||||||
|
isparentEmpty = cfg.parent == "0x0" || cfg.l_parent == "0x0" || cfg.r_parent == "0x0";
|
||||||
|
|
||||||
|
|
||||||
|
if (isparentEmpty) {
|
||||||
|
{
|
||||||
|
group.addShape('text', {
|
||||||
|
attrs: {
|
||||||
|
x: width, // 居中
|
||||||
|
y: height / 4 * 3,
|
||||||
|
textAlign: 'center',
|
||||||
|
textBaseline: 'middle',
|
||||||
|
text: "^",
|
||||||
|
fill: style.fill || '#000',
|
||||||
|
fontSize: style.fontSize || 14,
|
||||||
|
cursor: cfg.style.cursor
|
||||||
|
},
|
||||||
|
name: 'parent',
|
||||||
|
draggable: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//节点没有左孩子节点时
|
||||||
|
if (isLeftEmpty) {
|
||||||
|
group.addShape('text', {
|
||||||
|
attrs: {
|
||||||
|
x: width * (5 / 8),
|
||||||
|
y: height * (8 / 7),
|
||||||
|
textAlign: 'center',
|
||||||
|
textBaseline: 'middle',
|
||||||
|
text: '^',
|
||||||
|
fill: style.fill || '#000',
|
||||||
|
fontSize: 16,
|
||||||
|
cursor: cfg.style.cursor,
|
||||||
|
},
|
||||||
|
name: 'text',
|
||||||
|
draggable: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//节点没有右孩子节点时
|
||||||
|
if (isRightEmpty) {
|
||||||
|
group.addShape('text', {
|
||||||
|
attrs: {
|
||||||
|
x: width * (11 / 8),
|
||||||
|
y: height * (8 / 7),
|
||||||
|
textAlign: 'center',
|
||||||
|
textBaseline: 'middle',
|
||||||
|
text: '^',
|
||||||
|
fill: style.fill || '#000',
|
||||||
|
fontSize: 16,
|
||||||
|
cursor: cfg.style.cursor,
|
||||||
|
},
|
||||||
|
name: 'text',
|
||||||
|
draggable: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return wrapperRect;
|
||||||
|
},
|
||||||
|
|
||||||
|
getAnchorPoints() {
|
||||||
|
return [
|
||||||
|
[0.125, 0.5],
|
||||||
|
[0.875, 0.5],
|
||||||
|
[0.4, 1],
|
||||||
|
[0.5, 0],
|
||||||
|
[0.5, 0.125],
|
||||||
|
[0.6, 1],
|
||||||
|
];
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
@ -13,6 +13,7 @@ import G6 from '@antv/g6';
|
|||||||
import Pointer from "./RegisteredShape/pointer";
|
import Pointer from "./RegisteredShape/pointer";
|
||||||
import LinkListNode from "./RegisteredShape/linkListNode";
|
import LinkListNode from "./RegisteredShape/linkListNode";
|
||||||
import BinaryTreeNode from "./RegisteredShape/binaryTreeNode";
|
import BinaryTreeNode from "./RegisteredShape/binaryTreeNode";
|
||||||
|
import TriTreeNode from "./RegisteredShape/triTreeNode";
|
||||||
import CLenQueuePointer from "./RegisteredShape/clenQueuePointer";
|
import CLenQueuePointer from "./RegisteredShape/clenQueuePointer";
|
||||||
import TwoCellNode from "./RegisteredShape/twoCellNode";
|
import TwoCellNode from "./RegisteredShape/twoCellNode";
|
||||||
import ThreeCellNode from "./RegisteredShape/threeCellNode";
|
import ThreeCellNode from "./RegisteredShape/threeCellNode";
|
||||||
@ -65,6 +66,7 @@ SV.registeredShape = [
|
|||||||
Pointer,
|
Pointer,
|
||||||
LinkListNode,
|
LinkListNode,
|
||||||
BinaryTreeNode,
|
BinaryTreeNode,
|
||||||
|
TriTreeNode,
|
||||||
TwoCellNode,
|
TwoCellNode,
|
||||||
ThreeCellNode,
|
ThreeCellNode,
|
||||||
Cursor,
|
Cursor,
|
||||||
@ -92,5 +94,6 @@ SV.registerLayout = function(name: string, layoutCreator: LayoutCreator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SV.registeredLayout[name] = layoutCreator;
|
SV.registeredLayout[name] = layoutCreator;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user