Пример #1
0
def _nucleotide_key_text_callback(patch: patches.Wedge,
                                  nucleotide_body_patch: patches.Circle,
                                  text_object, x_border=0.2, y_border=0.1):
    # assumes that the coordinates are equal scaled in the view
    radius = nucleotide_body_patch.radius
    radius_with_width = radius + patch.width
    radius_with_half_width = radius + patch.width / 2

    initial_text_rotation = text_object.get_rotation()
    text_object.set_rotation(0)
    body_patch_window_extent = nucleotide_body_patch.get_window_extent()
    scale_pixel_to_units = body_patch_window_extent.width / 2 / radius
    wedge_height_pixel = scale_pixel_to_units * patch.width
    wedge_width = (2 * np.pi * radius_with_half_width *
                   np.abs(patch.theta2 - patch.theta1) / 360)

    text_width_max = min(
        wedge_width,
        2 * (radius_with_width ** 2 - radius_with_half_width ** 2) ** 0.5)
    text_width_max_pixel = scale_pixel_to_units * text_width_max

    _scale_font_size(text_object, text_width_max_pixel,
                     wedge_height_pixel, x_border, y_border)
    text_object.set_rotation(initial_text_rotation)
Пример #2
0
def _nucleotide_name_callback(patch: patches.Circle,
                              text_object, x_border=0.1, y_border=0.1):
    patch_window_extent = patch.get_window_extent()
    _scale_font_size(text_object, patch_window_extent.width,
                     patch_window_extent.height, x_border, y_border)