U
    Ñtœd›  ã                   @   sj   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 dZG d	d
„ d
ee
ƒZG dd„ deƒZdS )z‹This module provides implementations of Cairo-specific vertex drawers, i.e.
drawers that the Cairo graph drawer will use to draw vertices.
é    )Úpi)ÚAbstractVertexDrawer©ÚAttributeCollectorBase)ÚShapeDrawerDirectoryé   )ÚAbstractCairoDrawer)ÚAbstractCairoVertexDrawerÚCairoVertexDrawerc                   @   s   e Zd ZdZdd„ ZdS )r	   zCAbstract base class for vertex drawers that draw on a Cairo canvas.c                 C   s    t  | ||¡ t | ||¡ dS )aŒ  Constructs the vertex drawer and associates it to the given
        Cairo context and the given L{BoundingBox}.

        @param context: the context on which we will draw
        @param bbox:    the bounding box within which we will draw.
                        Can be anything accepted by the constructor
                        of L{BoundingBox} (i.e., a 2-tuple, a 4-tuple
                        or a L{BoundingBox} object).
        @param palette: the palette that can be used to map integer
                        color indices to colors when drawing vertices
        @param layout:  the layout of the vertices in the graph being drawn
        N)r   Ú__init__r   ©ÚselfÚcontextZbboxÚpaletteÚlayout© r   úT/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/igraph/drawing/cairo/vertex.pyr      s    z"AbstractCairoVertexDrawer.__init__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r	      s   r	   c                       s0   e Zd ZdZ‡ fdd„Zdd„ Zdd„ Z‡  ZS )r
   z3The default vertex drawer implementation of igraph.c                    s    t ƒ  ||||¡ |  ¡ | _d S )N)Úsuperr   Ú _construct_visual_vertex_builderÚVisualVertexBuilderr   ©Ú	__class__r   r   r   '   s    zCairoVertexDrawer.__init__c                    s   G ‡ fdd„dt ƒ}|S )Nc                       sz   e Zd ZdZdZd” jjfZd” jjfZdZ	dZ
e d ZdZd” jjfZd	Zd
Ze” jjd�ZdejfZdZdZdZdS )zOCairoVertexDrawer._construct_visual_vertex_builder.<locals>.VisualVertexBuilderz7Collects some visual properties of a vertex for drawingZvertex_ÚredÚblackg      ð?Né   g        z
sans-serifg      ,@)ÚfuncÚcircleg      4@)r   r   r   r   Z_kwds_prefixr   ÚgetÚcolorÚframe_colorÚframe_widthÚlabelr   Zlabel_angleZ
label_distZlabel_colorZfontZ
label_sizeÚdictr   Ú__getitem__Úpositionr   Zresolve_defaultÚshapeÚsizeÚwidthÚheightr   ©r   r   r   r   ,   s    

r   r   )r   r   r   r-   r   r   +   s    z2CairoVertexDrawer._construct_visual_vertex_builderc                 C   s†   | j }|jd k	r|jn|j}|jd k	r,|jn|j}|j ||d |d ||¡ |j|jŽ  | ¡  |j|j	Ž  | 
|j¡ | ¡  d S )Nr   r   )r   r+   r*   r,   r)   Z	draw_pathZset_source_rgbar"   Zfill_preserver#   Zset_line_widthr$   Ústroke)r   Zvisual_vertexZvertexZcoordsr   r+   r,   r   r   r   ÚdrawA   s    ÿýÿýzCairoVertexDrawer.draw)r   r   r   r   r   r   r/   Ú__classcell__r   r   r   r   r
   $   s   r
   N)r   Úmathr   Zigraph.drawing.baseclassesr   Zigraph.drawing.metamagicr   Zigraph.drawing.shapesr   Úbaser   Ú__all__r	   r
   r   r   r   r   Ú<module>   s   