* src/docgen/LPRDoc.py (write_at): Correct vertical offset.
* src/docgen/PdfDoc.py (write_at,draw_bar): Add functions. * src/docgen/PSDrawDoc.py (write_at): Add function; (draw_bar): Support for filling with color. * src/ReportUtils.py (draw_legend): Correct vertical offset. svn: r4045
This commit is contained in:
parent
08eadb1d9a
commit
e983226112
@ -1,3 +1,10 @@
|
||||
2005-02-17 Alex Roitman <shura@alex.neuro.umn.edu>
|
||||
* src/docgen/LPRDoc.py (write_at): Correct vertical offset.
|
||||
* src/docgen/PdfDoc.py (write_at,draw_bar): Add functions.
|
||||
* src/docgen/PSDrawDoc.py (write_at): Add function;
|
||||
(draw_bar): Support for filling with color.
|
||||
* src/ReportUtils.py (draw_legend): Correct vertical offset.
|
||||
|
||||
2005-02-16 Don Allingham <dallingham@users.sourceforge.net>
|
||||
* src/EditSource.py: commit events after deleting sources
|
||||
* src/Marriage.py: disable buttons in readonly mode
|
||||
|
@ -121,7 +121,7 @@ def draw_legend(doc, start_x, start_y, data):
|
||||
size = pt2cm(doc.get_style(pstyle).get_font().get_size())
|
||||
|
||||
doc.draw_bar(format, start_x, start_y, start_x + (2*size), start_y + size)
|
||||
doc.write_at(pstyle, legend, start_x + (3*size), start_y + (size*0.25))
|
||||
doc.write_at(pstyle, legend, start_x + (3*size), start_y - (size*0.25))
|
||||
start_y += size * 1.3
|
||||
|
||||
def draw_vertical_bar_graph(doc, format, start_x, start_y, height, width, data):
|
||||
|
@ -1071,7 +1071,7 @@ class LPRDoc(BaseDoc.BaseDoc):
|
||||
|
||||
self.gpc.setfont(find_font_from_fontstyle(fontstyle))
|
||||
x = self.left_margin + cm2u(x)
|
||||
y = self.top_margin - cm2u(y)
|
||||
y = self.top_margin - cm2u(y) - fontstyle.get_size() * _EXTRA_SPACING_FACTOR
|
||||
self.gpc.moveto(x,y)
|
||||
self.gpc.show(text)
|
||||
|
||||
|
@ -313,6 +313,17 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
def patch_text(self,text):
|
||||
return text.encode('iso-8859-1')
|
||||
|
||||
def write_at(self,style,text,x,y):
|
||||
para_style = self.style_list[style]
|
||||
|
||||
x = x + self.lmargin
|
||||
y = y + self.tmargin
|
||||
|
||||
self.f.write('gsave\n')
|
||||
self.f.write('%f cm %f cm moveto\n' % self.translate(x,y))
|
||||
self.f.write(self.fontdef(para_style))
|
||||
self.f.write('(%s) show grestore\n' % text)
|
||||
|
||||
def draw_bar(self,style,x1,y1,x2,y2):
|
||||
x1 = x1 + self.lmargin
|
||||
x2 = x2 + self.lmargin
|
||||
@ -320,6 +331,9 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
y2 = y2 + self.tmargin
|
||||
|
||||
box_type = self.draw_styles[style]
|
||||
fill_color = rgb_color(box_type.get_fill_color())
|
||||
color = rgb_color(box_type.get_color())
|
||||
|
||||
self.f.write('gsave\n')
|
||||
self.f.write("%f cm %f cm moveto\n" % self.translate(x1,y1))
|
||||
self.f.write("0 %f cm rlineto\n" % (y2-y1))
|
||||
@ -327,7 +341,8 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
self.f.write("0 %f cm rlineto\n" % (y1-y2))
|
||||
self.f.write('closepath\n')
|
||||
self.f.write("%.4f setlinewidth\n" % box_type.get_line_width())
|
||||
self.f.write('%.4f %.4f %.4f setrgbcolor stroke\n' % rgb_color(box_type.get_color()))
|
||||
self.f.write('gsave %.4f %.4f %.4f setrgbcolor fill grestore\n' % fill_color)
|
||||
self.f.write('%.4f %.4f %.4f setrgbcolor stroke\n' % color)
|
||||
self.f.write('grestore\n')
|
||||
|
||||
def draw_box(self,style,text,x,y):
|
||||
|
@ -379,7 +379,7 @@ class PdfDoc(BaseDoc.BaseDoc):
|
||||
self.drawing = reportlab.graphics.shapes.Drawing(x,y)
|
||||
|
||||
def end_page(self):
|
||||
self.story.append(self.drawing)
|
||||
self.story.append(self.drawing)
|
||||
|
||||
def draw_line(self,style,x1,y1,x2,y2):
|
||||
y1 = self.get_usable_height() - y1
|
||||
@ -397,8 +397,31 @@ class PdfDoc(BaseDoc.BaseDoc):
|
||||
strokeDashArray=line_array)
|
||||
self.drawing.add(l)
|
||||
|
||||
def draw_bar(self,style,x1,y1,x2,y2):
|
||||
pass
|
||||
def write_at(self, style, text, x, y):
|
||||
para_style = self.style_list[style]
|
||||
font_style = para_style.get_font()
|
||||
size = font_style.get_size()
|
||||
y = self.get_usable_height() - y
|
||||
|
||||
if text != "":
|
||||
lines = text.split('\n')
|
||||
self.left_print(lines,font_style,x*cm,y*cm - size)
|
||||
|
||||
def draw_bar(self, style, x1, y1, x2, y2):
|
||||
style = self.draw_styles[style]
|
||||
fill_color = make_color(style.get_fill_color())
|
||||
color = make_color(style.get_color())
|
||||
line_width = style.get_line_width()
|
||||
w = (x2-x1)*cm
|
||||
h = (y2-y1)*cm
|
||||
|
||||
y1 = self.get_usable_height() - y1
|
||||
|
||||
r = reportlab.graphics.shapes.Rect((x1)*cm,(y1*cm)-h,w,h,
|
||||
strokeWidth=line_width,
|
||||
fillColor=fill_color,
|
||||
strokeColor=color)
|
||||
self.drawing.add(r)
|
||||
|
||||
def draw_path(self,style,path):
|
||||
stype = self.draw_styles[style]
|
||||
|
Loading…
Reference in New Issue
Block a user