给指向freed结点的边增加freed标志
This commit is contained in:
parent
2a09ca6be1
commit
5bee1cda0a
@ -1,250 +1,237 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>DEMO</title>
|
|
||||||
<style>
|
|
||||||
* {
|
|
||||||
padding: 0;
|
|
||||||
margin: 0;
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
<head>
|
||||||
background-color: #fafafa;
|
<meta charset="UTF-8" />
|
||||||
border: 1px solid #ccc;
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
position: relative;
|
<title>DEMO</title>
|
||||||
}
|
<style>
|
||||||
|
* {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
.down {
|
.container {
|
||||||
display: flex;
|
background-color: #fafafa;
|
||||||
margin-top: 20px;
|
border: 1px solid #ccc;
|
||||||
}
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
#container {
|
.down {
|
||||||
width: 100%;
|
display: flex;
|
||||||
height: 500px;
|
margin-top: 20px;
|
||||||
position: relative;
|
}
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
#leak {
|
#container {
|
||||||
position: absolute;
|
width: 100%;
|
||||||
left: 0;
|
height: 500px;
|
||||||
opacity: 0;
|
position: relative;
|
||||||
top: 100px;
|
overflow: hidden;
|
||||||
width: 100%;
|
}
|
||||||
box-sizing: border-box;
|
|
||||||
padding: 4px;
|
|
||||||
border-top: 1px dashed #000;
|
|
||||||
pointer-events: none;
|
|
||||||
transition: opacity 0.75s ease-in-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
#leak > span {
|
#leak {
|
||||||
color: #000;
|
position: absolute;
|
||||||
}
|
left: 0;
|
||||||
</style>
|
opacity: 0;
|
||||||
</head>
|
top: 100px;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 4px;
|
||||||
|
border-top: 1px dashed #000;
|
||||||
|
pointer-events: none;
|
||||||
|
transition: opacity 0.75s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
<body>
|
#leak>span {
|
||||||
<div class="container" id="container">
|
color: #000;
|
||||||
<div id="leak">
|
}
|
||||||
<span>泄漏区</span>
|
</style>
|
||||||
</div>
|
</head>
|
||||||
</div>
|
|
||||||
|
|
||||||
<button id="btn-prev">prev</button>
|
<body>
|
||||||
<button id="btn-next">next</button>
|
<div class="container" id="container">
|
||||||
<button id="resize">resize</button>
|
<div id="leak">
|
||||||
<button id="relayout">relayout</button>
|
<span>泄漏区</span>
|
||||||
<button id="switch-mode">switch mode</button>
|
</div>
|
||||||
<button id="brush-select">brush-select</button>
|
</div>
|
||||||
<span id="pos"></span>
|
|
||||||
|
|
||||||
<script src="./../dist/sv.js"></script>
|
<button id="btn-prev">prev</button>
|
||||||
<script>
|
<button id="btn-next">next</button>
|
||||||
const Group = SV.Group,
|
<button id="resize">resize</button>
|
||||||
Bound = SV.Bound,
|
<button id="relayout">relayout</button>
|
||||||
G6 = SV.G6,
|
<button id="switch-mode">switch mode</button>
|
||||||
Vector = SV.Vector;
|
<button id="brush-select">brush-select</button>
|
||||||
</script>
|
<span id="pos"></span>
|
||||||
<script src="./Layouter/LinkList.js"></script>
|
|
||||||
<script src="./Layouter/BinaryTree.js"></script>
|
|
||||||
<script src="./Layouter/Stack.js"></script>
|
|
||||||
<script src="./Layouter/LinkQueue.js"></script>
|
|
||||||
<script src="./Layouter/GeneralizedList.js"></script>
|
|
||||||
<script src="./Layouter/ChainHashTable.js"></script>
|
|
||||||
<script src="./Layouter/Array.js"></script>
|
|
||||||
<script src="./Layouter/HashTable.js"></script>
|
|
||||||
<script src="./Layouter/LinkStack.js"></script>
|
|
||||||
<script src="./Layouter/AdjoinMatrixGraph.js"></script>
|
|
||||||
<script src="./Layouter/AdjoinTableGraph.js"></script>
|
|
||||||
<script src="./Layouter/SqQueue.js"></script>
|
|
||||||
<script src="./Layouter/PTree.js"></script>
|
|
||||||
<script src="./Layouter/PCTree.js"></script>
|
|
||||||
|
|
||||||
<script>
|
<script src="./../dist/sv.js"></script>
|
||||||
let cur = SV(document.getElementById('container'), {
|
<script>
|
||||||
view: {
|
const Group = SV.Group,
|
||||||
leakAreaHeight: 130,
|
Bound = SV.Bound,
|
||||||
groupPadding: 40,
|
G6 = SV.G6,
|
||||||
},
|
Vector = SV.Vector;
|
||||||
});
|
</script>
|
||||||
|
<script src="./Layouter/LinkList.js"></script>
|
||||||
|
<script src="./Layouter/BinaryTree.js"></script>
|
||||||
|
<script src="./Layouter/Stack.js"></script>
|
||||||
|
<script src="./Layouter/LinkQueue.js"></script>
|
||||||
|
<script src="./Layouter/GeneralizedList.js"></script>
|
||||||
|
<script src="./Layouter/ChainHashTable.js"></script>
|
||||||
|
<script src="./Layouter/Array.js"></script>
|
||||||
|
<script src="./Layouter/HashTable.js"></script>
|
||||||
|
<script src="./Layouter/LinkStack.js"></script>
|
||||||
|
<script src="./Layouter/AdjoinMatrixGraph.js"></script>
|
||||||
|
<script src="./Layouter/AdjoinTableGraph.js"></script>
|
||||||
|
<script src="./Layouter/SqQueue.js"></script>
|
||||||
|
<script src="./Layouter/PTree.js"></script>
|
||||||
|
<script src="./Layouter/PCTree.js"></script>
|
||||||
|
|
||||||
let data = [
|
<script>
|
||||||
{
|
let cur = SV(document.getElementById('container'), {
|
||||||
BinaryTree0: {
|
view: {
|
||||||
data: [
|
leakAreaHeight: 130,
|
||||||
{
|
groupPadding: 40,
|
||||||
external: ['T', 'p'],
|
},
|
||||||
child: ['0x615f40', '0x0'],
|
});
|
||||||
id: '0x615f10',
|
|
||||||
name: 'T',
|
|
||||||
data: 'W',
|
|
||||||
root: true,
|
|
||||||
type: 'default',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
child: ['0x615f70', '0x615fa0'],
|
|
||||||
id: '0x615f40',
|
|
||||||
name: 'T->lchild',
|
|
||||||
data: 'Q',
|
|
||||||
type: 'default',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
child: ['0x0', '0x615fd0'],
|
|
||||||
id: '0x615f70',
|
|
||||||
name: '(T->lchild)->lchild',
|
|
||||||
data: 'A',
|
|
||||||
type: 'default',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
child: ['0x0', '0x0'],
|
|
||||||
id: '0x615fd0',
|
|
||||||
name: '((T->lchild)->lchild)->rchild',
|
|
||||||
data: 'D',
|
|
||||||
type: 'default',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
child: ['0x616000', '0x616030'],
|
|
||||||
id: '0x615fa0',
|
|
||||||
name: '(T->lchild)->rchild',
|
|
||||||
data: 'U',
|
|
||||||
type: 'default',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
child: ['0x0', '0x0'],
|
|
||||||
id: '0x616000',
|
|
||||||
name: '((T->lchild)->rchild)->lchild',
|
|
||||||
data: 'S',
|
|
||||||
type: 'default',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
child: ['0x0', '0x0'],
|
|
||||||
id: '0x616030',
|
|
||||||
name: '((T->lchild)->rchild)->rchild',
|
|
||||||
data: 'V',
|
|
||||||
type: 'default',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
layouter: 'BinaryTree',
|
|
||||||
},
|
|
||||||
isEnterFunction: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
BinaryTree0: {
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
external: ['T', 'p'],
|
|
||||||
child: ['0x615f40', '0x0'],
|
|
||||||
id: '0x615f10',
|
|
||||||
name: 'T',
|
|
||||||
data: 'W',
|
|
||||||
root: true,
|
|
||||||
type: 'default',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
child: ['0x615f70', '0x615fa0'],
|
|
||||||
id: '0x615f40',
|
|
||||||
name: 'T->lchild',
|
|
||||||
data: 'Q',
|
|
||||||
type: 'default',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
child: ['0x0', '0x615fd0'],
|
|
||||||
id: '0x615f70',
|
|
||||||
name: '(T->lchild)->lchild',
|
|
||||||
data: 'A',
|
|
||||||
type: 'default',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
child: ['0x0', '0x0'],
|
|
||||||
id: '0x615fd0',
|
|
||||||
name: '((T->lchild)->lchild)->rchild',
|
|
||||||
data: 'D',
|
|
||||||
type: 'default',
|
|
||||||
}
|
|
||||||
],
|
|
||||||
layouter: 'BinaryTree',
|
|
||||||
},
|
|
||||||
isEnterFunction: false,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
let dataIndex = 0,
|
let data = [{
|
||||||
curData = data[dataIndex];
|
"BinaryTree0": {
|
||||||
|
"data": [{
|
||||||
|
"external": [
|
||||||
|
"T1",
|
||||||
|
"r"
|
||||||
|
],
|
||||||
|
"child": [
|
||||||
|
"0x617ee0",
|
||||||
|
"0x617f10"
|
||||||
|
],
|
||||||
|
"id": "0x617eb0",
|
||||||
|
"name": "T1",
|
||||||
|
"data": "Z",
|
||||||
|
"root": true,
|
||||||
|
"type": "default"
|
||||||
|
}, {
|
||||||
|
"child": [
|
||||||
|
"0x0",
|
||||||
|
"0x0"
|
||||||
|
],
|
||||||
|
"id": "0x617ee0",
|
||||||
|
"name": "T1->lchild",
|
||||||
|
"data": "A",
|
||||||
|
"type": "default"
|
||||||
|
}, {
|
||||||
|
"child": [
|
||||||
|
"0x0",
|
||||||
|
"0x617f40"
|
||||||
|
],
|
||||||
|
"id": "0x617f10",
|
||||||
|
"name": "T1->rchild",
|
||||||
|
"data": "B",
|
||||||
|
"type": "default",
|
||||||
|
"external": [
|
||||||
|
"t"
|
||||||
|
]
|
||||||
|
}, ],
|
||||||
|
"layouter": "BinaryTree"
|
||||||
|
},
|
||||||
|
"isEnterFunction": false
|
||||||
|
}, {
|
||||||
|
"BinaryTree1": {
|
||||||
|
"data": [{
|
||||||
|
"external": [
|
||||||
|
"T1",
|
||||||
|
"r"
|
||||||
|
],
|
||||||
|
"child": [
|
||||||
|
"0x617ee0",
|
||||||
|
"0x617f10"
|
||||||
|
],
|
||||||
|
"id": "0x617eb0",
|
||||||
|
"name": "T1",
|
||||||
|
"data": "Z",
|
||||||
|
"root": true,
|
||||||
|
"type": "default"
|
||||||
|
}, {
|
||||||
|
"child": [
|
||||||
|
"0x0",
|
||||||
|
"0x0"
|
||||||
|
],
|
||||||
|
"id": "0x617ee0",
|
||||||
|
"name": "T1->lchild",
|
||||||
|
"data": "A",
|
||||||
|
freed: 'freed',
|
||||||
|
"type": "default"
|
||||||
|
}, {
|
||||||
|
"child": [
|
||||||
|
"0x0",
|
||||||
|
"0x617f40"
|
||||||
|
],
|
||||||
|
"id": "0x617f10",
|
||||||
|
"name": "T1->rchild",
|
||||||
|
"data": "B",
|
||||||
|
"type": "default",
|
||||||
|
"external": [
|
||||||
|
"t"
|
||||||
|
]
|
||||||
|
}, ],
|
||||||
|
"layouter": "BinaryTree"
|
||||||
|
},
|
||||||
|
"isEnterFunction": false
|
||||||
|
}, ];
|
||||||
|
|
||||||
let enableBrushSelect = false;
|
let dataIndex = 0,
|
||||||
|
curData = data[dataIndex];
|
||||||
|
|
||||||
const container = document.getElementById('container'),
|
let enableBrushSelect = false;
|
||||||
pos = document.getElementById('pos');
|
|
||||||
|
|
||||||
const leak = document.getElementById('leak');
|
const container = document.getElementById('container'),
|
||||||
|
pos = document.getElementById('pos');
|
||||||
|
|
||||||
cur.render(curData);
|
const leak = document.getElementById('leak');
|
||||||
|
|
||||||
document.getElementById('btn-next').addEventListener('click', e => {
|
cur.render(curData);
|
||||||
curData = data[++dataIndex];
|
|
||||||
cur.render(curData);
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById('btn-prev').addEventListener('click', e => {
|
document.getElementById('btn-next').addEventListener('click', e => {
|
||||||
curData = data[--dataIndex];
|
curData = data[++dataIndex];
|
||||||
cur.render(curData);
|
cur.render(curData);
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('resize').addEventListener('click', e => {
|
document.getElementById('btn-prev').addEventListener('click', e => {
|
||||||
container.style.height = 800 + 'px';
|
curData = data[--dataIndex];
|
||||||
cur.resize(container.offsetWidth, container.offsetHeight);
|
cur.render(curData);
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('relayout').addEventListener('click', e => {
|
document.getElementById('resize').addEventListener('click', e => {
|
||||||
cur.reLayout();
|
container.style.height = 800 + 'px';
|
||||||
});
|
cur.resize(container.offsetWidth, container.offsetHeight);
|
||||||
|
});
|
||||||
|
|
||||||
document.getElementById('switch-mode').addEventListener('click', e => {
|
document.getElementById('relayout').addEventListener('click', e => {
|
||||||
cur.updateStyle('Array', newArrayOption);
|
cur.reLayout();
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('brush-select').addEventListener('click', e => {
|
document.getElementById('switch-mode').addEventListener('click', e => {
|
||||||
enableBrushSelect = !enableBrushSelect;
|
cur.updateStyle('Array', newArrayOption);
|
||||||
cur.switchBrushSelect(enableBrushSelect);
|
});
|
||||||
});
|
|
||||||
|
|
||||||
cur.on('onLeakAreaUpdate', payload => {
|
document.getElementById('brush-select').addEventListener('click', e => {
|
||||||
leak.style.opacity = payload.hasLeak ? 1 : 0;
|
enableBrushSelect = !enableBrushSelect;
|
||||||
leak.style.top = payload.leakAreaY - 40 + 'px';
|
cur.switchBrushSelect(enableBrushSelect);
|
||||||
});
|
});
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------
|
cur.on('onLeakAreaUpdate', payload => {
|
||||||
|
leak.style.opacity = payload.hasLeak ? 1 : 0;
|
||||||
|
leak.style.top = payload.leakAreaY - 40 + 'px';
|
||||||
|
});
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
container.addEventListener('mousemove', e => {
|
||||||
|
let x = e.offsetX,
|
||||||
|
y = e.offsetY;
|
||||||
|
pos.innerHTML = `${x},${y}`;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
container.addEventListener('mousemove', e => {
|
|
||||||
let x = e.offsetX,
|
|
||||||
y = e.offsetY;
|
|
||||||
pos.innerHTML = `${x},${y}`;
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
@ -43,9 +43,9 @@ export class SVLink extends SVModel {
|
|||||||
target: this.target.id,
|
target: this.target.id,
|
||||||
sourceAnchor,
|
sourceAnchor,
|
||||||
targetAnchor,
|
targetAnchor,
|
||||||
label: options.label,
|
label: this.target.sourceNode.freed ? 'freed' : options.label,
|
||||||
style: Util.objectClone<Style>(options.style),
|
style: Util.objectClone<Style>(options.style),
|
||||||
labelCfg: Util.objectClone<LinkLabelOption>(options.labelOptions),
|
labelCfg: this.target.sourceNode.freed ? {position: 'start', autoRotate: true, refY:5 ,style: { fontSize: 10, opacity: 0.7}} : Util.objectClone<LinkLabelOption>(options.labelOptions),
|
||||||
curveOffset: options.curveOffset
|
curveOffset: options.curveOffset
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user