Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
tianyazhichiC
algorithm-visualizer
提交
09189347
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
09189347
编写于
6月 19, 2016
作者:
J
Jason Park
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
improve coloring
上级
e01e4565
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
37 addition
and
54 deletion
+37
-54
js/module/tracer/array2d.js
js/module/tracer/array2d.js
+8
-16
js/module/tracer/chart.js
js/module/tracer/chart.js
+3
-7
js/module/tracer/coordinate_system.js
js/module/tracer/coordinate_system.js
+2
-4
js/module/tracer/directed_graph.js
js/module/tracer/directed_graph.js
+6
-11
js/module/tracer/tracer.js
js/module/tracer/tracer.js
+17
-15
js/module/tracer/weighted_directed_graph.js
js/module/tracer/weighted_directed_graph.js
+1
-1
未找到文件。
js/module/tracer/array2d.js
浏览文件 @
09189347
...
...
@@ -14,16 +14,12 @@ class Array2DTracer extends Tracer {
constructor
(
name
)
{
super
(
name
);
this
.
selectColor
=
'
#2962ff
'
;
this
.
notifyColor
=
'
#c51162
'
;
if
(
this
.
isNew
)
initView
(
this
);
}
_notify
(
x
,
y
,
v
)
{
this
.
manager
.
pushStep
(
this
.
capsule
,
{
type
:
'
notify
'
,
color
:
this
.
notifyColor
,
x
:
x
,
y
:
y
,
v
:
v
...
...
@@ -145,8 +141,7 @@ class Array2DTracer extends Tracer {
}
}
var
step
=
{
type
:
type
,
color
:
this
.
selectColor
type
:
type
};
$
.
extend
(
step
,
coord
);
this
.
manager
.
pushStep
(
this
.
capsule
,
step
);
...
...
@@ -163,8 +158,8 @@ class Array2DTracer extends Tracer {
case
'
denotify
'
:
case
'
select
'
:
case
'
deselect
'
:
var
color
Class
=
step
.
color
;
var
addClass
=
step
.
type
==
'
select
'
||
step
.
type
==
'
notify
'
;
var
color
=
step
.
type
==
'
select
'
||
step
.
type
==
'
deselect
'
?
this
.
color
.
selected
:
this
.
color
.
notified
;
var
paint
=
step
.
type
==
'
select
'
||
step
.
type
==
'
notify
'
;
var
sx
=
step
.
sx
;
var
sy
=
step
.
sy
;
var
ex
=
step
.
ex
;
...
...
@@ -173,7 +168,7 @@ class Array2DTracer extends Tracer {
if
(
sy
===
undefined
)
sy
=
step
.
y
;
if
(
ex
===
undefined
)
ex
=
step
.
x
;
if
(
ey
===
undefined
)
ey
=
step
.
y
;
this
.
paintColor
(
sx
,
sy
,
ex
,
ey
,
color
Class
,
addClass
);
this
.
paintColor
(
sx
,
sy
,
ex
,
ey
,
color
,
paint
);
break
;
case
'
separate
'
:
this
.
deseparate
(
step
.
x
,
step
.
y
);
...
...
@@ -292,22 +287,19 @@ class Array2DTracer extends Tracer {
this
.
refresh
();
}
paintColor
(
sx
,
sy
,
ex
,
ey
,
color
Class
,
addClass
)
{
paintColor
(
sx
,
sy
,
ex
,
ey
,
color
,
paint
)
{
for
(
var
i
=
sx
;
i
<=
ex
;
i
++
)
{
var
$row
=
this
.
$table
.
find
(
'
.mtbl-row
'
).
eq
(
i
);
for
(
var
j
=
sy
;
j
<=
ey
;
j
++
)
{
var
$col
=
$row
.
find
(
'
.mtbl-col
'
).
eq
(
j
);
if
(
addClass
)
$col
[
0
].
style
.
backgroundColor
=
colorClass
;
else
$col
[
0
].
style
.
backgroundColor
=
""
;
if
(
paint
)
$col
.
css
(
'
background
'
,
color
)
;
else
$col
.
css
(
'
background
'
,
''
)
;
}
}
}
clearColor
()
{
var
divs
=
this
.
$table
.
find
(
'
.mtbl-col
'
);
for
(
var
i
=
0
;
i
<
divs
.
length
;
i
++
){
divs
[
i
].
style
.
backgroundColor
=
""
;
}
this
.
$table
.
find
(
'
.mtbl-col
'
).
css
(
'
background
'
,
''
);
}
separate
(
x
,
y
)
{
...
...
js/module/tracer/chart.js
浏览文件 @
09189347
...
...
@@ -10,10 +10,6 @@ class ChartTracer extends Tracer {
constructor
(
name
)
{
super
(
name
);
this
.
selectColor
=
'
#2962ff
'
;
this
.
notifyColor
=
'
#c51162
'
;
this
.
defaultColor
=
'
rgb(136, 136, 136)
'
;
if
(
this
.
isNew
)
initView
(
this
);
}
...
...
@@ -25,7 +21,7 @@ class ChartTracer extends Tracer {
}
var
color
=
[];
for
(
var
i
=
0
;
i
<
C
.
length
;
i
++
)
color
.
push
(
this
.
defaultColor
);
for
(
var
i
=
0
;
i
<
C
.
length
;
i
++
)
color
.
push
(
this
.
color
.
default
);
this
.
chart
.
config
.
data
=
{
labels
:
C
.
map
(
String
),
datasets
:
[{
...
...
@@ -81,7 +77,7 @@ class ChartTracer extends Tracer {
case
'
denotify
'
:
case
'
select
'
:
case
'
deselect
'
:
let
color
=
step
.
type
==
'
notify
'
?
this
.
notifyColor
:
step
.
type
==
'
select
'
?
this
.
selectColor
:
this
.
defaultColor
;
let
color
=
step
.
type
==
'
notify
'
?
this
.
color
.
notified
:
step
.
type
==
'
select
'
?
this
.
color
.
selected
:
this
.
color
.
default
;
if
(
step
.
e
!==
undefined
)
for
(
var
i
=
step
.
s
;
i
<=
step
.
e
;
i
++
)
this
.
chart
.
config
.
data
.
datasets
[
0
].
backgroundColor
[
i
]
=
color
;
...
...
@@ -107,7 +103,7 @@ class ChartTracer extends Tracer {
if
(
data
.
datasets
.
length
)
{
const
backgroundColor
=
data
.
datasets
[
0
].
backgroundColor
;
for
(
let
i
=
0
;
i
<
backgroundColor
.
length
;
i
++
)
{
backgroundColor
[
i
]
=
this
.
defaultColor
;
backgroundColor
[
i
]
=
this
.
color
.
default
;
}
this
.
chart
.
update
();
}
...
...
js/module/tracer/coordinate_system.js
浏览文件 @
09189347
...
...
@@ -25,8 +25,7 @@ class CoordinateSystemTracer extends DirectedGraphTracer {
x
:
C
[
i
][
0
],
y
:
C
[
i
][
1
],
label
:
''
+
i
,
size
:
1
,
color
:
this
.
defaultColor
size
:
1
});
this
.
graph
.
read
({
nodes
:
nodes
,
...
...
@@ -49,7 +48,7 @@ class CoordinateSystemTracer extends DirectedGraphTracer {
case
'
leave
'
:
var
visit
=
step
.
type
==
'
visit
'
;
var
targetNode
=
this
.
graph
.
nodes
(
this
.
n
(
step
.
target
));
var
color
=
visit
?
this
.
visitedColor
:
this
.
leftColor
;
var
color
=
visit
?
this
.
color
.
visited
:
this
.
color
.
left
;
targetNode
.
color
=
color
;
if
(
step
.
source
!==
undefined
)
{
var
edgeId
=
this
.
e
(
step
.
source
,
step
.
target
);
...
...
@@ -62,7 +61,6 @@ class CoordinateSystemTracer extends DirectedGraphTracer {
id
:
this
.
e
(
step
.
target
,
step
.
source
),
source
:
this
.
n
(
step
.
source
),
target
:
this
.
n
(
step
.
target
),
color
:
color
,
size
:
1
});
}
...
...
js/module/tracer/directed_graph.js
浏览文件 @
09189347
...
...
@@ -14,11 +14,6 @@ class DirectedGraphTracer extends Tracer {
constructor
(
name
)
{
super
(
name
);
this
.
selectColor
=
'
#2962ff
'
;
this
.
visitedColor
=
'
#f50057
'
;
this
.
leftColor
=
'
#616161
'
;
this
.
defaultColor
=
'
#bdbdbd
'
;
if
(
this
.
isNew
)
initView
(
this
);
}
...
...
@@ -57,7 +52,7 @@ class DirectedGraphTracer extends Tracer {
case
'
leave
'
:
var
visit
=
step
.
type
==
'
visit
'
;
var
targetNode
=
this
.
graph
.
nodes
(
this
.
n
(
step
.
target
));
var
color
=
visit
?
this
.
visitedColor
:
this
.
leftColor
;
var
color
=
visit
?
this
.
color
.
visited
:
this
.
color
.
left
;
targetNode
.
color
=
color
;
if
(
step
.
source
!==
undefined
)
{
var
edgeId
=
this
.
e
(
step
.
source
,
step
.
target
);
...
...
@@ -135,7 +130,7 @@ class DirectedGraphTracer extends Tracer {
x
:
.
5
+
Math
.
sin
(
currentAngle
)
/
2
,
y
:
.
5
+
Math
.
cos
(
currentAngle
)
/
2
,
size
:
1
,
color
:
this
.
defaultColor
,
color
:
this
.
color
.
default
,
weight
:
0
});
...
...
@@ -147,7 +142,7 @@ class DirectedGraphTracer extends Tracer {
id
:
this
.
e
(
i
,
j
),
source
:
this
.
n
(
i
),
target
:
this
.
n
(
j
),
color
:
this
.
defaultColor
,
color
:
this
.
color
.
default
,
size
:
1
,
weight
:
refineByType
(
value
)
});
...
...
@@ -160,7 +155,7 @@ class DirectedGraphTracer extends Tracer {
id
:
this
.
e
(
i
,
j
),
source
:
this
.
n
(
i
),
target
:
this
.
n
(
j
),
color
:
this
.
defaultColor
,
color
:
this
.
color
.
default
,
size
:
1
,
weight
:
refineByType
(
G
[
i
][
j
])
});
...
...
@@ -208,10 +203,10 @@ class DirectedGraphTracer extends Tracer {
var
tracer
=
this
;
this
.
graph
.
nodes
().
forEach
(
function
(
node
)
{
node
.
color
=
tracer
.
defaultColor
;
node
.
color
=
tracer
.
color
.
default
;
});
this
.
graph
.
edges
().
forEach
(
function
(
edge
)
{
edge
.
color
=
tracer
.
defaultColor
;
edge
.
color
=
tracer
.
color
.
default
;
});
}
...
...
js/module/tracer/tracer.js
浏览文件 @
09189347
...
...
@@ -15,11 +15,13 @@ class Tracer {
constructor
(
name
)
{
this
.
module
=
this
.
constructor
;
this
.
selectColor
;
this
.
notifyColor
;
this
.
defaultColor
;
this
.
leftColor
;
this
.
visitedColor
;
this
.
color
=
{
selected
:
'
#2962ff
'
,
notified
:
'
#f50057
'
,
visited
:
'
#f50057
'
,
left
:
'
#616161
'
,
default
:
'
#bdbdbd
'
};
this
.
manager
=
app
.
getTracerManager
();
this
.
capsule
=
this
.
manager
.
allocate
(
this
);
...
...
@@ -48,24 +50,24 @@ class Tracer {
return
this
;
}
_setSelect
Fill
Color
(
c
)
{
this
.
selectColor
=
c
;
_setSelect
ed
Color
(
c
)
{
this
.
color
.
selected
=
c
;
}
_setNotif
yFill
Color
(
c
)
{
this
.
notifyColor
=
c
;
_setNotif
ied
Color
(
c
)
{
this
.
color
.
notified
=
c
;
}
_set
DefaultFillColor
(
c
)
{
this
.
defaultColor
=
c
;
_set
VisitedColor
(
c
)
{
this
.
color
.
visited
=
c
;
}
_setLeft
FillColor
(
c
)
{
this
.
leftColor
=
c
;
_setLeft
Color
(
c
)
{
this
.
color
.
left
=
c
;
}
_set
VisitedFillColor
(
c
)
{
this
.
visitedColor
=
c
;
_set
DefaultColor
(
c
)
{
this
.
color
.
default
=
c
;
}
processStep
(
step
,
options
)
{
...
...
js/module/tracer/weighted_directed_graph.js
浏览文件 @
09189347
...
...
@@ -56,7 +56,7 @@ class WeightedDirectedGraphTracer extends DirectedGraphTracer {
case
'
leave
'
:
var
visit
=
step
.
type
==
'
visit
'
;
var
targetNode
=
this
.
graph
.
nodes
(
this
.
n
(
step
.
target
));
var
color
=
visit
?
step
.
weight
===
undefined
?
this
.
selectColor
:
this
.
visitedColor
:
this
.
leftColor
;
var
color
=
visit
?
step
.
weight
===
undefined
?
this
.
color
.
selected
:
this
.
color
.
visited
:
this
.
color
.
left
;
targetNode
.
color
=
color
;
if
(
step
.
weight
!==
undefined
)
targetNode
.
weight
=
refineByType
(
step
.
weight
);
if
(
step
.
source
!==
undefined
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录