B
    @\                 @   s"  d Z ddlmZmZmZmZ ddlZeeZ	ddl
mZ ddl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mZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z& dd	l'm(Z(m)Z) dd
l*m+Z+ ddl,m-Z-m.Z. ddl/m0Z0 ddl1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7 ddl8m9Z9 ddl:m;Z;m<Z< ddl=m>Z> ddl?m@Z@mAZAmBZBmCZC ddlDmEZE ddlFmGZGmHZH ddlImJZJ dZKeG dd de9ZLeG dd deLZMeG dd deLZNeG dd deNZOeG dd  d eNZPeG d!d" d"eNZQeG d#d$ d$eNZReG d%d& d&e9ZSG d'd( d(eSZTG d)d* d*eSZUG d+d, d,eJZVG d-d. d.eOZWd/d0 ZXG d1d2 d2eOZYG d3d4 d4ePZZG d5d6 d6ePZ[G d7d8 d8eMZ\G d9d: d:eMZ]G d;d< d<eMZ^G d=d> d>eQZ_G d?d@ d@eRZ`dAd0 ZaG dBdC dCeOZbG dDdE dEeMZcG dFdG dGeMZdG dHdI dIeOZedJd0 ZfG dKdL dLeOZgG dMdN dNeQZhG dOdP dPe9ZiG dQdR dReRZjdSZkdTZlG dUdV dVeMZmG dWdX dXeMZnG dYdZ dZeMZoeG d[d\ d\eNZpG d]d^ d^epeOeQZqG d_d` d`epeOeQZrG dadb dbepeOeQZsG dcdd ddepeOeQZtG dedf dfepeOeQZudS )ga   Bokeh comes with a number of interactive tools.

There are five types of tool interactions:

.. hlist::
    :columns: 5

    * Pan/Drag
    * Click/Tap
    * Scroll/Pinch
    * Actions
    * Inspectors

For the first three comprise the category of gesture tools, and only
one tool for each gesture can be active at any given time. The active
tool is indicated on the toolbar by a highlight next to the tool.
Actions are immediate or modal operations that are only activated when
their button in the toolbar is pressed. Inspectors are passive tools that
merely report information or annotate the plot in some way, and may
always be active regardless of what other tools are currently active.

    )absolute_importdivisionprint_functionunicode_literalsN)FunctionType   )Anchor	Dimension
DimensionsLocationTooltipFieldFormatterTooltipAttachment)abstract)AutoBoolColorDateDatetimeDictEitherEnumImageIntFloatPercentInstanceListSeqStringTuple)nodejs_compileCompilationError)import_required)get_param_info	signature)error)INCOMPATIBLE_BOX_EDIT_RENDERER INCOMPATIBLE_POINT_DRAW_RENDERERINCOMPATIBLE_POLY_DRAW_RENDERERINCOMPATIBLE_POLY_EDIT_RENDERER&INCOMPATIBLE_POLY_EDIT_VERTEX_RENDERERNO_RANGE_TOOL_RANGES)Model   )BoxAnnotationPolyAnnotation)Callback)XYGlyphRectPatches	MultiLine)Range1d)RendererGlyphRenderer)	LayoutDOM)%ActionBoxEditToolBoxSelectToolBoxZoomToolCrosshairToolCustomActionCustomJSHoverDragEditToolFreehandDrawToolHelpTool	HoverTool
InspectionGestureLassoSelectToolPanToolPointDrawToolPolyDrawToolPolyEditToolPolySelectToolProxyToolbar	RangeToolRedoTool	ResetToolSaveToolScrollTapTapToolToolToolbarToolbarBase
ToolbarBoxUndoToolWheelPanToolWheelZoomTool
ZoomInToolZoomOutToolc               @   s   e Zd ZdZdS )rU   z3 A base class for all interactive tool types.

    N)__name__
__module____qualname____doc__ rb   rb   1lib/python3.7/site-packages/bokeh/models/tools.pyrU   y   s   rU   c               @   s   e Zd ZdZdS )r9   z> A base class for tools that are buttons in the toolbar.

    N)r^   r_   r`   ra   rb   rb   rb   rc   r9      s   r9   c               @   s   e Zd ZdZdS )rF   z: A base class for tools that respond to drag events.

    N)r^   r_   r`   ra   rb   rb   rb   rc   rF      s   rF   c               @   s   e Zd ZdZdS )r@   z: A base class for tools that respond to drag events.

    N)r^   r_   r`   ra   rb   rb   rb   rc   r@      s   r@   c               @   s   e Zd ZdZdS )rR   z< A base class for tools that respond to scroll events.

    N)r^   r_   r`   ra   rb   rb   rb   rc   rR      s   rR   c               @   s   e Zd ZdZdS )rS   z? A base class for tools that respond to tap/click events.

    N)r^   r_   r`   ra   rb   rb   rb   rc   rS      s   rS   c               @   s   e Zd ZdZedddZdS )rE   zM A base class for tools that perform "inspections", e.g. ``HoverTool``.

    Tz
    Whether an on/off toggle button should appear in the toolbar for this
    inspection tool. If ``False``, the viewers of a plot will not be able to
    toggle the inspector on or off using the toolbar.
    )helpN)r^   r_   r`   ra   r   Z
toggleablerb   rb   rb   rc   rE      s   rE   c               @   s:   e Zd ZdZeddddZedddZee	e
d	dZd
S )rW   z+ A base class for different toolbars.

    ZnormalZgreyzr
    What version of the Bokeh logo to display on the toolbar. If
    set to None, no logo will be displayed.
    )rd   Fz
    Whether the toolbar will be hidden by default. Default: False.
    If True, hides toolbar when cursor is not in canvas.
    )defaultrd   z-
    A list of tools to add to the plot.
    N)r^   r_   r`   ra   r   Zlogor   Zautohider   r   rU   Ztoolsrb   rb   rb   rc   rW      s   rW   c               @   sn   e Zd ZdZeeeeddZeeee	e
ee	ddZeeeeddZeeeeddZeeddZdS )	rV   z2 Collect tools to display for a single plot.

    zF
    Specify a drag tool to be active when the plot is displayed.
    )rd   zq
    Specify an inspection tool or sequence of inspection tools to be active when
    the plot is displayed.
    zN
    Specify a scroll/pinch tool to be active when the plot is displayed.
    zK
    Specify a tap/click tool to be active when the plot is displayed.
    a  
    Specify an active multi-gesture tool, for instance an edit tool or a range
    tool.

    Note that activating a multi-gesture tool will deactivate any other gesture
    tools as appropriate. For example, if a pan tool is set as the active drag,
    and this property is set to a ``BoxEditTool`` instance, the pan tool will
    be deactivated (i.e. the multi-gesture tool will take precedence).
    N)r^   r_   r`   ra   r   r   r   r@   Zactive_dragrE   r   Zactive_inspectrR   Zactive_scrollrS   Z
active_taprF   Zactive_multirb   rb   rb   rc   rV      s   


rV   c               @   s   e Zd ZdZdS )rM   zN A toolbar that allow to merge and proxy tools of toolbars in multiple plots. N)r^   r_   r`   ra   rb   rb   rb   rc   rM      s   rM   c               @   s(   e Zd ZdZeeddZeeddZ	dS )rX   z A layoutable toolbar that can accept the tools of multiple plots, and
    can merge the tools into a single button for convenience.

    zE
    A toolbar associated with a plot which holds all its tools.
    )rd   right)re   N)
r^   r_   r`   ra   r   rW   Ztoolbarr   r   Ztoolbar_locationrb   rb   rb   rc   rX      s   rX   c               @   s   e Zd ZdZeedddZdS )rH   a   *toolbar icon*: |pan_icon|

    The pan tool allows the user to pan a Plot by left-dragging
    a mouse, or on touch devices by dragging a finger or stylus, across
    the plot region.

    The pan tool also activates the border regions of a Plot for "single
    axis" panning. For instance, dragging in the vertical border or axis
    will effect a pan in the vertical direction only, with the horizontal
    dimension kept fixed.

    .. |pan_icon| image:: /_images/icons/Pan.png
        :height: 18pt

    bothz
    Which dimensions the pan tool is constrained to act in. By default
    the pan tool will pan in any dimension, but can be configured to only
    pan horizontally across the width of the plot, or vertically across the
    height of the plot.
    )re   rd   N)r^   r_   r`   ra   r   r
   
dimensionsrb   rb   rb   rc   rH      s   rH   c            
   C   s   t dddddddddgdS )	Noverlaycss	lightgreyg      ?blackg      ?r   )levelrender_mode
fill_color
fill_alpha
line_color
line_alpha
line_width	line_dash)r.   rb   rb   rb   rc   <lambda>  s   ru   c               @   s^   e Zd ZdZeeddZedddZeeddZ	edddZ
eeed	dZeed
d ZdS )rN   a(   *toolbar icon*: |range_icon|

    The range tool allows the user to update range objects for either or both
    of the x- or y-dimensions by dragging a corresponding shaded annotation to
    move it or change its boundaries.

    A common use case is to add this tool to a plot with a large fixed range,
    but to configure the tool range from a different plot. When the user
    manipulates the overlay, the range of the second plot will be updated
    automatically.

    .. |range_icon| image:: /_images/icons/Range.png
        :height: 18pt

    z|
    A range synchronized to the x-dimension of the overlay. If None, the overlay
    will span the entire x-dimension.
    )rd   Ta  
    Whether to respond to horizontal pan motions when an ``x_range`` is present.

    By default, when an ``x_range`` is specified, it is possible to adjust the
    horizontal position of the range box by panning horizontally inside the
    box, or along the top or bottom edge of the box. To disable this, and fix
    the  range box in place horizontally, set to False. (The box will still
    update if the ``x_range`` is updated programmatically.)
    )re   rd   z|
    A range synchronized to the y-dimension of the overlay. If None, the overlay
    will span the entire y-dimension.
    a  
    Whether to respond to vertical pan motions when a ``y_range`` is present.

    By default, when a ``y_range`` is specified, it is possible to adjust the
    vertical position of the range box by panning vertically inside the box, or
    along the top or bottom edge of the box. To disable this, and fix the range
    box in place vertically, set to False. (The box will still update if the
    ``y_range`` is updated programmatically.)
    zF
    A shaded annotation drawn to indicate the configured ranges.
    c             C   s   | j d kr| jd krdS d S )NzIAt least one of RangeTool.x_range or RangeTool.y_range must be configured)x_rangey_range)selfrb   rb   rc   _check_no_range_tool_rangesF  s    z%RangeTool._check_no_range_tool_rangesN)r^   r_   r`   ra   r   r5   rv   r   Zx_interactionrw   Zy_interactionr.   DEFAULT_RANGE_OVERLAYri   r%   r+   ry   rb   rb   rb   rc   rN     s   rN   c               @   s   e Zd ZdZeedddZdS )rZ   z *toolbar icon*: |wheel_pan_icon|

    The wheel pan tool allows the user to pan the plot along the configured
    dimension using the scroll wheel.

    .. |wheel_pan_icon| image:: /_images/icons/WheelPan.png
        :height: 18pt

    widthz
    Which dimension the wheel pan tool is constrained to act in. By
    default the wheel pan tool will pan the plot along the x-axis.
    )re   rd   N)r^   r_   r`   ra   r   r	   Z	dimensionrb   rb   rb   rc   rZ   K  s   	rZ   c               @   sB   e Zd ZdZeedddZedddZedddZ	e
dd	dZd
S )r[   a   *toolbar icon*: |wheel_zoom_icon|

    The wheel zoom tool will zoom the plot in and out, centered on the
    current mouse location.

    The wheel zoom tool also activates the border regions of a Plot for
    "single axis" zooming. For instance, zooming in the vertical border or
    axis will effect a zoom in the vertical direction only, with the
    horizontal dimension kept fixed.

    .. |wheel_zoom_icon| image:: /_images/icons/WheelZoom.png
        :height: 18pt

    rg   a
  
    Which dimensions the wheel zoom tool is constrained to act in. By
    default the wheel zoom tool will zoom in any dimension, but can be
    configured to only zoom horizontally across the width of the plot, or
    vertically across the height of the plot.
    )re   rd   Tz
    Whether or not zooming tool maintains its focus position. Setting it
    to False results in a more "gliding" behavior, allowing one to
    zoom out more smoothly, at the cost of losing the focus position.
    zf
    Whether scrolling on an axis (outside the central plot area) should
    zoom that dimension.
    gO贁N[?z
    Speed at which the wheel zooms. Default is 1/600. Optimal range is between
    0.001 and 0.09. High values will be clipped. Speed may very between browsers.
    N)r^   r_   r`   ra   r   r
   rh   r   Zmaintain_focusZzoom_on_axisr   Zspeedrb   rb   rb   rc   r[   [  s   r[   c               @   s2   e Zd ZdZedddZeeddZe	ddZ
dS )	r>   a*   Execute a custom action, e.g. ``CustomJS`` callback when a toolbar
    icon is activated.

    Example:

        .. code-block:: python

            tool = CustomAction(icon="icon.png",
                                callback=CustomJS(code='alert("foo")'))

            plot.add_tools(tool)

    zPerform a Custom ActionzF
    Tooltip displayed when hovering over the custom action icon.
    )re   rd   zO
    A Bokeh callback to execute when the custom action icon is activated.
    )rd   z
    An icon to display in the toolbar.

    The icon can provided as a string filename for an image, a PIL ``Image``
    object, or an RGB(A) NumPy array.
    N)r^   r_   r`   ra   r   Zaction_tooltipr   r0   callbackr   Ziconrb   rb   rb   rc   r>     s   r>   c               @   s   e Zd ZdZdS )rQ   a   *toolbar icon*: |save_icon|

    The save tool is an action. When activated, the tool opens a download dialog
    which allows to save an image reproduction of the plot in PNG format. If
    automatic download is not support by a web browser, the tool falls back to
    opening the generated image in a new tab or window. User then can manually
    save it by right clicking on the image and choosing "Save As" (or similar)
    menu item.

    .. |save_icon| image:: /_images/icons/Save.png
        :height: 18pt

    N)r^   r_   r`   ra   rb   rb   rb   rc   rQ     s   rQ   c               @   s   e Zd ZdZdS )rP   a{   *toolbar icon*: |reset_icon|

    The reset tool is an action. When activated in the toolbar, the tool
    resets the data bounds of the plot to their values when the plot was
    initially created.

    Optionally, the reset tool also resets the plat canvas dimensions to
    their original size

    .. |reset_icon| image:: /_images/icons/Reset.png
        :height: 18pt

    N)r^   r_   r`   ra   rb   rb   rb   rc   rP     s   rP   c               @   sP   e Zd ZdZeeddZeeee	e
dddZedddd	dZe	ed
dZdS )rT   ao   *toolbar icon*: |tap_icon|

    The tap selection tool allows the user to select at single points by
    left-clicking a mouse, or tapping with a finger.

    See :ref:`userguide_styling_selected_unselected_glyphs` for information
    on styling selected and unselected glyphs.

    .. |tap_icon| image:: /_images/icons/Tap.png
        :height: 18pt

    .. note::
        Selections can be comprised of multiple regions, even those
        made by different selection tools. Hold down the <<shift>> key
        while making a selection to append the new selection to any
        previous selection that might exist.

    z
    A list of names to query for. If set, only renderers that
    have a matching value for their ``name`` attribute will be used.
    )rd   autozo
    An explicit list of renderers to hit test against. If unset,
    defaults to all renderers on a plot.
    )re   rd   Zselectinspectac  
    This tool can be configured to either make selections or inspections
    on associated data sources. The difference is that selection changes
    propagate across bokeh and other components (e.g. selection glyph)
    will be notified. Inspections don't act like this, so it's useful to
    configure `callback` when setting `behavior='inspect'`.
    aG  
    A callback to execute *whenever a glyph is "hit"* by a mouse click
    or tap.

    This is often useful with the  :class:`~bokeh.models.callbacks.OpenURL`
    model to open URLs based on a user clicking or tapping a specific glyph.

    However, it may also be a :class:`~bokeh.models.callbacks.CustomJS`
    which can execute arbitrary JavaScript code in response to clicking or
    tapping glyphs. The callback will be executed for each individual glyph
    that is it hit by a click or tap, and will receive the ``TapTool`` model
    as  ``cb_obj``. The optional ``cb_data`` will have the data source as
    its ``.source`` attribute and the selection geometry as its
    ``.geometries`` attribute.

    The ``.geometries`` attribute has 5 members.
    ``.type`` is the geometry type, which always a ``.point`` for a tap event.
    ``.sx`` and ``.sy`` are the screen X and Y coordinates where the tap occurred.
    ``.x`` and ``.y`` are the converted data coordinates for the item that has
    been selected. The ``.x`` and ``.y`` values are based on the axis assigned
    to that glyph.

    .. note::
        This callback does *not* execute on every tap, only when a glyph is
        "hit". If you would like to execute a callback on every mouse tap,
        please see :ref:`userguide_interaction_jscallbacks_customjs_interactions`.

    N)r^   r_   r`   ra   r   r   namesr   r   r   r6   	renderersr   Zbehaviorr0   r|   rb   rb   rb   rc   rT     s   rT   c               @   sB   e Zd ZdZeedddZedddZe	dddZ
e	d	d
dZdS )r=   a=   *toolbar icon*: |crosshair_icon|

    The crosshair tool is a passive inspector tool. It is generally on
    at all times, but can be configured in the inspector's menu
    associated with the *toolbar icon* shown above.

    The crosshair tool draws a crosshair annotation over the plot,
    centered on the current mouse position. The crosshair tool may be
    configured to draw across only one dimension by setting the
    ``dimension`` property to only ``width`` or ``height``.

    .. |crosshair_icon| image:: /_images/icons/Crosshair.png
        :height: 18pt

    rg   a
  
    Which dimensions the crosshair tool is to track. By default, both a
    vertical and horizontal line will be drawn. If only "width" is supplied,
    only a horizontal line will be drawn. If only "height" is supplied,
    only a vertical line will be drawn.
    )re   rd   rl   a  
    A color to use to stroke paths with.

    Acceptable values are:

    - any of the 147 named `CSS colors`_, e.g ``'green'``, ``'indigo'``
    - an RGB(A) hex value, e.g., ``'#FF0000'``, ``'#44444444'``
    - a 3-tuple of integers (r,g,b) between 0 and 255
    - a 4-tuple of (r,g,b,a) where r,g,b are integers between 0..255 and a is between 0..1

    .. _CSS colors: http://www.w3schools.com/cssref/css_colornames.asp

    r-   z*
    Stroke width in units of pixels.
    g      ?z
    An alpha value to use to stroke paths with.

    Acceptable values are floating point numbers between 0 (transparent)
    and 1 (opaque).

    N)r^   r_   r`   ra   r   r
   rh   r   rq   r   rs   rr   rb   rb   rb   rc   r=     s   r=   c               C   s$   t dddddddddddd	d	gd
S )Nri   rj   screenrk   g      ?rl   g      ?r      )rm   rn   Z	top_unitsZ
left_unitsZbottom_unitsZright_unitsro   rp   rq   rr   rs   rt   )r.   rb   rb   rb   rc   ru   5  s   c               @   sH   e Zd ZdZeedddZeee	ddZ
edddZedd	dd
dZdS )r<   aU   *toolbar icon*: |box_zoom_icon|

    The box zoom tool allows users to define a rectangular
    region of a Plot to zoom to by dragging he mouse or a
    finger over the plot region. The end of the drag
    event indicates the selection region is ready.

    .. |box_zoom_icon| image:: /_images/icons/BoxZoom.png
        :height: 18pt

    rg   a  
    Which dimensions the zoom box is to be free in. By default,
    users may freely draw zoom boxes with any dimensions. If only
    "width" is supplied, the box will be constrained to span the entire
    vertical space of the plot, only the horizontal dimension can be
    controlled. If only "height" is supplied, the box will be constrained
    to span the entire horizontal space of the plot, and the vertical
    dimension can be controlled.
    )re   rd   zE
    A shaded annotation drawn to indicate the selection region.
    Fz
    Whether the box zoom region should be restricted to have the same
    aspect ratio as the plot region.

    .. note::
        If the tool is restricted to one dimension, this value has
        no effect.

    cornercenterz
    Indicates whether the rectangular zoom area should originate from a corner
    (top-left or bottom-right depending on direction) or the center of the box.
    N)r^   r_   r`   ra   r   r
   rh   r   r.   DEFAULT_BOX_OVERLAYri   r   Zmatch_aspectoriginrb   rb   rb   rc   r<   D  s   r<   c               @   s*   e Zd ZdZeedddZedddZdS )r\   z *toolbar icon*: |zoom_in_icon|

    The zoom-in tool allows users to click a button to zoom in
    by a fixed amount.

    .. |zoom_in_icon| image:: /_images/icons/ZoomIn.png
        :height: 18pt

    rg   a	  
    Which dimensions the zoom-in tool is constrained to act in. By
    default the zoom-in zoom tool will zoom in any dimension, but can be
    configured to only zoom horizontally across the width of the plot, or
    vertically across the height of the plot.
    )re   rd   g?z@
    Percentage to zoom for each click of the zoom-in tool.
    N)	r^   r_   r`   ra   r   r
   rh   r   factorrb   rb   rb   rc   r\   n  s
   	r\   c               @   s*   e Zd ZdZeedddZedddZdS )r]   z *toolbar icon*: |zoom_out_icon|

    The zoom-out tool allows users to click a button to zoom out
    by a fixed amount.

    .. |zoom_out_icon| image:: /_images/icons/ZoomOut.png
        :height: 18pt

    rg   a  
    Which dimensions the zoom-out tool is constrained to act in. By
    default the zoom-out tool will zoom in any dimension, but can be
    configured to only zoom horizontally across the width of the plot, or
    vertically across the height of the plot.
    )re   rd   g?z@
    Percentage to zoom for each click of the zoom-in tool.
    N)	r^   r_   r`   ra   r   r
   rh   r   r   rb   rb   rb   rc   r]     s
   	r]   c               @   sx   e Zd ZdZeeddZeeee	e
dddZedddZeed	d
dZe	eddZe	eeddZedddddZdS )r;   a   *toolbar icon*: |box_select_icon|

    The box selection tool allows users to make selections on a
    Plot by indicating a rectangular region by dragging the
    mouse or a finger over the plot region. The end of the drag
    event indicates the selection region is ready.

    See :ref:`userguide_styling_selected_unselected_glyphs` for information
    on styling selected and unselected glyphs.


    .. |box_select_icon| image:: /_images/icons/BoxSelect.png
        :height: 18pt

    z
    A list of names to query for. If set, only renderers that
    have a matching value for their ``name`` attribute will be used.
    )rd   r}   zo
    An explicit list of renderers to hit test against. If unset,
    defaults to all renderers on a plot.
    )re   rd   Fz
    Whether a selection computation should happen on every mouse
    event, or only once, when the selection region is completed. Default: False
    rg   a  
    Which dimensions the box selection is to be free in. By default,
    users may freely draw selections boxes with any dimensions. If only
    "width" is supplied, the box will be constrained to span the entire
    vertical space of the plot, only the horizontal dimension can be
    controlled. If only "height" is supplied, the box will be constrained
    to span the entire horizontal space of the plot, and the vertical
    dimension can be controlled.
    a  
    A callback to run in the browser on completion of drawing a selection box.
    The ``cb_data`` parameter that is available to the Callback code will contain
    one ``BoxSelectTool``-specific field:

    :geometry: object containing the coordinates of the selection box
    zE
    A shaded annotation drawn to indicate the selection region.
    r   r   z
    Indicates whether the rectangular selection area should originate from a corner
    (top-left or bottom-right depending on direction) or the center of the box.
    N)r^   r_   r`   ra   r   r   r   r   r   r   r6   r   r   select_every_mousemover   r
   rh   r0   r|   r.   r   ri   r   rb   rb   rb   rc   r;     s   r;   c               C   s   t ddddddddddgd		S )
Nri   r   rk   g      ?rl   g      ?r   r   )	rm   Zxs_unitsZys_unitsro   rp   rq   rr   rs   rt   )r/   rb   rb   rb   rc   ru     s   c               @   sZ   e Zd ZdZeeddZeeee	e
dddZedddZe	ed	dZe	eed
dZdS )rG   a   *toolbar icon*: |lasso_select_icon|

    The lasso selection tool allows users to make selections on a
    Plot by indicating a free-drawn "lasso" region by dragging the
    mouse or a finger over the plot region. The end of the drag
    event indicates the selection region is ready.

    See :ref:`userguide_styling_selected_unselected_glyphs` for information
    on styling selected and unselected glyphs.

    .. note::
        Selections can be comprised of multiple regions, even those
        made by different selection tools. Hold down the <<shift>> key
        while making a selection to append the new selection to any
        previous selection that might exist.

    .. |lasso_select_icon| image:: /_images/icons/LassoSelect.png
        :height: 18pt

    z
    A list of names to query for. If set, only renderers that
    have a matching value for their ``name`` attribute will be used.
    )rd   r}   zo
    An explicit list of renderers to hit test against. If unset,
    defaults to all renderers on a plot.
    )re   rd   Tz
    Whether a selection computation should happen on every mouse
    event, or only once, when the selection region is completed. Default: True
    a  
    A callback to run in the browser on every selection of a lasso area.
    The ``cb_data`` parameter that is available to the Callback code will contain
    one ``LassoSelectTool``-specific field:

    :geometry: object containing the coordinates of the lasso area
    zE
    A shaded annotation drawn to indicate the selection region.
    N)r^   r_   r`   ra   r   r   r   r   r   r   r6   r   r   r   r0   r|   r/   DEFAULT_POLY_OVERLAYri   rb   rb   rb   rc   rG     s   rG   c               @   sN   e Zd ZdZeeddZeeee	e
dddZe	eddZe	eeddZd	S )
rL   a-   *toolbar icon*: |poly_select_icon|

    The polygon selection tool allows users to make selections on a
    Plot by indicating a polygonal region with mouse clicks. single
    clicks (or taps) add successive points to the definition of the
    polygon, and a double click (or tap) indicates the selection
    region is ready.

    See :ref:`userguide_styling_selected_unselected_glyphs` for information
    on styling selected and unselected glyphs.

    .. note::
        Selections can be comprised of multiple regions, even those
        made by different selection tools. Hold down the <<shift>> key
        while making a selection to append the new selection to any
        previous selection that might exist.

    .. |poly_select_icon| image:: /_images/icons/PolygonSelect.png
        :height: 18pt

    z
    A list of names to query for. If set, only renderers that
    have a matching value for their ``name`` attribute will be used.
    )rd   r}   zo
    An explicit list of renderers to hit test against. If unset,
    defaults to all renderers on a plot.
    )re   rd   a  
    A callback to run in the browser on completion of drawing a polygon.
    The ``cb_data`` parameter that is available to the Callback code will contain
    one PolySelectTool-specific field:

    :geometry: object containing the coordinates of the polygon
    zE
    A shaded annotation drawn to indicate the selection region.
    N)r^   r_   r`   ra   r   r   r   r   r   r   r6   r   r0   r|   r/   r   ri   rb   rb   rb   rc   rL     s   rL   c               @   sJ   e Zd ZdZedd Zei fddZeee	e
ddZedd	d
ZdS )r?   aD   Define a custom formatter to apply to a hover tool field.

    This model can be configured with JavaScript code to format hover tooltips.
    The JavaScript code has access to the current value to format, some special
    variables, and any format configured on the tooltip. The variable ``value``
    will contain the untransformed value. The variable ``special_vars`` will
    provide a dict with the following contents:

    * ``x`` data-space x-coordinate of the mouse
    * ``y`` data-space y-coordinate of the mouse
    * ``sx`` screen-space x-coordinate of the mouse
    * ``sy`` screen-space y-coordinate of the mouse
    * ``data_x`` data-space x-coordinate of the hovered glyph
    * ``data_y`` data-space y-coordinate of the hovered glyph
    * ``indices`` column indices of all currently hovered glyphs
    * ``name`` value of the ``name`` property of the hovered glyph renderer

    If the hover is over a "multi" glyph such as ``Patches`` or ``MultiLine``
    then a ``segment_index`` key will also be present.

    Finally, the value of the format passed in the tooltip specification is
    available as the ``format`` variable.

    Example:

        As an example, the following code adds a custom formatter to format
        WebMercator northing coordinates (in meters) as a latitude:

        .. code-block:: python

            lat_custom = CustomJSHover(code="""
                var projections = require("core/util/projections");
                var x = special_vars.x
                var y = special_vars.y
                var coords = projections.wgs84_mercator.inverse([x, y])
                return "" + coords[1]
            """)

            p.add_tools(HoverTool(
                tooltips=[( 'lat','@y{custom}' )],
                formatters=dict(y=lat_custom)
            ))

    .. warning::
        The explicit purpose of this Bokeh Model is to embed *raw JavaScript
        code* for a browser to execute. If any part of the code is derived
        from untrusted user inputs, then you must take appropriate care to
        sanitize the user input prior to passing to Bokeh.

    c                s@   t |tstdtdd  fdd}||\}}| ||dS )a   Create a ``CustomJSHover`` instance from a Python functions. The
        function is translated to JavaScript using PScript.

        The python functions must have no positional arguments. It's
        possible to pass Bokeh models (e.g. a ``ColumnDataSource``) as keyword
        arguments to the functions.

        The ``code`` function namespace will contain the variable ``value``
        (the untransformed value) at render time as well as ``format`` and
        ``special_vars`` as described in the class description.

        Args:
            code (function) : a scalar function to transform a single ``value``

        Returns:
            CustomJSHover

        z9CustomJSHover.from_py_func only accepts function objects.pscriptz}To use Python functions for CustomJSHover, you need PScript ("conda install -c conda-forge pscript" or "pip install pscript")c                s~   t | }t|\}}t|t| dkr0td|rNtdd |D sNtdtt||} | ddd|  } | |fS )	Nr   z,Function may only contain keyword arguments.c             s   s   | ]}t |tV  qd S )N)
isinstancer,   ).0valuerb   rb   rc   	<genexpr>  s    zFCustomJSHover.from_py_func.<locals>.pscript_compile.<locals>.<genexpr>z$Default value must be a Bokeh Model.Ztransformerzreturn transformer(%s);
z, )	r$   r#   len
ValueErroranydictzipZpy2jsjoin)codeZsigZ	all_namesZdefault_valuesfunc_kwargs)r   rb   rc   pscript_compile  s    z3CustomJSHover.from_py_func.<locals>.pscript_compile)r   args)r   r   r   r"   )clsr   r   Zjsfuncr   rb   )r   rc   from_py_funcr  s    
zCustomJSHover.from_py_funcc             C   s.   t |ddd}d|kr t|j| |j|dS )a   Create a CustomJSHover instance from a CoffeeScript snippet.
        The function bodies are translated to JavaScript functions using
        node and therefore require return statements.

        The ``code`` snippet namespace will contain the variable ``value``
        (the untransformed value) at render time as well as ``format`` and
        ``special_vars`` as described in the class description.

        Example:

        .. code-block:: coffeescript

            formatter = CustomJSHover.from_coffeescript("return value + " total")

        Args:
            code (str) :
                A coffeescript snippet to transform a single ``value`` value

        Returns:
            CustomJSHover

        Zcoffeescriptz???)Zlangfiler%   )r   r   )r    r!   r%   r   )r   r   r   Zcompiledrb   rb   rc   from_coffeescript  s    
zCustomJSHover.from_coffeescriptz
    A mapping of names to Bokeh plot objects. These objects are made
    available to the callback code snippet as the values of named
    parameters to the callback.
    )rd    a  
    A snippet of JavaScript code to transform a single value. The variable
    ``value`` will contain the untransformed value and can be expected to be
    present in the function namespace at render time. Additionally, the
    variable ``special_vars`` will be available, and will provide a dict
    with the following contents:

    * ``x`` data-space x-coordinate of the mouse
    * ``y`` data-space y-coordinate of the mouse
    * ``sx`` screen-space x-coordinate of the mouse
    * ``sy`` screen-space y-coordinate of the mouse
    * ``data_x`` data-space x-coordinate of the hovered glyph
    * ``data_y`` data-space y-coordinate of the hovered glyph
    * ``indices`` column indices of all currently hovered glyphs

    If the hover is over a "multi" glyph such as ``Patches`` or ``MultiLine``
    then a ``segment_index`` key will also be present.

    Finally, the value of the format passed in the tooltip specification is
    available as the ``format`` variable.

    The snippet will be made into the body of a function and therefore requires
    a return statement.

    Example:

        .. code-block:: javascript

            code = '''
            return value + " total"
            '''
    )re   rd   N)r^   r_   r`   ra   classmethodr   r   r   r   r   r,   r   r   rb   rb   rb   rc   r?   >  s   21
r?   c            	   @   s   e Zd ZdZeeddZeeee	e
dddZe	eddZeeeeeedd	d
gddeeedd Zeeeeee	edd ddZedddddZedddddZeddddddddZeedddZeeddZed d!dZd"S )#rD   a   *toolbar icon*: |crosshair_icon|

    The hover tool is a passive inspector tool. It is generally on at
    all times, but can be configured in the inspector's menu associated
    with the *toolbar icon* shown above.

    By default, the hover tool displays informational tooltips whenever
    the cursor is directly over a glyph. The data to show comes from the
    glyph's data source, and what is to be displayed is configurable with
    the ``tooltips`` attribute that maps display names to columns in the
    data source, or to special known variables.

    Here is an example of how to configure and use the hover tool::

        # Add tooltip (name, field) pairs to the tool. See below for a
        # description of possible field values.
        hover.tooltips = [
            ("index", "$index"),
            ("(x,y)", "($x, $y)"),
            ("radius", "@radius"),
            ("fill color", "$color[hex, swatch]:fill_color"),
            ("foo", "@foo"),
            ("bar", "@bar"),
            ("baz", "@baz{safe}"),
            ("total", "@total{$0,0.00}"
        ]

    You can also supply a ``Callback`` to the ``HoverTool``, to build custom
    interactions on hover. In this case you may want to turn the tooltips
    off by setting ``tooltips=None``.

    .. warning::
        When supplying a callback or custom template, the explicit intent
        of this Bokeh Model is to embed *raw HTML and  JavaScript code* for
        a browser to execute. If any part of the code is derived from untrusted
        user inputs, then you must take appropriate care to sanitize the user
        input prior to passing to Bokeh.

    Hover tool does not currently work with the following glyphs:

        .. hlist::
            :columns: 3

            * annulus
            * arc
            * bezier
            * image
            * image_rgba
            * image_url
            * oval
            * patch
            * quadratic
            * ray
            * text

    .. |hover_icon| image:: /_images/icons/Hover.png
        :height: 18pt

    z
    A list of names to query for. If set, only renderers that
    have a matching value for their ``name`` attribute will be used.
    )rd   r}   zo
    An explicit list of renderers to hit test against. If unset,
    defaults to all renderers on a plot.
    )re   rd   a`  
    A callback to run in the browser whenever the input's value changes. The
    ``cb_data`` parameter that is available to the Callback code will contain two
    ``HoverTool`` specific fields:

    :index: object containing the indices of the hovered points in the data source
    :geometry: object containing the coordinates of the hover cursor
    )indexz$index)zdata (x, y)z($x, $y))zscreen (x, y)z
($sx, $sy)a  
    The (name, field) pairs describing what the hover tool should
    display when there is a hit.

    Field names starting with "@" are interpreted as columns on the
    data source. For instance, "@temp" would look up values to display
    from the "temp" column of the data source.

    Field names starting with "$" are special, known fields:

    :$index: index of hovered point in the data source
    :$name: value of the ``name`` property of the hovered glyph renderer
    :$x: x-coordinate under the cursor in data space
    :$y: y-coordinate under the cursor in data space
    :$sx: x-coordinate under the cursor in screen (canvas) space
    :$sy: y-coordinate under the cursor in screen (canvas) space
    :$color: color data from data source, with the syntax:
        ``$color[options]:field_name``. The available options
        are: 'hex' (to display the color as a hex value), and
        'swatch' to also display a small color swatch.

    Field names that begin with ``@`` are associated with columns in a
    ``ColumnDataSource``. For instance the field name ``"@price"`` will
    display values from the ``"price"`` column whenever a hover is triggered.
    If the hover is for the 17th glyph, then the hover tooltip will
    correspondingly display the 17th price value.

    Note that if a column name contains spaces, the it must be supplied by
    surrounding it in curly braces, e.g. ``@{adjusted close}`` will display
    values from a column named ``"adjusted close"``.

    Sometimes (especially with stacked charts) it is desirable to allow the
    name of the column be specified indirectly. The field name ``@$name`` is
    distinguished in that it will look up the ``name`` field on the hovered
    glyph renderer, and use that value as the column name. For instance, if
    a user hovers with the name ``"US East"``, then ``@$name`` is equivalent to
    ``@{US East}``.

    By default, values for fields (e.g. ``@foo``) are displayed in a basic
    numeric format. However it is possible to control the formatting of values
    more precisely. Fields can be modified by appending a format specified to
    the end in curly braces. Some examples are below.

    .. code-block:: python

        "@foo{0,0.000}"    # formats 10000.1234 as: 10,000.123

        "@foo{(.00)}"      # formats -10000.1234 as: (10000.123)

        "@foo{($ 0.00 a)}" # formats 1230974 as: $ 1.23 m

    Specifying a format ``{safe}`` after a field name will override automatic
    escaping of the tooltip data source. Any HTML tags in the data tags will
    be rendered as HTML in the resulting HoverTool output. See
    :ref:`custom_hover_tooltip` for a more detailed example.

    ``None`` is also a valid value for tooltips. This turns off the
    rendering of tooltips. This is mostly useful when supplying other
    actions on hover via the callback property.

    .. note::
        The tooltips attribute can also be configured with a mapping type,
        e.g. ``dict`` or ``OrderedDict``. However, if a ``dict`` is used,
        the visual presentation order is unspecified.

    c             C   s   t |  S )N)listitems)drb   rb   rc   ru   ~  s    zHoverTool.<lambda>c               C   s   t  S )N)r   rb   rb   rb   rc   ru     s    a  
    Specify the formatting scheme for data source columns, e.g.

    .. code-block:: python

        tool.formatters = dict(date="datetime")

    will cause format specifications for the "date" column to be interpreted
    according to the "datetime" formatting scheme. The following schemes are
    available:

    :``"numeral"``:
        Provides a wide variety of formats for numbers, currency, bytes, times,
        and percentages. The full set of formats can be found in the
        |NumeralTickFormatter| reference documentation.

    :``"datetime"``:
        Provides formats for date and time values. The full set of formats is
        listed in the |DatetimeTickFormatter| reference documentation.

    :``"printf"``:
        Provides formats similar to C-style "printf" type specifiers. See the
        |PrintfTickFormatter| reference documentation for complete details.

    If no formatter is specified for a column name, the default ``"numeral"``
    formatter is assumed.

    .. |NumeralTickFormatter| replace:: :class:`~bokeh.models.formatters.NumeralTickFormatter`
    .. |DatetimeTickFormatter| replace:: :class:`~bokeh.models.formatters.DatetimeTickFormatter`
    .. |PrintfTickFormatter| replace:: :class:`~bokeh.models.formatters.PrintfTickFormatter`

    ZmouseZhlineZvlinezh
    Whether to consider hover pointer as a point (x/y values), or a
    span on h or v directions.
    Zsnap_to_dataZfollow_mouseZnonez
    Whether the tooltip position should snap to the "center" (or other anchor)
    position of the associated glyph, or always follow the current mouse cursor
    position.
    prevnextZnearestZinterpa  
    When showing tooltips for lines, designates whether the tooltip position
    should be the "previous" or "next" points on the line, the "nearest" point
    to the current mouse position, or "interpolate" along the line to the
    current mouse position.
    r   z
    If point policy is set to `"snap_to_data"`, `anchor` defines the attachment
    point of a tooltip. The default is to attach to the center of a glyph.
    z
    Whether the tooltip should be displayed to the left or right of the cursor
    position or above or below it, or if it should be automatically placed
    in the horizontal or vertical dimension.
    Tz2
    Whether tooltip's arrow should be shown.
    N)r^   r_   r`   ra   r   r   r   r   r   r   r6   r   r0   r|   r   Zacceptsr   Ztooltipsr   r   r?   Z
formattersmodeZpoint_policyZline_policyr   Zanchorr   Z
attachmentr   Z
show_arrowrb   rb   rb   rc   rD     s6   ;BrD   z=Click the question mark to learn more about Bokeh plot tools.zLhttps://bokeh.pydata.org/en/latest/docs/user_guide/tools.html#built-in-toolsc               @   s(   e Zd ZdZeeddZeeddZdS )rC   z A button tool to provide a "help" link to users.

    The hover text can be customized through the ``help_tooltip`` attribute
    and the redirect site overridden as well.

    z=
    Tooltip displayed when hovering over the help icon.
    )re   rd   z3
    Site to be redirected through upon click.
    N)	r^   r_   r`   ra   r   DEFAULT_HELP_TIPZhelp_tooltipDEFAULT_HELP_URLZredirectrb   rb   rb   rc   rC     s
   rC   c               @   s   e Zd ZdZdS )rY   z *toolbar icon*: |undo_icon|

    Undo tool allows to restore previous state of the plot.

    .. |undo_icon| image:: /_images/icons/Undo.png
        :height: 18pt

    N)r^   r_   r`   ra   rb   rb   rb   rc   rY     s   rY   c               @   s   e Zd ZdZdS )rO   z *toolbar icon*: |redo_icon|

    Redo tool reverses the last action performed by undo tool.

    .. |redo_icon| image:: /_images/icons/Redo.png
        :height: 18pt

    N)r^   r_   r`   ra   rb   rb   rb   rc   rO     s   rO   c            	   @   sL   e Zd ZdZedddZeeee	e
eeddZeddZeeeddZdS )rA   z8 A base class for all interactive draw tool types.

    Nz>
    A custom tooltip label to override the default name.
    )rd   a_  
    Defines the value to insert on non-coordinate columns when a new
    glyph is inserted into the ``ColumnDataSource`` columns, e.g. when a
    circle glyph defines 'x', 'y' and 'color' columns, adding a new
    point will add the x and y-coordinates to 'x' and 'y' columns and
    the color column will be filled with the defined empty value.
    z
    An icon to display in the toolbar.

    The icon can provided as a string filename for an image, a PIL ``Image``
    object, or an RGB(A) NumPy array.
    z_
    An explicit list of renderers corresponding to scatter glyphs
    that may be edited.
    )r^   r_   r`   ra   r   Zcustom_tooltipr   r   r   r   r   r   r   Zempty_valuer   Zcustom_iconr   r   r6   r   rb   rb   rb   rc   rA     s   rA   c               @   s:   e Zd ZdZeedddZedddZe	e
dd Zd	S )
r:   aQ   *toolbar icon*: |box_edit_icon|

    Allows drawing, dragging and deleting ``Rect`` glyphs on one or more
    renderers by editing the underlying ``ColumnDataSource`` data. Like other
    drawing tools, the renderers that are to be edited must be supplied
    explicitly as a list. When drawing a new box the data will always be added
    to the ``ColumnDataSource`` on the first supplied renderer.

    The tool will automatically modify the columns on the data source
    corresponding to the ``x``, ``y``, ``width`` and ``height`` values
    of the glyph. Any additional columns in the data source will be
    padded with the declared ``empty_value``, when adding a new box.

    The supported actions include:

    * Add box: Hold shift then click and drag anywhere on the plot or
      double tap once to start drawing, move the mouse and double tap
      again to finish drawing.

    * Move box: Click and drag an existing box, the box will be
      dropped once you let go of the mouse button.

    * Delete box: Tap a box to select it then press <<backspace>> key
      while the mouse is within the plot area.

    To **Move** or **Delete** multiple boxes at once:

    * Move selection: Select box(es) with <<shift>>+tap (or another
      selection tool) then drag anywhere on the plot. Selecting and
      then dragging on a specific box will move both.

    * Delete selection: Select box(es) with <<shift>>+tap (or another
      selection tool) then press <<backspace>> while the mouse is
      within the plot area.

    .. |box_edit_icon| image:: /_images/icons/BoxEdit.png
        :height: 18pt
    rg   a  
    Which dimensions the box drawing is to be free in. By default,
    users may freely draw boxes with any dimensions. If only "width"
    is supplied, the box will be constrained to span the entire
    vertical space of the plot, only the horizontal dimension can be
    controlled. If only "height" is supplied, the box will be
    constrained to span the entire horizontal space of the plot, and
    the vertical dimension can be controlled.
    )re   rd   r   z
    Defines a limit on the number of boxes that can be drawn. By
    default there is no limit on the number of objects, but if enabled
    the oldest drawn box will be dropped to make space for the new box
    being added.
    c             C   sN   g }x$| j D ]}t|jts|| qW |rJddd |D }d| S d S )Nz, c             s   s   | ]}t |jjV  qd S )N)typeglyphr^   )r   rendererrb   rb   rc   r   H  s    z:BoxEditTool._check_compatible_renderers.<locals>.<genexpr>z%s glyph type(s) found.)r   r   r   r2   appendr   )rx   incompatible_renderersr   glyph_typesrb   rb   rc   _check_compatible_renderersA  s    z'BoxEditTool._check_compatible_renderersN)r^   r_   r`   ra   r   r
   rh   r   num_objectsr%   r&   r   rb   rb   rb   rc   r:     s   &r:   c               @   sD   e Zd ZdZedddZedddZedddZe	e
dd	 Zd
S )rI   aT   *toolbar icon*: |point_draw_icon|

    The PointDrawTool allows adding, dragging and deleting point-like
    glyphs (of ``XYGlyph`` type) on one or more renderers by editing the
    underlying ``ColumnDataSource`` data. Like other drawing tools, the
    renderers that are to be edited must be supplied explicitly as a list.
    Any newly added points will be inserted on the ``ColumnDataSource`` of
    the first supplied renderer.

    The tool will automatically modify the columns on the data source
    corresponding to the ``x`` and ``y`` values of the glyph. Any additional
    columns in the data source will be padded with the given ``empty_value``
    when adding a new point.

    .. note::
        The data source updates will trigger data change events continuously
        throughout the edit operations on the BokehJS side. In Bokeh server
        apps, the data source will only be synced once, when the edit operation
        finishes.

    The supported actions include:

    * Add point: Tap anywhere on the plot

    * Move point: Tap and drag an existing point, the point will be
      dropped once you let go of the mouse button.

    * Delete point: Tap a point to select it then press <<backspace>>
      key while the mouse is within the plot area.

    .. |point_draw_icon| image:: /_images/icons/PointDraw.png
        :height: 18pt
    Tz0
    Enables adding of new points on tap events.)re   rd   z7
    Enables dragging of existing points on pan events.r   z
    Defines a limit on the number of points that can be drawn. By
    default there is no limit on the number of objects, but if enabled
    the oldest drawn point will be dropped to make space for the new
    point.
    c             C   sN   g }x$| j D ]}t|jts|| qW |rJddd |D }d| S d S )Nz, c             s   s   | ]}t |jjV  qd S )N)r   r   r^   )r   r   rb   rb   rc   r     s    z<PointDrawTool._check_compatible_renderers.<locals>.<genexpr>z%s glyph type(s) found.)r   r   r   r1   r   r   )rx   r   r   r   rb   rb   rc   r   {  s    z)PointDrawTool._check_compatible_renderersN)r^   r_   r`   ra   r   adddragr   r   r%   r'   r   rb   rb   rb   rc   rI   K  s   !rI   c               @   sT   e Zd ZdZedddZedddZee	ddZ
eed	d
 Zeedd ZdS )rJ   a   *toolbar icon*: |poly_draw_icon|

    The PolyDrawTool allows drawing, selecting and deleting
    ``Patches`` and ``MultiLine`` glyphs on one or more renderers by
    editing the underlying ``ColumnDataSource`` data. Like other drawing
    tools, the renderers that are to be edited must be supplied
    explicitly as a list.

    The tool will automatically modify the columns on the data source
    corresponding to the ``xs`` and ``ys`` values of the glyph. Any
    additional columns in the data source will be padded with the
    declared ``empty_value``, when adding a new point.

    If a ``vertex_renderer`` with an point-like glyph is supplied the
    ``PolyDrawTool`` will use it to display the vertices of the
    multi-lines/patches on all supplied renderers. This also enables
    the ability to snap to existing vertices while drawing.

    The supported actions include:

    * Add patch/multi-line: Double tap to add the first vertex, then
      use tap to add each subsequent vertex, to finalize the draw
      action double tap to insert the final vertex or press the <<esc>
      key.

    * Move patch/multi-line: Tap and drag an existing
      patch/multi-line, the point will be dropped once you let go of
      the mouse button.

    * Delete patch/multi-line: Tap a patch/multi-line to select it
      then press <<backspace>> key while the mouse is within the plot
      area.

    .. |poly_draw_icon| image:: /_images/icons/PolyDraw.png
        :height: 18pt
    TzH
    Enables dragging of existing patches and multi-lines on pan events.)re   rd   r   a
  
    Defines a limit on the number of patches or multi-lines that can
    be drawn. By default there is no limit on the number of objects,
    but if enabled the oldest drawn patch or multi-line will be
    dropped to make space for the new patch or multi-line.
    zP
    The renderer used to render the vertices of a selected line or
    polygon.)rd   c             C   sR   g }x(| j D ]}t|jttfs|| qW |rNddd |D }d| S d S )Nz, c             s   s   | ]}t |jjV  qd S )N)r   r   r^   )r   r   rb   rb   rc   r     s    z;PolyDrawTool._check_compatible_renderers.<locals>.<genexpr>z%s glyph type(s) found.)r   r   r   r4   r3   r   r   )rx   r   r   r   rb   rb   rc   r     s    z(PolyDrawTool._check_compatible_renderersc             C   s2   | j d krd S | j j}t|ts.dt|j S d S )Nzglyph type %s found.)vertex_rendererr   r   r1   r   r^   )rx   r   rb   rb   rc   !_check_compatible_vertex_renderer  s
    

z.PolyDrawTool._check_compatible_vertex_rendererN)r^   r_   r`   ra   r   r   r   r   r   r7   r   r%   r(   r   r*   r   rb   rb   rb   rc   rJ     s   $
rJ   c               @   s,   e Zd ZdZedddZeedd ZdS )rB   a   *toolbar icon*: |freehand_draw_icon|

    Allows freehand drawing of ``Patches`` and ``MultiLine`` glyphs. The glyph
    to draw may be defined via the ``renderers`` property.

    The tool will automatically modify the columns on the data source
    corresponding to the ``xs`` and ``ys`` values of the glyph. Any
    additional columns in the data source will be padded with the
    declared ``empty_value``, when adding a new point.

    The supported actions include:

    * Draw vertices: Click and drag to draw a line

    * Delete patch/multi-line: Tap a patch/multi-line to select it
      then press <<backspace>> key while the mouse is within the plot
      area.

    .. |freehand_draw_icon| image:: /_images/icons/FreehandDraw.png
        :height: 18pt
    r   z
    Defines a limit on the number of patches or multi-lines that can
    be drawn. By default there is no limit on the number of objects,
    but if enabled the oldest drawn patch or multi-line will be
    overwritten when the limit is reached.
    )re   rd   c             C   sR   g }x(| j D ]}t|jttfs|| qW |rNddd |D }d| S d S )Nz, c             s   s   | ]}t |jjV  qd S )N)r   r   r^   )r   r   rb   rb   rc   r     s    z?FreehandDrawTool._check_compatible_renderers.<locals>.<genexpr>z%s glyph type(s) found.)r   r   r   r4   r3   r   r   )rx   r   r   r   rb   rb   rc   r     s    z,FreehandDrawTool._check_compatible_renderersN)	r^   r_   r`   ra   r   r   r%   r(   r   rb   rb   rb   rc   rB     s   rB   c               @   s<   e Zd ZdZeeddZeedd Z	ee
dd ZdS )	rK   a   *toolbar icon*: |poly_edit_icon|

    The PolyEditTool allows editing the vertices of one or more
    ``Patches`` or ``MultiLine`` glyphs. The glyphs to be edited can
    be defined via the ``renderers`` property and the renderer for the
    vertices can be defined via the ``vertex_renderer``, which must
    render a point-like Glyph (of ``XYGlyph`` type).

    The tool will automatically modify the columns on the data source
    corresponding to the ``xs`` and ``ys`` values of the glyph. Any
    additional columns in the data source will be padded with the
    declared ``empty_value``, when adding a new point.

    The supported actions include:

    * Show vertices: Double tap an existing patch or multi-line

    * Add vertex: Double tap an existing vertex to select it, the tool
      will draw the next point, to add it tap in a new location. To
      finish editing and add a point double tap otherwise press the
      <<esc> key to cancel.

    * Move vertex: Drag an existing vertex and let go of the mouse
      button to release it.

    * Delete vertex: After selecting one or more vertices press
      <<backspace>> while the mouse cursor is within the plot area.

    .. |poly_edit_icon| image:: /_images/icons/PolyEdit.png
        :height: 18pt
    zP
    The renderer used to render the vertices of a selected line or
    polygon.)rd   c             C   s$   | j j}t|ts dt|j S d S )Nzglyph type %s found.)r   r   r   r1   r   r^   )rx   r   rb   rb   rc   r     s    
z.PolyEditTool._check_compatible_vertex_rendererc             C   sR   g }x(| j D ]}t|jttfs|| qW |rNddd |D }d| S d S )Nz, c             s   s   | ]}t |jjV  qd S )N)r   r   r^   )r   r   rb   rb   rc   r   %  s   z;PolyEditTool._check_compatible_renderers.<locals>.<genexpr>z%s glyph type(s) found.)r   r   r   r4   r3   r   r   )rx   r   r   r   rb   rb   rc   r     s    

z(PolyEditTool._check_compatible_renderersN)r^   r_   r`   ra   r   r7   r   r%   r*   r   r)   r   rb   rb   rb   rc   rK     s
   rK   )vra   Z
__future__r   r   r   r   ZloggingZ	getLoggerr^   logtypesr   Z
core.enumsr   r	   r
   r   r   r   Zcore.has_propsr   Zcore.propertiesr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Zutil.compilerr    r!   Zutil.dependenciesr"   Zutil.futurer#   r$   Zcore.validationr%   Zcore.validation.errorsr&   r'   r(   r)   r*   r+   Zmodelr,   Zannotationsr.   r/   Z	callbacksr0   Zglyphsr1   r2   r3   r4   Zrangesr5   r   r6   r7   Zlayoutsr8   __all__rU   r9   rF   r@   rR   rS   rE   rW   rV   rM   rX   rH   rz   rN   rZ   r[   r>   rQ   rP   rT   r=   r   r<   r\   r]   r;   r   rG   rL   r?   rD   r   r   rC   rY   rO   rA   r:   rI   rJ   rB   rK   rb   rb   rb   rc   <module>   s   
 L +
 8'C2*;1- + \

C:F(