Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tlatools
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
tlatools
Commits
237e9131
Commit
237e9131
authored
Jan 18, 2018
by
William Schultz
Committed by
Markus Alexander Kuppe
Feb 7, 2018
Browse files
Options
Downloads
Patches
Plain Diff
POC for colorized state graph
parent
674e227c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tlatools/src/tlc2/util/DotStateWriter.java
+35
-7
35 additions, 7 deletions
tlatools/src/tlc2/util/DotStateWriter.java
with
35 additions
and
7 deletions
tlatools/src/tlc2/util/DotStateWriter.java
+
35
−
7
View file @
237e9131
...
@@ -28,7 +28,9 @@ package tlc2.util;
...
@@ -28,7 +28,9 @@ package tlc2.util;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
tlc2.tool.Action
;
import
tlc2.tool.Action
;
import
tlc2.tool.TLCState
;
import
tlc2.tool.TLCState
;
...
@@ -44,6 +46,9 @@ import util.UniqueString;
...
@@ -44,6 +46,9 @@ import util.UniqueString;
*/
*/
public
class
DotStateWriter
extends
StateWriter
{
public
class
DotStateWriter
extends
StateWriter
{
HashSet
<
String
>
availableColors
=
new
HashSet
<>(
Arrays
.
asList
(
"#6A041D"
,
"#53FF45"
,
"#1E2EDE"
));
HashMap
<
String
,
String
>
actionToColors
=
new
HashMap
<>();
public
DotStateWriter
(
final
String
fname
)
throws
IOException
{
public
DotStateWriter
(
final
String
fname
)
throws
IOException
{
this
(
fname
,
"strict "
);
this
(
fname
,
"strict "
);
}
}
...
@@ -102,6 +107,8 @@ public class DotStateWriter extends StateWriter {
...
@@ -102,6 +107,8 @@ public class DotStateWriter extends StateWriter {
Visualization
visualization
,
Action
action
)
{
Visualization
visualization
,
Action
action
)
{
final
String
successorsFP
=
Long
.
toString
(
successor
.
fingerPrint
());
final
String
successorsFP
=
Long
.
toString
(
successor
.
fingerPrint
());
// Write the transition
// Write the transition
this
.
writer
.
append
(
Long
.
toString
(
state
.
fingerPrint
()));
this
.
writer
.
append
(
Long
.
toString
(
state
.
fingerPrint
()));
this
.
writer
.
append
(
" -> "
);
this
.
writer
.
append
(
" -> "
);
...
@@ -118,20 +125,41 @@ public class DotStateWriter extends StateWriter {
...
@@ -118,20 +125,41 @@ public class DotStateWriter extends StateWriter {
this
.
writer
.
append
(
" [label=<"
);
this
.
writer
.
append
(
" [label=<"
);
this
.
writer
.
append
(
"<table border='0' cellborder='0' cellspacing='0'>"
);
this
.
writer
.
append
(
"<table border='0' cellborder='0' cellspacing='0'>"
);
this
.
writer
.
append
(
"<tr>"
);
this
.
writer
.
append
(
"<tr>"
);
String
color
=
"black"
;
if
(
action
!=
null
)
{
if
(
action
!=
null
)
{
this
.
writer
.
append
(
"<td bgcolor='white'><font point-size='12'>"
+
action
.
getActionName
()
+
"</font></td>"
);
if
(
actionToColors
.
containsKey
(
action
.
toString
()))
{
color
=
actionToColors
.
get
(
action
.
toString
());
}
else
{
color
=
availableColors
.
iterator
().
next
();
actionToColors
.
put
(
action
.
toString
(),
color
);
availableColors
.
remove
(
color
);
}
}
System
.
out
.
println
(
action
.
toString
());
System
.
out
.
println
(
color
);
this
.
writer
.
append
(
"<td bgcolor='white'>"
);
this
.
writer
.
append
(
"<font point-size='12'"
+
" color=\""
+
color
+
"\">"
+
action
.
getActionName
()
+
"</font>"
);
this
.
writer
.
append
(
"</td>"
);
}
this
.
writer
.
append
(
"</tr>"
);
this
.
writer
.
append
(
"<tr>"
);
// Print names of variables that changed in this transition.
// Print names of variables that changed in this transition.
this
.
writer
.
append
(
"<td bgcolor='white'><font color='#222222' point-size='
12
'>"
);
this
.
writer
.
append
(
"<td bgcolor='white'><font color='#222222' point-size='
9
'>"
);
this
.
writer
.
append
(
"("
);
//
this.writer.append("(");
HashMap
<
UniqueString
,
Value
>
diffMap
=
state
.
diff
(
successor
);
HashMap
<
UniqueString
,
Value
>
diffMap
=
state
.
diff
(
successor
);
ArrayList
<
String
>
changedVars
=
new
ArrayList
<>();
ArrayList
<
String
>
changedVars
=
new
ArrayList
<>();
for
(
UniqueString
key
:
diffMap
.
keySet
())
{
for
(
UniqueString
key
:
diffMap
.
keySet
())
{
changedVars
.
add
(
key
.
toString
());
// changedVars.add(key.toString());
this
.
writer
.
append
(
key
.
toString
());
this
.
writer
.
append
(
"<br/>"
);
}
}
this
.
writer
.
append
(
String
.
join
(
","
,
changedVars
));
// this.writer.append(String.join(",", changedVars));
this
.
writer
.
append
(
")</font></td></tr></table>"
);
// this.writer.append(")");
this
.
writer
.
append
(
">]"
);
this
.
writer
.
append
(
"</font></td></tr></table>"
);
this
.
writer
.
append
(
">"
);
this
.
writer
.
append
(
" color=\""
+
color
+
"\"]"
);
this
.
writer
.
append
(
";\n"
);
this
.
writer
.
append
(
";\n"
);
// If the successor is new, print the state's label. Labels are printed
// If the successor is new, print the state's label. Labels are printed
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment