B
    ncf                 @   s\   d dl T G dd deZG dd deZG dd deZG dd	 d	eZG d
d deZdS )   )*c               @   sP   e Zd ZdZdd Zdd Zdd Zdd	 ZG d
d deZ	G dd deZ
dS )EdgeOptionsz
    This is where the construction of the edges' options takes place.
    So far, the edge smoothness can be switched through this object
    as well as the edge color's inheritance. 
    c             C   s   |   | _|  | _d S )N)SmoothsmoothColorcolor)self r	   ,lib/python3.7/site-packages/pyvis/options.py__init__
   s    
zEdgeOptions.__init__c             C   s   || j _dS )ac  
        Whether or not to inherit colors from the source node.
        If this is set to `from` then the edge will take the color
        of the source node. If it is set to `to` then the color will
        be that of the destination node.

        .. note:: If set to `True` then the `from` behavior is adopted
                  and vice versa.
        N)r   inherit)r   statusr	   r	   r
   inherit_colors   s    
zEdgeOptions.inherit_colorsc             C   s   || j _dS )a  
        Change smooth option for edges. When using dynamic, the edges will
        have an invisible support node guiding the shape. This node is part
        of the physics simulation,

        :param smooth_type: Possible options are dynamic, continuous, discrete,
                            diagonalCross, straightCross, horizontal, vertical,
                            curvedCW, curvedCCW, cubicBezier
        
        :type smooth_type: str
        N)r   type)r   Zsmooth_typer	   r	   r
   toggle_smoothness   s    zEdgeOptions.toggle_smoothnessc             C   s
   t | jS )N)str__dict__)r   r	   r	   r
   __repr__(   s    zEdgeOptions.__repr__c               @   s    e Zd ZdZdd Zdd ZdS )zEdgeOptions.Smootha  
        When the edges are made to be smooth, the edges are drawn as a
        dynamic quadratic bezier curve. The drawing of these curves
        takes longer than that of the straight curves but it looks better.
        There is a difference between dynamic smooth curves and static
        smooth curves. The dynamic smooth curves have an invisible support
        node that takes part in the physics simulation. If there are a lot
        of edges, another kind of smooth than dynamic would be better for
        performance.
        c             C   s
   t | jS )N)r   r   )r   r	   r	   r
   r   6   s    zEdgeOptions.Smooth.__repr__c             C   s   d| _ d| _d S )NTZdynamic)enabledr   )r   r	   r	   r
   r   9   s    zEdgeOptions.Smooth.__init__N)__name__
__module____qualname____doc__r   r   r	   r	   r	   r
   r   +   s   
r   c               @   s    e Zd ZdZdd Zdd ZdS )zEdgeOptions.Colorz
        The color object contains the color information of the edge
        in every situation. When the edge only needs a single color value
        like 'rgb(120,32,14)', '#ffffff' or 'red' can be supplied instead
        of an object.
        c             C   s
   t | jS )N)r   r   )r   r	   r	   r
   r   D   s    zEdgeOptions.Color.__repr__c             C   s
   d| _ d S )NT)r   )r   r	   r	   r
   r   G   s    zEdgeOptions.Color.__init__N)r   r   r   r   r   r   r	   r	   r	   r
   r   =   s   r   N)r   r   r   r   r   r   r   r   objectr   r   r	   r	   r	   r
   r      s   r   c               @   s(   e Zd ZdZdd Zdd Zdd ZdS )	Interactionz
    Used for all user interaction with the network. Handles mouse
    and touch events as well as the navigation buttons and the popups.
    c             C   s
   t | jS )N)r   r   )r   r	   r	   r
   r   P   s    zInteraction.__repr__c             C   s   d| _ d| _d| _d S )NFT)ZhideEdgesOnDragZhideNodesOnDragZ	dragNodes)r   r	   r	   r
   r   S   s    zInteraction.__init__c             C   s
   | j | S )N)r   )r   itemr	   r	   r
   __getitem__X   s    zInteraction.__getitem__N)r   r   r   r   r   r   r   r	   r	   r	   r
   r   K   s   r   c               @   s*   e Zd ZdZdd Zd
ddZdd	 ZdS )	Configurezl
    Handles the HTML part of the canvas and generates
    an interactive option editor with filtering.
    c             C   s
   t | jS )N)r   r   )r   r	   r	   r
   r   b   s    zConfigure.__repr__FNc             C   s   || _ |r|| _d S )N)r   filter)r   r   Zfilter_r	   r	   r
   r   e   s    zConfigure.__init__c             C   s
   | j | S )N)r   )r   r   r	   r	   r
   r   j   s    zConfigure.__getitem__)FN)r   r   r   r   r   r   r   r	   r	   r	   r
   r   \   s   
r   c               @   sJ   e Zd ZdZdd ZdddZdd	 Zd
d Zdd ZG dd de	Z
dS )Layoutzd
    Acts as the camera that looks on the canvas.
    Does the animation, zooming and focusing.
    c             C   s
   t | jS )N)r   r   )r   r	   r	   r
   r   t   s    zLayout.__repr__NTc             C   s*   |sd| _ n|| _ || _| jdd| _d S )N    T)r   )
randomSeedimprovedLayoutHierarchicalhierarchical)r   r!   r"   r	   r	   r
   r   w   s
    zLayout.__init__c             C   s   || j _dS )z<
        The distance between the different levels.
        N)r$   levelSeparation)r   distancer	   r	   r
   set_separation   s    zLayout.set_separationc             C   s   || j _dS )z
        Distance between different trees (independent networks). This is
        only for the initial layout. If you enable physics, the repulsion
        model will denote the distance between the trees.
        N)r$   treeSpacing)r   r&   r	   r	   r
   set_tree_spacing   s    zLayout.set_tree_spacingc             C   s   || j _dS )a  
        Method for reducing whitespace. Can be used alone or together with
        block shifting. Enabling block shifting will usually speed up the
        layout process. Each node will try to move along its free axis to
        reduce the total length of it's edges. This is mainly for the
        initial layout. If you enable physics, they layout will be determined
        by the physics. This will greatly speed up the stabilization time
        N)r$   edgeMinimization)r   r   r	   r	   r
   set_edge_minimization   s    	zLayout.set_edge_minimizationc               @   s   e Zd Zdd Zddd	Zd
S )zLayout.Hierarchicalc             C   s
   | j | S )N)r   )r   r   r	   r	   r
   r      s    zLayout.Hierarchical.__getitem__F      Thubsizec             C   s.   || _ || _|| _|| _|| _|| _|| _d S )N)r   r%   r(   blockShiftingr*   parentCentralization
sortMethod)r   r   r%   r(   r/   r*   r0   r1   r	   r	   r
   r      s    	zLayout.Hierarchical.__init__N)Fr,   r-   TTTr.   )r   r   r   r   r   r	   r	   r	   r
   r#      s         r#   )NT)r   r   r   r   r   r   r'   r)   r+   r   r#   r	   r	   r	   r
   r   n   s   
r   c               @   s:   e Zd ZdZdd Zdd ZdddZd	d
 Zdd ZdS )Optionsa  
    Represents the global options of the network.
    This object consists of indiviual sub-objects
    that map to VisJS's modules of:
        - configure
        - layout
        - interaction
        - physics
        - edges
    
    The JSON representation of this object is directly passed
    in to the VisJS framework.
    In the future this can be expanded to completely mimic
    the structure VisJS can expect.
    c             C   s
   t | jS )N)r   r   )r   r	   r	   r
   r      s    zOptions.__repr__c             C   s
   | j | S )N)r   )r   r   r	   r	   r
   r      s    zOptions.__getitem__Nc             C   s0   |rt  | _t | _t | _t | _t | _	d S )N)
r   layoutr   Zinteractionr   Z	configureZPhysicsphysicsr   Zedges)r   r3   r	   r	   r
   r      s    zOptions.__init__c             C   s8   | dd dd}|d}||d }t|}|S )aG  
        This method should accept a JSON string and replace its internal
        options structure with the given argument after parsing it.
        In practice, this method should be called after using the browser
        to experiment with different physics and layout options, using
        the generated JSON options structure that is spit out from the
        front end to serve as input to this method as a string.

        :param new_options: The JSON like string of the options that will
                            override.
        
        :type new_options: str
        
  {N)replacefindjsonloads)r   Znew_optionsoptionsZfirst_bracketr	   r	   r
   set   s
    

zOptions.setc             C   s   t j| dd dddS )Nc             S   s   | j S )N)r   )or	   r	   r
   <lambda>       z!Options.to_json.<locals>.<lambda>T   )defaultZ	sort_keysindent)r;   dumps)r   r	   r	   r
   to_json   s    zOptions.to_json)N)	r   r   r   r   r   r   r   r>   rF   r	   r	   r	   r
   r2      s   
r2   N)r4   r   r   r   r   r   r2   r	   r	   r	   r
   <module>   s
   HB