def paint(self, di):
        gc = di.gc
        tx = di.tx

        trans = [tx(p) for p in self.points]
        points = [(t.x, t.y) for t in trans]
        gtk.draw_polygon(di.area, gc, gtk.FALSE, points)
    def paint(self, di):
        gc = di.gc
        tx = di.tx

        trans = [tx(p) for p in self.points]
        points = [(t.x, t.y) for t in trans]
        gtk.draw_polygon(di.area, gc, gtk.FALSE, points)
    def paint(self, di):
        gc = di.gc
        colormap = di.colormap
        tx = di.tx

        trans = [tx(p) for p in self.polygon.points]

        bounds = self.polygon.getBounds()
        if max(bounds.width, bounds.height) * di.canvas.scale > 30000:
            # gtk doesn't like getting coordinates bigger than 32767.
            # Those cause an illogical error message
            # "TypeError: sequence member not a 2-tuple"
            for p in trans:
                if p.x > 30000:
                    p.x = 30000
                elif p.x < -30000:
                    p.x = -30000
                if p.y > 30000:
                    p.y = 30000
                elif p.y < -30000:
                    p.y = -30000

        points = [(t.x, t.y) for t in trans]

        nofill = 1
        if self.style.textured and di.canvas.textured:
            if self.style.texture.scalable:
                gc.tile = self.style.texture.image[di.scale * 64]
            else:
                gc.tile = self.style.texture.image[1]
            # !@# Should align the texture
            gc.fill = GDK.TILED
            nofill = 0
        elif self.style.filled and di.canvas.filled:
            gc.foreground = colormap.alloc(*gcolor(self.style.color))
            nofill = 0
        if not nofill:
            gtk.draw_polygon(di.area, gc, gtk.TRUE, points)
            gc.fill = GDK.SOLID

        if self.edgeStyles is None:
            df = self.style.defaultEdgeStyle
            if df.style != LineStyle.STYLE_HIDDEN or nofill:
                gc.foreground = colormap.alloc(*gcolor(df.color))
                gtk.draw_polygon(di.area, gc, gtk.FALSE, points)
                # !@# dashed lines, width missing here
        else:
            si = 0
            cs = self.edgeStyles[0]
            for i in range(1, len(points)):
                if self.edgeStyles[i] == cs:
                    continue
                lstyle = cs or self.style.defaultEdgeStyle
                if lstyle.style != LineStyle.STYLE_HIDDEN or nofill:
                    gc.foreground = colormap.alloc(*gcolor(lstyle.color))
                    gtk.draw_lines(di.area, gc, points[si:i + 1])
                si = i
                cs = self.edgeStyles[i]
            points2 = points[si:]
            points2.append(points[0])
            lstyle = cs or self.style.defaultEdgeStyle
            if lstyle.style != LineStyle.STYLE_HIDDEN or nofill:
                gc.foreground = colormap.alloc(*gcolor(lstyle.color))
                gtk.draw_lines(di.area, gc, points2)

        if di.canvas.showPoints:
            for p in points:
                gtk.draw_rectangle(di.area, di.white_gc, gtk.FALSE, p[0] - 1,
                                   p[1] - 1, 2, 2)
    def paint(self, di):
        gc = di.gc
        colormap = di.colormap
        tx = di.tx

        trans = [tx(p) for p in self.polygon.points]

        bounds = self.polygon.getBounds()
        if max(bounds.width, bounds.height) * di.canvas.scale > 30000:
            # gtk doesn't like getting coordinates bigger than 32767.
            # Those cause an illogical error message
            # "TypeError: sequence member not a 2-tuple"
            for p in trans:
                if p.x > 30000:
                    p.x = 30000
                elif p.x < -30000:
                    p.x = -30000
                if p.y > 30000:
                    p.y = 30000
                elif p.y < -30000:
                    p.y = -30000

        points = [(t.x, t.y) for t in trans]

        nofill = 1
        if self.style.textured and di.canvas.textured:
            if self.style.texture.scalable:
                gc.tile = self.style.texture.image[di.scale * 64]
            else:
                gc.tile = self.style.texture.image[1]
            # !@# Should align the texture
            gc.fill = GDK.TILED
            nofill = 0
        elif self.style.filled and di.canvas.filled:
            gc.foreground = colormap.alloc(*gcolor(self.style.color))
            nofill = 0
        if not nofill:
            gtk.draw_polygon(di.area, gc, gtk.TRUE, points)
            gc.fill = GDK.SOLID

        if self.edgeStyles is None:
            df = self.style.defaultEdgeStyle
            if df.style != LineStyle.STYLE_HIDDEN or nofill:
                gc.foreground = colormap.alloc(*gcolor(df.color))
                gtk.draw_polygon(di.area, gc, gtk.FALSE, points)
                # !@# dashed lines, width missing here
        else:
            si = 0
            cs = self.edgeStyles[0]
            for i in range(1, len(points)):
                if self.edgeStyles[i] == cs:
                    continue
                lstyle = cs or self.style.defaultEdgeStyle
                if lstyle.style != LineStyle.STYLE_HIDDEN or nofill:
                    gc.foreground = colormap.alloc(*gcolor(lstyle.color))
                    gtk.draw_lines(di.area, gc, points[si:i+1])
                si = i
                cs = self.edgeStyles[i]
            points2 = points[si:]
            points2.append(points[0])
            lstyle = cs or self.style.defaultEdgeStyle
            if lstyle.style != LineStyle.STYLE_HIDDEN or nofill:
                gc.foreground = colormap.alloc(*gcolor(lstyle.color))
                gtk.draw_lines(di.area, gc, points2)

        if di.canvas.showPoints:
            for p in points:
                gtk.draw_rectangle(di.area, di.white_gc, gtk.FALSE,
                                   p[0] - 1, p[1] - 1, 2, 2)