From dd279a577fa4bb3b0f4704ca8dd133624a4a09c8 Mon Sep 17 00:00:00 2001 From: Rex Date: Mon, 21 Oct 2024 08:42:22 +0800 Subject: [PATCH] Revert --- plugins/graph/graph/Graph.js | 15 --------------- plugins/graph/graph/edge/AddEdge.js | 9 +++++---- plugins/graph/graph/edge/GetAllEdges.js | 2 +- plugins/graph/graph/edge/GetEdgesOfNode.js | 5 +++-- plugins/graph/graph/edge/IsEdge.js | 4 +++- plugins/graph/graph/edge/RemoveEdge.js | 5 +++-- plugins/graph/graph/neighbors/AreNeighborNodes.js | 6 ++++-- plugins/graph/graph/neighbors/GetNeighborNodes.js | 5 +++-- plugins/graph/graph/node/AddNode.js | 5 +++-- plugins/graph/graph/node/GetAllNodes.js | 2 +- plugins/graph/graph/node/GetNodesOfEdge.js | 5 +++-- plugins/graph/graph/node/IsNode.js | 4 +++- plugins/graph/graph/node/RemoveAllNodes.js | 4 ++-- plugins/graph/graph/node/RemoveNode.js | 5 +++-- .../graph/{graph => }/graphitem/GetGraphItem.js | 0 plugins/graph/{graph => }/graphitem/GetObjUID.js | 0 .../graph/{graph => }/graphitem/GraphItemData.js | 2 +- plugins/graph/{graph => }/graphitem/IsUID.js | 0 plugins/graph/{graph => }/graphitem/ObjBank.js | 2 +- .../{graph => }/graphitem/UIDListToObjList.js | 0 plugins/graph/{graph => }/graphitem/UIDToObj.js | 0 plugins/graph/layout/elkjs/BuildGraphData.js | 3 ++- 22 files changed, 41 insertions(+), 42 deletions(-) rename plugins/graph/{graph => }/graphitem/GetGraphItem.js (100%) rename plugins/graph/{graph => }/graphitem/GetObjUID.js (100%) rename plugins/graph/{graph => }/graphitem/GraphItemData.js (93%) rename plugins/graph/{graph => }/graphitem/IsUID.js (100%) rename plugins/graph/{graph => }/graphitem/ObjBank.js (75%) rename plugins/graph/{graph => }/graphitem/UIDListToObjList.js (100%) rename plugins/graph/{graph => }/graphitem/UIDToObj.js (100%) diff --git a/plugins/graph/graph/Graph.js b/plugins/graph/graph/Graph.js index a6899b6af5..1fad04d61f 100644 --- a/plugins/graph/graph/Graph.js +++ b/plugins/graph/graph/Graph.js @@ -1,8 +1,5 @@ import EE from '../../utils/eventemitter/EventEmitter.js'; import Methods from './Methods.js'; -import GetObjUID from './graphitem/GetObjUID.js'; -import UIDToObj from './graphitem/UIDToObj.js'; -import UIDListToObjList from './graphitem/UIDListToObjList.js'; import GraphData from 'graphology'; class Graph extends EE { @@ -76,18 +73,6 @@ class Graph extends EE { this.removeAllNodes(destroy); return this; } - - getObjUID(gameObject) { - return GetObjUID(gameObject); - } - - getObj(uid, out) { - if (Array.isArray(uid)) { - return UIDListToObjList(uid, out); - } else { - return UIDToObj(uid); - } - } } Object.assign( diff --git a/plugins/graph/graph/edge/AddEdge.js b/plugins/graph/graph/edge/AddEdge.js index fcfa282396..57b69b189e 100644 --- a/plugins/graph/graph/edge/AddEdge.js +++ b/plugins/graph/graph/edge/AddEdge.js @@ -1,4 +1,5 @@ -import GetGraphItem from '../graphitem/GetGraphItem.js'; +import GetGraphItem from '../../graphitem/GetGraphItem.js'; +import GetObjUID from '../../graphitem/GetObjUID.js'; const DIRAtoB = 1; const DIRBtoA = 2; @@ -27,9 +28,9 @@ var AddEdge = function (edgeGameObject, nodeAGameObject, nodeBGameObject, dir) { // Add edge GetGraphItem(edgeGameObject).setGraph(this); - var edgeUID = this.getObjUID(edgeGameObject); - var nodeAUID = this.getObjUID(nodeAGameObject); - var nodeBUID = this.getObjUID(nodeBGameObject); + var edgeUID = GetObjUID(edgeGameObject); + var nodeAUID = GetObjUID(nodeAGameObject); + var nodeBUID = GetObjUID(nodeBGameObject); if (!edgeUID || !nodeAUID || !nodeBUID) { return this; diff --git a/plugins/graph/graph/edge/GetAllEdges.js b/plugins/graph/graph/edge/GetAllEdges.js index 1ed74d0294..5c9b038c3c 100644 --- a/plugins/graph/graph/edge/GetAllEdges.js +++ b/plugins/graph/graph/edge/GetAllEdges.js @@ -1,4 +1,4 @@ -import UIDToObj from '../graphitem/UIDToObj.js'; +import UIDToObj from '../../graphitem/UIDToObj.js'; var GetAllEdges = function (out) { if (out === undefined) { diff --git a/plugins/graph/graph/edge/GetEdgesOfNode.js b/plugins/graph/graph/edge/GetEdgesOfNode.js index 9621b146a2..bf0894817a 100644 --- a/plugins/graph/graph/edge/GetEdgesOfNode.js +++ b/plugins/graph/graph/edge/GetEdgesOfNode.js @@ -1,11 +1,12 @@ -import UIDToObj from '../graphitem/UIDToObj.js'; +import UIDToObj from '../../graphitem/UIDToObj.js'; +import GetObjUID from '../../graphitem/GetObjUID.js'; var GetEdgesOfNode = function (nodeGameObject, out) { if (out === undefined) { out = []; } - var nodeUID = this.getObjUID(nodeGameObject); + var nodeUID = GetObjUID(nodeGameObject); this.graph.forEachEdge(nodeUID, function (edgeUID) { var edgeGameObject = UIDToObj(edgeUID); if (!edgeGameObject) { diff --git a/plugins/graph/graph/edge/IsEdge.js b/plugins/graph/graph/edge/IsEdge.js index 9cf9add2e4..11438309f6 100644 --- a/plugins/graph/graph/edge/IsEdge.js +++ b/plugins/graph/graph/edge/IsEdge.js @@ -1,6 +1,8 @@ +import GetObjUID from '../../graphitem/GetObjUID.js'; + var IsEdge = function (gameObejct) { // uid or game object - var uid = this.getObjUID(gameObejct); + var uid = GetObjUID(gameObejct); return this.graph.hasEdge(uid); } diff --git a/plugins/graph/graph/edge/RemoveEdge.js b/plugins/graph/graph/edge/RemoveEdge.js index 3620420aca..d0a57710ed 100644 --- a/plugins/graph/graph/edge/RemoveEdge.js +++ b/plugins/graph/graph/edge/RemoveEdge.js @@ -1,4 +1,5 @@ -import GetGraphItem from '../graphitem/GetGraphItem.js'; +import GetGraphItem from '../../graphitem/GetGraphItem.js'; +import GetObjUID from '../../graphitem/GetObjUID.js'; var RemoveEdge = function (edgeGameObject, destroy) { if (!this.isEdge(edgeGameObject)) { @@ -10,7 +11,7 @@ var RemoveEdge = function (edgeGameObject, destroy) { } // Remove node - var edgeUID = this.getObjUID(edgeGameObject); + var edgeUID = GetObjUID(edgeGameObject); this.graph.dropEdge(edgeUID); // Clear reference of graph diff --git a/plugins/graph/graph/neighbors/AreNeighborNodes.js b/plugins/graph/graph/neighbors/AreNeighborNodes.js index a95e587098..e31ed86f96 100644 --- a/plugins/graph/graph/neighbors/AreNeighborNodes.js +++ b/plugins/graph/graph/neighbors/AreNeighborNodes.js @@ -1,6 +1,8 @@ +import GetObjUID from '../../graphitem/GetObjUID.js'; + var AreNeighborNodes = function (nodeGameObjectA, nodeGameObjectB) { - var nodeUIDA = this.getObjUID(nodeGameObjectA), - nodeUIDB = this.getObjUID(nodeGameObjectB); + var nodeUIDA = GetObjUID(nodeGameObjectA), + nodeUIDB = GetObjUID(nodeGameObjectB); if (!nodeUIDA || !nodeUIDB) { return false; } diff --git a/plugins/graph/graph/neighbors/GetNeighborNodes.js b/plugins/graph/graph/neighbors/GetNeighborNodes.js index 7e4bdce846..4b1f473844 100644 --- a/plugins/graph/graph/neighbors/GetNeighborNodes.js +++ b/plugins/graph/graph/neighbors/GetNeighborNodes.js @@ -1,10 +1,11 @@ -import UIDToObj from '../graphitem/UIDToObj.js'; +import UIDToObj from '../../graphitem/UIDToObj.js'; +import GetObjUID from '../../graphitem/GetObjUID.js'; var GetNeighborNodes = function (nodeGameObject, out) { if (out === undefined) { out = []; } - var nodeUID = this.getObjUID(nodeGameObject); + var nodeUID = GetObjUID(nodeGameObject); if (!nodeUID) { return out; } diff --git a/plugins/graph/graph/node/AddNode.js b/plugins/graph/graph/node/AddNode.js index 637a3c9f7f..c3e840ba55 100644 --- a/plugins/graph/graph/node/AddNode.js +++ b/plugins/graph/graph/node/AddNode.js @@ -1,4 +1,5 @@ -import GetGraphItem from '../graphitem/GetGraphItem.js'; +import GetGraphItem from '../../graphitem/GetGraphItem.js'; +import GetObjUID from '../../graphitem/GetObjUID.js'; var AddNode = function (gameObejct) { if (this.isNode(gameObejct)) { @@ -7,7 +8,7 @@ var AddNode = function (gameObejct) { GetGraphItem(gameObejct).setGraph(this); - var nodeUID = this.getObjUID(gameObejct); + var nodeUID = GetObjUID(gameObejct); this.graph.addNode(nodeUID); return this; diff --git a/plugins/graph/graph/node/GetAllNodes.js b/plugins/graph/graph/node/GetAllNodes.js index 1a6e7c6dcb..c36b8bd71e 100644 --- a/plugins/graph/graph/node/GetAllNodes.js +++ b/plugins/graph/graph/node/GetAllNodes.js @@ -1,4 +1,4 @@ -import UIDToObj from '../graphitem/UIDToObj.js'; +import UIDToObj from '../../graphitem/UIDToObj.js'; var GetAllNodes = function (out) { if (out === undefined) { diff --git a/plugins/graph/graph/node/GetNodesOfEdge.js b/plugins/graph/graph/node/GetNodesOfEdge.js index f5cc23b685..9ffd8c50ef 100644 --- a/plugins/graph/graph/node/GetNodesOfEdge.js +++ b/plugins/graph/graph/node/GetNodesOfEdge.js @@ -1,11 +1,12 @@ -import UIDListToObjList from '../graphitem/UIDListToObjList.js'; +import UIDListToObjList from '../../graphitem/UIDListToObjList.js'; +import GetObjUID from '../../graphitem/GetObjUID.js'; var GetNodesOfEdge = function (edgeGameObject, out) { if (out === undefined) { out = []; } - var edgeUID = this.getObjUID(edgeGameObject); + var edgeUID = GetObjUID(edgeGameObject); if (!this.graph.hasEdge(edgeUID)) { return out; } diff --git a/plugins/graph/graph/node/IsNode.js b/plugins/graph/graph/node/IsNode.js index e2e19bb998..e534db03da 100644 --- a/plugins/graph/graph/node/IsNode.js +++ b/plugins/graph/graph/node/IsNode.js @@ -1,6 +1,8 @@ +import GetObjUID from '../../graphitem/GetObjUID.js'; + var IsNode = function (gameObejct) { // uid or game object - var uid = this.getObjUID(gameObejct); + var uid = GetObjUID(gameObejct); return this.graph.hasNode(uid); } diff --git a/plugins/graph/graph/node/RemoveAllNodes.js b/plugins/graph/graph/node/RemoveAllNodes.js index c7c8e9153c..c850428362 100644 --- a/plugins/graph/graph/node/RemoveAllNodes.js +++ b/plugins/graph/graph/node/RemoveAllNodes.js @@ -1,5 +1,5 @@ -import UIDToObj from '../graphitem/UIDToObj.js'; -import GetGraphItem from '../graphitem/GetGraphItem.js'; +import UIDToObj from '../../graphitem/UIDToObj.js'; +import GetGraphItem from '../../graphitem/GetGraphItem.js'; var RemoveAllNodes = function (destroy) { for (var nodeUid in this.nodes) { diff --git a/plugins/graph/graph/node/RemoveNode.js b/plugins/graph/graph/node/RemoveNode.js index 487d6f7697..bbce47bb4b 100644 --- a/plugins/graph/graph/node/RemoveNode.js +++ b/plugins/graph/graph/node/RemoveNode.js @@ -1,4 +1,5 @@ -import GetGraphItem from '../graphitem/GetGraphItem.js'; +import GetGraphItem from '../../graphitem/GetGraphItem.js'; +import GetObjUID from '../../graphitem/GetObjUID.js'; var RemoveNode = function (nodeGameObject, destroy) { if (!this.isNode(nodeGameObject)) { @@ -10,7 +11,7 @@ var RemoveNode = function (nodeGameObject, destroy) { } // Remove node - var nodeUID = this.getObjUID(nodeGameObject); + var nodeUID = GetGraphItem(nodeGameObject); this.graph.dropNode(nodeUID); // Clear reference of graph diff --git a/plugins/graph/graph/graphitem/GetGraphItem.js b/plugins/graph/graphitem/GetGraphItem.js similarity index 100% rename from plugins/graph/graph/graphitem/GetGraphItem.js rename to plugins/graph/graphitem/GetGraphItem.js diff --git a/plugins/graph/graph/graphitem/GetObjUID.js b/plugins/graph/graphitem/GetObjUID.js similarity index 100% rename from plugins/graph/graph/graphitem/GetObjUID.js rename to plugins/graph/graphitem/GetObjUID.js diff --git a/plugins/graph/graph/graphitem/GraphItemData.js b/plugins/graph/graphitem/GraphItemData.js similarity index 93% rename from plugins/graph/graph/graphitem/GraphItemData.js rename to plugins/graph/graphitem/GraphItemData.js index 8289a8b2f3..dd3c1c2ef0 100644 --- a/plugins/graph/graph/graphitem/GraphItemData.js +++ b/plugins/graph/graphitem/GraphItemData.js @@ -1,4 +1,4 @@ -import ComponentBase from '../../../utils/componentbase/ComponentBase.js'; +import ComponentBase from '../../utils/componentbase/ComponentBase.js'; import ObjBank from './ObjBank.js'; const uidKey = ObjBank.uidKey; diff --git a/plugins/graph/graph/graphitem/IsUID.js b/plugins/graph/graphitem/IsUID.js similarity index 100% rename from plugins/graph/graph/graphitem/IsUID.js rename to plugins/graph/graphitem/IsUID.js diff --git a/plugins/graph/graph/graphitem/ObjBank.js b/plugins/graph/graphitem/ObjBank.js similarity index 75% rename from plugins/graph/graph/graphitem/ObjBank.js rename to plugins/graph/graphitem/ObjBank.js index 3c8ae56541..8b4696af1a 100644 --- a/plugins/graph/graph/graphitem/ObjBank.js +++ b/plugins/graph/graphitem/ObjBank.js @@ -1,4 +1,4 @@ -import Bank from '../../../bank.js'; +import Bank from '../../bank.js'; var ObjBank = new Bank({ uidKey: '$uid', diff --git a/plugins/graph/graph/graphitem/UIDListToObjList.js b/plugins/graph/graphitem/UIDListToObjList.js similarity index 100% rename from plugins/graph/graph/graphitem/UIDListToObjList.js rename to plugins/graph/graphitem/UIDListToObjList.js diff --git a/plugins/graph/graph/graphitem/UIDToObj.js b/plugins/graph/graphitem/UIDToObj.js similarity index 100% rename from plugins/graph/graph/graphitem/UIDToObj.js rename to plugins/graph/graphitem/UIDToObj.js diff --git a/plugins/graph/layout/elkjs/BuildGraphData.js b/plugins/graph/layout/elkjs/BuildGraphData.js index 8a6b4345ed..4de1c26846 100644 --- a/plugins/graph/layout/elkjs/BuildGraphData.js +++ b/plugins/graph/layout/elkjs/BuildGraphData.js @@ -1,9 +1,10 @@ +import UIDToObj from '../../graphitem/UIDToObj.js'; import { GetTopLeft } from '../../../utils/bounds/GetBounds.js'; var BuildGraphData = function (graph, config) { var nodes = []; graph.graph.forEachNode(function (uid) { - var nodeGameObject = graph.getObj(uid); + var nodeGameObject = UIDToObj(uid); if (!nodeGameObject) { return; }