godot/edge.py
def _on_drawing(self, object, name, old, new):
        """ Handles the containers of drawing components being set.
        """
        attrs = [ "drawing", "arrowhead_drawing" ]

        others = [getattr(self, a) for a in attrs \
            if (a != name) and (getattr(self, a) is not None)]

        x, y = self.component.position
        print "POS:", x, y, self.component.position

        abs_x = [d.x + x for d in others]
        abs_y = [d.y + y for d in others]

        print "ABS:", abs_x, abs_y

        # Assume that he new drawing is positioned relative to graph origin.
        x1 = min( abs_x + [new.x] )
        y1 = min( abs_y + [new.y] )

        print "DRAW:", new.position
        new.position = [ new.x - x1, new.y - y1 ]
        print "DRAW:", new.position

#        for i, b in enumerate( others ):
#            self.drawing.position = [100, 100]
#            self.drawing.request_redraw()
#            print "OTHER:", b.position, abs_x[i] - x1
#            b.position = [ abs_x[i] - x1, abs_y[i] - y1 ]
#            b.x = 50
#            b.y = 50
#            print "OTHER:", b.position, abs_x[i], x1

#        for attr in attrs:
#            if attr != name:
#                if getattr(self, attr) is not None:
#                    drawing = getattr(self, attr)
#                    drawing.position = [50, 50]

        if old is not None:
            self.component.remove( old )
        if new is not None:
            self.component.add( new )

        print "POS NEW:", self.component.position
        self.component.position = [ x1, y1 ]
        print "POS NEW:", self.component.position
        self.component.request_redraw()
        print "POS NEW:", self.component.position
def _on_drawing(self, object, name, old, new):
        """ Handles the containers of drawing components being set.
        """
        attrs = [ "drawing", "arrowhead_drawing" ]

        others = [getattr(self, a) for a in attrs \
            if (a != name) and (getattr(self, a) is not None)]

        x, y = self.component.position
        print "POS:", x, y, self.component.position

        abs_x = [d.x + x for d in others]
        abs_y = [d.y + y for d in others]

        print "ABS:", abs_x, abs_y

        # Assume that he new drawing is positioned relative to graph origin.
        x1 = min( abs_x + [new.x] )
        y1 = min( abs_y + [new.y] )

        print "DRAW:", new.position
        new.position = [ new.x - x1, new.y - y1 ]
        print "DRAW:", new.position

#        for i, b in enumerate( others ):
#            self.drawing.position = [100, 100]
#            self.drawing.request_redraw()
#            print "OTHER:", b.position, abs_x[i] - x1
#            b.position = [ abs_x[i] - x1, abs_y[i] - y1 ]
#            b.x = 50
#            b.y = 50
#            print "OTHER:", b.position, abs_x[i], x1

#        for attr in attrs:
#            if attr != name:
#                if getattr(self, attr) is not None:
#                    drawing = getattr(self, attr)
#                    drawing.position = [50, 50]

        if old is not None:
            self.component.remove( old )
        if new is not None:
            self.component.add( new )

        print "POS NEW:", self.component.position
        self.component.position = [ x1, y1 ]
        print "POS NEW:", self.component.position
        self.component.request_redraw()
        print "POS NEW:", self.component.position
Handles the containers of drawing components being set.