B
    @\)                 @   s  d Z ddlmZmZmZmZ ddlmZ ddlZe	e
ZddlmZ ddlmZ ddlmZmZmZmZmZmZmZmZ dd	lmZ dd
lmZmZmZmZm Z  ddl!m"Z" ddl#m$Z$m%Z%m&Z& ddl'm(Z(m)Z)m*Z* ddl+m,Z,m-Z-m.Z.m/Z/ ddl0m1Z1m2Z2 dZ3eG dd de"Z4eG dd de4Z5G dd de5Z6G dd de5Z7dd Z8dd Z9G dd de5Z:eG dd  d e4Z;dS )!z\ Models (mostly base classes) for the various kinds of renderer
types that Bokeh supports.

    )absolute_importdivisionprint_functionunicode_literals)get_close_matchesN   )RenderLevel)abstract)AutoBoolEitherEnumFloatInstanceOverrideString)error)BAD_COLUMN_NAMEMISSING_GLYPHNO_SOURCE_FOR_GLYPHCDSVIEW_SOURCE_DOESNT_MATCHMALFORMED_GRAPH_SOURCE)Model   )GlyphCircle	MultiLine)LayoutProviderGraphHitTestPolicy	NodesOnly)ColumnDataSource
DataSourceRemoteSourceCDSView)
TileSourceWMTSTileSource)DataRendererGlyphRendererGraphRendererGuideRendererRendererTileRendererc               @   s(   e Zd ZdZeeddZedddZdS )r*   z0An abstract base class for renderer types.

    z>
    Specifies the level in which to paint this renderer.
    )helpTz"
    Is the renderer visible.
    )defaultr,   N)	__name__
__module____qualname____doc__r   r   levelr   Zvisible r3   r3   5lib/python3.7/site-packages/bokeh/models/renderers.pyr*   ?   s
   r*   c               @   s   e Zd ZdZdS )r&   zt An abstract base class for data renderer types (e.g. ``GlyphRenderer``, ``TileRenderer``, ``GraphRenderer``).

    N)r.   r/   r0   r1   r3   r3   r3   r4   r&   M   s   r&   c               @   sh   e Zd ZdZeedd ddZedddZe	d	d
dZ
edddZedddZeddZe	d	ddZdS )r+   z

    c               C   s   t  S )N)r%   r3   r3   r3   r4   <lambda>X   s    zTileRenderer.<lambda>zE
    Local data source to use when rendering glyphs on the plot.
    )r-   r,   g      ?z 
    tile opacity 0.0 - 1.0
    )r,   Tz8
    Enable image smoothing for the rendered tiles.
    r-   z
    A particular (named) x-range to use for computing screen
    locations when rendering glyphs on the plot. If unset, use the
    default x-range.
    z
    A particular (named) y-range to use for computing screen
    locations when rendering glyphs on the plot. If unset, use the
    default y-range.
    Zunderlay)r-   zs
    Flag enable/disable drawing of parent tiles while waiting for new tiles to arrive. Default value is True.
    N)r.   r/   r0   r1   r   r$   Ztile_sourcer   Zalphar   Z	smoothingr   x_range_namey_range_namer   r2   Zrender_parentsr3   r3   r3   r4   r+   S   s   

r+   c                   s   e Zd ZdZeedd Zeedd Zee	dd Z
eedd	 Z fd
dZeeddZeeddZedddZedddZeeddZeeeedddZeeeedddZeeddZeeddZedddZe ddZ!  Z"S )r'   z

    c             C   s   | j st| S d S )N)glyphstr)selfr3   r3   r4   _check_missing_glyph{   s     z"GlyphRenderer._check_missing_glyphc             C   s   | j st| S d S )N)data_sourcer9   )r:   r3   r3   r4   _check_no_source_for_glyph   s     z(GlyphRenderer._check_no_source_for_glyphc             C   s   | j | jjk	rt| S d S )N)r<   viewsourcer9   )r:   r3   r3   r4   _check_cdsview_source   s     z#GlyphRenderer._check_cdsview_sourcec                s    j s
d S  jsd S t jtr$d S t } j  }xl j jdd D ]V\}}||krZqHt|tsfqHt jt	stqHd|krH|d  jj
krH||d |f qHW |rdd  fdd|D D }dd t||D }dd |D }d	d
t| f S d S )NF)Zinclude_defaultsZfieldc             S   s    g | ]}|rd |d  ndqS )z" (closest match: "%s")r   "r3   ).0sr3   r3   r4   
<listcomp>   s    z8GlyphRenderer._check_bad_column_name.<locals>.<listcomp>c                s"   g | ]}t |d   jjddqS )r   r   )n)r   r<   column_names)rB   Zterm)r:   r3   r4   rD      s    c             S   s*   g | ]"\}}d  |d |g|d fqS ) r   r   )join)rB   mrC   r3   r3   r4   rD      s    c             S   s   g | ]\}}d ||f qS )zkey "%s" value "%sr3   )rB   vkr3   r3   r4   rD      s    z%s [renderer: %s]z, )r8   r<   
isinstancer"   setZ	dataspecsZproperties_with_valuesitemsdictr    rF   addziprH   sorted)r:   Zmissing_valuesZspecsnameitemZsuggestionsmissingr3   )r:   r4   _check_bad_column_name   s.       
 
  z$GlyphRenderer._check_bad_column_namec                s,   t t| jf | d|kr(t| jd| _d S )Nr>   )r?   )superr'   __init__r#   r<   r>   )r:   kw)	__class__r3   r4   rX      s    zGlyphRenderer.__init__zE
    Local data source to use when rendering glyphs on the plot.
    )r,   z
    A view into the data source to use when rendering glyphs. A default view
    of the entire data source is created when a view is not passed in during
    initialization.
    r-   z
    A particular (named) x-range to use for computing screen
    locations when rendering glyphs on the plot. If unset, use the
    default x-range.
    z
    A particular (named) y-range to use for computing screen
    locations when rendering glyphs on the plot. If unset, use the
    default y-range.
    z[
    The glyph to render, in conjunction with the supplied data source
    and ranges.
    autoz
    An optional glyph used for selected points.

    If set to "auto" then the standard glyph will be used for selected
    points.
    )r-   r,   a%  
    An optional glyph used for explicitly non-selected points
    (i.e., non-selected when there are other points that are selected,
    but not when no points at all are selected.)

    If set to "auto" then a glyph with a low alpha value (0.1) will
    be used for non-selected points.
    zv
    An optional glyph used for inspected points, e.g., those that are
    being hovered over by a ``HoverTool``.
    z
    Fr8   )r-   )#r.   r/   r0   r1   r   r   r;   r   r=   r   r@   r   rV   rX   r   r!   r<   r#   r>   r   r6   r7   r   r8   r   r
   Zselection_glyphZnonselection_glyphZhover_glyphZmuted_glyphr   Zmutedr   r2   __classcell__r3   r3   )rZ   r4   r'   v   s6   r'   c               C   s   t t ttg dddS )N)index)data)r8   r<   )r'   r   r    rO   r3   r3   r3   r4   r5      s   r5   c               C   s   t t ttg g dddS )N)startend)r^   )r8   r<   )r'   r   r    rO   r3   r3   r3   r4   r5      s   c               @   s   e Zd ZdZeedd ZedddZedddZ	e
eddZe
eed	d
Ze
eedd
Ze
edd dd
Ze
edd dd
ZeddZdS )r(   z

    c             C   sf   g }d| j jjkr|d d| jjjkr4|d d| jjjkrL|d |rbd|d|   S d S )	Nr]   zBColumn 'index' is missing in GraphSource.node_renderer.data_sourcer_   zBColumn 'start' is missing in GraphSource.edge_renderer.data_sourcer`   z@Column 'end' is missing in GraphSource.edge_renderer.data_sourcez ,z [%s])node_rendererr<   rF   appendedge_rendererrH   )r:   rU   r3   r3   r4   _check_malformed_graph_source   s    


z+GraphRenderer._check_malformed_graph_sourcer-   z
    A particular (named) x-range to use for computing screen
    locations when rendering graphs on the plot. If unset, use the
    default x-range.
    )r,   z
    A particular (named) y-range to use for computing screen
    locations when rendering graphs on the plot. If unset, use the
    default y-range.
    zs
    An instance of a ``LayoutProvider`` that supplies the layout of the network
    graph in cartesian space.
    zq
    Instance of a ``GlyphRenderer`` containing an ``XYGlyph`` that will be rendered
    as the graph nodes.
    )r-   r,   zy
    Instance of a ``GlyphRenderer`` containing an ``MultiLine`` Glyph that will be
    rendered as the graph edges.
    c               C   s   t  S )N)r   r3   r3   r3   r4   r5     s    zGraphRenderer.<lambda>zp
    An instance of a ``GraphHitTestPolicy`` that provides the logic for selection
    of graph components.
    c               C   s   t  S )N)r   r3   r3   r3   r4   r5     s    zq
    An instance of a ``GraphHitTestPolicy`` that provides the logic for inspection
    of graph components.
    r8   )r-   N)r.   r/   r0   r1   r   r   rd   r   r6   r7   r   r   Zlayout_providerr'   _DEFAULT_NODE_RENDERERra   _DEFAULT_EDGE_RENDERERrc   r   Zselection_policyZinspection_policyr   r2   r3   r3   r3   r4   r(      s"   

r(   c                   s6   e Zd ZdZedddZ fddZeddZ  Z	S )	r)   zz A base class for all guide renderer types. ``GuideRenderer`` is
    not generally useful to instantiate on its own.

    z.models.plots.Plotz<
    The plot to which this guide renderer is attached.
    )r,   c                s:   t t| jf | | jd k	r6| | jjkr6| jj|  d S )N)rW   r)   rX   plotZ	renderersrb   )r:   kwargs)rZ   r3   r4   rX   #  s    
zGuideRenderer.__init__Zoverlay)r-   )
r.   r/   r0   r1   r   rg   rX   r   r2   r\   r3   r3   )rZ   r4   r)     s
   r)   )<r1   Z
__future__r   r   r   r   Zdifflibr   ZloggingZ	getLoggerr.   logZ
core.enumsr   Zcore.has_propsr	   Zcore.propertiesr
   r   r   r   r   r   r   r   Zcore.validationr   Zcore.validation.errorsr   r   r   r   r   Zmodelr   Zglyphsr   r   r   Zgraphsr   r   r   Zsourcesr    r!   r"   r#   Ztilesr$   r%   __all__r*   r&   r+   r'   re   rf   r(   r)   r3   r3   r3   r4   <module>
   s4   
(#b8