Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 ta2@sdZdZddlTddlmZddlmZddlmZm Z dd Z Gd d d Z d d Z ddZ ddZGdddZedkredeedS)z3.3.0zXSuperclass for renderers to factor out common functionality and default implementations.)*) DerivedValue) rl_config)mmultinversecCs2i}x(|jjD]\}}|tkr|||<qW|S)zUsed to compute when we need to change the graphics state. For example, if we have two adjacent red shapes we don't need to set the pen color to red in between. Returns the effect the given shape would have on the graphics state)Z getPropertiesitemsSTATE_DEFAULTS)shapedeltapropvaluer>/tmp/tmp4i9tl1d3/lib64/python/reportlab/graphics/renderbase.py getStateDeltas  rc@sReZdZdZdddZddZddZd d Zd d Zd dZ ddZ ddZ dS) StateTrackera*Keeps a stack of transforms and state properties. It can contain any properties you want, but the keys 'transform' and 'ctm' have special meanings. The getCTM() method returns the current transformation matrix at any point, without needing to invert matrixes when you pop.NcCsg|_g|_|dkrtj}|rjxHtjD]<}d|ddj|dd}t||r*t||||<q*Wd|kr~|d|d<|jj|dS)Ninitialr transformctm) _deltas _combinedr copykeysupperhasattrgetattrappend)selfdefaults defaultObjkarrr__init__!s   zStateTracker.__init__cCs|S)Nr)rdrrr_applyDefaultObj5szStateTracker._applyDefaultObjcCsz|jdj}xN|jD]B\}}|dkrR|d|d<t|jdd|d|d<q|||<qW|jj||jj|dS)zTake a new state dictionary of changes and push it onto the stack. After doing this, the combined state is accessible through getState()rrrNr%)rrrrrr)rr newstatekeyr rrrpush8s   zStateTracker.pushcCst|jd=|jd}|jd}|jd=i}xF|jD]:\}}||}||kr2|dkrdt|d||<q2|||<q2W|S)zsteps back one, and returns a state dictionary with the deltas to reverse out of wherever you are. Depending on your back end, you may not need the return value, since you can get the complete state afterwards with getState()rrr%r%r%r%)rrrr)rnewStateZ lastDeltaZ reverseDeltar'ZcurValueZ prevValuerrrpopKs   zStateTracker.popcCs |jdS)z1returns the complete graphics state at this pointrr%)r)rrrrgetStatebszStateTracker.getStatecCs|jddS)z7returns the current transformation matrix at this pointrrr%)r)rrrrgetCTMfszStateTracker.getCTMcCs|jd|S)z>returns the complete graphics state value of key at this pointrr%)r)rr'rrr __getitem__jszStateTracker.__getitem__cCs||jd|<dS)z6sets the complete graphics state value of key to valuerNr%)r)rr'r rrr __setitem__nszStateTracker.__setitem__)NN) __name__ __module__ __qualname____doc__r"r$r(r*r+r,r-r.rrrrrs rc Cstddddddddddgd}ddlm}ddidd |d d d ddd ddgid d ddd d dgiddig}t|}td|jtx0|D](}td||j|td|jdqWx*|D]"}td|jtd|jdqWdS)NzTesting state trackerrr) fillColor strokeColorfontNamer)_baseGFontNamer3ZredZgreenZblue)r3r4r5rg?r4zinitial:zpushing:zstate:  zpopping:)printreportlab.graphics.shapesr6rr+r(r*)rr6deltasstr rrrtestStateTrackerrs$       r>c CsDt|tr@z*t|drd}n ||_d}|}|j}Wd|s>|`X|S)N_canvasr) isinstanceZUserNoderr?Z provideNode)nodecanvasocanvasZonoderrr_expandUserNodes   rDcCsL|j}|dkrH|}|j|j||j|}|jj|_|j||d|_|S)Ng?) renderScale __class__widthheight__dict__rZscale)r#rEorrrrenderScaledDrawings  rKc@seZdZdZddZddejfddZddZd d Z d d Z d dZ ddZ ddZ ddddddddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3S)4Rendererz*Virtual superclass for graphics renderers.cCstd||jfdS)Nz/%s operation not defined at superclass class=%s) ValueErrorrF)rZ operationrrr undefinedszRenderer.undefinedrc Cst|d|_|tjkrtj}||_||jd<|_d|_zl|rtt |dr`|j ||||j |j n|j |||j |j |j|j|||j||j|jWd|`|`|`|`|`XdS)zThis is the top level function, which draws the drawing at the given location. The recursive part is handled by drawNode.)r_drawingN drawBoundary)r_trackerr_unset_ showBoundaryr?rIrO_parentrrPrGrHrectZ saveState initStatedrawNoder*Z restoreState)rZdrawingrBxyrSrrrdraws"      z Renderer.drawcCsL|jjd}tt|ddd||f|d<|jj||j|idS)Nrrr%)rQrtuplelistr(applyStateChanges)rrXrYr<rrrrVs $ zRenderer.initStatecCs|jjdS)N)rQr*)rrrrr*sz Renderer.popcCs|jddS)zEThis is the recursive method called for each node in the treerWN)rN)rrArrrrWszRenderer.drawNodecCs|jjd}||S)z,Return current state parameter for given keyrr%)rQr)rr'Z currentStaterrr getStateValues zRenderer.getStateValuecCs<x6|jjD](\}}t|tr |j||}||j|<q WdS)zExamine a node for any values which are Derived, and replace them with their calculated values. Generally things may look at the drawing or their parent. N)rIrr@rZgetValue)rrAr'r ZnewValuerrrfillDerivedValuess  zRenderer.fillDerivedValuesc Cst|dd}zt||}|s"dSt|dr2d}n ||_d}|j|t|dd}|rd||||dt|tr||j|nt|tr|j |nt|t r|j |nt|t r|j |nt|tr|j|nt|tr|j|nt|tr|j|nt|tr|j|nrt|tr2|j|nZt|trJ|j|nBt|trb|j|n*t|trz|j|ntddt|Wd|s|`XdS)z1dispatch on the node's (super) class: shared coder?NrZ_drawTimeCallback)rBZrendererZ DrawingErrorz!Unexpected element %s in drawing!) rrDrr?r`r@ZLinedrawLineZImage drawImageZRectdrawRectZCircle drawCircleZEllipse drawEllipseZPolyLine drawPolyLineZPolygon drawPolygonPathdrawPathString drawStringGroup drawGroupZWedge drawWedgeZ DirectDrawZ drawDirectlyr:str)rrArBrCZdtcbrrrdrawNodeDispatchersP                            zRenderer.drawNodeDispatcherZ_strokeZ _lineWidthZ_lineCapZ _lineJoinZ_fillZ_fontZ _fontSize)ZstrokeZ stroke_widthZstroke_linecapZstroke_linejoinfillZ font_familyZ font_sizec Cszt|dd}xh|jD]\}t||}|s*q|j|z.t|drFd}n ||_d}||_|j|Wd|`|sp|`XqWdS)Nr?r)rZ getContentsrDr`rr?rTrW)rgrouprBrArCrrrrms     zRenderer.drawGroupcCs,|j}t|tr|j|n |j|dS)N)Z asPolygonr@rhrirg)rZwedgePrrrrn/s  zRenderer.drawWedgecCs$|j}x|D]}|j|qWdS)N)Z asPolygonsrg)rpathZpolygonsZpolygonrrrri8s zRenderer.drawPathcCs|jddS)Nrc)rN)rrUrrrrc=szRenderer.drawRectcCs|jddS)Nra)rN)rlinerrrraAszRenderer.drawLinecCs|jddS)Nrd)rN)rZcirclerrrrdDszRenderer.drawCirclecCs|jddS)Nrf)rN)rprrrrfGszRenderer.drawPolyLinecCs|jddS)Nre)rN)rZellipserrrreJszRenderer.drawEllipsecCs|jddS)Nrg)rN)rrvrrrrgMszRenderer.drawPolygoncCs|jddS)Nrk)rN)rZ stringObjrrrrkPszRenderer.drawStringcCs|jddS)z\This takes a set of states, and outputs the operators needed to set those propertiesr^N)rN)rr r)rrrr^SszRenderer.applyStateChangescOs tddS)Nrb)NotImplementedError)rargskwdsrrrrbXszRenderer.drawImageN)r/r0r1r2rNrrRrZrVr*rWr_r`rpZ _restoresrmrnrircrardrfrergrkr^rbrrrrrLs01 rL__main__z&this file has no script interpretationN) __version__r2r;Zreportlab.lib.validatorsr reportlabrrrrrrr>rDrKrLr/r:rrrrs   Y :