コード例 #1
0
 def display_x_values(self, win, date):
     displaystring = ("%.0f ") % (date, )
     font = drawing.font('6x10')
     green = drawing.colour('green')
     y = self.get_y() - 5
     gtk.draw_text(win, font.get_font(), green.get_colour(), 0, y,
                   displaystring)
コード例 #2
0
ファイル: ChartTools.py プロジェクト: brucewoodward/chase
    def motion_notify(self, current_chart, win, event, gtk_values):
        # make sure that the line is not on the edge of the screen.
        tmp_width = gtk_values['da'].get_window().width
        tmp_height = gtk_values['da'].get_window().height
        if event.x >= tmp_width or event.y >= tmp_height:
            return self

        yellow = drawing.colour('yellow')
        # line_drawing_common will add a height and width variable to the
        # class.
        window, red, event = line_drawing_common(self, current_chart, win,
                                                 event, gtk_values)
        x1 = event.x
        y1 = event.y
        # y2 = m (x2 - x1) * y1
        y2 = self.m * (self.width - x1) + y1
        if y2 > self.height:  # touching the bottom of the chart.
            y2 = self.height
        x2 = (y2 - y1) / self.m + x1
        draw_line(window, yellow.get_colour(), x1, y1, x2, y2)
        self.xstart = x1
        self.ystart = y1
        self.xend = x2
        self.yend = y2
        return self
コード例 #3
0
ファイル: ChartTools.py プロジェクト: brucewoodward/chase
 def motion_notify(self, current_chart, win, event, gtk_values):
     if self.xstart != -1 and self.ystart != -1:
         width = 0
         height = 0
         x1 = 0.0
         y1 = 0.0
         if current_chart == None:
             self
         yellow = drawing.colour('yellow')
         x = event.x
         y = event.y
         subchart = current_chart.translate_x_y_into_subchart(x, y)
         if subchart != self.subchart:
             return self
         s = gtk_values['secondary_pixmap']
         xold = self.xold
         yold = self.yold
         if xold == -1:
             xold = x
         if yold == -1:
             yold = y
         ypix = self.ypix
         xpix = self.xpix
         if xold >= xpix and yold >= ypix:
             x1 = xpix
             y1 = ypix
             width = xold - xpix + 1
             height = yold - ypix + 1
         elif xold > xpix and yold < ypix:
             x1 = xpix
             y1 = yold
             width = xold - xpix + 1
             height = ypix - yold + 1
         elif xold <= xpix and yold <= ypix:
             x1 = xold
             y1 = yold
             width = xpix - xold + 1
             height = ypix - yold + 1
         elif xold < xpix and yold > ypix:
             x1 = xold
             y1 = ypix
             width = abs(xpix - xold) + 1
             height = abs(ypix - yold) + 1
         else:
             print "what the hello"
             return self
         window = win.get_window()
         draw_pixmap(window,
                     win.get_style().fg_gc[STATE_ACTIVE], s, x1, y1, x1, y1,
                     width, height)
         draw_line(window, yellow.get_colour(), xpix, ypix, x, y)
         self.xold = x
         self.yold = y
     return self
コード例 #4
0
ファイル: ChartTools.py プロジェクト: brucewoodward/chase
def line_drawing_common(obj, current_chart, win, event, gtk_values):
    if current_chart == None:
        return
    red = drawing.colour('red')
    s = gtk_values['secondary_pixmap']
    ## Used more than once, so cache it.
    window = win.get_window()
    window = gtk_values['da'].get_window()
    obj.height = window.height
    obj.width = window.width
    draw_pixmap(window,
                win.get_style().fg_gc[STATE_ACTIVE], s, 0, 0, 0, 0,
                window.width, window.height)
    return window, red, event
コード例 #5
0
 def display_values(self, win, date, x, y, dataset):
     displaystring = ("%.0f ") % (date, )
     for d in self.drawables.keys():
         dr = self.drawables[d]
         drvalue = dr.get_value_at_x(x, dataset, date)
         # dataseries can have a null value at a given point
         if drvalue == None:
             continue
         for l in drvalue:
             # 0 is the title, 1 is the value.
             displaystring += ("%s:%.2f ") % (l[0], l[1])
     y = self.get_y() - 5
     font = drawing.font('6x10')
     green = drawing.colour('green')
     gtk.draw_text(win, font.get_font(), green.get_colour(), 0, y,
                   displaystring)
     del displaystring
コード例 #6
0
ファイル: YScale.py プロジェクト: brucewoodward/chase
def draw(ymax, ymin, scale_x1, x1, y1, height, \
         width, yscale, lowest, \
         scale_area, horizontal_grid_lines, minpix=20):
    interval = _calc_interval(ymax, ymin, height, minpix, yscale)
    drawline = drawing.drawline
    drawtext = drawing.drawtext
    drawpoints = drawing.drawpoints
    grey = drawing.colour('grey')
    drawline(grey, scale_x1+3, y1, scale_x1+3, y1 + height)
    ystart = _cal_ystart(interval, ymin)
    font = drawing.font('6x10')
    y = ystart
    gridpoints = []
    while (y < ymax):
        yv = y1 + height - ((y - lowest) * yscale)
        drawline(grey, scale_x1, int(yv), scale_x1+3, int(yv))
        drawtext(font, grey, scale_x1+7, int(yv)+5,
                 ("%.2f") % float(str(y)))
        if horizontal_grid_lines:
            for x in range(x1, width+1, 10):
                gridpoints.append((x,yv))
        y += interval
    if horizontal_grid_lines:
        drawpoints(grey, gridpoints)
コード例 #7
0
ファイル: XScale.py プロジェクト: brucewoodward/chase
 def _set_defaults(self):
     self.font = drawing.font('6x10')
     self.grey = drawing.colour('grey')