#-----------------------------------------------------------------------------# Copyright (c) Anaconda, Inc., and Bokeh Contributors.# All rights reserved.## The full license is in the file LICENSE.txt, distributed with this software.#-----------------------------------------------------------------------------''''''#-----------------------------------------------------------------------------# Boilerplate#-----------------------------------------------------------------------------from__future__importannotationsimportlogging# isort:skiplog=logging.getLogger(__name__)#-----------------------------------------------------------------------------# Imports#-----------------------------------------------------------------------------# Bokeh importsfrom...core.enumsimportCoordinateUnitsfrom...core.has_propsimportabstractfrom...core.propertiesimport(Enum,Include,Instance,InstanceDefault,Nullable,NumberSpec,Override,field,)from...core.property_mixinsimportFillProps,LinePropsfrom..graphicsimportMarkingfrom.annotationimportDataAnnotation#-----------------------------------------------------------------------------# Globals and constants#-----------------------------------------------------------------------------__all__=("Arrow","ArrowHead","NormalHead","OpenHead","TeeHead","VeeHead",)#-----------------------------------------------------------------------------# General API#-----------------------------------------------------------------------------
[docs]@abstractclassArrowHead(Marking):''' Base class for arrow heads. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)size=NumberSpec(default=25,help=""" The size, in pixels, of the arrow head. """)
# TODO: reversed = Bool(default=False)
[docs]classOpenHead(ArrowHead):''' Render an open-body arrow head. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)line_props=Include(LineProps,help=""" The {prop} values for the arrow head outline. """)
[docs]classNormalHead(ArrowHead):''' Render a closed-body arrow head. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)line_props=Include(LineProps,help=""" The {prop} values for the arrow head outline. """)fill_props=Include(FillProps,help=""" The {prop} values for the arrow head interior. """)fill_color=Override(default="black")
[docs]classTeeHead(ArrowHead):''' Render a tee-style arrow head. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)line_props=Include(LineProps,help=""" The {prop} values for the arrow head outline. """)
[docs]classVeeHead(ArrowHead):''' Render a vee-style arrow head. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)line_props=Include(LineProps,help=""" The {prop} values for the arrow head outline. """)fill_props=Include(FillProps,help=""" The {prop} values for the arrow head interior. """)fill_color=Override(default="black")
[docs]classArrow(DataAnnotation):''' Render arrows as an annotation. See :ref:`ug_basic_annotations_arrows` for information on plotting arrows. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)x_start=NumberSpec(default=field("x_start"),help=""" The x-coordinates to locate the start of the arrows. """)y_start=NumberSpec(default=field("y_start"),help=""" The y-coordinates to locate the start of the arrows. """)start_units=Enum(CoordinateUnits,default='data',help=""" The unit type for the start_x and start_y attributes. Interpreted as "data space" units by default. """)start=Nullable(Instance(ArrowHead),help=""" Instance of ``ArrowHead``. """)x_end=NumberSpec(default=field("x_end"),help=""" The x-coordinates to locate the end of the arrows. """)y_end=NumberSpec(default=field("y_end"),help=""" The y-coordinates to locate the end of the arrows. """)end_units=Enum(CoordinateUnits,default='data',help=""" The unit type for the end_x and end_y attributes. Interpreted as "data space" units by default. """)end=Nullable(Instance(ArrowHead),default=InstanceDefault(OpenHead),help=""" Instance of ``ArrowHead``. """)body_props=Include(LineProps,help=""" The {prop} values for the arrow body. """)
#-----------------------------------------------------------------------------# Dev API#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Private API#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Code#-----------------------------------------------------------------------------