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
f687e159
Commit
f687e159
authored
Jan 29, 2018
by
William Schultz
Committed by
Markus Alexander Kuppe
Feb 7, 2018
Browse files
Options
Downloads
Patches
Plain Diff
Fix border color issues and document member variables
parent
0c44606d
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
+42
-4
42 additions, 4 deletions
tlatools/src/tlc2/util/DotStateWriter.java
with
42 additions
and
4 deletions
tlatools/src/tlc2/util/DotStateWriter.java
+
42
−
4
View file @
f687e159
...
...
@@ -47,11 +47,20 @@ import util.UniqueString;
*/
public
class
DotStateWriter
extends
StateWriter
{
// Used for assigning unique color identifiers to each action type.
// Used for assigning unique color identifiers to each action type. Incremented by 1
// every time a new color is assigned to an action.
Integer
colorGen
=
1
;
HashMap
<
String
,
Integer
>
actionToColors
=
new
HashMap
<>();
// Maximum number of unique colors. Determined by the Graphviz color scheme that is used.
Integer
colorGenMax
=
12
;
// The Graphviz color scheme that is used for state transition edge colors. See
// https://www.graphviz.org/doc/info/colors.html for more details on color schemes.
static
String
dotColorScheme
=
"paired12"
;
// A mapping of action names to their assigned color ids.
HashMap
<
String
,
Integer
>
actionToColors
=
new
HashMap
<>();
public
DotStateWriter
(
final
String
fname
)
throws
IOException
{
this
(
fname
,
"strict "
);
}
...
...
@@ -148,6 +157,35 @@ public class DotStateWriter extends StateWriter {
}
}
/**
* Given an action, returns the associated color identifier for it. The color
* identifier is just an integer suitable for use in a GraphViz color scheme. This
* method updates the (action -> color) mapping if this action has not been seen
* before for this DotStateWriter instance.
*
* @param action
* @return the color identifier for the given action
*/
protected
Integer
getActionColor
(
Action
action
)
{
// Return a default color if the given action is null.
Integer
actionColor
=
1
;
if
(
action
!=
null
)
{
String
actionName
=
action
.
getActionName
();
// If this action has been seen before, retrieve its color.
if
(
actionToColors
.
containsKey
(
actionName
))
{
actionColor
=
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
,
actionColor
);
}
}
return
actionColor
;
}
/**
* Creates a DOT label for an edge representing a state transition.
*
...
...
@@ -159,7 +197,7 @@ public class DotStateWriter extends StateWriter {
protected
String
dotTransitionLabel
(
TLCState
state
,
TLCState
successor
,
Action
action
)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
" [label=<"
);
sb
.
append
(
"<table border='0'
cellborder='0' cellspacing='0'
>"
);
sb
.
append
(
"<table border='0'>"
);
sb
.
append
(
"<tr>"
);
Integer
color
=
0
;
if
(
action
!=
null
)
{
...
...
@@ -172,7 +210,7 @@ public class DotStateWriter extends StateWriter {
color
=
this
.
colorGen
;
actionToColors
.
put
(
actionName
,
color
);
}
sb
.
append
(
"<td
bgcolor='white' color='red'
>"
);
sb
.
append
(
"<td>"
);
sb
.
append
(
"<font point-size='12'"
+
" color=\""
+
color
+
"\">"
+
actionName
+
"</font>"
);
sb
.
append
(
"</td>"
);
}
...
...
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