|
|
|
@ -83,6 +83,7 @@ class Diagram:
|
|
|
|
|
direction: str = "LR",
|
|
|
|
|
curvestyle: str = "ortho",
|
|
|
|
|
outformat: str = "png",
|
|
|
|
|
autolabel: bool = False,
|
|
|
|
|
show: bool = True,
|
|
|
|
|
graph_attr: dict = {},
|
|
|
|
|
node_attr: dict = {},
|
|
|
|
@ -142,6 +143,7 @@ class Diagram:
|
|
|
|
|
self.dot.edge_attr.update(edge_attr)
|
|
|
|
|
|
|
|
|
|
self.show = show
|
|
|
|
|
self.autolabel = autolabel
|
|
|
|
|
|
|
|
|
|
def __str__(self) -> str:
|
|
|
|
|
return str(self.dot)
|
|
|
|
@ -292,11 +294,23 @@ class Node:
|
|
|
|
|
self._id = nodeid or self._rand_id()
|
|
|
|
|
self.label = label
|
|
|
|
|
|
|
|
|
|
# Node must be belong to a diagrams.
|
|
|
|
|
self._diagram = getdiagram()
|
|
|
|
|
if self._diagram is None:
|
|
|
|
|
raise EnvironmentError("Global diagrams context not set up")
|
|
|
|
|
|
|
|
|
|
if self._diagram.autolabel:
|
|
|
|
|
prefix = self.__class__.__name__
|
|
|
|
|
if self.label:
|
|
|
|
|
self.label = prefix + "\n" + self.label
|
|
|
|
|
else:
|
|
|
|
|
self.label = prefix
|
|
|
|
|
|
|
|
|
|
# fmt: off
|
|
|
|
|
# If a node has an icon, increase the height slightly to avoid
|
|
|
|
|
# that label being spanned between icon image and white space.
|
|
|
|
|
# Increase the height by the number of new lines included in the label.
|
|
|
|
|
padding = 0.4 * (label.count('\n'))
|
|
|
|
|
padding = 0.4 * (self.label.count('\n'))
|
|
|
|
|
self._attrs = {
|
|
|
|
|
"shape": "none",
|
|
|
|
|
"height": str(self._height + padding),
|
|
|
|
@ -306,10 +320,6 @@ class Node:
|
|
|
|
|
# fmt: on
|
|
|
|
|
self._attrs.update(attrs)
|
|
|
|
|
|
|
|
|
|
# Node must be belong to a diagrams.
|
|
|
|
|
self._diagram = getdiagram()
|
|
|
|
|
if self._diagram is None:
|
|
|
|
|
raise EnvironmentError("Global diagrams context not set up")
|
|
|
|
|
self._cluster = getcluster()
|
|
|
|
|
|
|
|
|
|
# If a node is in the cluster context, add it to cluster.
|
|
|
|
|