server/python/django/renkanmanager/utils.py
changeset 323 d5e2007c01d8
parent 318 815589aed866
child 324 a4a575e755aa
equal deleted inserted replaced
322:5897669370f4 323:d5e2007c01d8
    30 class NodePlacer():
    30 class NodePlacer():
    31     
    31     
    32     cat_nb_nodes = {}
    32     cat_nb_nodes = {}
    33     
    33     
    34     def init(self, cat_nb_nodes_initial):
    34     def init(self, cat_nb_nodes_initial):
    35         raise NotImplementedError( "Should have implemented get_place" )
    35         raise NotImplementedError( "Should have implemented init" )
    36     
    36     
    37     def get_place(self, category):
    37     def get_place(self, category):
    38         if not category or category not in self.cat_nb_nodes:
    38         if not category or category not in self.cat_nb_nodes:
    39             raise Http404
    39             raise Http404
    40         return self.cat_nb_nodes[category].pop(0)
    40         return self.cat_nb_nodes[category].pop(0)
    57             nb = cat_nb_nodes_initial[c]
    57             nb = cat_nb_nodes_initial[c]
    58             if isinstance(cat_nb_nodes_initial[c], tuple):
    58             if isinstance(cat_nb_nodes_initial[c], tuple):
    59                 order, nb = nb
    59                 order, nb = nb
    60             offset = float(self.max_length - nb) / 2
    60             offset = float(self.max_length - nb) / 2
    61             for i in xrange(nb):
    61             for i in xrange(nb):
    62                 self.cat_nb_nodes[c].append({ "x": order*300, "y": 100*(i+offset) })
    62                 self.cat_nb_nodes[c].append({ "x": order*500, "y": 100*(i+offset) })
    63         #logger.debug(self.cat_nb_nodes)
    63         #logger.debug(self.cat_nb_nodes)
    64 
    64 
    65 
    65 
    66 
    66 
    67 class CircleNodePlacer(NodePlacer):
    67 class CircleNodePlacer(NodePlacer):