def set_printer(self, file_name, basename): """initialize VCGWriter for a UML graph""" self.graph_file = open(file_name, 'w+') self.printer = VCGPrinter(self.graph_file) self.printer.open_graph(title=basename, layoutalgorithm='dfs', late_edge_labels='yes', port_sharing='no', manhattan_edges='yes') self.printer.emit_node = self.printer.node self.printer.emit_edge = self.printer.edge
def set_printer(self, file_name, basename): """initialize VCGWriter for a UML graph""" self.graph_file = open(file_name, "w+") self.printer = VCGPrinter(self.graph_file) self.printer.open_graph( title=basename, layoutalgorithm="dfs", late_edge_labels="yes", port_sharing="no", manhattan_edges="yes", ) self.printer.emit_node = self.printer.node self.printer.emit_edge = self.printer.edge
class VCGWriter(DiagramWriter): """write vcg graphs from a diagram definition and a project """ def __init__(self, config): styles = [ dict(arrowstyle='solid', backarrowstyle='none', backarrowsize=0), dict(arrowstyle='solid', backarrowstyle='none', backarrowsize=10), dict(arrowstyle='solid', backarrowstyle='none', linestyle='dotted', backarrowsize=10), dict(arrowstyle='solid', backarrowstyle='none', textcolor='green'), ] DiagramWriter.__init__(self, config, styles) def set_printer(self, file_name, basename): """initialize VCGWriter for a UML graph""" self.graph_file = open(file_name, 'w+') self.printer = VCGPrinter(self.graph_file) self.printer.open_graph(title=basename, layoutalgorithm='dfs', late_edge_labels='yes', port_sharing='no', manhattan_edges='yes') self.printer.emit_node = self.printer.node self.printer.emit_edge = self.printer.edge def get_title(self, obj): """get project title in vcg format""" return r'\fb%s\fn' % obj.title def get_values(self, obj): """get label and shape for classes. The label contains all attributes and methods """ if is_exception(obj.node): label = r'\fb\f09%s\fn' % obj.title else: label = r'\fb%s\fn' % obj.title if obj.shape == 'interface': shape = 'ellipse' else: shape = 'box' if not self.config.only_classnames: attrs = obj.attrs methods = [func.name for func in obj.methods] # box width for UML like diagram maxlen = max(len(name) for name in [obj.title] + methods + attrs) line = '_' * (maxlen + 2) label = r'%s\n\f%s' % (label, line) for attr in attrs: label = r'%s\n\f08%s' % (label, attr) if attrs: label = r'%s\n\f%s' % (label, line) for func in methods: label = r'%s\n\f10%s()' % (label, func) return dict(label=label, shape=shape) def close_graph(self): """close graph and file""" self.printer.close_graph() self.graph_file.close()
class VCGWriter(DiagramWriter): """write vcg graphs from a diagram definition and a project """ def __init__(self, config): styles = [dict(arrowstyle='solid', backarrowstyle='none', backarrowsize=0), dict(arrowstyle='solid', backarrowstyle='none', backarrowsize=10), dict(arrowstyle='solid', backarrowstyle='none', linestyle='dotted', backarrowsize=10), dict(arrowstyle='solid', backarrowstyle='none', textcolor='green'), ] DiagramWriter.__init__(self, config, styles) def set_printer(self, file_name, basename): """initialize VCGWriter for a UML graph""" self.graph_file = open(file_name, 'w+') self.printer = VCGPrinter(self.graph_file) self.printer.open_graph(title=basename, layoutalgorithm='dfs', late_edge_labels='yes', port_sharing='no', manhattan_edges='yes') self.printer.emit_node = self.printer.node self.printer.emit_edge = self.printer.edge def get_title(self, obj): """get project title in vcg format""" return r'\fb%s\fn' % obj.title def get_values(self, obj): """get label and shape for classes. The label contains all attributes and methods """ if is_exception(obj.node): label = r'\fb\f09%s\fn' % obj.title else: label = r'\fb%s\fn' % obj.title if obj.shape == 'interface': shape = 'ellipse' else: shape = 'box' if not self.config.only_classnames: attrs = obj.attrs methods = [func.name for func in obj.methods] # box width for UML like diagram maxlen = max(len(name) for name in [obj.title] + methods + attrs) line = '_' * (maxlen + 2) label = r'%s\n\f%s' % (label, line) for attr in attrs: label = r'%s\n\f08%s' % (label, attr) if attrs: label = r'%s\n\f%s' % (label, line) for func in methods: label = r'%s\n\f10%s()' % (label, func) return dict(label=label, shape=shape) def close_graph(self): """close graph and file""" self.printer.close_graph() self.graph_file.close()
class VCGWriter(DiagramWriter): """write vcg graphs from a diagram definition and a project""" def __init__(self, config): styles = [ dict(arrowstyle="solid", backarrowstyle="none", backarrowsize=0), dict(arrowstyle="solid", backarrowstyle="none", backarrowsize=10), dict( arrowstyle="solid", backarrowstyle="none", linestyle="dotted", backarrowsize=10, ), dict(arrowstyle="solid", backarrowstyle="none", textcolor="green"), ] DiagramWriter.__init__(self, config, styles) def set_printer(self, file_name, basename): """initialize VCGWriter for a UML graph""" self.graph_file = open(file_name, "w+") self.printer = VCGPrinter(self.graph_file) self.printer.open_graph( title=basename, layoutalgorithm="dfs", late_edge_labels="yes", port_sharing="no", manhattan_edges="yes", ) self.printer.emit_node = self.printer.node self.printer.emit_edge = self.printer.edge def get_title(self, obj): """get project title in vcg format""" return r"\fb%s\fn" % obj.title def get_values(self, obj): """get label and shape for classes. The label contains all attributes and methods """ if is_exception(obj.node): label = r"\fb\f09%s\fn" % obj.title else: label = r"\fb%s\fn" % obj.title if obj.shape == "interface": shape = "ellipse" else: shape = "box" if not self.config.only_classnames: attrs = obj.attrs methods = [func.name for func in obj.methods] # box width for UML like diagram maxlen = max(len(name) for name in [obj.title] + methods + attrs) line = "_" * (maxlen + 2) label = fr"{label}\n\f{line}" for attr in attrs: label = fr"{label}\n\f08{attr}" if attrs: label = fr"{label}\n\f{line}" for func in methods: label = fr"{label}\n\f10{func}()" return dict(label=label, shape=shape) def close_graph(self): """close graph and file""" self.printer.close_graph() self.graph_file.close()