Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
tianyazhichiC
algorithm-visualizer
提交
004d3e58
A
algorithm-visualizer
项目概览
tianyazhichiC
/
algorithm-visualizer
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
algorithm-visualizer
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
004d3e58
编写于
5月 20, 2016
作者:
J
Jason Park
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix some bugs
上级
05876b54
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
97 addition
and
49 deletion
+97
-49
css/stylesheet.css
css/stylesheet.css
+5
-0
js/module/array2d.js
js/module/array2d.js
+63
-46
js/module/graph.js
js/module/graph.js
+2
-2
js/script.js
js/script.js
+15
-1
js/tracer.js
js/tracer.js
+12
-0
未找到文件。
css/stylesheet.css
浏览文件 @
004d3e58
...
...
@@ -234,6 +234,11 @@ pre {
background
:
rgba
(
120
,
0
,
0
,
.8
);
}
.mtbl-wrapper
{
width
:
100%
;
height
:
100%
;
}
.mtbl-table
{
display
:
inline-table
;
color
:
white
;
...
...
js/module/array2d.js
浏览文件 @
004d3e58
...
...
@@ -3,7 +3,6 @@ var $table = null;
function
Array2DTracer
(
module
)
{
if
(
Tracer
.
call
(
this
,
module
||
Array2DTracer
))
{
initTable
();
initNavigator
(
this
);
return
true
;
}
return
false
;
...
...
@@ -44,12 +43,20 @@ Array2DTracer.prototype.createRandomData = function (N, M, min, max) {
// Override
Array2DTracer
.
prototype
.
setData
=
function
(
D
)
{
this
.
D
=
D
;
if
(
Tracer
.
prototype
.
setData
.
call
(
this
,
arguments
))
return
true
;
this
.
viewX
=
this
.
viewY
=
0
;
this
.
paddingH
=
6
;
this
.
paddingV
=
3
;
this
.
fontSize
=
16
;
if
(
Tracer
.
prototype
.
setData
.
call
(
this
,
arguments
))
{
$
(
'
.mtbl-row
'
).
each
(
function
(
i
)
{
$
(
this
).
children
().
each
(
function
(
j
)
{
$
(
this
).
text
(
D
[
i
][
j
]);
});
});
return
true
;
}
$table
.
empty
();
for
(
var
i
=
0
;
i
<
D
.
length
;
i
++
)
{
var
$row
=
$
(
'
<div class="mtbl-row">
'
);
...
...
@@ -167,8 +174,8 @@ Array2DTracer.prototype.processStep = function (step, options) {
Array2DTracer
.
prototype
.
getCellCss
=
function
()
{
return
{
padding
:
this
.
paddingV
+
'
px
'
+
this
.
paddingH
+
'
px
'
,
'
font-size
'
:
this
.
fontSize
padding
:
this
.
paddingV
.
toFixed
(
1
)
+
'
px
'
+
this
.
paddingH
.
toFixed
(
1
)
+
'
px
'
,
'
font-size
'
:
this
.
fontSize
.
toFixed
(
1
)
+
'
px
'
};
};
...
...
@@ -198,48 +205,58 @@ Array2DTracer.prototype.prevStep = function () {
this
.
step
(
finalIndex
);
};
var
initTable
=
function
()
{
$
(
'
.module_container
'
).
empty
();
$table
=
$
(
'
<div class="mtbl-table">
'
);
$
(
'
.module_container
'
).
append
(
$table
);
// Override
Array2DTracer
.
prototype
.
mousedown
=
function
(
e
)
{
Tracer
.
prototype
.
mousedown
.
call
(
this
,
e
);
this
.
dragX
=
e
.
pageX
;
this
.
dragY
=
e
.
pageY
;
this
.
dragging
=
true
;
};
var
initNavigator
=
function
(
tracer
)
{
var
x
,
y
,
dragging
=
false
;
var
$parent
=
$table
.
parent
();
$parent
.
mousedown
(
function
(
e
)
{
x
=
e
.
pageX
;
y
=
e
.
pageY
;
dragging
=
true
;
});
$parent
.
mousemove
(
function
(
e
)
{
if
(
dragging
)
{
tracer
.
viewX
+=
e
.
pageX
-
x
;
tracer
.
viewY
+=
e
.
pageY
-
y
;
x
=
e
.
pageX
;
y
=
e
.
pageY
;
tracer
.
refresh
();
}
});
$
(
document
).
mouseup
(
function
(
e
)
{
dragging
=
false
;
});
$parent
.
bind
(
'
DOMMouseScroll mousewheel
'
,
function
(
e
,
delta
)
{
e
=
e
.
originalEvent
;
var
delta
=
(
e
.
wheelDelta
!==
undefined
&&
e
.
wheelDelta
)
||
(
e
.
detail
!==
undefined
&&
-
e
.
detail
);
var
weight
=
1.01
;
var
ratio
=
delta
>
0
?
1
/
weight
:
weight
;
if
(
tracer
.
fontSize
<
8
&&
ratio
<
1
)
return
false
;
if
(
tracer
.
fontSize
>
36
&&
ratio
>
1
)
return
false
;
tracer
.
paddingV
*=
ratio
;
tracer
.
paddingH
*=
ratio
;
tracer
.
fontSize
*=
ratio
;
$
(
'
.mtbl-cell
'
).
css
(
tracer
.
getCellCss
());
tracer
.
refresh
();
e
.
preventDefault
();
});
// Override
Array2DTracer
.
prototype
.
mousemove
=
function
(
e
)
{
Tracer
.
prototype
.
mousemove
.
call
(
this
,
e
);
if
(
this
.
dragging
)
{
this
.
viewX
+=
e
.
pageX
-
this
.
dragX
;
this
.
viewY
+=
e
.
pageY
-
this
.
dragY
;
this
.
dragX
=
e
.
pageX
;
this
.
dragY
=
e
.
pageY
;
this
.
refresh
();
}
};
// Override
Array2DTracer
.
prototype
.
mouseup
=
function
(
e
)
{
Tracer
.
prototype
.
mouseup
.
call
(
this
,
e
);
this
.
dragging
=
false
;
};
// Override
Array2DTracer
.
prototype
.
mousewheel
=
function
(
e
)
{
Tracer
.
prototype
.
mousewheel
.
call
(
this
,
e
);
e
.
preventDefault
();
e
=
e
.
originalEvent
;
var
delta
=
(
e
.
wheelDelta
!==
undefined
&&
e
.
wheelDelta
)
||
(
e
.
detail
!==
undefined
&&
-
e
.
detail
);
var
weight
=
1.01
;
var
ratio
=
delta
>
0
?
1
/
weight
:
weight
;
if
(
this
.
fontSize
<
4
&&
ratio
<
1
)
return
;
if
(
this
.
fontSize
>
40
&&
ratio
>
1
)
return
;
this
.
paddingV
*=
ratio
;
this
.
paddingH
*=
ratio
;
this
.
fontSize
*=
ratio
;
$
(
'
.mtbl-cell
'
).
css
(
this
.
getCellCss
());
this
.
refresh
();
};
var
initTable
=
function
()
{
$module_container
.
empty
();
$table
=
$
(
'
<div class="mtbl-table">
'
);
$module_container
.
append
(
$table
);
};
var
paintColor
=
function
(
sx
,
sy
,
ex
,
ey
,
colorClass
,
addClass
)
{
...
...
@@ -254,7 +271,7 @@ var paintColor = function (sx, sy, ex, ey, colorClass, addClass) {
};
var
clearTableColor
=
function
()
{
$table
.
find
(
'
.mtbl-cell
'
).
css
(
'
background
'
,
''
);
$table
.
find
(
'
.mtbl-cell
'
).
removeClass
(
Object
.
keys
(
tableColorClass
).
join
(
'
'
)
);
};
var
tableColorClass
=
{
...
...
js/module/graph.js
浏览文件 @
004d3e58
...
...
@@ -182,7 +182,7 @@ GraphTracer.prototype.prevStep = function () {
};
var
initGraph
=
function
()
{
$
(
'
.module_container
'
)
.
empty
();
$
module_container
.
empty
();
if
(
sigmaCanvas
==
null
)
{
sigmaCanvas
=
$
.
extend
(
true
,
{},
sigma
.
canvas
);
}
else
{
...
...
@@ -190,7 +190,7 @@ var initGraph = function () {
}
s
=
new
sigma
({
renderer
:
{
container
:
$
(
'
.module_container
'
)
[
0
],
container
:
$
module_container
[
0
],
type
:
'
canvas
'
},
settings
:
{
...
...
js/script.js
浏览文件 @
004d3e58
$
.
ajaxSetup
({
cache
:
false
,
dataType
:
"
text
"
});
var
$module_container
=
$
(
'
.module_container
'
);
var
_tracer
=
new
Tracer
();
var
initEditor
=
function
(
id
)
{
var
editor
=
ace
.
edit
(
id
);
...
...
@@ -257,4 +258,17 @@ for (var i = 0; i < dividers.length; i++) {
$second
.
append
(
$divider
);
})(
divider
);
}
\ No newline at end of file
}
$module_container
.
mousedown
(
function
(
e
)
{
_tracer
.
mousedown
(
e
);
});
$module_container
.
mousemove
(
function
(
e
)
{
_tracer
.
mousemove
(
e
);
});
$
(
document
).
mouseup
(
function
(
e
)
{
_tracer
.
mouseup
(
e
);
});
$module_container
.
bind
(
'
DOMMouseScroll mousewheel
'
,
function
(
e
)
{
_tracer
.
mousewheel
(
e
);
});
\ No newline at end of file
js/tracer.js
浏览文件 @
004d3e58
...
...
@@ -141,6 +141,18 @@ Tracer.prototype.nextStep = function () {
this
.
step
(
this
.
traceIndex
+
1
);
};
Tracer
.
prototype
.
mousedown
=
function
(
e
)
{
};
Tracer
.
prototype
.
mousemove
=
function
(
e
)
{
};
Tracer
.
prototype
.
mouseup
=
function
(
e
)
{
};
Tracer
.
prototype
.
mousewheel
=
function
(
e
)
{
};
var
printTrace
=
function
(
message
)
{
$
(
'
#tab_trace .wrapper
'
).
append
(
$
(
'
<span>
'
).
append
(
message
+
'
<br/>
'
));
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录