def make_default_style(self, default_style): """Make the default output style for the Kinship Report.""" f = FontStyle() f.set_size(16) f.set_type_face(FONT_SANS_SERIF) f.set_bold(1) p = ParagraphStyle() p.set_header_level(1) p.set_bottom_border(1) p.set_bottom_margin(ReportUtils.pt2cm(8)) p.set_font(f) p.set_alignment(PARA_ALIGN_CENTER) p.set_description(_("The style used for the title of the page.")) default_style.add_paragraph_style("KIN-Title", p) font = FontStyle() font.set_size(12) font.set_bold(True) p = ParagraphStyle() p.set_header_level(3) p.set_font(font) p.set_top_margin(ReportUtils.pt2cm(6)) p.set_description(_('The basic style used for sub-headings.')) default_style.add_paragraph_style("KIN-Subtitle", p) font = FontStyle() font.set_size(10) p = ParagraphStyle() p.set_font(font) p.set_left_margin(0.5) p.set_description(_('The basic style used for the text display.')) default_style.add_paragraph_style("KIN-Normal", p)
def make_default_style(self, default_style): """Make the default output style for the Summary Report.""" font = FontStyle() font.set_size(16) font.set_type_face(FONT_SANS_SERIF) font.set_bold(1) para = ParagraphStyle() para.set_header_level(1) para.set_bottom_border(1) para.set_top_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_font(font) para.set_alignment(PARA_ALIGN_CENTER) para.set_description(_("The style used for the title of the page.")) default_style.add_paragraph_style("SR-Title", para) font = FontStyle() font.set_size(12) font.set_bold(True) para = ParagraphStyle() para.set_font(font) para.set_top_margin(0) para.set_description(_('The basic style used for sub-headings.')) default_style.add_paragraph_style("SR-Heading", para) font = FontStyle() font.set_size(12) para = ParagraphStyle() para.set(first_indent=-0.75, lmargin=.75) para.set_font(font) para.set_top_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_description(_('The basic style used for the text display.')) default_style.add_paragraph_style("SR-Normal", para)
def make_default_style(self, default_style): #Paragraph Styles font = FontStyle() font.set_type_face(FONT_SANS_SERIF) font.set_size(16) font.set_bold(True) para = ParagraphStyle() para.set_font(font) para.set_alignment(PARA_ALIGN_CENTER) para.set_description(_("The style used for the report title.")) default_style.add_paragraph_style('REC-Title', para) font = FontStyle() font.set_type_face(FONT_SANS_SERIF) font.set_size(12) font.set_bold(True) para = ParagraphStyle() para.set_font(font) para.set_alignment(PARA_ALIGN_CENTER) para.set_bottom_border(True) para.set_bottom_margin(ReportUtils.pt2cm(8)) para.set_description(_("The style used for the report subtitle.")) default_style.add_paragraph_style('REC-Subtitle', para) font = FontStyle() font.set_size(12) font.set_bold(True) para = ParagraphStyle() para.set_font(font) para.set_top_margin(ReportUtils.pt2cm(6)) para.set_description(_('The style used for headings.')) default_style.add_paragraph_style('REC-Heading', para) font = FontStyle() font.set_size(10) para = ParagraphStyle() para.set_font(font) para.set_left_margin(0.5) para.set_description(_('The basic style used for the text display.')) default_style.add_paragraph_style('REC-Normal', para) font = FontStyle() font.set_size(8) para = ParagraphStyle() para.set_font(font) para.set_alignment(PARA_ALIGN_CENTER) para.set_top_border(True) para.set_top_margin(ReportUtils.pt2cm(8)) para.set_description(_('The style used for the footer.')) default_style.add_paragraph_style('REC-Footer', para)
def draw_legend(doc, start_x, start_y, data, title, label_style): """ Draws a legend for a graph in the specified document. The data passed is used to define the legend. First item style is used for the optional Legend title. @param doc: Document to which the legend chart should be added @type doc: BaseDoc derived class @param start_x: x coordinate in centimeters where the left hand corner of the legend is placed. 0 is the left hand edge of the document. @type start_x: float @param start_y: y coordinate in centimeters where the top of the legend should be. 0 is the top edge of the document @type start_y: float @param data: List of tuples containing the data to be used to create the legend. In order to be compatible with the graph plots, the first and third values of the tuple used. The format is (graphics_format, value, legend_description). @type data: list """ style_sheet = doc.get_style_sheet() if title: gstyle = style_sheet.get_draw_style(label_style) pstyle_name = gstyle.get_paragraph_style() pstyle = style_sheet.get_paragraph_style(pstyle_name) size = ReportUtils.pt2cm(pstyle.get_font().get_size()) doc.draw_text(label_style, title, start_x + (3 * size), start_y - (size * 0.25)) start_y += size * 1.3 for (format, size, legend) in data: gstyle = style_sheet.get_draw_style(format) pstyle_name = gstyle.get_paragraph_style() pstyle = style_sheet.get_paragraph_style(pstyle_name) size = ReportUtils.pt2cm(pstyle.get_font().get_size()) doc.draw_box(format, "", start_x, start_y, (2 * size), size) doc.draw_text(label_style, legend, start_x + (3 * size), start_y - (size * 0.25)) start_y += size * 1.3
def make_default_style(self, default_style): """Make the default output style for the Number of Ancestors Report.""" font = FontStyle() font.set_size(16) font.set_type_face(FONT_SANS_SERIF) font.set_bold(1) para = ParagraphStyle() para.set_header_level(1) para.set_bottom_border(1) para.set_bottom_margin(ReportUtils.pt2cm(8)) para.set_font(font) para.set_alignment(PARA_ALIGN_CENTER) para.set_description(_("The style used for the title of the page.")) default_style.add_paragraph_style("NOA-Title", para) font = FontStyle() font.set_size(12) para = ParagraphStyle() para.set_font(font) para.set_description(_('The basic style used for the text display.')) default_style.add_paragraph_style("NOA-Normal", para)
def output_piechart(self, title, typename, data, lookup): # set layout variables middle_w = self.doc.get_usable_width() / 2 middle_h = self.doc.get_usable_height() / 2 middle = min(middle_w, middle_h) # start output self.doc.center_text('SC-title', title, middle_w, 0) style_sheet = self.doc.get_style_sheet() pstyle = style_sheet.get_paragraph_style('SC-Title') yoffset = ReportUtils.pt2cm(pstyle.get_font().get_size()) # collect data for output color = 0 chart_data = [] for key in lookup: style = "SC-color-%d" % color text = "%s (%d)" % (key, data[key]) # graphics style, value, and it's label chart_data.append((style, data[key], text)) color = (color + 1) % 7 # There are only 7 color styles defined margin = 1.0 legendx = 2.0 # output data... radius = middle - 2 * margin yoffset += margin + radius draw_pie_chart(self.doc, middle_w, yoffset, radius, chart_data, -90) yoffset += radius + 2 * margin if middle == middle_h: # Landscape legendx = 1.0 yoffset = margin text = _("%s (persons):") % typename draw_legend(self.doc, legendx, yoffset, chart_data, text, 'SC-legend')
def make_default_style(self, default_style): """Make the default output style for the Descendant Report.""" f = FontStyle() f.set_size(12) f.set_type_face(FONT_SANS_SERIF) f.set_bold(1) p = ParagraphStyle() p.set_header_level(1) p.set_bottom_border(1) p.set_top_margin(ReportUtils.pt2cm(3)) p.set_bottom_margin(ReportUtils.pt2cm(3)) p.set_font(f) p.set_alignment(PARA_ALIGN_CENTER) p.set_description(_("The style used for the title of the page.")) default_style.add_paragraph_style("DR-Title", p) f = FontStyle() f.set_size(10) for i in range(1, 33): p = ParagraphStyle() p.set_font(f) p.set_top_margin(ReportUtils.pt2cm(f.get_size() * 0.125)) p.set_bottom_margin(ReportUtils.pt2cm(f.get_size() * 0.125)) p.set_first_indent(-0.5) p.set_left_margin(min(10.0, float(i - 0.5))) p.set_description( _("The style used for the " "level %d display.") % i) default_style.add_paragraph_style("DR-Level%d" % min(i, 32), p) p = ParagraphStyle() p.set_font(f) p.set_top_margin(ReportUtils.pt2cm(f.get_size() * 0.125)) p.set_bottom_margin(ReportUtils.pt2cm(f.get_size() * 0.125)) p.set_left_margin(min(10.0, float(i - 0.5))) p.set_description( _("The style used for the " "spouse level %d display.") % i) default_style.add_paragraph_style("DR-Spouse%d" % min(i, 32), p)
def make_default_style(self, default_style): """Make the default output style for the End of Line Report.""" # Paragraph Styles f = FontStyle() f.set_size(16) f.set_type_face(FONT_SANS_SERIF) f.set_bold(1) p = ParagraphStyle() p.set_header_level(1) p.set_bottom_border(1) p.set_bottom_margin(ReportUtils.pt2cm(8)) p.set_font(f) p.set_alignment(PARA_ALIGN_CENTER) p.set_description(_("The style used for the title of the page.")) default_style.add_paragraph_style("EOL-Title", p) font = FontStyle() font.set(face=FONT_SANS_SERIF, size=12, italic=1) p = ParagraphStyle() p.set_bottom_margin(ReportUtils.pt2cm(6)) p.set_font(font) p.set_alignment(PARA_ALIGN_CENTER) p.set_description(_('The style used for the section headers.')) default_style.add_paragraph_style("EOL-Subtitle", p) font = FontStyle() font.set_size(10) p = ParagraphStyle() p.set_font(font) p.set_top_margin(ReportUtils.pt2cm(6)) p.set_bottom_margin(ReportUtils.pt2cm(6)) p.set_description(_('The basic style used for the text display.')) default_style.add_paragraph_style("EOL-Normal", p) font = FontStyle() font.set_size(12) font.set_italic(True) p = ParagraphStyle() p.set_font(font) p.set_top_margin(ReportUtils.pt2cm(6)) p.set_description(_('The basic style used for generation headings.')) default_style.add_paragraph_style("EOL-Generation", p) font = FontStyle() font.set_size(8) p = ParagraphStyle() p.set_font(font) p.set_top_margin(0) p.set_bottom_margin(ReportUtils.pt2cm(6)) p.set_description(_('The basic style used for the text display.')) default_style.add_paragraph_style("EOL-Pedigree", p) #Table Styles cell = TableCellStyle() default_style.add_cell_style('EOL-TableCell', cell) cell = TableCellStyle() cell.set_bottom_border(1) default_style.add_cell_style('EOL_GenerationCell', cell) table = TableStyle() table.set_width(100) table.set_columns(2) table.set_column_width(0, 10) table.set_column_width(1, 90) default_style.add_table_style('EOL-Table', table)
def make_default_style(self, default_style): """Make the default output style for the Tag Report.""" # Paragraph Styles f = FontStyle() f.set_size(16) f.set_type_face(FONT_SANS_SERIF) f.set_bold(1) p = ParagraphStyle() p.set_header_level(1) p.set_bottom_border(1) p.set_top_margin(ReportUtils.pt2cm(3)) p.set_bottom_margin(ReportUtils.pt2cm(3)) p.set_font(f) p.set_alignment(PARA_ALIGN_CENTER) p.set_description(_("The style used for the title of the page.")) default_style.add_paragraph_style("TR-Title", p) font = FontStyle() font.set(face=FONT_SANS_SERIF, size=14, italic=1) para = ParagraphStyle() para.set_font(font) para.set_header_level(2) para.set_top_margin(0.25) para.set_bottom_margin(0.25) para.set_description(_('The style used for the section headers.')) default_style.add_paragraph_style("TR-Heading", para) font = FontStyle() font.set_size(12) p = ParagraphStyle() p.set(first_indent=-0.75, lmargin=.75) p.set_font(font) p.set_top_margin(ReportUtils.pt2cm(3)) p.set_bottom_margin(ReportUtils.pt2cm(3)) p.set_description(_('The basic style used for the text display.')) default_style.add_paragraph_style("TR-Normal", p) font = FontStyle() font.set_size(12) font.set_bold(True) p = ParagraphStyle() p.set(first_indent=-0.75, lmargin=.75) p.set_font(font) p.set_top_margin(ReportUtils.pt2cm(3)) p.set_bottom_margin(ReportUtils.pt2cm(3)) p.set_description(_('The basic style used for table headings.')) default_style.add_paragraph_style("TR-Normal-Bold", p) para = ParagraphStyle() p.set(first_indent=-0.75, lmargin=.75) para.set_top_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_description(_('The basic style used for the note display.')) default_style.add_paragraph_style("TR-Note", para) #Table Styles cell = TableCellStyle() default_style.add_cell_style('TR-TableCell', cell) table = TableStyle() table.set_width(100) table.set_columns(4) table.set_column_width(0, 10) table.set_column_width(1, 30) table.set_column_width(2, 30) table.set_column_width(3, 30) default_style.add_table_style('TR-Table', table)
def make_default_style(self, default_style): """Make the default output style for the Individual Complete Report.""" # Paragraph Styles font = FontStyle() font.set_bold(1) font.set_type_face(FONT_SANS_SERIF) font.set_size(16) para = ParagraphStyle() para.set_alignment(PARA_ALIGN_CENTER) para.set_top_margin(ReportUtils.pt2cm(8)) para.set_bottom_margin(ReportUtils.pt2cm(8)) para.set_font(font) para.set_description(_("The style used for the title of the page.")) default_style.add_paragraph_style("IDS-Title", para) font = FontStyle() font.set_bold(1) font.set_type_face(FONT_SANS_SERIF) font.set_size(12) font.set_italic(1) para = ParagraphStyle() para.set_font(font) para.set_top_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_description(_("The style used for category labels.")) default_style.add_paragraph_style("IDS-TableTitle", para) font = FontStyle() font.set_bold(1) font.set_type_face(FONT_SANS_SERIF) font.set_size(12) para = ParagraphStyle() para.set_font(font) para.set_top_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_description(_("The style used for the spouse's name.")) default_style.add_paragraph_style("IDS-Spouse", para) font = FontStyle() font.set_size(12) para = ParagraphStyle() para.set_font(font) para.set_top_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_description(_('The basic style used for the text display.')) default_style.add_paragraph_style("IDS-Normal", para) # Table Styles tbl = TableStyle() tbl.set_width(100) tbl.set_columns(2) tbl.set_column_width(0, 20) tbl.set_column_width(1, 80) default_style.add_table_style("IDS-IndTable", tbl) tbl = TableStyle() tbl.set_width(100) tbl.set_columns(2) tbl.set_column_width(0, 50) tbl.set_column_width(1, 50) default_style.add_table_style("IDS-ParentsTable", tbl) cell = TableCellStyle() cell.set_top_border(1) cell.set_bottom_border(1) default_style.add_cell_style("IDS-TableHead", cell) cell = TableCellStyle() default_style.add_cell_style("IDS-NormalCell", cell) cell = TableCellStyle() cell.set_longlist(1) default_style.add_cell_style("IDS-ListCell", cell) tbl = TableStyle() tbl.set_width(100) tbl.set_columns(3) tbl.set_column_width(0, 20) tbl.set_column_width(1, 40) tbl.set_column_width(2, 40) default_style.add_table_style('IDS-PersonTable', tbl) Endnotes.add_endnote_styles(default_style)