63 if c=="northwest": |
63 if c=="northwest": |
64 self.cat_nb_nodes[c].append({ "x": order*500, "y": offset }) |
64 self.cat_nb_nodes[c].append({ "x": order*500, "y": offset }) |
65 else: |
65 else: |
66 self.cat_nb_nodes[c].append({ "x": order*500, "y": 100*(i+offset) }) |
66 self.cat_nb_nodes[c].append({ "x": order*500, "y": 100*(i+offset) }) |
67 |
67 |
|
68 |
|
69 class HorLineNodePlacer(NodePlacer): #horizontal lines |
|
70 |
|
71 max_length = 0 |
|
72 |
|
73 def init(self, cat_nb_nodes_initial): |
|
74 for c in cat_nb_nodes_initial: |
|
75 nb = cat_nb_nodes_initial[c] |
|
76 if isinstance(cat_nb_nodes_initial[c], tuple): |
|
77 _, nb = nb |
|
78 self.max_length = nb if nb > self.max_length else self.max_length |
|
79 for i_cat,c in enumerate(cat_nb_nodes_initial): |
|
80 self.cat_nb_nodes[c] = [] |
|
81 order = i_cat |
|
82 nb = cat_nb_nodes_initial[c] |
|
83 if isinstance(cat_nb_nodes_initial[c], tuple): |
|
84 order, nb = nb |
|
85 offset = float(self.max_length - nb) / 2 |
|
86 for i in xrange(nb): |
|
87 if c=="northwest": |
|
88 self.cat_nb_nodes[c].append({ "x": offset, "y": order*500 }) |
|
89 else: |
|
90 self.cat_nb_nodes[c].append({ "x": 100*(i+offset), "y": order*500 }) |
68 |
91 |
69 |
92 |
70 class CircleNodePlacer(NodePlacer): |
93 class CircleNodePlacer(NodePlacer): |
71 |
94 |
72 def init(self, cat_nb_nodes_initial): |
95 def init(self, cat_nb_nodes_initial): |