def process_componentElement(report, element): """ Process component jrxml element. :param report: dictionary holding report information :param element: jrxml component element # :param row_data: a row from data source """ component_element = element.get('child') if component_element is not None: report_element = process_reportElement(report, component_element[0].get('reportElement')) # get reportElement for tag in component_element[1:]: for key, value in tag.items(): if componentElement_dict.get(key) is not None: componentElement_dict[key](report, key, value, report_element)
def process_image(report, element): """ Process jrxml 'image' element. :param report: dictionary holding report information :param element: jrxml image element to process """ image_element = element.get('child') if image_element is not None: report_element = process_reportElement( report, image_element[0].get('reportElement')) # get reportElement # get scaleImage attribute on image element add_attr2attributes(element, report_element) for tag in image_element[1:]: for key, value in tag.items(): if image_dict[key] is not None: image_dict[key](report, value, report_element)
def process_static_text(report, element): """ Process jrxml staticText element. :param report: dictionary holding report information :param element: :param row_data: a row from data source """ static_text_element = element.get('child') if static_text_element is not None: report_element = process_reportElement(report, static_text_element[0].get('reportElement')) # get reportElement for tag in static_text_element[1:]: for key, value in tag.items(): if static_text_dict[key] is not None: if key == 'textElement': report_element = process_textElement(report, value, report_element) else: static_text_dict[key](report=report, element=value, attributes=report_element)
def process_rectangle(report, element): """ Process jrxml "rectangle" element. :param report: :param element: :return: """ # global report_info rectangle_element = element.get('child') if rectangle_element is not None: attributes = process_reportElement( report, rectangle_element[0].get('reportElement')) # get reportElement # get radius attribute on rectangle element add_attr2attributes(element, attributes) # set attributes from following graphicElement attributes = process_graphicElement(report, rectangle_element, attributes) # set line attributes line_style = attributes.get('lineStyle') line_width = float(attributes.get('lineWidth', '1.0')) fore_color = attributes.get('forecolor') mode = attributes.get('mode') background_color = attributes.get('backcolor') if mode == 'Opaque': fill = 1 else: fill = 0 # draw rectangle if line_style == 'Double': # double line consists of wide solid line with thin white line in between draw_rectangle(report, attributes, line_style_dict['Solid'], line_width * 1.5, fore_color, background_color, fill) draw_rectangle(report, attributes, line_style_dict['Solid'], line_width * 0.3, '#FFFFFF', background_color, fill) else: draw_rectangle(report, attributes, line_style, line_width, fore_color, background_color, fill)
def process_textField(report, element): """ Process textField jrxml element. :param report: dictionary holding report information :param element: # :param row_data: a row from data source """ text_field = element.get('child') if text_field is not None: attributes = process_reportElement(report, text_field[0].get('reportElement')) # get reportElement # set attributes to reportElement (e.g. pattern, isBlankWhenNull) add_attr2attributes(element, attributes) for tag in text_field[1:]: for key, value in tag.items(): if textField_dict[key] is not None: if key == 'textElement': attributes = process_textElement(report, value, attributes) else: # reportElement, box textField_dict[key](report, value, attributes)
def process_ellipse(report, element): """ Process jrxml 'ellipse' element :param report:. :param element: """ # global report_info ellipse_element = element.get('child') if ellipse_element is not None: report_element = process_reportElement( report, ellipse_element[0].get('reportElement')) # get reportElement # set attributes from following graphicElement report_element = process_graphicElement(report, ellipse_element, report_element) # set line attributes line_style = report_element.get('lineStyle') line_width = float(report_element.get('lineWidth', '1.0')) fore_color = report_element.get('forecolor') mode = report_element.get('mode') background_color = report_element.get('backcolor') if mode == 'Opaque': fill = 1 else: fill = 0 # draw ellipse if line_style == 'Double': # double line consists of wide solid line with thin white line in between draw_ellipse(report, report_element, line_style_dict['Solid'], line_width * 1.0, fore_color, background_color, fill) draw_ellipse(report, report_element, line_style_dict['Solid'], line_width * 0.5, '#FFFFFF', background_color, fill) else: draw_ellipse(report, report_element, line_style, line_width, fore_color, background_color, fill)
def process_line(report, element): """ Process jrxml line element. :param report: dictionary holding report information :param element: jrxml line element """ line_element = element.get('child') if line_element is not None: report_element = process_reportElement( report, line_element[0].get('reportElement')) # get reportElement # get attributes on line element (e.g. "direction") to determine which direction to draw a line add_attr2attributes(element, report_element) # set attributes from following graphicElement # reportElement = process_graphicElement(report, line_element, report_element) process_graphicElement(report, line_element, report_element) # set line attributes line_style = report_element.get('lineStyle') line_width = float(report_element.get('lineWidth', '1.0')) line_color = report_element.get('lineColor') draw_diagonal_line(report, report_element, line_style, line_width, line_color)