• R/O
  • HTTP
  • SSH
  • HTTPS

AI004: コミット

サブプロジェクトAI004


コミットメタ情報

リビジョン0e5621a24677e4b286131effd81035a59261eca0 (tree)
日時2014-04-26 10:51:52
作者hikarupsp <hikarupsp@user...>
コミッターhikarupsp

ログメッセージ

自動追尾を再実装。

変更サマリ

差分

--- a/mgcanvas/index.html
+++ b/mgcanvas/index.html
@@ -23,7 +23,7 @@ onload = function() {
2323 var c = document.getElementById("mainCanvas");
2424 mgmain = new MGCanvas(c);
2525
26-
26+ /*
2727 mgmain.setGraph([[
2828 "A","B","C","D","E","F",
2929 ],[
@@ -35,7 +35,7 @@ onload = function() {
3535 ["A", "E"],
3636 ["A", "B"],
3737 ]]);
38-
38+ */
3939 /*
4040 mgmain.setGraph([[
4141 "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P",
@@ -137,7 +137,7 @@ onload = function() {
137137 <canvas id="mainCanvas" width="1024" height="768" style="border:1px solid #000000;"></canvas>
138138 <br />
139139 <button onclick="mgmain.bringToCenter();">Center</button>
140-<button onclick="mgmain.isFrozen = !mgmain.isFrozen;">Freeze</button>
140+<button onclick="mgmain.isPaused = !mgmain.isPaused;">Freeze</button>
141141 <button onclick="mgmain.zoomIn();">+</button>
142142 <button onclick="mgmain.zoomOut();">-</button>
143143 <button onclick="mgmain.moveViewRelative(0, -10);">↑</button>
--- a/mgcanvas/mgcanvas.js
+++ b/mgcanvas/mgcanvas.js
@@ -1,7 +1,3 @@
1-//文字列をキーとする。
2-
3-//まず、最も多数のエッジを持つノードを探す。
4-//それを起点にして、エッジをたどる。
51
62 function MGCanvas(canvasDOMObj){
73 var that = this;
@@ -10,7 +6,8 @@ function MGCanvas(canvasDOMObj){
106 this.tickPerSecond = 30;
117 this.tickCount = 0;
128 this.tickTimer = window.setInterval(function(){ that.tick(); }, 1000 / this.tickPerSecond);
13- this.isFrozen = false;
9+ this.isPaused = false;
10+ this.isEnabledAutomaticTracking = true;
1411 this.nodeList = new Array();
1512 this.edgeList = new Array();
1613 this.selectedNode = null;
@@ -60,6 +57,7 @@ function MGCanvas(canvasDOMObj){
6057 var edge = that.getEdgeAtPointP(p);
6158 that.selectEdge(edge);
6259 that.isMouseDown = true;
60+ that.isEnabledAutomaticTracking = false;
6361 };
6462 this.canvas.onmouseup = function (e){
6563 that.isMouseDown = false;
@@ -81,6 +79,12 @@ MGCanvas.prototype = {
8179 this.edgeList.push(new MGEdge(this, p[i][2], n(p[i][0]), n(p[i][1])));
8280 }
8381 },
82+ addNode: function(identifier, uuid){
83+
84+ },
85+ addEdge: function(identifier, uuid, nodeid){
86+
87+ },
8488 bringToCenter: function(){
8589 // 重心を求めて、それを表示オフセットに設定する
8690 var g = new Point2D(0, 0);
@@ -95,6 +99,8 @@ MGCanvas.prototype = {
9599
96100 this.positionOffset.x = -g.x;
97101 this.positionOffset.y = -g.y;
102+
103+ this.isEnabledAutomaticTracking = true;
98104 },
99105 zoomIn: function(){
100106 this.context.scale(2, 2);
@@ -108,10 +114,10 @@ MGCanvas.prototype = {
108114 this.positionOffset.x += -x;
109115 this.positionOffset.y += -y;
110116 },
111- /*
112117 bringInScreen: function(){
113118 //大きく外れていないときには動かさない
114119 var g = new Point2D(0, 0);
120+ var f = new Point2D(0, 0);
115121 var p;
116122 p = this.nodeList;
117123 for(var i = 0, iLen = p.length; i < iLen; i++){
@@ -120,16 +126,17 @@ MGCanvas.prototype = {
120126 }
121127 g.x /= p.length;
122128 g.y /= p.length;
129+ g.x += this.positionOffset.x;
130+ g.y += this.positionOffset.y;
123131 if( g.x < this.displayRect.origin.x / 2 ||
124132 g.x > -this.displayRect.origin.x / 2 ||
125133 g.y < this.displayRect.origin.y / 2 ||
126134 g.y > -this.displayRect.origin.x / 2){
127135
128- this.positionOffset.x = -g.x;
129- this.positionOffset.y = -g.y;
136+ this.positionOffset.x += -g.x;
137+ this.positionOffset.y += -g.y;
130138 }
131139 },
132- */
133140 tick: function(){
134141 var p;
135142 var t;
@@ -141,6 +148,15 @@ MGCanvas.prototype = {
141148 this.tickCount++;
142149
143150 //
151+ // AutomaticTracking
152+ //
153+
154+ if(this.isEnabledAutomaticTracking && (this.tickCount % 30 == 0)){
155+ this.bringInScreen();
156+ }
157+
158+
159+ //
144160 // View moving with mouse
145161 //
146162 if(this.isMouseDown){
@@ -150,7 +166,7 @@ MGCanvas.prototype = {
150166 );
151167 }
152168
153- if(!this.isFrozen){
169+ if(!this.isPaused){
154170 //
155171 // Check
156172 //
旧リポジトリブラウザで表示