improve showBoundary usage
authorrobin <robin@reportlab.com>
Thu, 04 Apr 2019 12:54:54 +0100
changeset 4493 ed067f3c4678
parent 4492 c0721260ecc1
child 4494 7850f3baf921
improve showBoundary usage
src/reportlab/graphics/renderbase.py
src/reportlab/graphics/shapes.py
src/reportlab/pdfgen/pdfimages.py
src/reportlab/platypus/figures.py
--- a/src/reportlab/graphics/renderbase.py	Thu Apr 04 12:54:19 2019 +0100
+++ b/src/reportlab/graphics/renderbase.py	Thu Apr 04 12:54:54 2019 +0100
@@ -195,7 +195,11 @@
         drawing._parent = None
         try:
             #bounding box
-            if showBoundary: canvas.rect(x, y, drawing.width, drawing.height)
+            if showBoundary:
+                if hasattr(canvas,'drawBoundary'):
+                    canvas.drawBoundary(showBoundary,x,y,drawing.width,drawing.height)
+                else:
+                    canvas.rect(x, y, drawing.width, drawing.height)
             canvas.saveState()
             self.initState(x,y)  #this is the push()
             self.drawNode(drawing)
--- a/src/reportlab/graphics/shapes.py	Thu Apr 04 12:54:19 2019 +0100
+++ b/src/reportlab/graphics/shapes.py	Thu Apr 04 12:54:54 2019 +0100
@@ -695,7 +695,8 @@
         draw itself in a story.  It is specific to PDF and should not
         be used directly."""
         from reportlab.graphics import renderPDF
-        renderPDF.draw(self, self.canv, 0, 0, showBoundary=showBoundary)
+        renderPDF.draw(self, self.canv, 0, 0,
+                showBoundary=showBoundary if showBoundary is not _unset_ else getattr(self,'_showBoundary',_unset_))
 
     def wrap(self, availWidth, availHeight):
         width = self.width
--- a/src/reportlab/pdfgen/pdfimages.py	Thu Apr 04 12:54:19 2019 +0100
+++ b/src/reportlab/pdfgen/pdfimages.py	Thu Apr 04 12:54:54 2019 +0100
@@ -186,7 +186,7 @@
             canvas._code.append(line)
         canvas._code.append('Q')
         if showBoundary:
-            canvas.rect(x,y,width,height,stroke=1,fill=0)
+            canvas.drawBoundary(showBoundary,x,y,width,height)
         return True
 
     def format(self, document):
--- a/src/reportlab/platypus/figures.py	Thu Apr 04 12:54:19 2019 +0100
+++ b/src/reportlab/platypus/figures.py	Thu Apr 04 12:54:54 2019 +0100
@@ -122,20 +122,7 @@
             self.drawCaption()
 
     def drawBorder(self):
-        canv = self.canv
-        border = self.border
-        bc = getattr(border,'color',None)
-        bw = getattr(border,'width',None)
-        bd = getattr(border,'dashArray',None)
-        ss = bc or bw or bd
-        if ss:
-            canv.saveState()
-            if bc: canv.setStrokeColor(bc)
-            if bw: canv.setLineWidth(bw)
-            if bd: canv.setDash(bd)
-        canv.rect(0, 0, self.width, self.figureHeight,fill=0,stroke=1)
-        if ss:
-            canv.restoreState()
+        self.canv.drawBoundary(self.border,0,0,self.width, self.figureHeight)
 
     def _doBackground(self, color):
         self.canv.saveState()