server/python/django/renkanmanager/utils.py
changeset 333 935cffdf3904
parent 324 a4a575e755aa
child 334 de35ce18643a
equal deleted inserted replaced
332:1a4b145c0607 333:935cffdf3904
    58             nb = cat_nb_nodes_initial[c]
    58             nb = cat_nb_nodes_initial[c]
    59             if isinstance(cat_nb_nodes_initial[c], tuple):
    59             if isinstance(cat_nb_nodes_initial[c], tuple):
    60                 order, nb = nb
    60                 order, nb = nb
    61             offset = float(self.max_length - nb) / 2
    61             offset = float(self.max_length - nb) / 2
    62             for i in xrange(nb):
    62             for i in xrange(nb):
    63                 self.cat_nb_nodes[c].append({ "x": order*500, "y": 100*(i+offset) })
    63                 if c=="northwest":
       
    64                     self.cat_nb_nodes[c].append({ "x": order*500, "y": offset })
       
    65                 else:
       
    66                     self.cat_nb_nodes[c].append({ "x": order*500, "y": 100*(i+offset) })
    64 
    67 
    65 
    68 
    66 
    69 
    67 class CircleNodePlacer(NodePlacer):
    70 class CircleNodePlacer(NodePlacer):
    68     
    71     
    75                 order, nb = nb
    78                 order, nb = nb
    76             order -= 1
    79             order -= 1
    77             for i in xrange(nb):
    80             for i in xrange(nb):
    78                 radius = (order*500) if order>0 else 100
    81                 radius = (order*500) if order>0 else 100
    79                 angle = 2 * math.pi * i / nb
    82                 angle = 2 * math.pi * i / nb
    80                 self.cat_nb_nodes[c].append({ "x": radius*math.cos(angle), "y": radius*math.sin(angle) })
    83                 if c=="northwest":
       
    84                     self.cat_nb_nodes[c].append({ "x": -radius, "y": -radius })
       
    85                 else:
       
    86                     self.cat_nb_nodes[c].append({ "x": radius*math.cos(angle), "y": radius*math.sin(angle) })
    81 
    87 
    82 
    88 
    83 
    89 
    84 def renkan_copier(user, old_rk_id):
    90 def renkan_copier(user, old_rk_id):
    85     old_rk = get_object_or_404(Renkan, rk_id=old_rk_id)
    91     old_rk = get_object_or_404(Renkan, rk_id=old_rk_id)