bpmn_diagram_visualizer.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:bpmn-python 作者: KrzyHonk 项目源码 文件源码
def visualize_diagram(bpmn_diagram):
    """
    Shows a simple visualization of diagram

    :param bpmn_diagram: an instance of BPMNDiagramGraph class.
    """
    g = bpmn_diagram.diagram_graph
    pos = bpmn_diagram.get_nodes_positions()
    nx.draw_networkx_nodes(g, pos, node_shape='s', node_color='white',
                           nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.task))
    nx.draw_networkx_nodes(g, pos, node_shape='s', node_color='white',
                           nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.subprocess))
    nx.draw_networkx_nodes(g, pos, node_shape='d', node_color='white',
                           nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.complex_gateway))
    nx.draw_networkx_nodes(g, pos, node_shape='o', node_color='white',
                           nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.event_based_gateway))
    nx.draw_networkx_nodes(g, pos, node_shape='d', node_color='white',
                           nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.inclusive_gateway))
    nx.draw_networkx_nodes(g, pos, node_shape='d', node_color='white',
                           nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.exclusive_gateway))
    nx.draw_networkx_nodes(g, pos, node_shape='d', node_color='white',
                           nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.parallel_gateway))
    nx.draw_networkx_nodes(g, pos, node_shape='o', node_color='white',
                           nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.start_event))
    nx.draw_networkx_nodes(g, pos, node_shape='o', node_color='white',
                           nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.intermediate_catch_event))
    nx.draw_networkx_nodes(g, pos, node_shape='o', node_color='white',
                           nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.end_event))
    nx.draw_networkx_nodes(g, pos, node_shape='o', node_color='white',
                           nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.intermediate_throw_event))

    node_labels = {}
    for node in g.nodes(data=True):
        node_labels[node[0]] = node[1].get(consts.Consts.node_name)
    nx.draw_networkx_labels(g, pos, node_labels)

    nx.draw_networkx_edges(g, pos)

    edge_labels = {}
    for edge in g.edges(data=True):
        edge_labels[(edge[0], edge[1])] = edge[2].get(consts.Consts.name)
    nx.draw_networkx_edge_labels(g, pos, edge_labels)

    plt.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号