src/hdalab/utils.py
changeset 291 44af3e5e4114
parent 290 fb86765b4c54
child 293 b33caeba7faa
--- a/src/hdalab/utils.py	Wed Jul 09 12:26:11 2014 +0200
+++ b/src/hdalab/utils.py	Thu Jul 10 16:17:00 2014 +0200
@@ -43,12 +43,33 @@
     
     def init(self, cat_nb_nodes_initial):
         for c in cat_nb_nodes_initial:
+            nb = cat_nb_nodes_initial[c]
+            if isinstance(cat_nb_nodes_initial[c], tuple):
+                _, nb = nb
+            self.max_length = nb if nb > self.max_length else self.max_length
+        for i_cat,c in enumerate(cat_nb_nodes_initial):
+            self.cat_nb_nodes[c] = []
+            order = i_cat
+            nb = cat_nb_nodes_initial[c]
+            if isinstance(cat_nb_nodes_initial[c], tuple):
+                order, nb = nb
+            offset = float(self.max_length - nb) / 2
+            for i in xrange(nb):
+                self.cat_nb_nodes[c].append({ "x": order*300, "y": 100*(i+offset) })
+        #logger.debug(self.cat_nb_nodes)
+
+
+
+class CircleNodePlacer(NodePlacer):
+    
+    def init(self, cat_nb_nodes_initial):
+        for c in cat_nb_nodes_initial:
             self.max_length = cat_nb_nodes_initial[c] if cat_nb_nodes_initial[c] > self.max_length else self.max_length
         for i_cat,c in enumerate(cat_nb_nodes_initial):
             self.cat_nb_nodes[c] = []
             offset = float(self.max_length - cat_nb_nodes_initial[c]) / 2
             for i in xrange(cat_nb_nodes_initial[c]):
-                self.cat_nb_nodes[c].append({ "x": i_cat*200, "y": 100*(i+offset) })
+                self.cat_nb_nodes[c].append({ "x": i_cat*400, "y": 200*(i+offset) })
         #logger.debug(self.cat_nb_nodes)