diff --git a/python/tg_to_gry.py b/python/tg_to_gry.py index 1d17fd985d9b14d70cbcfb3e0e23c841b777d229..bb738c1d3de7dcba193ccdabfbb4837c15c02b4f 100644 --- a/python/tg_to_gry.py +++ b/python/tg_to_gry.py @@ -144,27 +144,24 @@ def _add_view_object(view_object, gry_graph): view_object["AD"])) def _trace_v_spacing(tg_nodes): - # start off maximums with default node height - maximums = defaultdict(lambda:settings["trace_node_height"]) + # start off with default node height + row_heights = defaultdict(lambda:settings["trace_node_height"]) w = settings["trace_node_width"] default_v_spacing = settings["trace_node_v_spacing"] - # get the max height for each row for tg_node in tg_nodes: # event in event list - maximums[tg_node[4]] = max(maximums[tg_node[4]], + row_heights[tg_node[4]] = max(row_heights[tg_node[4]], margined_text_height(strip_underscore(tg_node[0]), w)) - # calculate the adjusted spacing at each row - keys = sorted(maximums.keys()) - count = len(maximums) - adjusted_v_spacing = [0]*count + keys = sorted(row_heights.keys()) + count = keys[-1] + 1 # trace-generator can skip rows + adjusted_v_spacing = [0]*count # create the array and set the first to 0 for i in range(1, count): adjusted_v_spacing[i] = adjusted_v_spacing[i-1] \ - + maximums[i-1] / 2 \ - + maximums[i] / 2 + default_v_spacing - + + row_heights[i-1] / 2 \ + + row_heights[i] / 2 + default_v_spacing return adjusted_v_spacing - + def _trace_edge(tg_edge, relation, label, nodes, placer): gry_edge = dict() if relation == "IN" or relation == "FOLLOWS": @@ -185,7 +182,7 @@ def _trace_edge(tg_edge, relation, label, nodes, placer): gry_from_node = nodes[from_id] gry_to_node = nodes[to_id] ep1_x, ep1_y, ep2_x, ep2_y = placer.place_cubic_bezier_points( - from_id, gry_from_node["x"], gry_from_node["y"], + from_id, gry_from_node["x"], gry_from_node["y"], to_id, gry_to_node["x"], gry_to_node["y"]) gry_edge["ep1_x"] = ep1_x gry_edge["ep1_y"] = ep1_y