def __drawLabel(self, configuration, cr, x0, y0, format='pdf'): boundingRect = self.__getLabelSize(configuration, format=format) padding = 2 useStructures = self.__useStructureForLabel(configuration) y = y0 for i, spec in enumerate(configuration.species): if i > 0: rect = self.__getTextSize('+', padding=padding, format=format) x = x0 - 0.5 * (rect[2] - boundingRect[2]) + 2 * padding self.__drawText('+', cr, x, y) y += rect[3] if useStructures: moleculeDrawer = MoleculeDrawer() cr.save() surf, c, rect = moleculeDrawer.draw(spec.molecule[0], format=format) cr.restore() x = x0 - 0.5 * (rect[2] - boundingRect[2]) cr.save() moleculeDrawer.render(cr, offset=(x, y)) cr.restore() y += rect[3] else: rect = self.__getTextSize(spec.label, padding=padding, format=format) x = x0 - 0.5 * (rect[2] - boundingRect[2]) + 2 * padding self.__drawText(spec.label, cr, x, y) y += rect[3] return boundingRect
def _draw_label(self, configuration, cr, x0, y0, file_format='pdf'): bounding_rect = self._get_label_size(configuration, file_format=file_format) padding = 2 use_structures = self._use_structure_for_label(configuration) y = y0 for i, spec in enumerate(configuration.species_list): if i > 0: rect = self._get_text_size('+', padding=padding, file_format=file_format) x = x0 - 0.5 * (rect[2] - bounding_rect[2]) + 2 * padding self._draw_text('+', cr, x, y) y += rect[3] if use_structures: molecule_drawer = MoleculeDrawer() cr.save() rect = molecule_drawer.draw(spec.molecule[0], file_format=file_format)[2] cr.restore() x = x0 - 0.5 * (rect[2] - bounding_rect[2]) cr.save() molecule_drawer.render(cr, offset=(x, y)) cr.restore() y += rect[3] else: rect = self._get_text_size(spec.label, padding=padding, file_format=file_format) x = x0 - 0.5 * (rect[2] - bounding_rect[2]) + 2 * padding self._draw_text(spec.label, cr, x, y) y += rect[3] return bounding_rect