From 28d7b47034caed7921f50e95487aa49ce9e33309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E8=8D=A3=E7=87=8A?= <1349557306@qq.com> Date: Sat, 26 Mar 2022 22:16:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=93=88=E5=B8=8C?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=E8=87=AA=E5=AE=9A=E4=B9=89=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/RegisteredShape/chainHashTableNode.ts | 74 +++++++++++++++++++ yarn.lock | 87 ++++++++++++----------- 2 files changed, 120 insertions(+), 41 deletions(-) create mode 100644 src/RegisteredShape/chainHashTableNode.ts diff --git a/src/RegisteredShape/chainHashTableNode.ts b/src/RegisteredShape/chainHashTableNode.ts new file mode 100644 index 0000000..cce9ec0 --- /dev/null +++ b/src/RegisteredShape/chainHashTableNode.ts @@ -0,0 +1,74 @@ +import { Util } from '../Common/util'; +export default Util.registerShape( + 'chain-hashtable-node', + { + draw(cfg, group) { + cfg.size = cfg.size || [30, 30]; + + 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, + fill: cfg.style.backgroundFill || '#eee' + }, + name: 'wrapper', + draggable: true + }); + + const style = (cfg.labelCfg && cfg.labelCfg.style) || {}; + + if (cfg.label) { + group.addShape('text', { + attrs: { + x: width, + y: height, + textAlign: 'center', + textBaseline: 'middle', + text: cfg.label, + fill: style.fill || '#000', + fontSize: style.fontSize || 16 + }, + name: 'text', + draggable: true + }); + } + + //节点没有后续指针时 + if (!cfg.next && !cfg.loopNext) { + group.addShape('text', { + attrs: { + x: width, + y: height, + textAlign: 'center', + textBaseline: 'middle', + text: '^', + fill: style.fill || '#000', + fontSize: 16, + cursor: cfg.style.cursor, + }, + name: 'text', + draggable: true, + }); + } + + return wrapperRect; + }, + + getAnchorPoints() { + return [ + [1 / 6, 0], + [0.5, 0], + [0.5, 0.5], + [5 / 6, 0.5], + [0.5, 1], + [0, 0.5] + ]; + } + } +) \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index d8771fb..6b75601 100644 --- a/yarn.lock +++ b/yarn.lock @@ -124,10 +124,10 @@ probe.gl "^3.1.1" reflect-metadata "^0.1.13" -"@antv/g6-core@0.4.1": - version "0.4.1" - resolved "https://registry.yarnpkg.com/@antv/g6-core/-/g6-core-0.4.1.tgz#3351838e8ecfd2588bf48f5ee766f3ddea34f989" - integrity sha512-ZpugNMz3V76K+cLVpoj5If3yrFq81bKZET3IkG2LWdZ0bvDt5G94XUjcBG7Xi/doerq7cDOJrW6z3t2DqnvvfA== +"@antv/g6-core@0.6.3": + version "0.6.3" + resolved "https://registry.yarnpkg.com/@antv/g6-core/-/g6-core-0.6.3.tgz#b6c9b5d53c7dca8f92d0b2d9f14013c82754ebf3" + integrity sha512-37RwHTZtJ3IgM+V3dbMnQJ3iRvqf4Th4Dh2aVBmpMsj9yMyRwE04auJefJFedCVITl4YIa9o7iayi+HG7K3oSg== dependencies: "@antv/algorithm" "^0.1.8" "@antv/dom-util" "^2.0.1" @@ -140,19 +140,19 @@ ml-matrix "^6.5.0" tslib "^2.1.0" -"@antv/g6-element@0.4.1": - version "0.4.1" - resolved "https://registry.yarnpkg.com/@antv/g6-element/-/g6-element-0.4.1.tgz#0c4eba46ca3f72912bfd13be90ee23d7796f006c" - integrity sha512-z/N+4mJWWauKuKJWEVtlTcvGYygU2Cin7WgBtOM1vORXKLLwl/UHrdqvg+K/CA3WoZUCymOjwNy4ty+Eb8SLkA== +"@antv/g6-element@0.6.3": + version "0.6.3" + resolved "https://registry.yarnpkg.com/@antv/g6-element/-/g6-element-0.6.3.tgz#341a6443345e9f46c704060fd0e6c841abffc1de" + integrity sha512-ZWvjSTUqARIHERIC20lDx4UJz3In6WErfiL4yHxMmjo9lIjxuHwUHKJu5Mkkm3JdEZwZOZeJn5HVlJsYuYl7Vg== dependencies: "@antv/g-base" "^0.5.1" - "@antv/g6-core" "0.4.1" + "@antv/g6-core" "0.6.3" "@antv/util" "~2.0.5" -"@antv/g6-pc@0.4.1": - version "0.4.1" - resolved "https://registry.yarnpkg.com/@antv/g6-pc/-/g6-pc-0.4.1.tgz#b7ce223f9d1da2d0fd09e873afdcca59e29baa86" - integrity sha512-+PQZsmC4M2nm5tnqmUiBSGPZgrObzhTHRODQa1BgodFsqezbw/U/GMK8A752Mhiz/Bz1DkVIHrn4x8dyrLfx7w== +"@antv/g6-pc@0.6.3": + version "0.6.3" + resolved "https://registry.yarnpkg.com/@antv/g6-pc/-/g6-pc-0.6.3.tgz#c56f515f6ac16d83fc0cce314a0a582a0ca72d9c" + integrity sha512-VE2WvCYEADus8uu9dMVwgY/BAjBLjNZl3K/KNhgQekVmFPMGFFXjwFyfiCTQWWQOrD72arbaetzPojLEN4khvQ== dependencies: "@ant-design/colors" "^4.0.5" "@antv/algorithm" "^0.1.8" @@ -162,11 +162,11 @@ "@antv/g-canvas" "^0.5.2" "@antv/g-math" "^0.1.1" "@antv/g-svg" "^0.5.1" - "@antv/g6-core" "0.4.1" - "@antv/g6-element" "0.4.1" - "@antv/g6-plugin" "0.4.1" + "@antv/g6-core" "0.6.3" + "@antv/g6-element" "0.6.3" + "@antv/g6-plugin" "0.6.3" "@antv/hierarchy" "^0.6.7" - "@antv/layout" "0.1.19-beta.5" + "@antv/layout" "^0.2.1" "@antv/matrix-util" "^3.1.0-beta.3" "@antv/path-util" "^2.0.3" "@antv/util" "~2.0.5" @@ -176,27 +176,27 @@ insert-css "^2.0.0" ml-matrix "^6.5.0" -"@antv/g6-plugin@0.4.1": - version "0.4.1" - resolved "https://registry.yarnpkg.com/@antv/g6-plugin/-/g6-plugin-0.4.1.tgz#4696d27a23efbefa5a290845e45648b9bd11def5" - integrity sha512-1rOVZ+GkgeHj0VWc9dd6obyvOOVElRCBM7O5QcjOl9jxmAHI6ZQIXkkHZDPyFaUjFo0qIxjBM8Lnrb3+iBqVNw== +"@antv/g6-plugin@0.6.3": + version "0.6.3" + resolved "https://registry.yarnpkg.com/@antv/g6-plugin/-/g6-plugin-0.6.3.tgz#8175edb17ce212c873f8f6daa747a9c43bcd77a8" + integrity sha512-O7ZSawPPOPILQ+K/AtBbviwHr35i2ebH/qeHNiq6/hZ6FHv3uDNzSIQfDwv8fBgGdNw3QSDz4AkV0GCU+PmbKw== dependencies: "@antv/dom-util" "^2.0.2" "@antv/g-base" "^0.5.1" "@antv/g-canvas" "^0.5.2" "@antv/g-svg" "^0.5.2" - "@antv/g6-core" "0.4.1" + "@antv/g6-core" "0.6.3" "@antv/matrix-util" "^3.1.0-beta.3" "@antv/scale" "^0.3.4" "@antv/util" "^2.0.9" insert-css "^2.0.0" -"@antv/g6@^4.4.1": - version "4.4.1" - resolved "https://registry.yarnpkg.com/@antv/g6/-/g6-4.4.1.tgz#c7290bfae5c6e0a9b0e4349ab4d2c50d3a2f2956" - integrity sha512-7chX89HuWgGGmSnwlS54xUEI/g+CiH4lB/OrrQ/CG3LedZ+TvFEI22giDr10WsB2SgHrbJpbxxtY57O7FwbKhA== +"@antv/g6@^4.6.1": + version "4.6.3" + resolved "https://registry.yarnpkg.com/@antv/g6/-/g6-4.6.3.tgz#3eff301c92a234354753f3cdce92b2368c876d64" + integrity sha512-afRMbymOmCQ+hJtcI5VeiYNM0OxNpMdy1Ldp6hReJiBNVV+lGyLxs1DW0m/ruyZwyaN4tABzreXMSU4pvqVhAA== dependencies: - "@antv/g6-pc" "0.4.1" + "@antv/g6-pc" "0.6.3" "@antv/hierarchy@^0.6.7": version "0.6.8" @@ -205,14 +205,15 @@ dependencies: "@antv/util" "^2.0.7" -"@antv/layout@0.1.19-beta.5": - version "0.1.19-beta.5" - resolved "https://registry.yarnpkg.com/@antv/layout/-/layout-0.1.19-beta.5.tgz#41b31ae55ae50a9d72ad8efab253fb8b40049337" - integrity sha512-t5H9WNoI4werPqjOR1ebZeThwkEofoLyYXEscmU36u0kEa0aXxzFtvdSl6XrYgZRXuEZ+2f6H1FNvGho8jmS7Q== +"@antv/layout@^0.2.1": + version "0.2.1" + resolved "https://registry.yarnpkg.com/@antv/layout/-/layout-0.2.1.tgz#18de7144cebf9e91eaf0b7bedddbbff22aaf474c" + integrity sha512-2ed+KBaSOPoiNdNBGUoyaqHPjFMtEBPrd3YOTeobaE80P1cKF9fycHnidgz2QChcvBNacMOyIC3j6cLJ7KizGA== dependencies: "@antv/g-webgpu" "0.5.5" + "@dagrejs/graphlib" "2.1.4" d3-force "^2.0.1" - dagrejs "^0.2.1" + dagre-compound "^0.0.11" ml-matrix "^6.5.0" "@antv/matrix-util@^3.0.4": @@ -266,6 +267,13 @@ dependencies: regenerator-runtime "^0.13.4" +"@dagrejs/graphlib@2.1.4": + version "2.1.4" + resolved "https://registry.yarnpkg.com/@dagrejs/graphlib/-/graphlib-2.1.4.tgz#86c70e4f073844a2f4ada254c8c7b88a6bdacdb1" + integrity sha512-QCg9sL4uhjn468FDEsb/S9hS2xUZSrv/+dApb1Ze5VKO96pTXKNJZ6MGhIpgWkc1TVhbVGH9/7rq/Mf8/jWicw== + dependencies: + lodash "^4.11.1" + "@probe.gl/stats@3.4.1": version "3.4.1" resolved "https://registry.yarnpkg.com/@probe.gl/stats/-/stats-3.4.1.tgz#5bc0ec5f87ae3195c22a98363e9c15031fbfe8e8" @@ -1074,6 +1082,11 @@ d3-timer@^1.0.9: resolved "https://registry.yarnpkg.com/d3-timer/-/d3-timer-1.0.10.tgz#dfe76b8a91748831b13b6d9c793ffbd508dd9de5" integrity sha512-B1JDm0XDaQC+uvo4DT79H0XmBskgS3l6Ve+1SBCfxgmtIb1AVrPIoqd+nPSv+loMX8szQ0sVUhGngL7D5QPiXw== +dagre-compound@^0.0.11: + version "0.0.11" + resolved "https://registry.yarnpkg.com/dagre-compound/-/dagre-compound-0.0.11.tgz#8d3d1004d756f420582d29f28c92045375018987" + integrity sha512-UrSgRP9LtOZCYb9e5doolZXpc7xayyszgyOs7uakTK4n4KsLegLVTRRtq01GpQd/iZjYw5fWMapx9ed+c80MAQ== + dagre@^0.8.5: version "0.8.5" resolved "https://registry.yarnpkg.com/dagre/-/dagre-0.8.5.tgz#ba30b0055dac12b6c1fcc247817442777d06afee" @@ -1082,14 +1095,6 @@ dagre@^0.8.5: graphlib "^2.1.8" lodash "^4.17.15" -dagrejs@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/dagrejs/-/dagrejs-0.2.1.tgz#1d5738c17fe7989ff90983ce845c74599bae6786" - integrity sha512-4bb1y+4aM1xtkK7ieP0V7Xn/34GQfnCapl0yubrOMX8Qb/PIwM1Dii2uUBv/KtuzrQtxPliSP4r5MQBsnP6gNg== - dependencies: - graphlib "^2.1.8" - lodash "^4.17.19" - debug@^2.2.0, debug@^2.3.3: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" @@ -1913,7 +1918,7 @@ locate-path@^3.0.0: p-locate "^3.0.0" path-exists "^3.0.0" -lodash@^4.17.15, lodash@^4.17.19: +lodash@^4.11.1, lodash@^4.17.15: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==