
    A j)                     \    	 d dl mZ d dlmZ dZn# e$ r dZY nw xY w G d de          ZdS )    NTFc                   :    e Zd Zd
dZd Zd Zd Zd Zd Zd	 Z	dS )PlotMethodstextNc                 "   t           st          d          |j        dk    r|dv rt          d| d          |j        dk    r|dv rt          d| d          t	          | |          } ||          }||                    |           d	S |S )
ad  Plot elements found on PDF page based on kind
        specified, useful for debugging and playing with different
        parameters to get the best output.

        Parameters
        ----------
        table: camelot.core.Table
            A Camelot Table.
        kind : str, optional (default: 'text')
            {'text', 'grid', 'contour', 'joint', 'line'}
            The element type for which a plot should be generated.
        filepath: str, optional (default: None)
            Absolute path for saving the generated plot.

        Returns
        -------
        fig : matplotlib.fig.Figure

        z$matplotlib is required for plotting.lattice)textedgez&Lattice flavor does not support kind=''stream)jointlinez%Stream flavor does not support kind='N)_HAS_MPLImportErrorflavorNotImplementedErrorgetattrsavefig)selftablekindfilenameplot_methodfigs         dC:\Users\Terasoftware\OneDrive\Desktop\faahhh\fyndo\fyndo\venv\Lib\site-packages\camelot/plotting.py__call__zPlotMethods.__call__   s    (  	FDEEE<9$ 	W)= 	W%&Vt&V&V&VWWW\X% 	W$2C*C 	W%&Ud&U&U&UVVVdD))k%   	KK!!!4
    c           
         t          j                    }|                    dd          }g g }}|j        D ]}|                    |d         |d         g           |                    |d         |d         g           |                    t          j        |d         |d         f|d         |d         z
  |d         |d         z
                       |                    t          |          dz
  t          |          dz              |                    t          |          dz
  t          |          dz              |S )	zGenerates a plot for all text elements present
        on the PDF page.

        Parameters
        ----------
        table : camelot.core.Table

        Returns
        -------
        fig : matplotlib.fig.Figure

        o   equalaspectr            
   )pltfigureadd_subplot_textextend	add_patchpatches	Rectangleset_xlimminmaxset_ylim)r   r   r   axxsysts          r   r   zPlotMethods.text2   s    jll__S_11RB 	T 	TAIIqtQqTl###IIqtQqTl###LL*AaD!A$<1!adQqTkRRSSSS
CGGbL#b''B,///
CGGbL#b''B,///
r   c                    t          j                    }|                    dd          }|j        D ]>}|D ]7}|j        rF|                    |j        d         |j        d         g|j        d         |j        d         g           |j        rF|                    |j	        d         |j
        d         g|j	        d         |j
        d         g           |j        rF|                    |j        d         |j
        d         g|j        d         |j
        d         g           |j        rF|                    |j        d         |j	        d         g|j        d         |j	        d         g           9@|S )zGenerates a plot for the detected table grids
        on the PDF page.

        Parameters
        ----------
        table : camelot.core.Table

        Returns
        -------
        fig : matplotlib.fig.Figure

        r   r   r   r   r"   )r%   r&   r'   cellsleftplotlbltrightrbrttopbottom)r   r   r   r1   rowcells         r   gridzPlotMethods.gridJ   sZ    jll__S_11; 		P 		PC P P9 PGGTWQZ4twqz471:6NOOO: PGGTWQZ4twqz471:6NOOO8 PGGTWQZ4twqz471:6NOOO; PGGTWQZ4twqz471:6NOOOP 
r   c           
         	 |j         \  }}d}n# t          $ r d|j        di}}d}Y nw xY wt          j                    }|                    dd          }g g }}|s|j        D ]}	|                    |	d         |	d         g           |                    |	d	         |	d
         g           |                    t          j
        |	d         |	d	         f|	d         |	d         z
  |	d
         |	d	         z
  d                     |                                D ]}	|                    t          j
        |	d         |	d	         f|	d         |	d         z
  |	d
         |	d	         z
  dd                     |s|                    |	d         |	d         g           |                    |	d	         |	d
         g           |                    t          |          dz
  t          |          dz              |                    t          |          dz
  t          |          dz              |r|                    |           |S )zGenerates a plot for all table boundaries present
        on the PDF page.

        Parameters
        ----------
        table : camelot.core.Table

        Returns
        -------
        fig : matplotlib.fig.Figure

        TNFr   r   r   r   r!   r"   r#   bluecolorred)fillrF   r$   )_image	TypeError_bboxr%   r&   r'   r(   r)   r*   r+   r,   keysr-   r.   r/   r0   imshow)
r   r   img
table_bbox_FOR_LATTICEr   r1   r2   r3   r4   s
             r   contourzPlotMethods.contoure   sR   	!#lOCLL 	! 	! 	!#ek4%8C LLL	! jll__S_11RB 	[  		1Q41,'''		1Q41,'''%1qtadQqTk1Q4!A$;f      "" 
	8 
	8ALL!qT1Q4L!A$1+qtad{e    
   8		1Q41,'''		1Q41,'''CGGbL#b''B,777CGGbL#b''B,777 	IIcNNN
s    ))c           
         t          j                    }|                    dd          }g g }}|j        D ]}|                    |d         |d         g           |                    |d         |d         g           |                    t          j        |d         |d         f|d         |d         z
  |d         |d         z
  d	                     |                    t          |          d
z
  t          |          d
z              |                    t          |          d
z
  t          |          d
z              |j        D ]0}|                    |j        |j        g|j        |j        g           1|S )zGenerates a plot for relevant textedges.

        Parameters
        ----------
        table : camelot.core.Table

        Returns
        -------
        fig : matplotlib.fig.Figure

        r   r   r   r   r!   r"   r#   rD   rE   r$   )r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   
_textedgesr8   xy0y1)r   r   r   r1   r2   r3   r4   tes           r   r   zPlotMethods.textedge   sa    jll__S_11RB 	 	AIIqtQqTl###IIqtQqTl###LL!1Q41,!qtQqTAaD[PVWWW    	CGGbL#b''B,///
CGGbL#b''B,///" 	2 	2BGGRT24L25"%.1111
r   c                 ~   |j         \  }}t          j                    }|                    dd          }g }g }|                                D ]C}||         D ]8}	|                    |	d                    |                    |	d                    9D|                    ||d           |                    |           |S )zGenerates a plot for all line intersections present
        on the PDF page.

        Parameters
        ----------
        table : camelot.core.Table

        Returns
        -------
        fig : matplotlib.fig.Figure

        r   r   r   r   r"   ro)rI   r%   r&   r'   rL   appendr8   rM   )
r   r   rN   rO   r   r1   x_coordy_coordkcoords
             r   r   zPlotMethods.joint   s      ,Zjll__S_11"" 	) 	)A#A ) )uQx(((uQx(((() 	$'''
		#
r   c                 J   t          j                    }|                    dd          }|j        \  }}|D ]4}|                    |d         |d         g|d         |d         g           5|D ]4}|                    |d         |d         g|d         |d         g           5|S )zGenerates a plot for all line segments present
        on the PDF page.

        Parameters
        ----------
        table : camelot.core.Table

        Returns
        -------
        fig : matplotlib.fig.Figure

        r   r   r   r   r!   r"   r#   )r%   r&   r'   	_segmentsr8   )r   r   r   r1   vertical
horizontalvhs           r   r   zPlotMethods.line   s     jll__S_11$* 	0 	0AGGQqT1Q4L1Q41,//// 	0 	0AGGQqT1Q4L1Q41,////
r   )r   N)
__name__
__module____qualname__r   r   rB   rQ   r   r   r    r   r   r   r      s        # # # #J  0  6/ / /b  :  4    r   r   )	matplotlib.pyplotpyplotr%   matplotlib.patchesr+   r   r   objectr   rh   r   r   <module>rm      s   ######(((((( HH    HHHU U U U U& U U U U Us    