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
2da9ac09
Commit
2da9ac09
authored
Feb 3, 2018
by
William Schultz
Committed by
Markus Alexander Kuppe
Feb 7, 2018
Browse files
Options
Downloads
Patches
Plain Diff
Clean up DotStateWriter
parent
5076581d
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
+15
-11
15 additions, 11 deletions
tlatools/src/tlc2/util/DotStateWriter.java
with
15 additions
and
11 deletions
tlatools/src/tlc2/util/DotStateWriter.java
+
15
−
11
View file @
2da9ac09
...
...
@@ -111,7 +111,7 @@ public class DotStateWriter extends StateWriter {
this
.
writer
.
append
(
Long
.
toString
(
state
.
fingerPrint
()));
this
.
writer
.
append
(
" [style = filled]"
);
this
.
writer
.
append
(
" [label=<"
);
this
.
writer
.
append
(
stateToDotStr
(
state
,
state
));
this
.
writer
.
append
(
stateToDotStr
(
state
));
this
.
writer
.
append
(
">]"
);
this
.
writer
.
append
(
"\n"
);
}
...
...
@@ -173,7 +173,7 @@ public class DotStateWriter extends StateWriter {
// Write the successor's label.
this
.
writer
.
append
(
successorsFP
);
this
.
writer
.
append
(
" [label=<"
);
String
stateStr
=
stateToDotStr
(
state
,
successor
);
String
stateStr
=
stateToDotStr
(
state
);
this
.
writer
.
append
(
stateStr
);
this
.
writer
.
append
(
">]"
);
this
.
writer
.
append
(
";\n"
);
...
...
@@ -191,22 +191,23 @@ public class DotStateWriter extends StateWriter {
*/
protected
Integer
getActionColor
(
Action
action
)
{
// Return a default color if the given action is null.
Integer
actionColor
=
1
;
if
(
action
!=
null
)
{
if
(
action
==
null
)
{
return
1
;
}
else
{
String
actionName
=
action
.
getActionName
();
// If this action has been seen before, retrieve its color.
if
(
actionToColors
.
containsKey
(
actionName
))
{
actionColor
=
actionToColors
.
get
(
actionName
);
return
actionToColors
.
get
(
actionName
);
}
// If this action has not been seen yet, get the next available color
// and assign it to this action.
else
{
this
.
colorGen
++;
actionColor
=
this
.
colorGen
;
actionToColors
.
put
(
actionName
,
actionC
olor
)
;
action
To
Color
s
.
put
(
actionName
,
this
.
colorGen
)
;
return
this
.
c
olor
Gen
;
}
}
return
actionColor
;
}
/**
...
...
@@ -253,12 +254,15 @@ public class DotStateWriter extends StateWriter {
return
sb
.
toString
();
}
protected
static
String
stateToDotStr
(
TLCState
state
,
TLCState
successor
)
{
/**
* Given a TLC state, generate a string representation suitable for a HTML DOT graph label.
*/
protected
static
String
stateToDotStr
(
TLCState
state
)
{
StringBuilder
sb
=
new
StringBuilder
();
HashMap
<
UniqueString
,
Value
>
valMap
=
s
uccessor
.
getVals
();
HashMap
<
UniqueString
,
Value
>
valMap
=
s
tate
.
getVals
();
// Generate a string representation of state.
for
(
UniqueString
key
:
state
.
getVals
()
.
keySet
())
{
for
(
UniqueString
key
:
valMap
.
keySet
())
{
String
valString
=
(
key
.
toString
()
+
" = "
+
valMap
.
get
(
key
).
toString
());
sb
.
append
(
valString
);
// New line between variables.
...
...
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