Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 NebÐcã@s0dZdZddlmZddlmZddlmZddlTddl Tddl m Z Gdd „d ƒZ Gd d „d e ejƒZGd d „d eƒZiZGdd„dƒZGdd„de ƒZdd„Zdd„ZGdd„de ƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGd d!„d!e ƒZd"d#„Zd$d%„Zed&k�r,eƒd'S)(z3.3.0z-Base class for user-defined graphical widgetsé)Úshapes)Ú rl_config)Úcolors)Ú*)Úrefc@sFeZdZdZdZdd„Zejr&dd„Zddd „Z d d „Z dd d„Z dS)Ú PropHolderzBase for property holdersNcCs°|jdk r¬x<|jjƒD].}|ddkrd||f}||jkst|ƒ‚qWxb|jjƒD]T\}}d||f}t||ƒszt|ƒ‚t||ƒ}|||jjf}|j |ƒsTtd|ƒ‚qTWdS)a0If the _attrMap attribute is not None, this checks all expected attributes are present; no unwanted attributes are present; and (if a checking function is found) checks each attribute has a valid value. Either succeeds or raises an informative exception. NrÚ_z#Unexpected attribute %s found in %szMissing attribute %s from %sz-Invalid value %s for attribute %s in class %s) Ú_attrMapÚ__dict__ÚkeysÚAssertionErrorÚitemsÚhasattrÚgetattrÚ __class__Ú__name__Úvalidate)ÚselfÚkeyÚmsgÚattrZ metavalueÚvalueÚargs©rú>/tmp/tmp4i9tl1d3/lib64/python/reportlab/graphics/widgetbase.pyÚverifys     zPropHolder.verifycCst|||ƒdS)zSBy default we verify. This could be off in some parallel base classes.N)ÚvalidateSetattr)rÚnamerrrrÚ __setattr__.szPropHolder.__setattr__éc Cs¨ddlm}i}x’|jjƒD]„}|dd…dkrt||ƒ}|r˜||ƒr˜|j|d�}xL|jƒD]6\}}|ddkr‚||d||f<q\||d||f<q\Wq|||<qW|S) aJReturns a list of all properties which can be edited and which are not marked as private. This may include 'child widgets' or 'primitive shapes'. You are free to override this and provide alternative implementations; the default one simply returns everything without a leading underscore. r)Ú isValidChildrr)Úrecurú[z%s%sz%s.%s)Úreportlab.lib.validatorsr r r rÚ getPropertiesr ) rr!r ÚpropsrZ componentÚ childPropsZchildKeyZ childValuerrrr$4s      zPropHolder.getPropertiesc Cs¨i}xt|jƒD]h\}}|jddƒ}t|ƒdkr)rrrrÚ provideNode–szWidget.provideNodecCs |jƒjƒS)zGReturn outer boundary as x1,y1,x2,y2. Can be overridden for efficiency)r>Ú getBounds)rrrrrA™szWidget.getBoundsN) rr5r6r7r<r>r?r@rArrrrr8„s r8c@sReZdZdZeeedd�eedd�eedd�eddd�d�Zdd d „Zd d„Z dS)Ú ScaleWidgetz Contents with a scale and offsetzx offset)Údesczy offsetÚscaleNzContained drawable elements)ÚxÚyrDÚcontentsrçð?cCs>||_||_|sg}nt|ttfƒs*|f}t|ƒ|_||_dS)N)rErFÚ isinstanceÚtupler0rGrD)rrErFrDrGrrrÚ__init__¥s zScaleWidget.__init__c Cs&tj|jd|jdd|j|j|jfiŽS)NÚ transformr)rÚGrouprGrDrErF)rrrrr>®szScaleWidget.draw)rrrHN) rr5r6r7ÚAttrMapÚ AttrMapValueÚisNumberr rKr>rrrrrB�s    rBc@seZdZdd„ZdS)Ú CloneMixincKs4|jƒ}|jjƒ|jj|jƒ|r0|jj|ƒ|S)N)rr ÚclearÚupdate)rÚkwdsÚnrrrÚclone´s   zCloneMixin.cloneN)rr5r6rVrrrrrQ³srQc@sleZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z ddd„Z dd„Z dd„Z dd„Z ddd„ZdS)ÚTypedPropertyCollectiona€A container with properties for objects of the same kind. This makes it easy to create lists of objects. You initialize it with a class of what it is to contain, and that is all you can add to it. You can assign properties to the collection as a whole, or to a numeric index within it; if so it creates a new child object to hold that data. So: wedges = TypedPropertyCollection(WedgeProperties) wedges.strokeWidth = 2 # applies to all wedges.strokeColor = colors.red # applies to all wedges[3].strokeColor = colors.blue # only to one The last line should be taken as a prescription of how to create wedge no. 3 if one is needed; no error is raised if there are only two data points. We try and make sensible use of tuple indices. line[(3,x)] is backed by line[(3,)] == line[3] & line cKs|f|Ž|jd<i|jd<dS)NÚ_valueÚ _children)r )rZ exampleClassrTrrrrKÒsz TypedPropertyCollection.__init__cCsGdd„d|tƒ}|S)Nc@s eZdZdd„Zedd„ƒZdS)z5TypedPropertyCollection.wKlassFactory..WKlassc Sshy|jjdj||ƒS|j}|j}|j}x*|rX||krJt|||ƒS|dd…}q0Wt||ƒSdS)Nrréÿÿÿÿ)rÚ __bases__Ú __getattr__ÚparentrYÚ__propholder_index__r)rrr]ÚcrErrrr\ÙszATypedPropertyCollection.wKlassFactory..WKlass.__getattr__cSs|jƒS)N)Ú__propholder_parent__)rrrrr]åsz.WKlass.parentN)rr5r6r\Úpropertyr]rrrrÚWKlassØs rb)rQ)rÚKlassrbrrrÚ wKlassFactory×sz%TypedPropertyCollection.wKlassFactoryc CsÔt|ttfƒrt|ƒn|f}y |j|Stk rÎ|jj}|tkrPt|}n|j|ƒt|<}|ƒ}x6t t|j j ƒƒfdd„t|j j ƒƒƒD] }|j |=q�W|j j tt|ƒ|dd…d�ƒ||j|<|SXdS)NcSs||kS)Nr)rEÚKrrrÚ÷sz5TypedPropertyCollection.__getitem__..r)r`r^rZ)rIrJr0rYr+rXrÚ _ItemWrapperrdÚfilterr r r rSÚdictÚ weakref_ref)rrErcrbr.ÚirrrÚ __getitem__ês   ,  z#TypedPropertyCollection.__getitem__cCs"t|ttfƒrt|ƒn|f|jkS)N)rIrJr0rY)rrrrrÚ __contains__sz$TypedPropertyCollection.__contains__cCs$t||jjƒs td|jjjƒ‚dS)Nz0This collection can only hold objects of type %s)rIrXrr r)rrrrrrÚ __setitem__sz#TypedPropertyCollection.__setitem__cCstt|jjƒƒƒS)N)r)r0rYr )rrrrÚ__len__szTypedPropertyCollection.__len__rcCs²i}x*|jj|d�jƒD]\}}||d|<qWx||jjƒD]n}|j|j|d�}xV|jƒD]J\}}t||ƒ s~t||ƒ|kr\dt|ƒdkr�|n|d|f}|||<q\WqgszTwoCircles.drawN)rr5r6rKr>rrrrr„bsr„c @s\eZdZdZeeeƒeeƒeeƒeeƒeeƒeedddƒƒd�Z dd„Z dd „Z d d „Z d S) ÚFacez�This draws a face with two eyes. It exposes a couple of properties to configure itself and hides all other details. ÚhappyÚsadÚok)rErFÚsizeÚ skinColorÚeyeColorÚmoodcCs*d|_d|_d|_d|_tj|_d|_dS)Né éPrŒ)rErFr�r�rÚbluer‘r’)rrrrrK{s z Face.__init__cCsdS)Nr)rrrrr?ƒsz Face.democ Csž|j}tjƒ}dddd|j|jg|_|jtj|d|d|d|jd�ƒ|jtj|d|d|dt j d�ƒ|jtj|d|d|d|j d�ƒ|jtj|d|d|dt j d�ƒ|jtj|d|d|d|j d�ƒ|jtj |d|d |d |d |d |d gdd �ƒ|j d k�r,d}n|j dk�r>d}nd}|jtj |d |d|d|d|d |d||d |d|gt jt j|dd�ƒ|S)Nrrgà?)rgffffffÖ?gÍÌÌÌÌÌä?gš™™™™™¹?çš™™™™™©?g333333ã?gš™™™™™Ù?g333333Ó?)ÚpointsrrŒr�gš™™™™™É?gffffffæ?g¸…ëQ¸ž?)r—rr~r|gš™™™™™©¿r–)r�rrMrErFrLÚaddr‡r�rÚwhiter‘ZPolygonr’Zpinkrˆ)rÚsÚgÚoffsetrrrr>†s2&&&&&&     z Face.drawN) rr5r6r7rNrOrPr‚ÚOneOfr rKr?r>rrrrr‹ksr‹c@s$eZdZdd„Zdd„Zdd„ZdS)ÚTwoFacescCs,tƒ|_d|j_tƒ|_d|j_d|j_dS)NrŒr…r�)r‹ÚfaceOner’ÚfaceTworE)rrrrrK³s zTwoFaces.__init__cCstj|j|jƒS)zJust return a group)rrMrŸr )rrrrr>ºsz TwoFaces.drawcCsdS)zQThe default case already looks good enough, no implementation needed hereNr)rrrrr?¾sz TwoFaces.demoN)rr5r6rKr>r?rrrrrž²sržc@sPeZdZdZeejeedd�d�Z dd„Z dd„Z dd d „Z d d „Z dd„Zd S)ÚSizerz.Container to show size of all enclosed objectszContained drawable elements)rC)ZBASErGcGs2g|_tj|_tj|_x|D]}|j|ƒqWdS)N)rGrZcyanrZmagentar~r˜)rÚelementsÚelemrrrrKÉs  zSizer.__init__cCs4|r0|t|jjƒƒkr$ttƒ|j|<t|||ƒdS)zLif name is not None add an attribute pointing to node and add to the attrMapN)r0r r rOr r*)rrÚnoderrrÚ _addNamedNodeÑszSizer._addNamedNodeNcCs4|dk r0t|ƒstdƒ‚|jj|ƒ|j||ƒdS)z“Appends non-None child node to the 'contents' attribute. In addition, if a name is provided, it is subsequently accessible by name Nz1Can only add Shape or UserNode objects to a Group)r r rGÚappendr¥)rr¤rrrrr˜Øs z Sizer.addcCs:|jr2g}x|jD]}|j|jƒƒqWtj|ƒSdSdS)Nr)rrrr)rGr¦rArZgetRectsBounds)rÚbr£rrrrAâs   zSizer.getBoundscCsbtjƒ}|jƒ\}}}}tj|||||||j|jd�}|j|ƒx|jD]}|j|ƒqLW|S)N)rErFÚwidthÚheightrr~)rrMrAÚRectrr~r˜rG)rr›Úx1Úy1Zx2Úy2Úrr£rrrr>ìs   z Sizer.draw)N)rr5r6r7rNrZ SolidShaperOZisListOfShapesr rKr¥r˜rAr>rrrrr¡Ãs  r¡c@seZdZeeedd�eedd�eedd�eeddd�eeddd�eed dd�eed dd�eed d�ee eƒd d�ee eƒd d�ee eƒdd�eeddd�eeddd�eeddd�ee ddd�eeddd�edddd�ee ddƒddd�ee e dddd�ddd�d�Zdd„Zdd „ZdS)!ÚCandleStickPropertieszWidth of a line.)rCzColor of a line or border.zDash array of a line.zcross line widthr)rCr{zcross line low valuezcross line high valuezwidth of the box partzfill color of boxzstroke color of boxzDash array of the box.zWidth of the box lines.zlow value of the boxzmiddle box line valuezhigh value of the boxzwhether to show box sideszposition of the candleNz our chartÚverticalZ horizontalzcandle directionré)ZemptyOKÚloÚhi)r|r~r}Ú crossWidthÚcrossLoÚcrossHiÚboxWidthÚ boxFillColorÚboxStrokeColorÚboxStrokeDashArrayÚboxStrokeWidthÚboxLoÚboxMidÚboxHiÚboxSidesÚpositionÚchartÚ candleKindÚaxescKs0|jddƒ|_|jdtjƒ|_|jddƒ|_|jddƒ|_|jddƒ|_|jddƒ|_|jd dƒ|_ |jd dƒ|_ |jd t j ƒ|_ |jd t j ƒ|_|jd t j ƒ|_|jddƒ|_|jddƒ|_|jddƒ|_|jddƒ|_|jddƒ|_|jddƒ|_|jdddgƒ|_|jddƒ}|�r"t|ƒndd„|_dS)Nr|rr~r}r´érµr¶r·r¸r¹r»rºr¼r½r¾r¿TrÀrÂr°rÃZ categoryAxisZ valueAxisrÁcSsdS)Nrrrrrrf'sz0CandleStickProperties.__init__..)Úpopr|rZblackr~r}r´rµr¶r·r¸ÚNotSetOrZ_not_setr¹r»rºr¼r½r¾r¿rÀrÂrÃrjrÁ)rrTrÁrrrrKs( zCandleStickProperties.__init__c s4|jƒ}t||jdƒ}t|ddƒ‰ˆs2t|dƒ‰‡fdd„}t||jdƒ}t|ddƒ‰ˆsht|dƒ‰‡fdd„} tjƒj‰|j‰|j‰|j‰|j } | |j ƒ} | |j ƒ} |j } |j }tj|jˆƒ}tj|jˆƒ}tj|jˆƒ}| |jƒ}| |jƒ}| |jƒ}||jƒ}|j‰d| ||fk}d| | fk}‡‡‡‡‡fd d „}|�rXt||ƒt||ƒ}}|�rXt| | ƒt| | ƒ} } | �s�| |k�s�| |k�ræ||| || ƒ| dk �rX||| d | || d | ƒ||| d | || d | ƒnr|�rX| |k�r"||| ||ƒ||| d | || d | ƒ| |k�rX||||| ƒ||| d | || d | ƒ|�r.|| d }|}||}| }ˆd k�r˜||||f\}}}}ˆtj|||||j�r²|nd|||d �ƒ|j�s||d | ||d | |ƒ||d | ||d | |ƒ|dk �r.||d | ||d | |ƒˆjS)zthe symbol interfacerZmidScaleNrDcs|dk rˆ|ƒSdS)Nr)rE)Ú_xScalerrrf/sz0CandleStickProperties.__call__..rcs|dk rˆ|ƒSdS)Nr)rE)Ú_yScalerrrf3sc s<ˆdkr||}}||}}ˆtj||||ˆˆˆd�ƒdS)Nr°)r|r~r})rZLine)Zx0Zy0r«r¬)ÚGrÂr~r}r|rrÚaLineGs  z-CandleStickProperties.__call__..aLinegà?r°)r~r|r}r)rÁrrÃrrMr˜r|r~r}r´rµr¶r·r¸rÆZconditionalValuer¹r»rºr¼r½r¾rÀrÂÚminÚmaxrªr¿Ú__self__)rZ_xZ_yÚ_sizeZ_colorrÁZxAZxScaleZyAZyScaler´rµr¶r·r¸r¹r»rºr¼r½r¾rÀZhaveBoxZhaveLinerÊrErFÚhÚwr)rÉrÇrÈrÂr~r}r|rÚ__call__)sz                    * zCandleStickProperties.__call__)rr5r6rNrOrPr‚r�ZisNumberOrNonerÆZ isBooleanr�Z SequenceOfrƒr rKrÑrrrrr¯üs,              r¯cKs ttf|ŽS)N)rWr¯)rTrrrÚ CandleStickslsrÒcCsddlm}t|ƒ}tj|_|jtjtjtj fd�t t t ƒƒt jddƒ}tƒ}|j|ƒddlm}|j|ddƒt d ƒt jddƒ}tƒ}tj|_d |_|j|d d �t d ƒ|jƒ|j|ddƒt dƒ|jƒ}|j|ddƒt dƒt dƒ|jƒdS)Nr)ÚWedgeProperties)ri�éÈ)Ú renderPDFzsample_widget.pdfzA Sample Widgetzsaved sample_widget.pdfr�ZtheFace)rzdrawing 1 properties:zface.pdfzsaved face.pdfz face_copy.pdfzAn expanded drawingzsaved face_copy.pdfzdrawing 2 properties:)Z#reportlab.graphics.charts.piechartsrÓrWrrˆrrrr•Zgreenr™r2r)rgrZDrawingr„r˜Úreportlab.graphicsrÕZ drawToFiler‹Zyellowr�r’r4ZexpandUserNodes)rÓZwedgesÚdZtcrÕÚfZd2rrrÚtestos2      rÙÚ__main__N)Ú __version__r7rÖrÚ reportlabrZ reportlab.librr#Zreportlab.lib.attrmapÚweakrefrrjrZUserNoder8rBrgrQrWrwryrzr„r‹ržr¡r¯rÒrÙrrrrrÚs2    vn. G9p