コード例 #1
0
ファイル: rect.py プロジェクト: jggatc/pyj2d
    def __init__(self, *arg):
        """
        Return Rect that is subclassed from java.awt.Rectangle.
        
        Alternative arguments:
        
        * x, y, width, height
        * (x, y), (width, height)
        * (x, y, width, height)
        * Rect
        * Obj with rect attribute

        Rect has the attributes::
        
        x, y, width, height
        top, left, bottom, right
        topleft, bottomleft, topright, bottomright
        midtop, midleft, midbottom, midright
        center, centerx, centery
        size, w, h
        
        Module initialization places pyj2d.Rect in module's namespace.
        """
        def unpack(arg, lst=[]):
            for x in arg:
                if not isinstance(x, tuple):
                    lst.append(x)
                else:
                    lst = unpack(x, lst)
            return lst

        try:
            x = arg[0]
            y = arg[1]
            w = arg[2]
            h = arg[3]
        except IndexError:
            try:
                x = arg[0][0]
                y = arg[0][1]
                w = arg[0][2]
                h = arg[0][3]
            except (IndexError, TypeError, AttributeError):
                arg = unpack(arg)
                try:
                    x = arg[0]
                    y = arg[1]
                    w = arg[2]
                    h = arg[3]
                except IndexError:
                    if hasattr(arg[0], 'rect'):
                        arg[0] = arg[0].rect
                    x = arg[0].x
                    y = arg[0].y
                    w = arg[0].width
                    h = arg[0].height
        try:
            Rectangle.__init__(self, x, y, w, h)
        except TypeError:
            Rectangle.__init__(self, int(x), int(y), int(w), int(h))
コード例 #2
0
ファイル: rect.py プロジェクト: jggatc/pyj2d
    def __init__(self, *arg):
        """
        Return Rect that is subclassed from java.awt.Rectangle.
        
        Alternative arguments:
        
        * x,y,w,h
        * (x,y),(w,h)
        * (x,y,w,h)
        * Rect
        * Obj with rect attribute

        Rect has the attributes::
        
            x, y, width, height
        
        Additional Rect attributes::
        
            top, left, bottom, right, topleft, bottomleft, topright, bottomright,
            midtop, midleft, midbottom, midright, center, centerx, centery,
            size, w, h.
        
        Module initialization places pyj2d.Rect in module's namespace.
        """
        def unpack(arg, lst=[]):
            for x in arg:
                if not isinstance(x, tuple):
                    lst.append(x)
                else:
                    lst = unpack(x, lst)
            return lst
        try:
            x,y,w,h = arg[0], arg[1], arg[2], arg[3]
        except IndexError:
            try:
                x,y,w,h = arg[0][0], arg[0][1], arg[0][2], arg[0][3]
            except (IndexError, TypeError, AttributeError):
                arg = unpack(arg)
                try:
                    x,y,w,h = arg[0], arg[1], arg[2], arg[3]
                except IndexError:
                    if hasattr(arg[0], 'rect'):
                        arg[0] = arg[0].rect
                    x,y,w,h = arg[0].x, arg[0].y, arg[0].width, arg[0].height
        try:
            Rectangle.__init__(self, x, y, w, h)
        except TypeError:
            Rectangle.__init__(self, int(x), int(y), int(w), int(h))
コード例 #3
0
    def __init__(self, *arg):
        """
        Return Rect that is subclassed from java.awt.Rectangle.
        
        Alternative arguments:
        
        * x,y,w,h
        * (x,y),(w,h)
        * (x,y,w,h)
        * Rect
        * Obj with rect attribute

        Rect has the attributes::
        
            x, y, width, height
        
        Additional Rect attributes::
        
            top, left, bottom, right, topleft, bottomleft, topright, bottomright,
            midtop, midleft, midbottom, midright, center, centerx, centery,
            size, w, h.
        
        Module initialization places pyj2d.Rect in module's namespace.
        """
        try:
            x, y, w, h = arg[0], arg[1], arg[2], arg[3]
        except IndexError:
            try:
                x, y, w, h = arg[0].rect.x, arg[0].rect.y, arg[
                    0].rect.width, arg[0].rect.height
            except AttributeError:
                try:
                    x, y, w, h = arg[0].x, arg[0].y, arg[0].width, arg[
                        0].height
                except AttributeError:
                    try:
                        x, y, w, h = arg[0][0], arg[0][1], arg[1][0], arg[1][1]
                    except IndexError:
                        x, y, w, h = arg[0][0], arg[0][1], arg[0][2], arg[0][3]
        try:
            Rectangle.__init__(self, x, y, w, h)
        except TypeError:
            Rectangle.__init__(self, int(x), int(y), int(w), int(h))
コード例 #4
0
ファイル: rect.py プロジェクト: YuliReiri/WinLifeGame
    def __init__(self, *arg):
        """
        Return Rect that is subclassed from java.awt.Rectangle.
        
        Alternative arguments:
        
        * x,y,w,h
        * (x,y),(w,h)
        * (x,y,w,h)
        * Rect
        * Obj with rect attribute

        Rect has the attributes::
        
            x, y, width, height
        
        Additional Rect attributes::
        
            top, left, bottom, right, topleft, bottomleft, topright, bottomright,
            midtop, midleft, midbottom, midright, center, centerx, centery,
            size, w, h.
        
        Module initialization places pyj2d.Rect in module's namespace.
        """
        try:
            x,y,w,h = arg[0], arg[1], arg[2], arg[3]
        except IndexError:
            try:
                x,y,w,h = arg[0].rect.x, arg[0].rect.y, arg[0].rect.width, arg[0].rect.height
            except AttributeError:
                try:
                    x,y,w,h = arg[0].x, arg[0].y, arg[0].width, arg[0].height
                except AttributeError:
                    try:
                        x,y,w,h = arg[0][0], arg[0][1], arg[1][0], arg[1][1]
                    except IndexError:
                        x,y,w,h = arg[0][0], arg[0][1], arg[0][2], arg[0][3]
        try:
            Rectangle.__init__(self, x, y, w, h)
        except TypeError:
            Rectangle.__init__(self, int(x), int(y), int(w), int(h))
コード例 #5
0
 def __init__(self):
     Rectangle.__init__(self, 6, 7)
コード例 #6
0
 def __init__(self):
     Rectangle.__init__(self, 6, 7)