コード例 #1
0
    def draw(self, points, can=None):
        """Parameter <points> specifies the
        list of points the arrow traverses through.
        It should contain at least two points, i.e.,
        the tail and tip. Parameter
        <can> is an optional parameter that specifies the output.
        <<canvas>>
        """
        if can == None: can = canvas.default_canvas()
        self.type_check()
        xtip = points[-1][0]
        ytip = points[-1][1]

        xtail = points[-2][0]
        ytail = points[-2][1]

        can.newpath()
        can.set_line_style(self.line_style)
        if len(points) > 2:
            can.moveto(points[0][0], points[0][1])
            for i in range(1, len(points) - 1):
                can.lineto(points[i][0], points[i][1])

        draw_arrowbody(can, xscale(xtail), yscale(ytail), yscale(xtip),
                       yscale(ytip), nscale(self.head_len))

        can.set_fill_color(self.head_color)
        draw_arrowhead(can, xscale(xtail), yscale(ytail), xscale(xtip),
                       yscale(ytip), nscale(self.thickness),
                       nscale(self.head_len), self.head_style)

        can.setbb(xtail, ytail)
        can.setbb(xtip, ytip)
コード例 #2
0
    def draw(self, can=None):
        if can == None:
            can = canvas.default_canvas()
        x = self.loc[0]
        y = self.loc[1]
        text_width = font.text_width(self.text)
        text_height = font.text_height(self.text)[0]
        (halign, valign, angle) = font.get_align(self.text)

        if self.line_style or self.fill_style:
            width = text_width + self.left_fudge + self.right_fudge
            height = text_height + self.bottom_fudge + self.top_fudge
            can.round_rectangle(self.line_style, self.fill_style,
                                x - self.left_fudge, y - self.bottom_fudge,
                                x - self.left_fudge + width,
                                y - self.bottom_fudge + height, self.radius,
                                self.shadow)

        if halign == 'L':
            can.show(x, y, self.text)
        elif halign == 'C':
            can.show(x + text_width / 2.0, y, self.text)
        elif halign == 'R':
            can.show(x + text_width, y, self.text)
        else:
            raise Exception, "Unsupported alignment (" + halign + ")"

        # draw arrows
        for t in self._arrows:
            (tipLoc, tail, arrow) = t
            if tail:
                (x, y, width, height) = self.get_dimension()
                origin = [x, y]
                for ch in tail:
                    if ch == 'l':
                        origin[0] = x
                    elif ch == 'c':
                        origin[0] = x + width / 2.0
                    elif ch == 'r':
                        origin[0] = x + width
                    elif ch == 'b':
                        origin[1] = y
                    elif ch == 'm':
                        origin[1] = y + height / 2.0
                    elif ch == 't':
                        origin[1] = y + height
                    else:
                        raise ValueError, tail + ": unknown tail location spec."
            else:
                origin = self.choose_end_point(tipLoc[0], tipLoc[1])
            arrow.draw((origin, tipLoc), can)
コード例 #3
0
    def draw(self, can = None):
        if can == None:
            can = canvas.default_canvas()
        x = self.loc[0]
        y = self.loc[1]
        text_width = font.text_width(self.text)
        text_height = font.text_height(self.text)[0]
        (halign, valign, angle) = font.get_align(self.text)
        
        if self.line_style or self.fill_style:
            width = text_width+self.left_fudge+self.right_fudge
            height = text_height+self.bottom_fudge+self.top_fudge
            can.round_rectangle(self.line_style, self.fill_style,
                                   x-self.left_fudge, y-self.bottom_fudge,
                                   x-self.left_fudge+width, y-self.bottom_fudge+height,
                                   self.radius, self.shadow)

        if halign == 'L':
            can.show(x, y, self.text)
        elif halign == 'C':
            can.show(x+text_width/2.0, y, self.text)
        elif halign == 'R':
            can.show(x+text_width, y, self.text)
        else:
            raise Exception, "Unsupported alignment (" + halign + ")"

        # draw arrows
        for t in self._arrows:
            (tipLoc, tail, arrow) = t
            if tail:
                (x, y, width, height) = self.get_dimension()
                origin = [x, y]
                for ch in tail:
                    if ch == 'l':
                        origin[0] = x
                    elif ch == 'c':
                        origin[0] = x+width/2.0
                    elif ch == 'r':
                        origin[0] = x+width
                    elif ch == 'b':
                        origin[1] = y
                    elif ch == 'm':
                        origin[1] = y+height/2.0
                    elif ch == 't':
                        origin[1] = y+height
                    else:
                        raise ValueError, tail +  ": unknown tail location spec."
            else:
                origin = self.choose_end_point(tipLoc[0], tipLoc[1])
            arrow.draw((origin, tipLoc), can)
コード例 #4
0
ファイル: arrow.py プロジェクト: AbdAllah-Ahmed/openerp-env
    def draw(self, points, can = None):
        """Parameter <points> specifies the
        list of points the arrow traverses through.
        It should contain at least two points, i.e.,
        the tail and tip. Parameter
        <can> is an optional parameter that specifies the output.
        <<canvas>>
        """
        if can == None: can = canvas.default_canvas()
        assert self.check_integrity()
        xtip = points[-1][0]
        ytip = points[-1][1]
        
        xtail = points[-2][0]
        ytail = points[-2][1]

        can.newpath()
        can.set_line_style(self.line_style)
        if len(points) > 2:
            can.moveto(points[0][0], points[0][1])
            for i in range(1, len(points)-1):
                can.lineto(points[i][0], points[i][1])

        draw_arrowbody(can, xscale(xtail), yscale(ytail),
                       yscale(xtip), yscale(ytip),
                       nscale(self.head_len))

        can.set_fill_color(self.head_color)
        draw_arrowhead(can, xscale(xtail), yscale(ytail),
                       xscale(xtip), yscale(ytip),
                       nscale(self.thickness),
                       nscale(self.head_len),
                       self.head_style)
        
        can.setbb(xtail, ytail)
        can.setbb(xtip, ytip)
コード例 #5
0
ファイル: area.py プロジェクト: AbdAllah-Ahmed/openerp-env
    def draw(self, can = None):
        "Draw the charts."

        if can == None:
            can = canvas.default_canvas()
            
        assert self.check_integrity()
        
        for plot in self.__plots:
            plot.check_integrity()
            
        self.x_range, self.x_grid_interval = \
                      self.__get_data_range(self.x_range, 'X',
                                            self.x_coord,
                                            self.x_grid_interval)
            
        self.y_range, self.y_grid_interval = \
                      self.__get_data_range(self.y_range, 'Y',
                                            self.y_coord,
                                            self.y_grid_interval)
        
        can.rectangle(self.border_line_style, self.bg_style,
                      self.loc[0], self.loc[1],
                      self.loc[0] + self.size[0], self.loc[1] + self.size[1])

        if not self.x_grid_over_plot:
            self.__draw_x_grid_and_axis(can)

        if not self.y_grid_over_plot:
            self.__draw_y_grid_and_axis(can)

        clipbox = theme.adjust_bounding_box([self.loc[0], self.loc[1],
                                             self.loc[0] + self.size[0],
                                             self.loc[1] + self.size[1]])

        can.clip(clipbox[0], clipbox[1],
                 clipbox[2], clipbox[3])

        for plot in self.__plots:
            plot.draw(self, can)
            
        can.endclip()
            
        if self.x_grid_over_plot:
            self.__draw_x_grid_and_axis(can)
        if self.y_grid_over_plot:
            self.__draw_y_grid_and_axis(can)

        if self.legend == _dummy_legend:
            self.legend = legend.T()
            
        if self.legend:
            legends = []
            for plot in self.__plots:
                entry = plot.get_legend_entry()
                if entry == None:
                    pass
                elif type(entry) != ListType:
                    legends.append(entry)
                else:
                    for e in entry:
                        legends.append(e)
            self.legend.draw(self, legends, can)
コード例 #6
0
ファイル: text_box.py プロジェクト: luowy/xtc
    def draw(self, can = None):
        if can == None:
            can = canvas.default_canvas()
        x = self.loc[0]
        y = self.loc[1]
        text_width = font.text_width(self.text)
        text_height = font.text_height(self.text)[0]
        (halign, valign, angle) = font.get_align(self.text)
        
        if self.line_style or self.fill_style:
            if self.callout == False:
                width = text_width+self.left_fudge+self.right_fudge
                height = text_height+self.bottom_fudge+self.top_fudge
                can.round_rectangle(self.line_style, self.fill_style,
                                    x-self.left_fudge, y-self.bottom_fudge,
                                    x-self.left_fudge+width, y-self.bottom_fudge+height,
                                    self.radius, self.shadow)
            else:
                width = text_width+self.left_fudge+self.right_fudge
                height = text_height+self.bottom_fudge+self.top_fudge

                cx = x + self.callout_shift
                cy = y
                csize = self.callout_size

                x1 = x-self.left_fudge
                y1 = y-self.bottom_fudge
                x2 = x-self.left_fudge+width
                y2 = y-self.bottom_fudge+height

                p0 = (cx,y1-csize)
                p1 = (cx-csize,y1)
                p2 = (cx+csize,y1)

                px0,py0 = p0
                px1,py1 = p1
                px2,py2 = p2

                can.polygon(None, self.fill_style,
                            [p0, p1, p2])

                can.line(self.line_style, px0, py0, px1, py1)
                can.line(self.line_style, px0, py0, px2, py2)

                can.round_rectangle(None, self.fill_style,
                                    x-self.left_fudge, y-self.bottom_fudge,
                                    x-self.left_fudge+width, y-self.bottom_fudge+height,
                                    self.radius, self.shadow)

                can.line(self.line_style, x2, y1, x2, y2)
                can.line(self.line_style, x2, y2, x1, y2)
                can.line(self.line_style, x1, y2, x1, y1)
                can.line(self.line_style, x1, y1, px1, y1)
                can.line(self.line_style, px2, y1, x2, y1)



        if halign == 'L':
            can.show(x, y, self.text)
        elif halign == 'C':
            can.show(x+text_width/2.0, y, self.text)
        elif halign == 'R':
            can.show(x+text_width, y, self.text)
        else:
            raise Exception, "Unsupported alignment (" + halign + ")"

        # draw arrows
        for t in self._arrows:
            (tipLoc, tail, arrow) = t
            if tail:
                (x, y, width, height) = self.get_dimension()
                origin = [x, y]
                for ch in tail:
                    if ch == 'l':
                        origin[0] = x
                    elif ch == 'c':
                        origin[0] = x+width/2.0
                    elif ch == 'r':
                        origin[0] = x+width
                    elif ch == 'b':
                        origin[1] = y
                    elif ch == 'm':
                        origin[1] = y+height/2.0
                    elif ch == 't':
                        origin[1] = y+height
                    else:
                        raise ValueError, tail +  ": unknown tail location spec."
            else:
                origin = self.choose_end_point(tipLoc[0], tipLoc[1])
            arrow.draw((origin, tipLoc), can)
コード例 #7
0
ファイル: area.py プロジェクト: glosoftgroup/odoo-sample
    def draw(self, can=None):
        "Draw the charts."

        if can == None:
            can = canvas.default_canvas()

        assert self.check_integrity()

        for plot in self.__plots:
            plot.check_integrity()

        self.x_range, self.x_grid_interval = \
                      self.__get_data_range(self.x_range, 'X',
                                            self.x_coord,
                                            self.x_grid_interval)

        self.y_range, self.y_grid_interval = \
                      self.__get_data_range(self.y_range, 'Y',
                                            self.y_coord,
                                            self.y_grid_interval)

        can.rectangle(self.border_line_style, self.bg_style, self.loc[0],
                      self.loc[1], self.loc[0] + self.size[0],
                      self.loc[1] + self.size[1])

        if not self.x_grid_over_plot:
            self.__draw_x_grid_and_axis(can)

        if not self.y_grid_over_plot:
            self.__draw_y_grid_and_axis(can)

        clipbox = theme.adjust_bounding_box([
            self.loc[0], self.loc[1], self.loc[0] + self.size[0],
            self.loc[1] + self.size[1]
        ])

        can.clip(clipbox[0], clipbox[1], clipbox[2], clipbox[3])

        for plot in self.__plots:
            plot.draw(self, can)

        can.endclip()

        if self.x_grid_over_plot:
            self.__draw_x_grid_and_axis(can)
        if self.y_grid_over_plot:
            self.__draw_y_grid_and_axis(can)

        if self.legend == _dummy_legend:
            self.legend = legend.T()

        if self.legend:
            legends = []
            for plot in self.__plots:
                entry = plot.get_legend_entry()
                if entry == None:
                    pass
                elif type(entry) != ListType:
                    legends.append(entry)
                else:
                    for e in entry:
                        legends.append(e)
            self.legend.draw(self, legends, can)