Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure all items has correct color (based on scope) #93

Merged
merged 1 commit into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions pytm/pytm.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,9 @@ def check(self):

def dfd(self, **kwargs):
self._is_drawn = True
color = _setColor(self)
label = _setLabel(self)
print("%s [\n\tshape = square;" % self._uniq_name())
print("{0} [\n\tshape = square;\n\tcolor = {1};\n\tfontcolor = {1};".format(self._uniq_name(), color))
print('\tlabel = <<table border="0" cellborder="0" cellpadding="2"><tr><td><b>{0}</b></td></tr></table>>;'.format(label))
print("]")

Expand Down Expand Up @@ -519,7 +520,7 @@ def dfd(self, **kwargs):
color = _setColor(self)
pngpath = dirname(__file__) + "/images/lambda.png"
label = _setLabel(self)
print('{0} [\n\tshape = none\n\tfixedsize=shape\n\timage="{2}"\n\timagescale=true\n\tcolor = {1}'.format(self._uniq_name(), color, pngpath))
print('{0} [\n\tshape = none\n\tfixedsize=shape\n\timage="{2}"\n\timagescale=true\n\tcolor = {1};\n\tfontcolor = {1};'.format(self._uniq_name(), color, pngpath))
print('\tlabel = <<table border="0" cellborder="0" cellpadding="2"><tr><td><b>{}</b></td></tr></table>>;'.format(label))
print("]")

Expand Down Expand Up @@ -568,7 +569,7 @@ def dfd(self, **kwargs):
self._is_drawn = True
color = _setColor(self)
label = _setLabel(self)
print("{0} [\n\tshape = circle\n\tcolor = {1}".format(self._uniq_name(), color))
print("{0} [\n\tshape = circle\n\tcolor = {1};\n\tfontcolor = {1};".format(self._uniq_name(), color))
print('\tlabel = <<table border="0" cellborder="0" cellpadding="2"><tr><td><b>{}</b></td></tr></table>>;'.format(label))
print("]")

Expand Down Expand Up @@ -615,8 +616,8 @@ def dfd(self, **kwargs):
self._is_drawn = True
color = _setColor(self)
label = _setLabel(self)
print("{0} [\n\tshape = none;\n\tcolor = {1};".format(self._uniq_name(), color))
print('\tlabel = <<table sides="TB" cellborder="0" cellpadding="2"><tr><td><font color="{1}"><b>{0}</b></font></td></tr></table>>;'.format(label, color))
print("{0} [\n\tshape = none;\n\tcolor = {1};\n\tfontcolor = {1};".format(self._uniq_name(), color))
print('\tlabel = <<table sides="TB" cellborder="0" cellpadding="2"><tr><td><b>{0}</b></td></tr></table>>;'.format(label))
print("]")


Expand All @@ -632,8 +633,9 @@ def __init__(self, name, **kwargs):

def dfd(self, **kwargs):
self._is_drawn = True
color = _setColor(self)
label = _setLabel(self)
print("%s [\n\tshape = square;" % self._uniq_name())
print("{0} [\n\tshape = square;\n\tcolor = {1};\n\tfontcolor = {1};".format(self._uniq_name(), color))
print('\tlabel = <<table border="0" cellborder="0" cellpadding="2"><tr><td><b>{0}</b></td></tr></table>>;'.format(label))
print("]")

Expand Down Expand Up @@ -685,8 +687,8 @@ def dfd(self, **kwargs):
self._is_drawn = True
color = _setColor(self)
label = _setLabel(self)
print("{0} [\n\tshape = circle;\n\tcolor = {1};\n".format(self._uniq_name(), color))
print('\tlabel = <<table border="0" cellborder="0" cellpadding="2"><tr><td><font color="{1}"><b>{0}</b></font></td></tr></table>>;'.format(label, color))
print("{0} [\n\tshape = circle;\n\tcolor = {1};\n\tfontcolor = {1};".format(self._uniq_name(), color))
print('\tlabel = <<table border="0" cellborder="0" cellpadding="2"><tr><td><b>{0}</b></td></tr></table>>;'.format(label))
print("]")


Expand All @@ -698,8 +700,8 @@ def dfd(self, **kwargs):
self._is_drawn = True
color = _setColor(self)
label = _setLabel(self)
print("{0} [\n\tshape = doublecircle;\n\tcolor = {1};\n".format(self._uniq_name(), color))
print('\tlabel = <<table border="0" cellborder="0" cellpadding="2"><tr><td><font color="{1}"><b>{0}</b></font></td></tr></table>>;'.format(label, color))
print("{0} [\n\tshape = doublecircle;\n\tcolor = {1};\n\tfontcolor = {1};".format(self._uniq_name(), color))
print('\tlabel = <<table border="0" cellborder="0" cellpadding="2"><tr><td><b>{0}</b></td></tr></table>>;'.format(label))
print("]")


Expand Down Expand Up @@ -753,13 +755,13 @@ def dfd(self, mergeResponses=False, **kwargs):
if self.response.order >= 0:
resp_label = "({0}) {1}".format(self.response.order, resp_label)
label += "<br/>" + resp_label
print("\t{0} -> {1} [\n\t\tcolor = {2};\n\t\tdir = {3};\n".format(
print("\t{0} -> {1} [\n\t\tcolor = {2};\n\t\tfontcolor = {2};\n\t\tdir = {3};\n".format(
self.source._uniq_name(),
self.sink._uniq_name(),
color,
direction,
))
print('\t\tlabel = <<table border="0" cellborder="0" cellpadding="2"><tr><td><font color="{1}"><b>{0}</b></font></td></tr></table>>;'.format(label, color))
print('\t\tlabel = <<table border="0" cellborder="0" cellpadding="2"><tr><td><b>{0}</b></td></tr></table>>;'.format(label))
print("\t]")


Expand Down
20 changes: 14 additions & 6 deletions tests/dfd.dot
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ subgraph cluster_boundary_Internet_acf3059e70 {

actor_User_579e9aae81 [
shape = square;
color = black;
fontcolor = black;
label = <<table border="0" cellborder="0" cellpadding="2"><tr><td><b>User</b></td></tr></table>>;
]

Expand All @@ -45,38 +47,44 @@ subgraph cluster_boundary_ServerDB_88f2d9c06f {
datastore_SQLDatabase_d2006ce1bb [
shape = none;
color = black;
label = <<table sides="TB" cellborder="0" cellpadding="2"><tr><td><font color="black"><b>SQL Database</b></font></td></tr></table>>;
fontcolor = black;
label = <<table sides="TB" cellborder="0" cellpadding="2"><tr><td><b>SQL Database</b></td></tr></table>>;
]

}

server_WebServer_f2eb7a3ff7 [
shape = circle
color = black
color = black;
fontcolor = black;
label = <<table border="0" cellborder="0" cellpadding="2"><tr><td><b>Web Server</b></td></tr></table>>;
]
actor_User_579e9aae81 -> server_WebServer_f2eb7a3ff7 [
color = black;
fontcolor = black;
dir = forward;

label = <<table border="0" cellborder="0" cellpadding="2"><tr><td><font color="black"><b>User enters<br/>comments (*)</b></font></td></tr></table>>;
label = <<table border="0" cellborder="0" cellpadding="2"><tr><td><b>User enters<br/>comments (*)</b></td></tr></table>>;
]
server_WebServer_f2eb7a3ff7 -> datastore_SQLDatabase_d2006ce1bb [
color = black;
fontcolor = black;
dir = forward;

label = <<table border="0" cellborder="0" cellpadding="2"><tr><td><font color="black"><b>Insert query<br/>with comments</b></font></td></tr></table>>;
label = <<table border="0" cellborder="0" cellpadding="2"><tr><td><b>Insert query<br/>with comments</b></td></tr></table>>;
]
datastore_SQLDatabase_d2006ce1bb -> server_WebServer_f2eb7a3ff7 [
color = black;
fontcolor = black;
dir = forward;

label = <<table border="0" cellborder="0" cellpadding="2"><tr><td><font color="black"><b>Retrieve<br/>comments</b></font></td></tr></table>>;
label = <<table border="0" cellborder="0" cellpadding="2"><tr><td><b>Retrieve<br/>comments</b></td></tr></table>>;
]
server_WebServer_f2eb7a3ff7 -> actor_User_579e9aae81 [
color = black;
fontcolor = black;
dir = forward;

label = <<table border="0" cellborder="0" cellpadding="2"><tr><td><font color="black"><b>Show comments<br/>(*)</b></font></td></tr></table>>;
label = <<table border="0" cellborder="0" cellpadding="2"><tr><td><b>Show comments<br/>(*)</b></td></tr></table>>;
]
}