• R/O
  • HTTP
  • SSH
  • HTTPS

AI004: コミット

サブプロジェクトAI004


コミットメタ情報

リビジョン84a566b0d4a930b53d0da3297a10dbac20a5e24d (tree)
日時2014-05-05 19:18:19
作者hikarupsp <hikarupsp@user...>
コミッターhikarupsp

ログメッセージ

エッジの同期を追加。まだ不完全。

変更サマリ

差分

--- a/memdb/memdb.js
+++ b/memdb/memdb.js
@@ -7,11 +7,13 @@ function MemoryDB(syncPHPURL){
77 this.root = new Array();
88 //
99 this.nodeList = new Array();
10+ this.edgeList = new Array();
1011 //
1112 this.syncPHPURL = syncPHPURL;
1213 this.isEnabledNetDB = true;
1314 //
14- this.callback_updatedNode = null; // function(nodeinstance){};
15+ this.callback_updatedNode = null; // function(nodeInstance){};
16+ this.callback_updatedEdge = null; // function(edgeInstance){};
1517 }
1618 MemoryDB.prototype = {
1719 UUID_Null: "00000000-0000-0000-0000-000000000000",
@@ -25,20 +27,29 @@ MemoryDB.prototype = {
2527 // XMLHttpRequest オブジェクトを作成
2628 rq = new XMLHttpRequest();
2729 }catch(e){}
30+ if(rq){
31+ return rq;
32+ }
2833 // Internet Explorer
2934 try{
3035 rq = new ActiveXObject('MSXML2.XMLHTTP.6.0');
3136 }catch(e){}
37+ if(rq){
38+ return rq;
39+ }
3240 try{
3341 rq = new ActiveXObject('MSXML2.XMLHTTP.3.0');
3442 }catch(e){}
43+ if(rq){
44+ return rq;
45+ }
3546 try{
3647 rq = new ActiveXObject('MSXML2.XMLHTTP');
3748 }catch(e){}
38- if(rq == null){
39- return null;
49+ if(rq){
50+ return rq;
4051 }
41- return rq;
52+ return null;
4253 },
4354 requestObjectDisableCache: function(rq){
4455 //call after open request.
@@ -75,14 +86,18 @@ MemoryDB.prototype = {
7586 syncDB: function(){
7687 // MySQLと同期
7788 // 定期的に呼び出されることを想定
89+ this.syncDBNode();
90+ this.syncDBEdge();
91+ },
92+ syncDBNode: function(){
7893 var r, a, d;
79- if(this.root.length == 0){
94+ if(this.nodeList.length == 0){
8095 // 初回同期時は全て取得
8196 r = this.sendRequestSync("GET", this.syncPHPURL + "?action=getallnode", null);
8297 } else{
8398 // 差分のみを取得
8499 d = this.getNodeFromUUID(this.UUID_Node_MemoryDBNetworkTimestamp).identifier;
85- r = this.sendRequestSync("GET", this.syncPHPURL + "?action=getnodemod&t=" + d, null);
100+ r = this.sendRequestSync("GET", this.syncPHPURL + "?action=getallnodemod&t=" + d, null);
86101 }
87102 a = r.split("\n");
88103 for(var i = 0, iLen = a.length; i < iLen; i++){
@@ -97,7 +112,40 @@ MemoryDB.prototype = {
97112 }
98113 this.updateNodeInternal(d[2], d[1], d[0]);
99114 }
100- //console.log(this.root);
115+ },
116+ syncDBEdge: function(){
117+ var r, a, d;
118+ if(this.edgeList.length == 0){
119+ // 初回同期時は全て取得
120+ r = this.sendRequestSync("GET", this.syncPHPURL + "?action=getalledge", null);
121+ } else{
122+ // 差分のみを取得
123+ /*
124+ d = this.getNodeFromUUID(this.UUID_Node_MemoryDBNetworkTimestamp).identifier;
125+ r = this.sendRequestSync("GET", this.syncPHPURL + "?action=getallnodemod&t=" + d, null);
126+ */
127+ return;
128+ }
129+ a = r.split("\n");
130+ for(var i = 0, iLen = a.length; i < iLen; i++){
131+ try{
132+ d = eval(a[i]);
133+ } catch(e){
134+ console.log(i + ": " + e + "\n");
135+ continue;
136+ }
137+ if(d === undefined){
138+ continue;
139+ }
140+ if( d[0] != this.UUID_Node_MemoryDBNetworkTimestamp &&
141+ d[0] != this.UUID_Node_MemoryDBNetworkResponseCode){
142+ // edge data
143+ this.updateEdgeInternal(d[2], d[3], d[1], d[0]);
144+ } else{
145+ // node data
146+ this.updateNodeInternal(d[2], d[1], d[0]);
147+ }
148+ }
101149 },
102150 updateNode: function(ident, tid, nid){
103151 // 該当タグのデータを書き換え、もしくは新規作成する。
@@ -151,6 +199,61 @@ MemoryDB.prototype = {
151199 this.callback_updatedNode(t);
152200 }
153201 },
202+ updateEdge: function(nid0, nid1, tid, eid){
203+ // 該当タグのデータを書き換え、もしくは新規作成する。
204+ // 可能であればネットワークに反映する
205+ // eid(nodeid)は省略可能で、省略時は新たなUUIDが自動的に付与される
206+ // tid(typeid)も省略可能で、省略時はNullUUIDが付与される
207+ // 戻り値はMemoryDBEdgeTagインスタンス
208+ // エラー発生時はundefinedを返す。
209+ this.updateEdgeInternal(nid0, nid1, tid, eid, true);
210+ },
211+ updateEdgeInternal: function(nid0, nid1, tid, eid, enableSync){
212+ // 基本的にローカルデータのみ変更
213+ // enableSync == trueでネットワーク同期する
214+ var t, s, r;
215+ if(!tid){
216+ tid = this.UUID_Null;
217+ }
218+ if(!eid){
219+ eid = this.createUUID();
220+ }
221+ // 存在確認
222+ t = this.getEdgeFromUUID(eid);
223+ if(t){
224+ // 変更
225+ /*
226+ t.typeid = tid;
227+ t.identifier = ident;
228+ if(enableSync && this.isEnabledNetDB){
229+ s = this.syncPHPURL + "?action=updatenode";
230+ s += "&nid=" + encodeURIComponent(nid);
231+ s += "&tid=" + encodeURIComponent(tid);
232+ s += "&ident=" + encodeURIComponent(ident);
233+ r = this.sendRequestSync("GET", s, null);
234+ //console.log(r);
235+ }
236+ */
237+ return;
238+ } else{
239+ // 新規作成
240+ t = new MemoryDBEdgeTag(eid, tid, nid0, nid1);
241+ this.root.push(t);
242+ this.edgeList.push(t);
243+ if(enableSync && this.isEnabledNetDB){
244+ s = this.syncPHPURL + "?action=addedge";
245+ s += "&eid=" + encodeURIComponent(eid);
246+ s += "&tid=" + encodeURIComponent(tid);
247+ s += "&nid0=" + encodeURIComponent(nid0);
248+ s += "&nid1=" + encodeURIComponent(nid1);
249+ r = this.sendRequestSync("GET", s, null);
250+ console.log(r);
251+ }
252+ }
253+ if(this.callback_updatedEdge){
254+ this.callback_updatedEdge(t);
255+ }
256+ },
154257 createUUID: function(){
155258 var f = this.createUUIDSub;
156259 return (f() + f() + "-" + f() + "-" + f() + "-" + f() + "-" + f() + f() + f());
@@ -161,6 +264,9 @@ MemoryDB.prototype = {
161264 getNodeFromUUID: function(nodeid){
162265 return this.nodeList.isIncluded(nodeid, function(a, b){ return a.nodeid == b; });
163266 },
267+ getEdgeFromUUID: function(edgeid){
268+ return this.edgeList.isIncluded(edgeid, function(a, b){ return a.edgeid == b; });
269+ },
164270 }
165271
166272 function MemoryDBNodeTag(nodeid, typeid, identifier){
@@ -173,8 +279,11 @@ MemoryDBNodeTag.prototype = {
173279
174280 }
175281
176-function MemoryDBEdgeTag(typeUUIDStr){
177- this.uuid = null;
282+function MemoryDBEdgeTag(edgeid, typeid, nodeid0, nodeid1){
283+ this.edgeid = edgeid;
284+ this.typeid = typeid;
285+ this.nodeid0 = nodeid0;
286+ this.nodeid1 = nodeid1;
178287 }
179288 MemoryDBEdgeTag.prototype = {
180289
--- a/memdb/memdb.php
+++ b/memdb/memdb.php
@@ -47,7 +47,7 @@ insert into Node (
4747 define("QUERY_ADD_Node_TYPES", "sssi");
4848 //
4949 define("QUERY_ADD_Edge", "
50-insert into Node (
50+insert into Edge (
5151 edgeid, typeid, nodeid0, nodeid1, modtimestamp
5252 ) values (
5353 unhex(replace(?, '-', '')), unhex(replace(?, '-', '')), unhex(replace(?, '-', '')), unhex(replace(?, '-', '')), ?
@@ -63,10 +63,18 @@ WHERE
6363 ");
6464 define("QUERY_UPDATE_Node_TYPES", "ssis");
6565 //
66-
66+define("QUERY_UPDATE_Edge", "
67+UPDATE Edge SET
68+ typeid=unhex(replace(?, '-', '')), nodeid0=unhex(replace(?, '-', '')), nodeid1=unhex(replace(?, '-', '')), modtimestamp=?
69+WHERE
70+ edgeid=unhex(replace(?, '-', ''))
71+");
72+define("QUERY_UPDATE_Edge_TYPES", "sssis");
73+//
6774 define("QUERY_SELECT_ALL_Node", "select hex(nodeid), hex(typeid), identifier from Node");
6875 define("QUERY_SELECT_ALL_Node_With_modtimestamp", "select hex(nodeid), hex(typeid), identifier, modtimestamp from Node");
6976 define("QUERY_SELECT_ALL_Edge", "select hex(edgeid), hex(typeid), hex(nodeid0), hex(nodeid1) from Edge");
77+define("QUERY_SELECT_ALL_Edge_With_modtimestamp", "select hex(edgeid), hex(typeid), hex(nodeid0), hex(nodeid1), modtimestamp from Edge");
7078
7179 define("QUERY_SELECT_modified_Node", "select hex(nodeid), hex(typeid), identifier from Node WHERE modtimestamp>?");
7280 define("QUERY_SELECT_modified_Node_TYPES", "i");
@@ -104,7 +112,30 @@ if(isset($_GET['action'])){
104112 // put timestamp tag
105113 echoMemoryDBNetworkTimestamp();
106114 exit();
107- } else if(strcmp($action, 'getnodemod') == 0){
115+ } else if(strcmp($action, 'getalledge') == 0){
116+ $stmt = $db->prepare(QUERY_SELECT_ALL_Edge);
117+ $stmt->execute();
118+ //
119+ $stmt->store_result();
120+ if($stmt->errno != 0){
121+ exitWithResponseCode("A0518702-C90C-4785-B5EA-1A213DD0205B");
122+ }
123+
124+ $stmt->bind_result($uuid, $typeid, $nid0, $nid1);
125+ while($stmt->fetch()){
126+ echoEdge(
127+ getFormedUUIDString($uuid),
128+ getFormedUUIDString($typeid),
129+ getFormedUUIDString($nid0),
130+ getFormedUUIDString($nid1)
131+ );
132+ echo(PHP_EOL);
133+ }
134+ $stmt->close();
135+ // put timestamp tag
136+ echoMemoryDBNetworkTimestamp();
137+ exit();
138+ } else if(strcmp($action, 'getallnodemod') == 0){
108139 if(isset($_GET['t'])){
109140 $ts = $_GET['t'];
110141 } else{
@@ -154,6 +185,29 @@ if(isset($_GET['action'])){
154185 echo($stmt->num_rows);
155186 $stmt->close();
156187 exit(" OK " . getTimeStampMs());
188+ } else if(strcmp($action, 'viewalledge') == 0){
189+ $stmt = $db->prepare(QUERY_SELECT_ALL_Edge_With_modtimestamp);
190+ $stmt->execute();
191+ //
192+ $stmt->store_result();
193+ if($stmt->errno != 0){
194+ exitWithResponseCode("A0518702-C90C-4785-B5EA-1A213DD0205B");
195+ }
196+
197+ $stmt->bind_result($uuid, $typeid, $nid0, $nid1, $mts);
198+ while($stmt->fetch()){
199+ echoEdge(
200+ getFormedUUIDString($uuid),
201+ getFormedUUIDString($typeid),
202+ getFormedUUIDString($nid0),
203+ getFormedUUIDString($nid1)
204+ );
205+ echo(' @' . $mts);
206+ echo("<br />");
207+ }
208+ echo($stmt->num_rows);
209+ $stmt->close();
210+ exit(" OK " . getTimeStampMs());
157211 } else if(strcmp($action, 'addnode') == 0){
158212 if(isset($_GET['nid'])){
159213 $nodeid = $_GET['nid'];
@@ -210,6 +264,72 @@ if(isset($_GET['action'])){
210264 }
211265 $stmt->close();
212266 exitWithResponseCode("cea95615-649c-4837-9e24-0c968fa57647", "OK");
267+ } else if(strcmp($action, 'addedge') == 0){
268+ if(isset($_GET['eid'])){
269+ $edgeid = $_GET['eid'];
270+ } else{
271+ exitWithResponseCode("A0518702-C90C-4785-B5EA-1A213DD0205B", "edgeid needed.");
272+ }
273+ if(isset($_GET['tid'])){
274+ $typeid = $_GET['tid'];
275+ } else{
276+ exitWithResponseCode("A0518702-C90C-4785-B5EA-1A213DD0205B", "typeid needed.");
277+ }
278+ if(isset($_GET['nid0'])){
279+ $nid0 = $_GET['nid0'];
280+ } else{
281+ exitWithResponseCode("A0518702-C90C-4785-B5EA-1A213DD0205B", "nodeid0 needed.");
282+ }
283+ if(isset($_GET['nid1'])){
284+ $nid1 = $_GET['nid1'];
285+ } else{
286+ exitWithResponseCode("A0518702-C90C-4785-B5EA-1A213DD0205B", "nodeid1 needed.");
287+ }
288+
289+ $stmt = $db->prepare(QUERY_ADD_Edge);
290+ $mts = getTimeStampMs();
291+ $stmt->bind_param(QUERY_ADD_Edge_TYPES, $edgeid, $typeid, $nid0, $nid1, $mts);
292+ $stmt->execute();
293+ //
294+ $stmt->store_result();
295+ if($stmt->errno != 0){
296+ exitWithResponseCode("A0518702-C90C-4785-B5EA-1A213DD0205B", mysqli_error($db));
297+ }
298+ $stmt->close();
299+ exitWithResponseCode("cea95615-649c-4837-9e24-0c968fa57647", "OK");
300+ } else if(strcmp($action, 'updateedge') == 0){
301+ if(isset($_GET['eid'])){
302+ $edgeid = $_GET['eid'];
303+ } else{
304+ exitWithResponseCode("A0518702-C90C-4785-B5EA-1A213DD0205B", "edgeid needed.");
305+ }
306+ if(isset($_GET['tid'])){
307+ $typeid = $_GET['tid'];
308+ } else{
309+ exitWithResponseCode("A0518702-C90C-4785-B5EA-1A213DD0205B", "typeid needed.");
310+ }
311+ if(isset($_GET['nid0'])){
312+ $nid0 = $_GET['nid0'];
313+ } else{
314+ exitWithResponseCode("A0518702-C90C-4785-B5EA-1A213DD0205B", "nodeid0 needed.");
315+ }
316+ if(isset($_GET['nid1'])){
317+ $nid1 = $_GET['nid1'];
318+ } else{
319+ exitWithResponseCode("A0518702-C90C-4785-B5EA-1A213DD0205B", "nodeid1 needed.");
320+ }
321+
322+ $stmt = $db->prepare(QUERY_UPDATE_Edge);
323+ $mts = getTimeStampMs();
324+ $stmt->bind_param(QUERY_UPDATE_Edge_TYPES, $typeid, $nid0, $nid1, $mts, $edgeid);
325+ $stmt->execute();
326+ //
327+ $stmt->store_result();
328+ if($stmt->errno != 0){
329+ exitWithResponseCode("A0518702-C90C-4785-B5EA-1A213DD0205B", mysqli_error($db));
330+ }
331+ $stmt->close();
332+ exitWithResponseCode("cea95615-649c-4837-9e24-0c968fa57647", "OK");
213333 }
214334 }
215335
@@ -236,6 +356,11 @@ function echoNode($nid, $tid, $ident)
236356 echo('["' . $nid .'","' . $tid .'","' . $ident . '"]');
237357 }
238358
359+function echoEdge($eid, $tid, $nid0, $nid1)
360+{
361+ echo('["' . $eid .'","' . $tid .'","' . $nid0 .'","' . $nid1 . '"]');
362+}
363+
239364 function connectDB()
240365 {
241366 $db = new mysqli('localhost', DATABASE_USER, DATABASE_PWD, DATABASE_NAME);
--- a/mgcanvas/index.html
+++ b/mgcanvas/index.html
@@ -21,8 +21,52 @@ var mgmain;
2121 var memdb;
2222
2323 onload = function() {
24+ var that = this;
25+ var DOM_Node0ID = document.getElementById("nidBox0");
26+ var DOM_Node0Ident = document.getElementById("identBox0");
27+ var DOM_Node1ID = document.getElementById("nidBox1");
28+ var DOM_Node1Ident = document.getElementById("identBox1");
29+ var DOM_EdgeID = document.getElementById("eidBox");
30+ var DOM_EdgeTypeID = document.getElementById("etidBox");
31+
2432 memdb = new MemoryDB("./../memdb/memdb.php");
2533 mgmain = new MGCanvas(document.getElementById("mainCanvas"));
34+ document.getElementById("updateButton0").onclick = function(){
35+ mgmain.setIdentifierForSelectedNode(DOM_Node0Ident.value);
36+ };
37+ document.getElementById("updateButton1").onclick = function(){
38+ mgmain.setIdentifierForSelectedNode(DOM_Node1Ident.value, true);
39+ };
40+ document.getElementById("connectNodesButton").onclick = function(){
41+ memdb.updateEdge(DOM_Node0ID.value, DOM_Node1ID.value);
42+ };
43+ mgmain.callback_selectedNodeChanged = function(newNode){
44+ if(newNode){
45+ DOM_Node0ID.value = newNode.nodeid;
46+ DOM_Node0Ident.value = newNode.identifier;
47+ } else{
48+ DOM_Node0ID.value = "not selected";
49+ DOM_Node0Ident.value = "";
50+ }
51+ };
52+ mgmain.callback_selectedNodeDestinationChanged = function(newNode){
53+ if(newNode){
54+ DOM_Node1ID.value = newNode.nodeid;
55+ DOM_Node1Ident.value = newNode.identifier;
56+ } else{
57+ DOM_Node1ID.value = "not selected";
58+ DOM_Node1Ident.value = "";
59+ }
60+ };
61+ mgmain.callback_selectedEdgeChanged = function(newEdge){
62+ if(newEdge){
63+ DOM_EdgeID.value = newEdge.edgeid;
64+ DOM_EdgeTypeID.value = newEdge.typeid;
65+ } else{
66+ DOM_EdgeID.value = "not selected";
67+ DOM_EdgeTypeID.value = "";
68+ }
69+ };
2670 mgmain.setSourceMemoryDB(memdb);
2771 }
2872 </script>
@@ -30,7 +74,7 @@ onload = function() {
3074 <body>
3175 <h1>Mind Graph Canvas</h1>
3276 <canvas id="mainCanvas" width="1024" height="768" style="border:1px solid #000000;"></canvas>
33-<br />
77+<h3>Control</h3>
3478 <button onclick="mgmain.bringToCenter();">Center</button>
3579 <button onclick="mgmain.isPaused = !mgmain.isPaused;">Freeze</button>
3680 <button onclick="mgmain.zoomIn();">+</button>
@@ -39,11 +83,17 @@ onload = function() {
3983 <button onclick="mgmain.moveViewRelative(0, 10);">↓</button>
4084 <button onclick="mgmain.moveViewRelative(-10, 0);">←</button>
4185 <button onclick="mgmain.moveViewRelative(10, 0);">→</button>
42-<br />
43-identifier:<input id="identBox" type="text"></input>
44-<br />
45-<button onclick="mgmain.setIdentifierForSelectedNode(getElementById('identBox').value);">setNodeIdent</button>
46-<button onclick="memdb.updateNode(getElementById('identBox').value);">addNode</button>
86+<h3>Node0</h3>
87+id:<input disabled id="nidBox0" type="text" size="50"></input>
88+identifier:<input id="identBox0" type="text" size="25"></input>
89+<button id="updateButton0">updateNode</button>
90+<h3>Node1</h3>
91+id:<input disabled id="nidBox1" type="text" size="50"></input>
92+identifier:<input id="identBox1" type="text" size="25"></input>
93+<button id="updateButton1">updateNode</button>
94+<h3>Edge</h3>
95+id :<input disabled id="eidBox" type="text" size="50"></input>
96+type :<input disabled id="etidBox" type="text" size="50"></input><button id="connectNodesButton">connectNodes</button>
4797
4898 </body>
4999 </html>
\ No newline at end of file
--- a/mgcanvas/mgcanvas.js
+++ b/mgcanvas/mgcanvas.js
@@ -1,22 +1,31 @@
11
22 function MGCanvas(canvasDOMObj){
33 var that = this;
4-
4+ //
55 this.initGraphicContext(canvasDOMObj);
6+ //
67 this.tickPerSecond = 30;
78 this.tickCount = 0;
89 this.tickTimer = window.setInterval(function(){ that.tick(); }, 1000 / this.tickPerSecond);
910 this.isPaused = false;
1011 this.isEnabledAutomaticTracking = true;
12+ //
1113 this.nodeList = new Array();
1214 this.edgeList = new Array();
15+ //
1316 this.selectedNode = null;
17+ this.callback_selectedNodeChanged = null; //function(newNodeInstance){};
18+ //
19+ this.selectedNodeDestination = null;
20+ this.callback_selectedNodeDestinationChanged = null; //function(newNodeInstance){};
21+ //
1422 this.selectedEdge = null;
23+ this.callback_selectedEdgeChanged = null; //function(newEdgeInstance){};
24+ //
1525 this.srcMemoryDB = null;
1626 this.srcMemoryDBSyncPerTick = 60;
1727 this.srcMemoryDBSyncCount = this.srcMemoryDBSyncPerTick;
18-
19- var that = this;
28+
2029 window.addEventListener('keydown', function(event){
2130 switch(event.keyCode){
2231 case 37: //左カーソル
@@ -56,7 +65,7 @@ function MGCanvas(canvasDOMObj){
5665 var p = that.convertPointToGraphLayerFromCanvasLayerP(that.lastMousePosition);
5766 //console.log(p.x + "," + p.y);
5867 var node = that.getNodeAtPointP(p);
59- that.selectNode(node);
68+ that.selectNode(node, e.shiftKey);
6069 var edge = that.getEdgeAtPointP(p);
6170 that.selectEdge(edge);
6271 that.isMouseDown = true;
@@ -92,12 +101,32 @@ MGCanvas.prototype = {
92101 // 新規追加
93102 n = new MGNode(that, t.identifier);
94103 n.nodeid = t.nodeid;
104+ n.typeid = t.typeid;
95105 that.nodeList.push(n);
96106 } else{
97107 // 更新
98108 n.identifier = t.identifier;
109+ n.typeid = t.typeid;
99110 }
100- }
111+ };
112+ mdb.callback_updatedEdge = function(t){
113+ var e;
114+ var n = function(nid){ return that.nodeList.isIncluded(nid, function(a, b){ return (a.nodeid == b); }); };
115+ e = that.edgeList.isIncluded(t.edgeid, function(a, b){ return a.edgeid == b; });
116+ if(!e){
117+ // 新規追加
118+ e = new MGEdge(that, "", n(t.nodeid0), n(t.nodeid1));
119+ e.edgeid = t.edgeid;
120+ e.typeid = t.typeid;
121+ that.edgeList.push(e);
122+ } else{
123+ // 更新
124+ // e.identifier
125+ e.node0 = n(t.nodeid0);
126+ e.node1 = n(t.nodeid1);
127+ e.typeid = t.typeid;
128+ }
129+ };
101130 },
102131 bringToCenter: function(){
103132 // 重心を求めて、それを表示オフセットに設定する
@@ -382,7 +411,7 @@ MGCanvas.prototype = {
382411 this.context.translate(w, h);
383412 this.displayRect = new Rectangle(-w, -h, this.canvas.width, this.canvas.height);
384413 this.currentScale = 1;
385- this.zoomOut();
414+ //this.zoomOut();
386415 this.positionOffset = new Point2D(0, 0);
387416 },
388417 convertPointToGraphLayerFromCanvasLayerP: function(pCanvas){
@@ -422,16 +451,43 @@ MGCanvas.prototype = {
422451 }
423452 return null;
424453 },
425- selectNode: function(node){
426- if(this.selectedNode){
427- this.selectedNode.isSelected = false;
428- }
429- if(node){
430- node.isSelected = true;
454+ selectNode: function(node, destNode){
455+ if(!destNode){
456+ // 通常のノード選択
457+ if(this.selectedNode == node){
458+ return;
459+ }
460+ if(this.selectedNode){
461+ this.selectedNode.isSelected = false;
462+ }
463+ if(node){
464+ node.isSelected = true;
465+ }
466+ this.selectedNode = node;
467+ if(this.callback_selectedNodeChanged){
468+ this.callback_selectedNodeChanged(this.selectedNode);
469+ }
470+ } else{
471+ // 接続先のノード選択(Shiftキーを押しながら)
472+ if(this.selectedNodeDestination == node){
473+ return;
474+ }
475+ if(this.selectedNodeDestination){
476+ this.selectedNodeDestination.isSelected = false;
477+ }
478+ if(node){
479+ node.isSelected = true;
480+ }
481+ this.selectedNodeDestination = node;
482+ if(this.callback_selectedNodeDestinationChanged){
483+ this.callback_selectedNodeDestinationChanged(this.selectedNodeDestination);
484+ }
431485 }
432- this.selectedNode = node;
433486 },
434487 selectEdge: function(edge){
488+ if(this.selectedEdge == edge){
489+ return;
490+ }
435491 if(this.selectedEdge){
436492 this.selectedEdge.isSelected = false;
437493 }
@@ -439,13 +495,26 @@ MGCanvas.prototype = {
439495 edge.isSelected = true;
440496 }
441497 this.selectedEdge = edge;
498+ if(this.callback_selectedEdgeChanged){
499+ this.callback_selectedEdgeChanged(this.selectedEdge);
500+ }
442501 },
443- setIdentifierForSelectedNode: function(str){
444- if(this.selectedNode){
445- if(this.srcMemoryDB){
446- this.srcMemoryDB.updateNode(str, this.selectedNode.typeid, this.selectedNode.nodeid);
447- } else{
448- this.selectedNode.identifier = str;
502+ setIdentifierForSelectedNode: function(str, destNode){
503+ if(!destNode){
504+ if(this.selectedNode){
505+ if(this.srcMemoryDB){
506+ this.srcMemoryDB.updateNode(str, this.selectedNode.typeid, this.selectedNode.nodeid);
507+ } else{
508+ this.selectedNode.identifier = str;
509+ }
510+ }
511+ } else{
512+ if(this.selectedNodeDestination){
513+ if(this.srcMemoryDB){
514+ this.srcMemoryDB.updateNode(str, this.selectedNodeDestination.typeid, this.selectedNodeDestination.nodeid);
515+ } else{
516+ this.selectedNodeDestination.identifier = str;
517+ }
449518 }
450519 }
451520 },
@@ -545,9 +614,14 @@ MGNode.prototype = {
545614
546615 function MGEdge(env, identifier, node0, node1){
547616 this.env = env;
617+ //
548618 this.identifier = identifier;
549619 this.node0 = node0;
550620 this.node1 = node1;
621+ //
622+ this.edgeid = null;
623+ this.typeid = null;
624+ //
551625 this.freeLength = 250;
552626 //
553627 this.strokeStyle = "rgba(0, 0, 0, 0.5)";
@@ -563,8 +637,9 @@ MGEdge.prototype = {
563637 this.env.context.strokeStyle = this.strokeStyle;
564638 }
565639 if(this.node0 && this.node1){
566- this.drawCurvedLineP(this.node0.position, this.node1.position);
567- this.env.strokeRect(this.centerPoint.x - 8, this.centerPoint.y - 8, 16, 16);
640+ //this.drawCurvedLineP(this.node0.position, this.node1.position);
641+ this.env.drawLineP(this.node0.position, this.node1.position)
642+ //this.env.strokeRect(this.centerPoint.x - 8, this.centerPoint.y - 8, 16, 16);
568643 if(this.identifier){
569644 this.env.drawText(this.identifier.toString(), this.centerPoint.x, this.centerPoint.y);
570645 }
旧リポジトリブラウザで表示