#-----------------------------------------------------------------------------# 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.has_propsimportabstractfrom..core.propertiesimport(Dict,Either,Float,Instance,Int,Len,Seq,String,)from..modelimportModelfrom.expressionsimportCoordinateTransform#-----------------------------------------------------------------------------# Globals and constants#-----------------------------------------------------------------------------__all__=('EdgesAndLinkedNodes','EdgeCoordinates','EdgesOnly','GraphCoordinates','GraphHitTestPolicy','LayoutProvider','NodeCoordinates','NodesAndAdjacentNodes','NodesAndLinkedEdges','NodesOnly','StaticLayoutProvider',)#-----------------------------------------------------------------------------# General API#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Dev API#-----------------------------------------------------------------------------
[docs]@abstractclassLayoutProvider(Model):''' '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)@propertydefnode_coordinates(self)->NodeCoordinates:returnNodeCoordinates(layout=self)@propertydefedge_coordinates(self)->EdgeCoordinates:returnEdgeCoordinates(layout=self)
[docs]classStaticLayoutProvider(LayoutProvider):''' '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)graph_layout=Dict(Either(Int,String),Len(Seq(Float),2),default={},help=""" The coordinates of the graph nodes in cartesian space. The keys of the dictionary correspond to node indices or labels and the values are two element sequences containing the x and y coordinates of the nodes. .. code-block:: python { 0 : [0.5, 0.5], 1 : [1.0, 0.86], 2 : [0.86, 1], } """)
[docs]@abstractclassGraphCoordinates(CoordinateTransform):''' Abstract class for coordinate transform expression obtained from ``LayoutProvider`` '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)layout=Instance(LayoutProvider)
[docs]classNodeCoordinates(GraphCoordinates):''' Node coordinate expression obtained from ``LayoutProvider`` '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)
[docs]classEdgeCoordinates(GraphCoordinates):''' Node coordinate expression obtained from ``LayoutProvider`` '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)
[docs]@abstractclassGraphHitTestPolicy(Model):''' '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)
[docs]classEdgesOnly(GraphHitTestPolicy):''' With the ``EdgesOnly`` policy, only graph edges are able to be selected and inspected. There is no selection or inspection of graph nodes. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)
[docs]classNodesOnly(GraphHitTestPolicy):''' With the ``NodesOnly`` policy, only graph nodes are able to be selected and inspected. There is no selection or inspection of graph edges. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)
[docs]classNodesAndLinkedEdges(GraphHitTestPolicy):''' With the ``NodesAndLinkedEdges`` policy, inspection or selection of graph nodes will result in the inspection or selection of the node and of the linked graph edges. There is no direct selection or inspection of graph edges. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)
[docs]classEdgesAndLinkedNodes(GraphHitTestPolicy):''' With the ``EdgesAndLinkedNodes`` policy, inspection or selection of graph edges will result in the inspection or selection of the edge and of the linked graph nodes. There is no direct selection or inspection of graph nodes. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)
[docs]classNodesAndAdjacentNodes(GraphHitTestPolicy):''' With the ``NodesAndAdjacentNodes`` policy, inspection or selection of graph nodes will also result in the inspection or selection any nodes that are immediately adjacent (connected by a single edge). There is no selection or inspection of graph edges, and no indication of which node is the tool-selected one from the policy-selected nodes. '''# explicit __init__ to support Init signaturesdef__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)