Beispiel #1
0
 def __init__(self, width=400, height=200, *args, **kw):
     Drawing.__init__(self, width, height, *args, **kw)
     smallFontSize = float(os.environ.get('smallFontSize', '40'))
     self._add(self,
               String(65,
                      10,
                      'text0',
                      fontSize=80,
                      fontName='Helvetica',
                      fillColor=toColor('blue'),
                      strokeColor=toColor('red'),
                      strokeWidth=1.5,
                      textRenderMode=0),
               name='S0',
               validate=None,
               desc=None)
     self._add(self,
               String(405,
                      20,
                      'text1',
                      fontSize=80,
                      fontName='Helvetica',
                      fillColor=toColor('blue'),
                      strokeColor=toColor('red'),
                      strokeWidth=1.5,
                      textRenderMode=1,
                      textAnchor='end'),
               name='S1',
               validate=None,
               desc=None)
     self._add(self,
               String(190,
                      90,
                      'text2',
                      fontSize=80,
                      fontName='Helvetica',
                      fillColor=toColor('blue'),
                      strokeColor=toColor('red'),
                      strokeWidth=1.5,
                      textRenderMode=2),
               name='S2',
               validate=None,
               desc=None)
     self._add(self,
               String(240,
                      150,
                      'text3',
                      fontSize=smallFontSize,
                      fontName='Helvetica',
                      fillColor=toColor('green'),
                      strokeColor=toColor('magenta'),
                      strokeWidth=0.5,
                      textRenderMode=2),
               name='S3',
               validate=None,
               desc=None)
     self._add(self,
               String(140,
                      150,
                      'text4',
                      fontSize=smallFontSize,
                      fontName='Helvetica',
                      fillColor=toColor('green'),
                      strokeColor=toColor('magenta'),
                      strokeWidth=0.5,
                      textRenderMode=1),
               name='S4',
               validate=None,
               desc=None)
     self._add(self,
               String(70,
                      120,
                      'text5',
                      fontSize=smallFontSize,
                      fontName='Helvetica',
                      fillColor=toColor('green'),
                      strokeColor=toColor('magenta'),
                      strokeWidth=0.5,
                      textRenderMode=0),
               name='S5',
               validate=None,
               desc=None)
     self._add(self,
               Line(40,
                    40,
                    70,
                    70,
                    strokeWidth=0.5,
                    strokeColor=toColor('green')),
               name='L0',
               validate=None,
               desc=None)
     self._add(self,
               definePath([('moveTo', 80, 80), ('lineTo', 110, 110),
                           ('lineTo', 80, 110), 'closePath'],
                          fillColor=None,
                          strokeWidth=2,
                          strokeColor=toColor('yellow')),
               name='P0',
               validate=None,
               desc=None)
 def __init__(self, width=400, height=200, *args, **kw):
     Drawing.__init__(self, width, height, *args, **kw)
     self.transform = (1, 0, 0, 1, 0, 0)
     self.add(
         Rect(230,
              53.42857,
              24,
              6.857143,
              rx=0,
              ry=0,
              fillColor=Color(1, 0, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(230,
              77.42857,
              -57,
              6.857143,
              rx=0,
              ry=0,
              fillColor=Color(1, 0, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(230,
              101.4286,
              20,
              6.857143,
              rx=0,
              ry=0,
              fillColor=Color(1, 0, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(230,
              125.4286,
              50,
              6.857143,
              rx=0,
              ry=0,
              fillColor=Color(1, 0, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(230,
              149.4286,
              92,
              6.857143,
              rx=0,
              ry=0,
              fillColor=Color(1, 0, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(230,
              63.71429,
              6,
              6.857143,
              rx=0,
              ry=0,
              fillColor=Color(0, .501961, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(230,
              87.71429,
              -49,
              6.857143,
              rx=0,
              ry=0,
              fillColor=Color(0, .501961, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(230,
              111.7143,
              -30,
              6.857143,
              rx=0,
              ry=0,
              fillColor=Color(0, .501961, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(230,
              135.7143,
              40,
              6.857143,
              rx=0,
              ry=0,
              fillColor=Color(0, .501961, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(230,
              159.7143,
              68,
              6.857143,
              rx=0,
              ry=0,
              fillColor=Color(0, .501961, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(79,
              50,
              79,
              170,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(79,
              50,
              74,
              50,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(79,
              74,
              74,
              74,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(79,
              98,
              74,
              98,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(79,
              122,
              74,
              122,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(79,
              146,
              74,
              146,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(79,
              170,
              74,
              170,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, -71, 62)
     v0.add(
         String(-30.688,
                -3.2,
                'Q3 2000',
                textAnchor='start',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, -71, 86)
     v0.add(
         String(-44.912,
                -3.2,
                'Year to Date',
                textAnchor='start',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, -71, 110)
     v0.add(
         String(-37.352,
                -3.2,
                '12 months',
                textAnchor='start',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, -71, 134)
     v0.add(
         String(-39.576,
                1.6,
                'Annualised',
                textAnchor='start',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0.add(
         String(-39.576,
                -8,
                '3 years',
                textAnchor='start',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, -71, 158)
     v0.add(
         String(-53.368,
                -3.2,
                'Since 07.10.99',
                textAnchor='start',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         Line(80,
              50,
              380,
              50,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(80,
              50,
              80,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(130,
              50,
              130,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(180,
              50,
              180,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(230,
              50,
              230,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(280,
              50,
              280,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(330,
              50,
              330,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(380,
              50,
              380,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 80, 45)
     v0.add(
         String(0,
                -8,
                '-15',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 130, 45)
     v0.add(
         String(0,
                -8,
                '-10',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 180, 45)
     v0.add(
         String(0,
                -8,
                '-5',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 230, 45)
     v0.add(
         String(0,
                -8,
                '0',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 280, 45)
     v0.add(
         String(0,
                -8,
                '5',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 330, 45)
     v0.add(
         String(0,
                -8,
                '10',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 380, 45)
     v0.add(
         String(0,
                -8,
                '15',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
Beispiel #3
0
    def _Flag_Brazil(self):
        s = _size  # abbreviate as we will use this a lot
        g = Group()

        m = s / 14
        self._width = w = (m * 20)

        def addStar(x, y, size, g=g, w=w, s=s, m=m):
            st = Star()
            st.fillColor = colors.mintcream
            st.size = size * m
            st.x = (w / 2) + (x * (0.35 * m))
            st.y = (s / 2) + (y * (0.35 * m))
            g.add(st)

        g.add(
            Rect(0,
                 0,
                 w,
                 s,
                 fillColor=colors.green,
                 strokeColor=None,
                 strokeWidth=0))
        g.add(
            Polygon(points=[
                1.7 * m, (s / 2), (w / 2), s - (1.7 * m), w - (1.7 * m),
                (s / 2), (w / 2), 1.7 * m
            ],
                    fillColor=colors.yellow,
                    strokeColor=None,
                    strokeWidth=0))
        g.add(
            Circle(cx=w / 2,
                   cy=s / 2,
                   r=3.5 * m,
                   fillColor=colors.blue,
                   strokeColor=None,
                   strokeWidth=0))
        g.add(
            Wedge((w / 2) - (2 * m),
                  0,
                  8.5 * m,
                  50,
                  98.1,
                  8.5 * m,
                  fillColor=colors.mintcream,
                  strokeColor=None,
                  strokeWidth=0))
        g.add(
            Wedge((w / 2), (s / 2),
                  3.501 * m,
                  156,
                  352,
                  3.501 * m,
                  fillColor=colors.mintcream,
                  strokeColor=None,
                  strokeWidth=0))
        g.add(
            Wedge((w / 2) - (2 * m),
                  0,
                  8 * m,
                  48.1,
                  100,
                  8 * m,
                  fillColor=colors.blue,
                  strokeColor=None,
                  strokeWidth=0))
        g.add(
            Rect(0,
                 0,
                 w, (s / 4) + 1.7 * m,
                 fillColor=colors.green,
                 strokeColor=None,
                 strokeWidth=0))
        g.add(
            Polygon(points=[
                1.7 * m, (s / 2), (w / 2), s / 2 - 2 * m, w - (1.7 * m),
                (s / 2), (w / 2), 1.7 * m
            ],
                    fillColor=colors.yellow,
                    strokeColor=None,
                    strokeWidth=0))
        g.add(
            Wedge(w / 2,
                  s / 2,
                  3.502 * m,
                  166,
                  342.1,
                  3.502 * m,
                  fillColor=colors.blue,
                  strokeColor=None,
                  strokeWidth=0))

        addStar(3.2, 3.5, 0.3)
        addStar(-8.5, 1.5, 0.3)
        addStar(-7.5, -3, 0.3)
        addStar(-4, -5.5, 0.3)
        addStar(0, -4.5, 0.3)
        addStar(7, -3.5, 0.3)
        addStar(-3.5, -0.5, 0.25)
        addStar(0, -1.5, 0.25)
        addStar(1, -2.5, 0.25)
        addStar(3, -7, 0.25)
        addStar(5, -6.5, 0.25)
        addStar(6.5, -5, 0.25)
        addStar(7, -4.5, 0.25)
        addStar(-5.5, -3.2, 0.25)
        addStar(-6, -4.2, 0.25)
        addStar(-1, -2.75, 0.2)
        addStar(2, -5.5, 0.2)
        addStar(4, -5.5, 0.2)
        addStar(5, -7.5, 0.2)
        addStar(5, -5.5, 0.2)
        addStar(6, -5.5, 0.2)
        addStar(-8.8, -3.2, 0.2)
        addStar(2.5, 0.5, 0.2)
        addStar(-0.2, -3.2, 0.14)
        addStar(-7.2, -2, 0.14)
        addStar(0, -8, 0.1)

        sTmp = "ORDEM E PROGRESSO"
        nTmp = len(sTmp)
        delta = 0.850848010347 / nTmp
        radius = 7.9 * m
        centerx = (w / 2) - (2 * m)
        centery = 0
        for i in range(nTmp):
            rad = 2 * pi - i * delta - 4.60766922527
            x = cos(rad) * radius + centerx
            y = sin(rad) * radius + centery
            if i == 6:
                z = 0.35 * m
            else:
                z = 0.45 * m
            g2 = Group(
                String(x,
                       y,
                       sTmp[i],
                       fontName='Helvetica-Bold',
                       fontSize=z,
                       strokeColor=None,
                       fillColor=colors.green))
            g2.rotate(rad)
            g.add(g2)
        return g
 def __init__(self, width=400, height=200, *args, **kw):
     Drawing.__init__(self, width, height, *args, **kw)
     self.transform = (1, 0, 0, 1, 0, 0)
     self.add(
         Rect(50,
              50,
              300,
              125,
              rx=0,
              ry=0,
              fillColor=None,
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(58.33333,
              50,
              33.33333,
              20.83333,
              rx=0,
              ry=0,
              fillColor=Color(1, 0, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(208.3333,
              50,
              33.33333,
              125,
              rx=0,
              ry=0,
              fillColor=Color(1, 0, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(91.66667,
              50,
              33.33333,
              41.66667,
              rx=0,
              ry=0,
              fillColor=Color(0, .501961, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(241.6667,
              50,
              33.33333,
              104.1667,
              rx=0,
              ry=0,
              fillColor=Color(0, .501961, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(125,
              50,
              33.33333,
              62.5,
              rx=0,
              ry=0,
              fillColor=Color(0, 0, 1, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(275,
              50,
              33.33333,
              83.33333,
              rx=0,
              ry=0,
              fillColor=Color(0, 0, 1, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(158.3333,
              50,
              33.33333,
              83.33333,
              rx=0,
              ry=0,
              fillColor=Color(1, 0, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(308.3333,
              50,
              33.33333,
              62.5,
              rx=0,
              ry=0,
              fillColor=Color(1, 0, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              49,
              350,
              49,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              49,
              50,
              44,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(200,
              49,
              200,
              44,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(350,
              49,
              350,
              44,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 125, 44)
     v0.add(
         String(-10,
                -10,
                'Ying',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 275, 44)
     v0.add(
         String(-10.83,
                -10,
                'Yang',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         Line(50,
              50,
              50,
              175,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              50,
              45,
              50,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              81.25,
              45,
              81.25,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              112.5,
              45,
              112.5,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              143.75,
              45,
              143.75,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              175,
              45,
              175,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 50)
     v0.add(
         String(-5,
                -4,
                '0',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 81.25)
     v0.add(
         String(-10,
                -4,
                '15',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 112.5)
     v0.add(
         String(-10,
                -4,
                '30',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 143.75)
     v0.add(
         String(-10,
                -4,
                '45',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 175)
     v0.add(
         String(-10,
                -4,
                '60',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
Beispiel #5
0
    def draw(self):
        colorNamePairs = self.colorNamePairs
        autoCP = isAuto(colorNamePairs)
        if autoCP:
            chart = getattr(colorNamePairs, 'chart',
                            getattr(colorNamePairs, 'obj', None))
            swatchMarker = None
            autoCP = Auto(obj=chart)
            n = chart._seriesCount
            chartTexts = self._getTexts(colorNamePairs)
        else:
            swatchMarker = getattr(self, 'swatchMarker', None)
            if isAuto(swatchMarker):
                chart = getattr(swatchMarker, 'chart',
                                getattr(swatchMarker, 'obj', None))
                swatchMarker = Auto(obj=chart)
            n = len(colorNamePairs)
        dx = self.dx
        dy = self.dy
        alignment = self.alignment
        columnMaximum = self.columnMaximum
        deltax = self.deltax
        deltay = self.deltay
        dxTextSpace = self.dxTextSpace
        fontName = self.fontName
        fontSize = self.fontSize
        fillColor = self.fillColor
        strokeWidth = self.strokeWidth
        strokeColor = self.strokeColor
        subCols = self.subCols
        leading = fontSize * 1.2
        yGap = self.yGap
        if not deltay:
            deltay = max(dy, leading) + self.autoYPadding
        ba = self.boxAnchor
        maxWidth = self._calculateMaxBoundaries(colorNamePairs)
        nCols = int((n + columnMaximum - 1) / columnMaximum)
        xW = dx + dxTextSpace + self.autoXPadding
        variColumn = self.variColumn
        if variColumn:
            width = reduce(operator.add, [m[-1]
                                          for m in maxWidth], 0) + xW * nCols
        else:
            deltax = max(maxWidth[-1] + xW, deltax)
            width = maxWidth[-1] + nCols * deltax
            maxWidth = nCols * [maxWidth]

        thisx = self.x
        thisy = self.y - self.dy
        if ba not in ('ne', 'n', 'nw', 'autoy'):
            height = self._calcHeight()
            if ba in ('e', 'c', 'w'):
                thisy += height / 2.
            else:
                thisy += height
        if ba not in ('nw', 'w', 'sw', 'autox'):
            if ba in ('n', 'c', 's'):
                thisx -= width / 2
            else:
                thisx -= width
        upperlefty = thisy

        g = Group()

        ascent = getFont(fontName).face.ascent / 1000.
        if ascent == 0: ascent = 0.718  # default (from helvetica)
        ascent *= fontSize  # normalize

        lim = columnMaximum - 1
        callout = getattr(self, 'callout', None)
        scallout = getattr(self, 'swatchCallout', None)
        dividerLines = self.dividerLines
        if dividerLines:
            dividerWidth = self.dividerWidth
            dividerColor = self.dividerColor
            dividerDashArray = self.dividerDashArray
            dividerOffsX = self.dividerOffsX
            dividerOffsY = self.dividerOffsY

        for i in xrange(n):
            if autoCP:
                col = autoCP
                col.index = i
                name = chartTexts[i]
            else:
                col, name = colorNamePairs[i]
                if isAuto(swatchMarker):
                    col = swatchMarker
                    col.index = i
                if isAuto(name):
                    name = getattr(swatchMarker, 'chart',
                                   getattr(swatchMarker, 'obj',
                                           None)).getSeriesName(
                                               i, 'series %d' % i)
            T = _getLines(name)
            S = []
            aS = S.append
            j = int(i / columnMaximum)
            jOffs = maxWidth[j]

            # thisy+dy/2 = y+leading/2
            y = y0 = thisy + (dy - ascent) * 0.5

            if callout: callout(self, g, thisx, y, (col, name))
            if alignment == "left":
                x = thisx
                xn = thisx + jOffs[-1] + dxTextSpace
            elif alignment == "right":
                x = thisx + dx + dxTextSpace
                xn = thisx
            else:
                raise ValueError, "bad alignment"
            if not isSeqType(name):
                T = [T]
            yd = y
            for k, lines in enumerate(T):
                y = y0
                kk = k * 2
                x1 = x + jOffs[kk]
                x2 = x + jOffs[kk + 1]
                sc = subCols[k, i]
                anchor = sc.align
                fN = getattr(sc, 'fontName', fontName)
                fS = getattr(sc, 'fontSize', fontSize)
                fC = getattr(sc, 'fillColor', fillColor)
                fL = getattr(sc, 'leading', 1.2 * fontSize)
                if fN == fontName:
                    fA = (ascent * fS) / fontSize
                else:
                    fA = getFont(fontName).face.ascent / 1000.
                    if fA == 0: fA = 0.718
                    fA *= fS
                if anchor == 'left':
                    anchor = 'start'
                    xoffs = x1
                elif anchor == 'right':
                    anchor = 'end'
                    xoffs = x2
                elif anchor == 'numeric':
                    xoffs = x2
                else:
                    anchor = 'middle'
                    xoffs = 0.5 * (x1 + x2)
                for t in lines:
                    aS(
                        String(xoffs,
                               y,
                               t,
                               fontName=fN,
                               fontSize=fS,
                               fillColor=fC,
                               textAnchor=anchor))
                    y -= fL
                yd = min(yd, y)
                y += fL
                for iy, a in ((y - max(fL - fA, 0), 'underlines'),
                              (y + fA, 'overlines')):
                    il = getattr(sc, a, None)
                    if il:
                        if not isinstance(il, (tuple, list)): il = (il, )
                        for l in il:
                            l = copy.copy(l)
                            l.y1 += iy
                            l.y2 += iy
                            l.x1 += x1
                            l.x2 += x2
                            aS(l)
            x = xn
            y = yd
            leadingMove = 2 * y0 - y - thisy

            if dividerLines:
                xd = thisx + dx + dxTextSpace + jOffs[-1] + dividerOffsX[1]
                yd = thisy + dy * 0.5 + dividerOffsY
                if ((dividerLines & 1) and i % columnMaximum) or (
                    (dividerLines & 2) and not i % columnMaximum):
                    g.add(
                        Line(thisx + dividerOffsX[0],
                             yd,
                             xd,
                             yd,
                             strokeColor=dividerColor,
                             strokeWidth=dividerWidth,
                             strokeDashArray=dividerDashArray))

                if (dividerLines & 4) and (i % columnMaximum == lim
                                           or i == (n - 1)):
                    yd -= max(deltay, leadingMove) + yGap
                    g.add(
                        Line(thisx + dividerOffsX[0],
                             yd,
                             xd,
                             yd,
                             strokeColor=dividerColor,
                             strokeWidth=dividerWidth,
                             strokeDashArray=dividerDashArray))

            # Make a 'normal' color swatch...
            if isAuto(col):
                chart = getattr(col, 'chart', getattr(col, 'obj', None))
                c = chart.makeSwatchSample(getattr(col, 'index', i), x, thisy,
                                           dx, dy)
            elif isinstance(col, colors.Color):
                if isSymbol(swatchMarker):
                    c = uSymbol2Symbol(swatchMarker, x + dx / 2.,
                                       thisy + dy / 2., col)
                else:
                    c = self._defaultSwatch(x,
                                            thisy,
                                            dx,
                                            dy,
                                            fillColor=col,
                                            strokeWidth=strokeWidth,
                                            strokeColor=strokeColor)
            elif col is not None:
                try:
                    c = copy.deepcopy(col)
                    c.x = x
                    c.y = thisy
                    c.width = dx
                    c.height = dy
                except:
                    c = None
            else:
                c = None

            if c:
                g.add(c)
                if scallout: scallout(self, g, thisx, y0, i, (col, name), c)

            map(g.add, S)
            if self.colEndCallout and (i % columnMaximum == lim
                                       or i == (n - 1)):
                if alignment == "left":
                    xt = thisx
                else:
                    xt = thisx + dx + dxTextSpace
                yd = thisy + dy * 0.5 + dividerOffsY - (
                    max(deltay, leadingMove) + yGap)
                self.colEndCallout(self, g, thisx, xt, yd, jOffs[-1],
                                   jOffs[-1] + dx + dxTextSpace)

            if i % columnMaximum == lim:
                if variColumn:
                    thisx += jOffs[-1] + xW
                else:
                    thisx = thisx + deltax
                thisy = upperlefty
            else:
                thisy = thisy - max(deltay, leadingMove) - yGap

        return g
Beispiel #6
0
    def draw(self):
        colorNamePairs = self.colorNamePairs
        autoCP = isAuto(colorNamePairs)
        if autoCP:
            chart = getattr(colorNamePairs,'chart',getattr(colorNamePairs,'obj',None))
            swatchMarker = None
            autoCP = Auto(obj=chart)
            n = chart._seriesCount
            chartTexts = self._getTexts(colorNamePairs)
        else:
            swatchMarker = getattr(self,'swatchMarker',None)
            if isAuto(swatchMarker):
                chart = getattr(swatchMarker,'chart',getattr(swatchMarker,'obj',None))
                swatchMarker = Auto(obj=chart)
            n = len(colorNamePairs)
        dx = self.dx
        dy = self.dy
        alignment = self.alignment
        columnMaximum = self.columnMaximum
        deltax = self.deltax
        deltay = self.deltay
        dxTextSpace = self.dxTextSpace
        fontName = self.fontName
        fontSize = self.fontSize
        fillColor = self.fillColor
        strokeWidth = self.strokeWidth
        strokeColor = self.strokeColor
        leading = fontSize*1.2
        yGap = self.yGap
        if not deltay:
            deltay = max(dy,leading)+self.autoYPadding
        ba = self.boxAnchor
        maxWidth = self._calculateMaxWidth(colorNamePairs)
        nCols = int((n+columnMaximum-1)/columnMaximum)
        xW = dx+dxTextSpace+self.autoXPadding
        variColumn = self.variColumn
        if variColumn:
            width = reduce(operator.add,maxWidth,0)+xW*(nCols-1)
        else:
            deltax = max(maxWidth+xW,deltax)
            width = maxWidth+(nCols-1)*deltax
            maxWidth = nCols*[maxWidth]

        thisx = self.x
        thisy = self.y - self.dy
        if ba not in ('ne','n','nw','autoy'):
            height = self._calcHeight()
            if ba in ('e','c','w'):
                thisy += height/2.
            else:
                thisy += height
        if ba not in ('nw','w','sw','autox'):
            if ba in ('n','c','s'):
                thisx -= width/2
            else:
                thisx -= width
        upperlefty = thisy

        g = Group()
        def gAdd(t,g=g,fontName=fontName,fontSize=fontSize,fillColor=fillColor):
            t.fontName = fontName
            t.fontSize = fontSize
            t.fillColor = fillColor
            return g.add(t)

        ascent=getFont(fontName).face.ascent/1000.
        if ascent==0: ascent=0.718 # default (from helvetica)
        ascent *= fontSize # normalize

        lim = columnMaximum - 1
        callout = getattr(self,'callout',None)
        dividerLines = self.dividerLines
        if dividerLines:
            dividerWidth = self.dividerWidth
            dividerColor = self.dividerColor
            dividerDashArray = self.dividerDashArray
            dividerOffsX = self.dividerOffsX
            dividerOffsY = self.dividerOffsY

        for i in xrange(n):
            if autoCP:
                col = autoCP
                col.index = i
                name = chartTexts[i]
            else:
                col, name = colorNamePairs[i]
                if isAuto(swatchMarker):
                    col = swatchMarker
                    col.index = i
                if isAuto(name):
                    name = getattr(swatchMarker,'chart',getattr(swatchMarker,'obj',None)).getSeriesName(i,'series %d' % i)
            T = _getLines(name)
            S = []
            j = int(i/columnMaximum)

            # thisy+dy/2 = y+leading/2
            y = y0 = thisy+(dy-ascent)*0.5

            if callout: callout(self,g,thisx,y,(col,name))
            if alignment == "left":
                if isSeqType(name):
                    for t in T[0]:
                        S.append(String(thisx,y,t,fontName=fontName,fontSize=fontSize,fillColor=fillColor,
                                textAnchor = "start"))
                        y -= leading
                    yd = y
                    y = y0
                    for t in T[1]:
                        S.append(String(thisx+maxWidth[j],y,t,fontName=fontName,fontSize=fontSize,fillColor=fillColor,
                                textAnchor = "end"))
                        y -= leading
                    y = min(yd,y)
                else:
                    for t in T:
                        # align text to left
                        S.append(String(thisx+maxWidth[j],y,t,fontName=fontName,fontSize=fontSize,fillColor=fillColor,
                                textAnchor = "end"))
                        y -= leading
                x = thisx+maxWidth[j]+dxTextSpace
            elif alignment == "right":
                if isSeqType(name):
                    y0 = y
                    for t in T[0]:
                        S.append(String(thisx+dx+dxTextSpace,y,t,fontName=fontName,fontSize=fontSize,fillColor=fillColor,
                                textAnchor = "start"))
                        y -= leading
                    yd = y
                    y = y0
                    for t in T[1]:
                        S.append(String(thisx+dx+dxTextSpace+maxWidth[j],y,t,fontName=fontName,fontSize=fontSize,fillColor=fillColor,
                                textAnchor = "end"))
                        y -= leading
                    y = min(yd,y)
                else:
                    for t in T:
                        # align text to right
                        S.append(String(thisx+dx+dxTextSpace,y,t,fontName=fontName,fontSize=fontSize,fillColor=fillColor,
                                textAnchor = "start"))
                        y -= leading
                x = thisx
            else:
                raise ValueError, "bad alignment"
            leadingMove = 2*y0-y-thisy

            if dividerLines:
                xd = thisx+dx+dxTextSpace+maxWidth[j]+dividerOffsX[1]
                yd = thisy+dy*0.5+dividerOffsY
                if ((dividerLines&1) and i%columnMaximum) or ((dividerLines&2) and not i%columnMaximum):
                    g.add(Line(thisx+dividerOffsX[0],yd,xd,yd,
                        strokeColor=dividerColor, strokeWidth=dividerWidth, strokeDashArray=dividerDashArray))

                if (dividerLines&4) and (i%columnMaximum==lim or i==(n-1)):
                    yd -= max(deltay,leadingMove)+yGap
                    g.add(Line(thisx+dividerOffsX[0],yd,xd,yd,
                        strokeColor=dividerColor, strokeWidth=dividerWidth, strokeDashArray=dividerDashArray))

            # Make a 'normal' color swatch...
            if isAuto(col):
                chart = getattr(col,'chart',getattr(col,'obj',None))
                g.add(chart.makeSwatchSample(getattr(col,'index',i),x,thisy,dx,dy))
            elif isinstance(col, colors.Color):
                if isSymbol(swatchMarker):
                    g.add(uSymbol2Symbol(swatchMarker,x+dx/2.,thisy+dy/2.,col))
                else:
                    g.add(self._defaultSwatch(x,thisy,dx,dy,fillColor=col,strokeWidth=strokeWidth,strokeColor=strokeColor))
            else:
                try:
                    c = copy.deepcopy(col)
                    c.x = x
                    c.y = thisy
                    c.width = dx
                    c.height = dy
                    g.add(c)
                except:
                    pass

            map(gAdd,S)
            if self.colEndCallout and (i%columnMaximum==lim or i==(n-1)):
                if alignment == "left":
                    xt = thisx
                else:
                    xt = thisx+dx+dxTextSpace
                yd = thisy+dy*0.5+dividerOffsY - (max(deltay,leadingMove)+yGap)
                self.colEndCallout(self, g, thisx, xt, yd, maxWidth[j], maxWidth[j]+dx+dxTextSpace)

            if i%columnMaximum==lim:
                if variColumn:
                    thisx += maxWidth[j]+xW
                else:
                    thisx = thisx+deltax
                thisy = upperlefty
            else:
                thisy = thisy-max(deltay,leadingMove)-yGap

        return g
Beispiel #7
0
# encoding:utf-8
__author__ = 'admin'
from reportlab.graphics.shapes import Drawing, String
from reportlab.graphics import renderPDF

d = Drawing(100, 100)
s = String(50, 50, "Hello World!", textAnchor="middle")

d.add(s)

renderPDF.drawToFile(d, "hello.pdf", "A Simple PDF File")
Beispiel #8
0
 def __init__(self, width=400, height=200, *args, **kw):
     Drawing.__init__(self, width, height, *args, **kw)
     self.transform = (1, 0, 0, 1, 0, 0)
     self.add(
         Line(10,
              10,
              390,
              190,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Circle(100,
                100,
                20,
                fillColor=Color(0, .501961, 0, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=1,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Circle(200,
                100,
                40,
                fillColor=Color(0, .501961, 0, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=1,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Circle(300,
                100,
                30,
                fillColor=Color(0, .501961, 0, 1),
                fillOpacity=None,
                strokeColor=Color(0, 0, 0, 1),
                strokeWidth=1,
                strokeLineCap=0,
                strokeLineJoin=0,
                strokeMiterLimit=0,
                strokeDashArray=None,
                strokeOpacity=None))
     self.add(
         Wedge(330,
               100,
               40,
               -10,
               40,
               yradius=None,
               annular=False,
               fillColor=Color(0, .501961, 0, 1),
               fillOpacity=None,
               strokeColor=Color(0, 0, 0, 1),
               strokeWidth=1,
               strokeLineCap=0,
               strokeLineJoin=0,
               strokeMiterLimit=0,
               strokeDashArray=None,
               strokeOpacity=None))
     self.add(
         PolyLine(points=[
             120, 10, 130, 20, 140, 10, 150, 20, 160, 10, 170, 20, 180, 10,
             190, 20, 200, 10
         ],
                  strokeColor=Color(0, 0, 0, 1),
                  strokeWidth=1,
                  strokeLineCap=0,
                  strokeLineJoin=0,
                  strokeMiterLimit=0,
                  strokeDashArray=None,
                  strokeOpacity=None,
                  fillColor=Color(0, .501961, 0, 1)))
     self.add(
         Polygon(points=[300, 20, 350, 20, 390, 80, 300, 75, 330, 40],
                 fillColor=Color(0, .501961, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Ellipse(50,
                 150,
                 40,
                 20,
                 fillColor=Color(0, .501961, 0, 1),
                 fillOpacity=None,
                 strokeColor=Color(0, 0, 0, 1),
                 strokeWidth=1,
                 strokeLineCap=0,
                 strokeLineJoin=0,
                 strokeMiterLimit=0,
                 strokeDashArray=None,
                 strokeOpacity=None))
     self.add(
         Rect(120,
              150,
              60,
              30,
              rx=0,
              ry=0,
              fillColor=Color(0, .501961, 0, 1),
              fillOpacity=None,
              strokeColor=Color(1, 1, 0, 1),
              strokeWidth=10,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(220,
              150,
              60,
              30,
              rx=10,
              ry=10,
              fillColor=Color(0, .501961, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         String(10,
                50,
                'Basic Shapes',
                textAnchor='start',
                fontName='Helvetica',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
Beispiel #9
0
    def makeSectors(self):
        # normalize slice data
        if type(self.data) in (ListType, TupleType) and type(
                self.data[0]) in (ListType, TupleType):
            #it's a nested list, more than one sequence
            normData = []
            n = []
            for l in self.data:
                t = self.normalizeData(l)
                normData.append(t)
                n.append(len(t))
            self._seriesCount = max(n)
        else:
            normData = self.normalizeData(self.data)
            n = len(normData)
            self._seriesCount = n

        #labels
        if self.labels is None:
            labels = []
            if type(n) not in (ListType, TupleType):
                labels = [''] * n
            else:
                for m in n:
                    labels = list(labels) + [''] * m
        else:
            labels = self.labels
            #there's no point in raising errors for less than enough labels if
            #we silently create all for the extreme case of no labels.
            if type(n) not in (ListType, TupleType):
                i = n - len(labels)
                if i > 0:
                    labels = list(labels) + [''] * i
            else:
                tlab = 0
                for m in n:
                    tlab = tlab + m
                i = tlab - len(labels)
                if i > 0:
                    labels = list(labels) + [''] * i

        xradius = self.width / 2.0
        yradius = self.height / 2.0
        centerx = self.x + xradius
        centery = self.y + yradius

        if self.direction == "anticlockwise":
            whichWay = 1
        else:
            whichWay = -1

        g = Group()
        sn = 0

        startAngle = self.startAngle  #% 360
        styleCount = len(self.slices)
        if type(self.data[0]) in (ListType, TupleType):
            #multi-series doughnut
            iradius = (self.height / 5.0) / len(self.data)
            for series in normData:
                i = 0
                for angle in series:
                    endAngle = (startAngle + (angle * whichWay))  #% 360
                    if abs(startAngle - endAngle) >= 1e-5:
                        if startAngle < endAngle:
                            a1 = startAngle
                            a2 = endAngle
                        else:
                            a1 = endAngle
                            a2 = startAngle

                    #if we didn't use %stylecount here we'd end up with the later sectors
                    #all having the default style
                    sectorStyle = self.slices[i % styleCount]

                    # is it a popout?
                    cx, cy = centerx, centery
                    if sectorStyle.popout != 0:
                        # pop out the sector
                        averageAngle = (a1 + a2) / 2.0
                        aveAngleRadians = averageAngle * pi / 180.0
                        popdistance = sectorStyle.popout
                        cx = centerx + popdistance * cos(aveAngleRadians)
                        cy = centery + popdistance * sin(aveAngleRadians)

                    if type(n) in (ListType, TupleType):
                        theSector = Wedge(
                            cx,
                            cy,
                            xradius + (sn * iradius) - iradius,
                            a1,
                            a2,
                            yradius=yradius + (sn * iradius) - iradius,
                            radius1=yradius + (sn * iradius) - (2 * iradius))
                    else:
                        theSector = Wedge(cx,
                                          cy,
                                          xradius,
                                          a1,
                                          a2,
                                          yradius=yradius,
                                          radius1=iradius)

                    theSector.fillColor = sectorStyle.fillColor
                    theSector.strokeColor = sectorStyle.strokeColor
                    theSector.strokeWidth = sectorStyle.strokeWidth
                    theSector.strokeDashArray = sectorStyle.strokeDashArray

                    g.add(theSector)
                    startAngle = endAngle

                    text = self.getSeriesName(i, '')
                    if text:
                        averageAngle = (a1 + a2) / 2.0
                        aveAngleRadians = averageAngle * pi / 180.0
                        labelRadius = sectorStyle.labelRadius
                        labelX = centerx + (0.5 * self.width *
                                            cos(aveAngleRadians) * labelRadius)
                        labelY = centery + (0.5 * self.height *
                                            sin(aveAngleRadians) * labelRadius)
                        _addWedgeLabel(self, text, g.add, averageAngle, labelX,
                                       labelY, sectorStyle)
                    i = i + 1
                sn = sn + 1

        else:
            i = 0
            #single series doughnut
            iradius = self.height / 5.0
            for angle in normData:
                endAngle = (startAngle + (angle * whichWay))  #% 360
                if abs(startAngle - endAngle) >= 1e-5:
                    if startAngle < endAngle:
                        a1 = startAngle
                        a2 = endAngle
                    else:
                        a1 = endAngle
                        a2 = startAngle

                #if we didn't use %stylecount here we'd end up with the later sectors
                #all having the default style
                sectorStyle = self.slices[i % styleCount]

                # is it a popout?
                cx, cy = centerx, centery
                if sectorStyle.popout != 0:
                    # pop out the sector
                    averageAngle = (a1 + a2) / 2.0
                    aveAngleRadians = averageAngle * pi / 180.0
                    popdistance = sectorStyle.popout
                    cx = centerx + popdistance * cos(aveAngleRadians)
                    cy = centery + popdistance * sin(aveAngleRadians)

                if n > 1:
                    theSector = Wedge(cx,
                                      cy,
                                      xradius,
                                      a1,
                                      a2,
                                      yradius=yradius,
                                      radius1=iradius)
                elif n == 1:
                    theSector = Wedge(cx,
                                      cy,
                                      xradius,
                                      a1,
                                      a2,
                                      yradius=yradius,
                                      iradius=iradius)

                theSector.fillColor = sectorStyle.fillColor
                theSector.strokeColor = sectorStyle.strokeColor
                theSector.strokeWidth = sectorStyle.strokeWidth
                theSector.strokeDashArray = sectorStyle.strokeDashArray

                g.add(theSector)

                # now draw a label
                if labels[i] != "":
                    averageAngle = (a1 + a2) / 2.0
                    aveAngleRadians = averageAngle * pi / 180.0
                    labelRadius = sectorStyle.labelRadius
                    labelX = centerx + (0.5 * self.width *
                                        cos(aveAngleRadians) * labelRadius)
                    labelY = centery + (0.5 * self.height *
                                        sin(aveAngleRadians) * labelRadius)

                    theLabel = String(labelX, labelY, labels[i])
                    theLabel.textAnchor = "middle"
                    theLabel.fontSize = sectorStyle.fontSize
                    theLabel.fontName = sectorStyle.fontName
                    theLabel.fillColor = sectorStyle.fontColor

                    g.add(theLabel)

                startAngle = endAngle
                i = i + 1

        return g
Beispiel #10
0
	def __init__(self,width=400,height=200,*args,**kw):
		Drawing.__init__(self,width,height,*args,**kw)
		self.transform = (1,0,0,1,0,0)
		self.add(Ellipse(210,100,60,50,fillColor=Color(0,.545098,.545098,1),fillOpacity=None,strokeColor=Color(0,0,0,1),strokeWidth=1,strokeLineCap=0,strokeLineJoin=1,strokeMiterLimit=0,strokeDashArray=None,strokeOpacity=None))
		self.add(String(210,40,'a',textAnchor='middle',fontName='Times-Roman',fontSize=10,fillColor=Color(0,0,0,1)))
Beispiel #11
0
 def __init__(self, width=400, height=200, *args, **kw):
     Drawing.__init__(self, width, height, *args, **kw)
     self.transform = (1, 0, 0, 1, 0, 0)
     self.add(
         Wedge(200,
               100,
               50,
               -172.236,
               -170,
               yradius=50,
               annular=False,
               fillColor=Color(.27451, .509804, .705882, 1),
               fillOpacity=None,
               strokeColor=Color(0, 0, 0, 1),
               strokeWidth=1,
               strokeLineCap=0,
               strokeLineJoin=1,
               strokeMiterLimit=0,
               strokeDashArray=None,
               strokeOpacity=None))
     self.add(
         Wedge(200,
               100,
               50,
               -174.472,
               -172.236,
               yradius=50,
               annular=False,
               fillColor=Color(.847059, .74902, .847059, 1),
               fillOpacity=None,
               strokeColor=Color(0, 0, 0, 1),
               strokeWidth=1,
               strokeLineCap=0,
               strokeLineJoin=1,
               strokeMiterLimit=0,
               strokeDashArray=None,
               strokeOpacity=None))
     self.add(
         Wedge(200,
               100,
               50,
               -176.7081,
               -174.472,
               yradius=50,
               annular=False,
               fillColor=Color(.392157, .584314, .929412, 1),
               fillOpacity=None,
               strokeColor=Color(0, 0, 0, 1),
               strokeWidth=1,
               strokeLineCap=0,
               strokeLineJoin=1,
               strokeMiterLimit=0,
               strokeDashArray=None,
               strokeOpacity=None))
     self.add(
         Wedge(200,
               100,
               50,
               -178.9441,
               -176.7081,
               yradius=50,
               annular=False,
               fillColor=Color(.690196, .768627, .870588, 1),
               fillOpacity=None,
               strokeColor=Color(0, 0, 0, 1),
               strokeWidth=1,
               strokeLineCap=0,
               strokeLineJoin=1,
               strokeMiterLimit=0,
               strokeDashArray=None,
               strokeOpacity=None))
     self.add(
         Wedge(200,
               100,
               50,
               -181.1801,
               -178.9441,
               yradius=50,
               annular=False,
               fillColor=Color(.498039, 1, .831373, 1),
               fillOpacity=None,
               strokeColor=Color(0, 0, 0, 1),
               strokeWidth=1,
               strokeLineCap=0,
               strokeLineJoin=1,
               strokeMiterLimit=0,
               strokeDashArray=None,
               strokeOpacity=None))
     self.add(
         Wedge(200,
               100,
               50,
               -248.2609,
               -181.1801,
               yradius=50,
               annular=False,
               fillColor=Color(.372549, .619608, .627451, 1),
               fillOpacity=None,
               strokeColor=Color(0, 0, 0, 1),
               strokeWidth=1,
               strokeLineCap=0,
               strokeLineJoin=1,
               strokeMiterLimit=0,
               strokeDashArray=None,
               strokeOpacity=None))
     self.add(
         Wedge(200,
               100,
               50,
               -360.0621,
               -248.2609,
               yradius=50,
               annular=False,
               fillColor=Color(1, 1, 0, 1),
               fillOpacity=None,
               strokeColor=Color(0, 0, 0, 1),
               strokeWidth=1,
               strokeLineCap=0,
               strokeLineJoin=1,
               strokeMiterLimit=0,
               strokeDashArray=None,
               strokeOpacity=None))
     self.add(
         Wedge(200,
               100,
               50,
               -362.2981,
               -360.0621,
               yradius=50,
               annular=False,
               fillColor=Color(.27451, .509804, .705882, 1),
               fillOpacity=None,
               strokeColor=Color(0, 0, 0, 1),
               strokeWidth=1,
               strokeLineCap=0,
               strokeLineJoin=1,
               strokeMiterLimit=0,
               strokeDashArray=None,
               strokeOpacity=None))
     self.add(
         Wedge(200,
               100,
               50,
               -364.5342,
               -362.2981,
               yradius=50,
               annular=False,
               fillColor=Color(.847059, .74902, .847059, 1),
               fillOpacity=None,
               strokeColor=Color(0, 0, 0, 1),
               strokeWidth=1,
               strokeLineCap=0,
               strokeLineJoin=1,
               strokeMiterLimit=0,
               strokeDashArray=None,
               strokeOpacity=None))
     self.add(
         Wedge(200,
               100,
               50,
               -366.7702,
               -364.5342,
               yradius=50,
               annular=False,
               fillColor=Color(.392157, .584314, .929412, 1),
               fillOpacity=None,
               strokeColor=Color(0, 0, 0, 1),
               strokeWidth=1,
               strokeLineCap=0,
               strokeLineJoin=1,
               strokeMiterLimit=0,
               strokeDashArray=None,
               strokeOpacity=None))
     self.add(
         Wedge(200,
               100,
               50,
               -369.0062,
               -366.7702,
               yradius=50,
               annular=False,
               fillColor=Color(.690196, .768627, .870588, 1),
               fillOpacity=None,
               strokeColor=Color(0, 0, 0, 1),
               strokeWidth=1,
               strokeLineCap=0,
               strokeLineJoin=1,
               strokeMiterLimit=0,
               strokeDashArray=None,
               strokeOpacity=None))
     self.add(
         Wedge(200,
               100,
               50,
               -371.2422,
               -369.0062,
               yradius=50,
               annular=False,
               fillColor=Color(.498039, 1, .831373, 1),
               fillOpacity=None,
               strokeColor=Color(0, 0, 0, 1),
               strokeWidth=1,
               strokeLineCap=0,
               strokeLineJoin=1,
               strokeMiterLimit=0,
               strokeDashArray=None,
               strokeOpacity=None))
     self.add(
         Wedge(200,
               100,
               50,
               -373.4783,
               -371.2422,
               yradius=50,
               annular=False,
               fillColor=Color(.372549, .619608, .627451, 1),
               fillOpacity=None,
               strokeColor=Color(0, 0, 0, 1),
               strokeWidth=1,
               strokeLineCap=0,
               strokeLineJoin=1,
               strokeMiterLimit=0,
               strokeDashArray=None,
               strokeOpacity=None))
     self.add(
         Wedge(200,
               100,
               50,
               -462.9193,
               -373.4783,
               yradius=50,
               annular=False,
               fillColor=Color(1, 1, 0, 1),
               fillOpacity=None,
               strokeColor=Color(0, 0, 0, 1),
               strokeWidth=1,
               strokeLineCap=0,
               strokeLineJoin=1,
               strokeMiterLimit=0,
               strokeDashArray=None,
               strokeOpacity=None))
     self.add(
         Wedge(200,
               100,
               50,
               -507.6398,
               -462.9193,
               yradius=50,
               annular=False,
               fillColor=Color(.27451, .509804, .705882, 1),
               fillOpacity=None,
               strokeColor=Color(0, 0, 0, 1),
               strokeWidth=1,
               strokeLineCap=0,
               strokeLineJoin=1,
               strokeMiterLimit=0,
               strokeDashArray=None,
               strokeOpacity=None))
     self.add(
         Wedge(200,
               100,
               50,
               -530,
               -507.6398,
               yradius=50,
               annular=False,
               fillColor=Color(.847059, .74902, .847059, 1),
               fillOpacity=None,
               strokeColor=Color(0, 0, 0, 1),
               strokeWidth=1,
               strokeLineCap=0,
               strokeLineJoin=1,
               strokeMiterLimit=0,
               strokeDashArray=None,
               strokeOpacity=None))
     self.add(
         String(140,
                138.736,
                'example1',
                textAnchor='end',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(140,
                129.056,
                'example2',
                textAnchor='end',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(140,
                119.3865,
                'example3',
                textAnchor='end',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(140,
                109.724,
                'example4',
                textAnchor='end',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(140,
                100.065,
                'example5',
                textAnchor='end',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(140,
                134.1744,
                'example6',
                textAnchor='end',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(260,
                149.6475,
                'example7',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(260,
                128.7643,
                'example8',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(260,
                120.4247,
                'example9',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(260,
                112.0907,
                'example10',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(260,
                103.7656,
                'example11',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(260,
                95.45302,
                'example12',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(260,
                87.15654,
                'example13',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(260,
                49.00712,
                'example14',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(140,
                51.01934,
                'example15',
                textAnchor='end',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(140,
                78.32193,
                'example16',
                textAnchor='end',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         Line(150.5996,
              92.28001,
              145.2998,
              141.736,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(145.2998,
              141.736,
              140,
              141.736,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(150.336,
              94.2133,
              145.168,
              132.056,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(145.168,
              132.056,
              140,
              132.056,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(150.148,
              96.1554,
              145.074,
              122.3865,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(145.074,
              122.3865,
              140,
              122.3865,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(150.036,
              98.10336,
              145.018,
              112.724,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(145.018,
              112.724,
              140,
              112.724,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(150,
              100.0542,
              145,
              103.065,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(145,
              103.065,
              140,
              103.065,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(158.903,
              128.4787,
              149.4515,
              137.1744,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(149.4515,
              137.1744,
              140,
              137.1744,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(228.0764,
              141.3729,
              244.0382,
              152.6475,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(244.0382,
              152.6475,
              260,
              152.6475,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(249.9894,
              98.97022,
              254.9947,
              131.7643,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(254.9947,
              131.7643,
              260,
              131.7643,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(249.9112,
              97.02061,
              254.9556,
              123.4247,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(254.9556,
              123.4247,
              260,
              123.4247,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(249.7569,
              95.07554,
              254.8785,
              115.0907,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(254.8785,
              115.0907,
              260,
              115.0907,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(249.5269,
              93.13797,
              254.7634,
              106.7656,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(254.7634,
              106.7656,
              260,
              106.7656,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(249.2214,
              91.21085,
              254.6107,
              98.45302,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(254.6107,
              98.45302,
              260,
              98.45302,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(248.8411,
              89.29712,
              254.4205,
              90.15654,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(254.4205,
              90.15654,
              260,
              90.15654,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(226.3487,
              57.50594,
              243.1744,
              52.00712,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(243.1744,
              52.00712,
              260,
              52.00712,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(171.1217,
              59.18279,
              155.5609,
              54.01934,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(155.5609,
              54.01934,
              140,
              54.01934,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(153.3775,
              81.93494,
              146.6888,
              81.32193,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(146.6888,
              81.32193,
              140,
              81.32193,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=.5,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
Beispiel #12
0
 def __init__(self, width=400, height=200, *args, **kw):
     Drawing.__init__(self, width, height, *args, **kw)
     self.transform = (1, 0, 0, 1, 0, 0)
     self.add(
         Rect(59.375,
              110,
              18.75,
              9.6,
              rx=0,
              ry=0,
              fillColor=Color(1, 0, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(119.375,
              110,
              18.75,
              -22.8,
              rx=0,
              ry=0,
              fillColor=Color(1, 0, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(179.375,
              110,
              18.75,
              8,
              rx=0,
              ry=0,
              fillColor=Color(1, 0, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(239.375,
              110,
              18.75,
              20,
              rx=0,
              ry=0,
              fillColor=Color(1, 0, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(299.375,
              110,
              18.75,
              39.96,
              rx=0,
              ry=0,
              fillColor=Color(1, 0, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(81.875,
              110,
              18.75,
              2.4,
              rx=0,
              ry=0,
              fillColor=Color(0, .501961, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(141.875,
              110,
              18.75,
              -19.6,
              rx=0,
              ry=0,
              fillColor=Color(0, .501961, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(201.875,
              110,
              18.75,
              -12,
              rx=0,
              ry=0,
              fillColor=Color(0, .501961, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(261.875,
              110,
              18.75,
              16,
              rx=0,
              ry=0,
              fillColor=Color(0, .501961, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(321.875,
              110,
              18.75,
              39.96,
              rx=0,
              ry=0,
              fillColor=Color(0, .501961, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 68.75, 129.6)
     v0.add(
         String(0,
                -6,
                '2.40',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=6,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 128.75, 77.2)
     v0.add(
         String(0,
                1.2,
                '-5.70',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=6,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 188.75, 128)
     v0.add(
         String(0,
                -6,
                '2.00',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=6,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 248.75, 140)
     v0.add(
         String(0,
                -6,
                '5.00',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=6,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 308.75, 159.96)
     v0.add(
         String(0,
                -6,
                '9.99',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=6,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 91.25, 122.4)
     v0.add(
         String(0,
                -6,
                '0.60',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=6,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 151.25, 80.4)
     v0.add(
         String(0,
                1.2,
                '-4.90',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=6,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 211.25, 88)
     v0.add(
         String(0,
                1.2,
                '-3.00',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=6,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 271.25, 136)
     v0.add(
         String(0,
                -6,
                '4.00',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=6,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 331.25, 159.96)
     v0.add(
         String(0,
                -6,
                '9.99',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=6,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         Line(50,
              49,
              350,
              49,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              49,
              50,
              44,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(110,
              49,
              110,
              44,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(170,
              49,
              170,
              44,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(230,
              49,
              230,
              44,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(290,
              49,
              290,
              44,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(350,
              49,
              350,
              44,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 80, -11)
     v0.add(
         String(-15.344,
                -8,
                'Q3 2000',
                textAnchor='start',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 140, -11)
     v0.add(
         String(-22.456,
                -8,
                'Year to Date',
                textAnchor='start',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 200, -11)
     v0.add(
         String(-18.676,
                -8,
                '12 months',
                textAnchor='start',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 260, -11)
     v0.add(
         String(-19.788,
                -8,
                'Annualised',
                textAnchor='start',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0.add(
         String(-19.788,
                -17.6,
                '3 years',
                textAnchor='start',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 320, -11)
     v0.add(
         String(-26.684,
                -8,
                'Since 07.10.99',
                textAnchor='start',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         Line(50,
              50,
              50,
              170,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              50,
              45,
              50,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              70,
              45,
              70,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              90,
              45,
              90,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              110,
              45,
              110,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              130,
              45,
              130,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              150,
              45,
              150,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              170,
              45,
              170,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 50)
     v0.add(
         String(0,
                -8,
                '-15',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 70)
     v0.add(
         String(0,
                -8,
                '-10',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 90)
     v0.add(
         String(0,
                -8,
                '-5',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 110)
     v0.add(
         String(0,
                -8,
                '0',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 130)
     v0.add(
         String(0,
                -8,
                '5',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 150)
     v0.add(
         String(0,
                -8,
                '10',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 45, 170)
     v0.add(
         String(0,
                -8,
                '15',
                textAnchor='middle',
                fontName='Helvetica',
                fontSize=8,
                fillColor=Color(0, 0, 0, 1)))
Beispiel #13
0
    def convertText(self, node):
        attrConv = self.attrConverter
        xml_space = node.getAttribute("{%s}space" % XML_NS)
        if xml_space:
            preserve_space = xml_space == 'preserve'
        else:
            preserve_space = self.preserve_space

        gr = Group()

        frag_lengths = []

        dx0, dy0 = 0, 0
        x1, y1 = 0, 0
        ff = attrConv.findAttr(node, "font-family") or DEFAULT_FONT_NAME
        ff = attrConv.convertFontFamily(ff)
        fs = attrConv.findAttr(node, "font-size") or "12"
        fs = attrConv.convertLength(fs)
        convertLength = partial(attrConv.convertLength, em_base=fs)
        x, y = map(node.getAttribute, ('x', 'y'))
        x, y = map(convertLength, (x, y))
        for c in itertools.chain([node], node.getchildren()):
            has_x, has_y = False, False
            dx, dy = 0, 0
            baseLineShift = 0
            if node_name(c) == 'text':
                text = self.clean_text(c.text, preserve_space)
                if not text:
                    continue
            elif node_name(c) == 'tspan':
                text = self.clean_text(c.text, preserve_space)
                if not text:
                    continue
                x1, y1, dx, dy = [
                    c.attrib.get(name, '') for name in ("x", "y", "dx", "dy")
                ]
                has_x, has_y = (x1 != '', y1 != '')
                x1, y1, dx, dy = map(convertLength, (x1, y1, dx, dy))
                dx0 = dx0 + dx
                dy0 = dy0 + dy
                baseLineShift = c.attrib.get("baseline-shift", '0')
                if baseLineShift in ("sub", "super", "baseline"):
                    baseLineShift = {
                        "sub": -fs / 2,
                        "super": fs / 2,
                        "baseline": 0
                    }[baseLineShift]
                else:
                    baseLineShift = convertLength(baseLineShift, fs)
            else:
                continue

            frag_lengths.append(stringWidth(text, ff, fs))
            new_x = (x1 + dx) if has_x else (x + dx0 + sum(frag_lengths[:-1]))
            new_y = (y1 + dy) if has_y else (y + dy0)
            shape = String(new_x, -(new_y - baseLineShift), text)
            self.applyStyleOnShape(shape, node)
            if node_name(c) == 'tspan':
                self.applyStyleOnShape(shape, c)

            gr.add(shape)

        gr.scale(1, -1)

        return gr
from reportlab.graphics.shapes import Drawing, String
from reportlab.graphics import renderPDF
d = Drawing(100, 100)
s = String(50, 50, 'Hello, fish!', textAnchor='middle')
d.add(s)
renderPDF.drawToFile(d, 'hello.pdf', 'A simple PDF file')
    def draw(self):
        g = Group()
        ys = self.bottomPadding + (
            self.triangleHeight /
            2) + self.sourceLabelOffset + self.sourceLabelFontSize
        if self.background:
            x, y = self._getDrawingDimensions()
            g.add(
                Rect(-self.leftPadding,
                     -ys,
                     x,
                     y,
                     strokeColor=None,
                     strokeWidth=0,
                     fillColor=self.background))

        ascent = getFont(self.labelFontName).face.ascent / 1000.
        if ascent == 0: ascent = 0.718  # default (from helvetica)
        ascent = ascent * self.labelFontSize  # normalize

        colorsList = self._getColors()

        # Draw the boxes - now uses ShadedRect from grids
        x = 0
        for f in range(0, self.numberOfBoxes):
            sr = ShadedRect()
            sr.x = x
            sr.y = 0
            sr.width = self.boxWidth
            sr.height = self.boxHeight
            sr.orientation = 'vertical'
            sr.numShades = 30
            sr.fillColorStart = colorsList[f]
            sr.fillColorEnd = colorsList[f + 1]
            sr.strokeColor = None
            sr.strokeWidth = 0

            g.add(sr)

            g.add(
                Rect(x,
                     0,
                     self.boxWidth,
                     self.boxHeight,
                     strokeColor=self.boxOutlineColor,
                     strokeWidth=self.boxOutlineWidth,
                     fillColor=None))

            g.add(
                String(x + self.boxWidth / 2., (self.boxHeight - ascent) / 2.,
                       text=str(f + 1),
                       fillColor=self.labelFillColor,
                       strokeColor=self.labelStrokeColor,
                       textAnchor='middle',
                       fontName=self.labelFontName,
                       fontSize=self.labelFontSize))
            x = x + self.boxWidth + self.boxSpacing

        #do triangles
        xt = (self.trianglePosition * self.boxWidth)
        if self.trianglePosition > 1:
            xt = xt + (self.trianglePosition - 1) * self.boxSpacing
        xt = xt - (self.boxWidth / 2)
        g.add(
            Polygon(strokeColor=self.triangleStrokeColor,
                    strokeWidth=self.triangleStrokeWidth,
                    fillColor=self.triangleFillColor,
                    points=[
                        xt, self.boxHeight - (self.triangleHeight / 2),
                        xt - (self.triangleWidth / 2),
                        self.boxHeight + (self.triangleHeight / 2),
                        xt + (self.triangleWidth / 2),
                        self.boxHeight + (self.triangleHeight / 2), xt,
                        self.boxHeight - (self.triangleHeight / 2)
                    ]))
        g.add(
            Polygon(strokeColor=self.triangleStrokeColor,
                    strokeWidth=self.triangleStrokeWidth,
                    fillColor=self.triangleFillColor,
                    points=[
                        xt, 0 + (self.triangleHeight / 2),
                        xt - (self.triangleWidth / 2),
                        0 - (self.triangleHeight / 2),
                        xt + (self.triangleWidth / 2),
                        0 - (self.triangleHeight / 2), xt,
                        0 + (self.triangleHeight / 2)
                    ]))

        #source label
        if self.sourceLabelText != None:
            g.add(
                String(x - self.boxSpacing,
                       0 - (self.triangleHeight / 2) - self.sourceLabelOffset -
                       (self.sourceLabelFontSize),
                       text=self.sourceLabelText,
                       fillColor=self.sourceLabelFillColor,
                       textAnchor='end',
                       fontName=self.sourceLabelFontName,
                       fontSize=self.sourceLabelFontSize))

        g.shift(self.leftPadding, ys)

        return g
Beispiel #16
0
 def __init__(self, width=400, height=200, *args, **kw):
     Drawing.__init__(self, width, height, *args, **kw)
     self.transform = (1, 0, 0, 1, 0, 0)
     self.add(
         Line(250,
              10,
              250,
              190,
              strokeColor=Color(.501961, .501961, .501961, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         String(250,
                130,
                'Hello World',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(50,
                130,
                'start:',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(250,
                100,
                'Hello World',
                textAnchor='middle',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(50,
                100,
                'middle:',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(250,
                70,
                'Hello World',
                textAnchor='end',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         String(50,
                70,
                'end:',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
Beispiel #17
0
    def _draw_labels(self, cur_drawing, left_labels, right_labels):
        """Layout and draw sub-feature labels for the chromosome (PRIVATE).

        Tries to place each label at the same vertical position as the
        feature it applies to, but will adjust the positions to avoid or
        at least reduce label overlap.

        Draws the label text and a coloured line linking it to the
        location (i.e. feature) it applies to.
        """
        if not self._sub_components:
            return
        color_label = self._color_labels

        segment_width = (self.end_x_position - self.start_x_position) * self.chr_percent
        label_sep = (
            self.end_x_position - self.start_x_position
        ) * self.label_sep_percent
        segment_x = self.start_x_position + 0.5 * (
            self.end_x_position - self.start_x_position - segment_width
        )

        y_limits = []
        for sub_component in self._sub_components:
            y_limits.extend(
                (sub_component.start_y_position, sub_component.end_y_position)
            )
        y_min = min(y_limits)
        y_max = max(y_limits)
        del y_limits
        # Now do some label placement magic...
        # from reportlab.pdfbase import pdfmetrics
        # font = pdfmetrics.getFont('Helvetica')
        # h = (font.face.ascent + font.face.descent) * 0.90
        h = self.label_size
        for x1, x2, labels, anchor in [
            (
                segment_x,
                segment_x - label_sep,
                _place_labels(left_labels, y_min, y_max, h),
                "end",
            ),
            (
                segment_x + segment_width,
                segment_x + segment_width + label_sep,
                _place_labels(right_labels, y_min, y_max, h),
                "start",
            ),
        ]:
            for (y1, y2, color, back_color, name) in labels:
                cur_drawing.add(
                    Line(x1, y1, x2, y2, strokeColor=color, strokeWidth=0.25)
                )
                label_string = String(x2, y2, name, textAnchor=anchor)
                label_string.fontName = "Helvetica"
                label_string.fontSize = h
                if color_label:
                    label_string.fillColor = color
                if back_color:
                    w = stringWidth(name, label_string.fontName, label_string.fontSize)
                    if x1 > x2:
                        w = w * -1.0
                    cur_drawing.add(
                        Rect(
                            x2,
                            y2 - 0.1 * h,
                            w,
                            h,
                            strokeColor=back_color,
                            fillColor=back_color,
                        )
                    )
                cur_drawing.add(label_string)
Beispiel #18
0
    def testUtf8Canvas(self):
        """Verify canvas declared as utf8 autoconverts.

        This assumes utf8 input. It converts to the encoding of the
        underlying font, so both text lines APPEAR the same."""

        c = Canvas(outputfile('test_pdfbase_encodings_utf8.pdf'))

        c.drawString(100, 700, testUTF8)

        # Set a font with UTF8 encoding
        c.setFont('Vera', 12)

        # This should pass the UTF8 through unchanged
        c.drawString(100, 600, testUTF8)
        # and this should convert from Unicode to UTF8
        c.drawString(100, 500, testUni)

        # now add a paragraph in Latin-1 in the latin-1 style
        p = Paragraph(testUTF8, style=self.styNormal, encoding="utf-8")
        w, h = p.wrap(150, 100)
        p.drawOn(c, 100, 400)  #3
        c.rect(100, 300, w, h)

        # now add a paragraph in UTF-8 in the UTF-8 style
        p2 = Paragraph(testUTF8, style=self.styTrueType, encoding="utf-8")
        w, h = p2.wrap(150, 100)
        p2.drawOn(c, 300, 400)  #4
        c.rect(100, 300, w, h)

        # now add a paragraph in Unicode in the latin-1 style
        p3 = Paragraph(testUni, style=self.styNormal)
        w, h = p3.wrap(150, 100)
        p3.drawOn(c, 100, 300)
        c.rect(100, 300, w, h)

        # now add a paragraph in Unicode in the UTF-8 style
        p4 = Paragraph(testUni, style=self.styTrueType)
        p4.wrap(150, 100)
        p4.drawOn(c, 300, 300)
        c.rect(300, 300, w, h)

        # now a graphic
        d1 = Drawing(400, 50)
        d1.add(Ellipse(200, 25, 200, 12.5, fillColor=None))
        d1.add(String(200, 25, testUTF8, textAnchor='middle',
                      encoding='utf-8'))
        d1.drawOn(c, 100, 150)

        # now a graphic in utf8
        d2 = Drawing(400, 50)
        d2.add(Ellipse(200, 25, 200, 12.5, fillColor=None))
        d2.add(
            String(200,
                   25,
                   testUTF8,
                   fontName='Vera',
                   textAnchor='middle',
                   encoding='utf-8'))
        d2.drawOn(c, 100, 100)

        # now a graphic in Unicode with T1 font
        d3 = Drawing(400, 50)
        d3.add(Ellipse(200, 25, 200, 12.5, fillColor=None))
        d3.add(String(200, 25, testUni, textAnchor='middle'))
        d3.drawOn(c, 100, 50)

        # now a graphic in Unicode with TT font
        d4 = Drawing(400, 50)
        d4.add(Ellipse(200, 25, 200, 12.5, fillColor=None))
        d4.add(String(200, 25, testUni, fontName='Vera', textAnchor='middle'))
        d4.drawOn(c, 100, 0)

        extracted = extractText(c.getCurrentPageContent())
        self.assertEquals(extracted[0], expectedCp1252)
        self.assertEquals(extracted[1], extracted[2])
        #self.assertEquals(subsetToUnicode(self.vera, extracted[1]), testUni)
        c.save()
Beispiel #19
0
#!/usr/bin/python
from reportlab.graphics.shapes import Drawing, String
from reportlab.graphics import renderPDF

d = Drawing(100, 100)
s = String(50, 50, 'Hello,Chicory', textAnchor='middle')

d.add(s)
renderPDF.drawToFile(d, 'hello.pdf', 'A Simple PDF file')
Beispiel #20
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#author: David Pay
#date: 06-16-2018

from reportlab.graphics.shapes import Drawing, String
from reportlab.graphics import renderPDF

d = Drawing(100, 100)
s = String(50, 50, 'Hello World!', textAnchor='middle')

d.add(s)

renderPDF.drawToFile(d, 'hello.pdf', 'A simple PDF file')
Beispiel #21
0
 def __init__(self, width=400, height=200, *args, **kw):
     Drawing.__init__(self, width, height, *args, **kw)
     self.transform = (1, 0, 0, 1, 0, 0)
     self.add(
         Line(50,
              50,
              350,
              50,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              50,
              50,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(143.75,
              50,
              143.75,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(237.5,
              50,
              237.5,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(331.25,
              50,
              331.25,
              45,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 50, 45)
     v0.add(
         String(-5,
                -10,
                '10',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 143.75, 45)
     v0.add(
         String(-5,
                -10,
                '20',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 237.5, 45)
     v0.add(
         String(-5,
                -10,
                '30',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 331.25, 45)
     v0.add(
         String(-5,
                -10,
                '40',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         Line(100,
              50,
              100,
              175,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(100,
              50,
              95,
              50,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(100,
              89.0625,
              95,
              89.0625,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(100,
              128.125,
              95,
              128.125,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(100,
              167.1875,
              95,
              167.1875,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 95, 50)
     v0.add(
         String(-10,
                -4,
                '10',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 95, 89.0625)
     v0.add(
         String(-10,
                -4,
                '20',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 95, 128.125)
     v0.add(
         String(-10,
                -4,
                '30',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 95, 167.1875)
     v0.add(
         String(-10,
                -4,
                '40',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
Beispiel #22
0
    def __init__(self, width=1000, height=400, *args, **kwargs):
        Drawing.__init__(self, width, height, *args, **kwargs)
        # background color
        self.background = Rect(0,
                               0,
                               self.width,
                               self.height,
                               strokeWidth=0,
                               fillColor=colors.lightgrey)
        # end here
        self.add(Circle(500, 200, 180), name='circle_perfect')
        self.add(Circle(500, 200, 145), name='circle_good')
        self.add(Circle(500, 200, 115), name='circle_medium')
        self.add(Circle(500, 200, 85), name='circle_bad')
        self.add(Circle(500, 200, 50), name='circle_awful')
        self.add(Circle(500, 200, 20), name='circle_center')
        self.add(SpiderChart(), name='background_chart')
        self.add(SpiderChart(), name='chart')

        # QR code
        qrw = QrCodeWidget('Well met')

        # QR size
        qrw.barHeight = 150
        qrw.barWidth = 150

        # QR position
        qrw.y = 100
        qrw.x = 10

        self.add(qrw)
        # end here

        # barcode
        barcode_group = Group()
        barcode = createBarcodeDrawing('EAN13',
                                       value='1234567890',
                                       width=200,
                                       height=100)

        barcode_group.add(barcode)
        barcode_group.shift(10, 10)  # barcode position
        self.add(barcode_group)
        # end here

        self.add(String(470, 386, 'Аналіз крові'), name='text0')
        self.add(String(605, 352, 'Антропометрія'), name='text1')
        self.add(String(670, 275, 'Постава'), name='text2')
        self.add(String(685, 170, 'Композиція тіла'), name='text3')
        self.add(String(645, 75, 'Електрокардіограмма'), name='text4')
        self.add(String(550, 10, 'Варіаційна пульсометрія'), name='text5')
        self.add(String(350, 10, 'Система дихання'), name='text6')
        self.add(String(220, 75, 'Кистьова динамометрія'), name='text7')
        self.add(String(225, 170, 'Основний обмін'), name='text8')
        self.add(String(160, 275, 'Карідореспіраторний профіль'), name='text9')
        self.add(String(330, 350, 'Психотест'), name='text10')

        # info
        self.add(String(840, 366, 'Чудово'), name='info_perfect')
        self.circle_perfect.fillColor = colors.Color(0, 0, 255, alpha=0.3)
        self.circle_perfect.strokeColor = colors.transparent
        self.info_perfect.fontName = 'HelveticaNeueC'
        self.info_perfect.fontSize = 12
        self.add(Rect(800, 356, 30, 30), name='rect_perfect')
        self.rect_perfect.fillColor = colors.Color(0, 0, 255, alpha=0.3)
        self.rect_perfect.strokeColor = colors.transparent

        self.add(String(840, 326, 'Добре'), name='info_good')
        self.circle_good.fillColor = colors.Color(0, 255, 0, alpha=0.5)
        self.circle_good.strokeColor = colors.transparent
        self.info_good.fontName = 'HelveticaNeueC'
        self.info_good.fontSize = 12
        self.add(Rect(800, 316, 30, 30), name='rect_good')
        self.rect_good.fillColor = colors.Color(0, 255, 0, alpha=0.5)
        self.rect_good.strokeColor = colors.transparent

        self.add(String(840, 286, 'Задовільно'), name='info_medium')
        self.circle_medium.fillColor = colors.yellow
        self.circle_medium.strokeColor = colors.transparent
        self.info_medium.fontName = 'HelveticaNeueC'
        self.info_medium.fontSize = 12
        self.add(Rect(800, 276, 30, 30), name='rect_medium')
        self.rect_medium.fillColor = colors.yellow
        self.rect_medium.strokeColor = colors.transparent

        self.add(String(840, 246, 'Погано'), name='info_bad')
        self.circle_bad.fillColor = colors.orange
        self.circle_bad.strokeColor = colors.transparent
        self.info_bad.fontName = 'HelveticaNeueC'
        self.info_bad.fontSize = 12
        self.add(Rect(800, 236, 30, 30), name='rect_bad')
        self.rect_bad.fillColor = colors.orange
        self.rect_bad.strokeColor = colors.transparent

        self.add(String(840, 206, 'Дуже погано'), name='info_awful')
        self.circle_awful.fillColor = colors.red
        self.circle_awful.strokeColor = colors.transparent
        self.info_awful.fontName = 'HelveticaNeueC'
        self.info_awful.fontSize = 12
        self.add(Rect(800, 196, 30, 30), name='rect_awful')
        self.rect_awful.fillColor = colors.red
        self.rect_awful.strokeColor = colors.transparent

        # end here

        self.chart.x = 20
        self.chart.y = 40
        self.chart.width = self.width - 40
        self.chart.height = self.height - 80

        self.background_chart.x = 10
        self.background_chart.y = 20
        self.background_chart.width = self.width - 20
        self.background_chart.height = self.height - 40

        # ruin has com to my code TODO rework this garbage
        self.text0.fontName = 'HelveticaNeueC'
        self.text0.fontSize = 12
        self.text1.fontName = 'HelveticaNeueC'
        self.text1.fontSize = 12
        self.text2.fontName = 'HelveticaNeueC'
        self.text2.fontSize = 12
        self.text3.fontName = 'HelveticaNeueC'
        self.text3.fontSize = 12
        self.text4.fontName = 'HelveticaNeueC'
        self.text4.fontSize = 12
        self.text5.fontName = 'HelveticaNeueC'
        self.text5.fontSize = 12
        self.text6.fontName = 'HelveticaNeueC'
        self.text6.fontSize = 12
        self.text7.fontName = 'HelveticaNeueC'
        self.text7.fontSize = 12
        self.text8.fontName = 'HelveticaNeueC'
        self.text8.fontSize = 12
        self.text9.fontName = 'HelveticaNeueC'
        self.text9.fontSize = 12
        self.text10.fontName = 'HelveticaNeueC'
        self.text10.fontSize = 12
        # end here aaaaaaaaaaaaaaaaaa

        self.chart.labels = [
            ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '
        ]
        self.background_chart.labels = [
            ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '
        ]

        self.chart.data = [
            [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],  # style
            [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],  # style
            [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],  # style
            [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],  # style
            [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],  # style
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  # values
        ]

        self.background_chart.data = [
            [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],  # style
            [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],  # style
            [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],  # style
            [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],  # style
            [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],  # style
        ]

        # style
        self.chart.strands.strokeColor = colors.transparent
        self.background_chart.strands.strokeColor = colors.transparent
        self.background_chart.spokes.strokeColor = colors.lightgrey
        # self.chart.strands[1].strokeWidth = 15
        # self.chart.strands[1].strokeColor = colors.lightgreen
        # self.chart.strands[2].strokeWidth = 15
        # self.chart.strands[2].strokeColor = colors.yellow
        # self.chart.strands[3].strokeWidth = 15
        # self.chart.strands[3].strokeColor = colors.orange
        # self.chart.strands[4].strokeWidth = 15
        # self.chart.strands[4].strokeColor = colors.red

        # self.background_chart.strands[0].fillColor = colors.Color(0, 0, 255, alpha=0.3)
        # self.background_chart.strands[1].fillColor = colors.Color(0, 255, 0, alpha=0.5)
        # self.background_chart.strands[2].fillColor = colors.yellow
        # self.background_chart.strands[3].fillColor = colors.orange
        # self.background_chart.strands[4].fillColor = colors.red

        # self.chart.strands[0].strokeColor = colors.blue
        # self.chart.strands[0].strokeDashArray = (4, 4)
        # self.chart.strands[0].symbol = makeMarker("Circle")
        # self.chart.strands[0].strokeWidth = 0.5
        # self.chart.strands[0].symbol.fillColor = colors.black

        #end here

        self.chart.strandLabels.format = 'values'

        # main graph style
        self.chart.strands[5].strokeColor = colors.darkblue
        self.chart.spokes.strokeColor = colors.transparent

        self.chart.strands[5].symbol = makeMarker('FilledCircle', size=11)
        # self.chart.strandLabels.dR = -20
        self.chart.strands[5].symbol.fillColor = colors.white
        self.chart.strands[5].strokeWidth = 2
Beispiel #23
0
legend.fontName = 'Helvetica'
legend.fontSize = 8
lp.x = 50
lp.y = 100
lp.height = 125
lp.width = 300
lp.data = [list(zip(times, pred)), list(
    zip(times, high)), list(zip(times, low))]

lp.lines[0].strokeColor = colorPred
lp.lines[1].strokeColor = colorHigh
lp.lines[2].strokeColor = colorLow


# Since the year is a decimal we need to change the format
lp.xValueAxis.labelTextFormat = utils.formatter

# Draw graph
drawing.add(lp)
drawing.add(legend)
drawing.add(
    String(
        250,
        300,
        'Sunspots',
        fontsize=15,
        filegendColor=colors.grey))

# Create output PDF
renderPDF.drawToFile(drawing, 'report.pdf', 'Sunspots')
    def label(self, ean13: str, description: str, sku, color, composition,
              origin_country) -> Drawing:
        """
        Generate a drawing with EAN-13 barcode and descriptive text.

        :param origin_country:
        :param composition:
        :param sku:
        :param color:
        :param ean13: The EAN-13 Code.
        :type ean13: str
        :param description: Short product description.
        :type description: str
        :return: Drawing with barcode and description
        :rtype: Drawing
        """

        # First column of sticker
        barcode = Ean13BarcodeWidget(ean13)
        barcode.barWidth = BAR_WIDTH
        barcode.barHeight = BAR_HEIGHT
        x0, y0, bw, bh = barcode.getBounds()
        x_alignment = 10
        barcode.x = x_alignment  # center barcode
        top_element_height = LABEL_HEIGHT / 2
        barcode.y = top_element_height  # spacing from label bottom (pt)

        product_name = String(x_alignment,
                              top_element_height - STICKER_ELEMENT_Y_DISTANCE,
                              description,
                              fontName="Helvetica",
                              fontSize=10)
        color = String(x_alignment,
                       top_element_height - 2 * STICKER_ELEMENT_Y_DISTANCE,
                       "Color: {}".format(color),
                       fontName="Helvetica",
                       fontSize=10)
        composition = String(x_alignment,
                             top_element_height -
                             3 * STICKER_ELEMENT_Y_DISTANCE,
                             "{}".format(composition),
                             fontName="Helvetica",
                             fontSize=8)

        # Second column of sticker
        column2_y_top = LABEL_HEIGHT / 1.3
        origin_country = String(COLUMN2_X,
                                column2_y_top,
                                "Made in: {}".format(origin_country),
                                fontName="Helvetica",
                                fontSize=10)
        sku_drawing_element = String(COLUMN2_X,
                                     column2_y_top -
                                     STICKER_ELEMENT_Y_DISTANCE,
                                     "SKU: {}".format(sku),
                                     fontName="Helvetica",
                                     fontSize=10)
        size_text = String(COLUMN2_X,
                           column2_y_top - STICKER_ELEMENT_Y_DISTANCE * 2.5,
                           "Size: ",
                           fontName="Helvetica",
                           fontSize=10)
        size = String(COLUMN2_X + 35,
                      column2_y_top - STICKER_ELEMENT_Y_DISTANCE * 2.5,
                      "{}".format(sku.split("-")[-1]),
                      fontName="Helvetica",
                      fontSize=15,
                      textAnchor="middle")

        label_drawing = Drawing(LABEL_WIDTH, LABEL_HEIGHT)
        label_drawing.add(barcode)
        label_drawing.add(product_name)
        label_drawing.add(color)
        label_drawing.add(composition)
        # Column 2
        label_drawing.add(origin_country)
        label_drawing.add(sku_drawing_element)
        label_drawing.add(size_text)
        label_drawing.add(size)
        return label_drawing
Beispiel #25
0
    def make_graphs(self, canvas=None, left_margin=None):  #text=None):
        from reportlab.graphics import renderPDF
        from reportlab.lib.pagesizes import letter
        from reportlab.graphics.shapes import Drawing, String
        from reportlab.graphics.charts.legends import Legend
        from reportlab.graphics.charts.lineplots import LinePlot
        from reportlab.graphics.widgets.markers import makeMarker
        from reportlab.lib import colors
        from reportlab.lib.units import inch
        #help(colors)

        self.framework = {
            4: dict(status=SpotClass.SPINDLE, color=colors.black),
            5: dict(status=SpotClass.OVERLAP, color=colors.limegreen),
            6: dict(status=SpotClass.OUTLIER, color=colors.greenyellow),
            7: dict(status=SpotClass.ICE, color=colors.skyblue),
        }

        # set size and position
        width, height = letter
        #letter_landscape = (width,height)
        plot_dim = 3.0 * inch

        # construct scatter plot
        plot_dxdy_pos = (left_margin * inch, height - plot_dim - 0.5 * inch)
        plot_dxdy = LinePlot()
        plot_dxdy.data = self.plot_dxdy_data

        std_colors = {0: colors.darkred, 1: colors.red, 2: colors.salmon}
        for key in std_colors.keys():
            plot_dxdy.lines[key].strokeColor = None
            plot_dxdy.lines[key].symbol = makeMarker('Circle')
            plot_dxdy.lines[key].symbol.strokeColor = None
            plot_dxdy.lines[key].symbol.fillColor = std_colors[key]
            plot_dxdy.lines[key].symbol.size = 1.2

        for key in self.framework.keys():
            plot_dxdy.lines[key].strokeColor = None
            plot_dxdy.lines[key].symbol = makeMarker('Circle')
            plot_dxdy.lines[key].symbol.strokeColor = None
            plot_dxdy.lines[key].symbol.fillColor = self.framework[key][
                "color"]
            plot_dxdy.lines[key].symbol.size = 1.2

        plot_dxdy.lines[3].strokeColor = None
        plot_dxdy.lines[3].symbol = makeMarker('Circle')
        plot_dxdy.lines[3].symbol.strokeColor = colors.blue
        plot_dxdy.lines[3].symbol.fillColor = None
        plot_dxdy.lines[3].symbol.strokeWidth = 0.6
        plot_dxdy.lines[3].symbol.size = plot_dim * (self.sqrtr2)
        #print plot_dxdy.lines[3].symbol.getProperties()
        plot_dxdy.width = plot_dim
        plot_dxdy.height = plot_dim
        plot_dxdy.xValueAxis.valueMax = 1.0
        plot_dxdy.xValueAxis.valueMin = -1.0
        plot_dxdy.xValueAxis.joinAxis = plot_dxdy.yValueAxis
        plot_dxdy.xValueAxis.joinAxisMode = 'value'
        plot_dxdy.xValueAxis.joinAxisPos = -1.0
        plot_dxdy.yValueAxis.valueMax = 1.0
        plot_dxdy.yValueAxis.valueMin = -1.0
        d_dxdy = Drawing(plot_dim, plot_dim)
        d_dxdy.add(plot_dxdy)

        # construct cdf plot
        plot_cdf_pos = (left_margin * inch,
                        height - 2.0 * (plot_dim + 0.5 * inch))
        plot_cdf = LinePlot()
        plot_cdf.data = self.plot_cdf_data
        plot_cdf.lines[0].strokeColor = colors.blue

        for key in std_colors.keys():
            plot_cdf.lines[key + 1].strokeColor = None
            plot_cdf.lines[key + 1].symbol = makeMarker('Circle')
            plot_cdf.lines[key + 1].symbol.strokeColor = None
            plot_cdf.lines[key + 1].symbol.fillColor = std_colors[key]
            plot_cdf.lines[key + 1].symbol.size = 1.2

        if (len(self.plot_cdf_data) == 5):
            plot_cdf.lines[4].strokeColor = colors.green
        plot_cdf.width = plot_dim
        plot_cdf.height = plot_dim
        plot_cdf.xValueAxis.valueMax = 1.0
        plot_cdf.xValueAxis.valueMin = 0.0
        plot_cdf.yValueAxis.valueMax = 1.0
        plot_cdf.yValueAxis.valueMin = 0.0
        d_cdf = Drawing(plot_dim, plot_dim)
        d_cdf.add(plot_cdf)

        # construct pdf plot
        plot_pdf_pos = (left_margin * inch,
                        height - 3.0 * (plot_dim + 0.5 * inch))
        plot_pdf = LinePlot()
        plot_pdf.data = self.plot_pdf_data
        plot_pdf.lines[1].strokeColor = colors.blue
        plot_pdf.lines[0].strokeColor = None
        plot_pdf.lines[0].symbol = makeMarker('Circle')
        plot_pdf.lines[0].symbol.strokeColor = colors.red
        plot_pdf.lines[0].symbol.size = 1
        plot_pdf.width = plot_dim
        plot_pdf.height = plot_dim
        plot_pdf.xValueAxis.valueMax = 1.0
        plot_pdf.xValueAxis.valueMin = 0.0
        d_pdf = Drawing(2 * plot_dim, plot_dim)
        d_pdf.add(plot_pdf)

        # add legend
        legend = Legend()
        legend.alignment = 'right'
        legend.colorNamePairs = [
            (std_colors[0],
             'Inliers (%d' % int(self.fraction * 100.0) + '% used for fit)'),
            (std_colors[1], 'Other inliers'),
            (std_colors[2], 'Outliers, reject next round'),
        ]
        for key in self.framework.keys():
            legend.colorNamePairs.append(
                (self.framework[key]["color"],
                 "%s" % self.framework[key]["status"]))

        legend.x = plot_dim - 1.0 * inch
        legend.y = plot_dim
        legend.columnMaximum = 8
        d_pdf.add(legend)

        # add titles
        title_pos = (plot_dim / 2.0, plot_dim + 0.25 * inch)
        title_dxdy = String(title_pos[0], title_pos[1], 'dx vs. dy (all)')
        title_dxdy.fontSize = 15
        title_dxdy.textAnchor = 'middle'
        d_dxdy.add(title_dxdy)
        title_cdf = String(title_pos[0], title_pos[1], 'cdf (good)')
        title_cdf.fontSize = 15
        title_cdf.textAnchor = 'middle'
        d_cdf.add(title_cdf)
        title_pdf = String(title_pos[0], title_pos[1], 'pdf (good)')
        title_pdf.fontSize = 15
        title_pdf.textAnchor = 'middle'
        d_pdf.add(title_pdf)

        # draw everything
        renderPDF.draw(d_dxdy, canvas, plot_dxdy_pos[0], plot_dxdy_pos[1])
        renderPDF.draw(d_cdf, canvas, plot_cdf_pos[0], plot_cdf_pos[1])
        renderPDF.draw(d_pdf, canvas, plot_pdf_pos[0], plot_pdf_pos[1])
Beispiel #26
0
    def draw(self):
        fillColor = self.fillColor
        strokeColor = self.strokeColor

        g = Group()
        g.add(
            Rect(x=0,
                 y=0,
                 fillColor=self.fillColor,
                 strokeColor=self.fillColor,
                 width=self.borderWidth,
                 height=self.height))
        g.add(
            Rect(x=0,
                 y=self.height - self.borderWidth,
                 fillColor=self.fillColor,
                 strokeColor=self.fillColor,
                 width=self.width,
                 height=self.borderWidth))

        g2 = Group()
        rl = RL_CorpLogo()
        rl.height = 1.25 * cm
        rl.width = 1.9 * cm
        rl.draw()
        g2.add(rl)
        g.add(g2)
        g2.shift(x=(self.width - (rl.width + (self.width / 42))),
                 y=(self.height - (rl.height + (self.height / 42))))

        g.add(
            String(x=self.borderWidth / 5.0,
                   y=((self.height - (rl.height + (self.height / 42))) +
                      ((38 / 90.5) * rl.height)),
                   fontSize=6,
                   fillColor=self.altStrokeColor,
                   fontName="Helvetica-BoldOblique",
                   textAnchor='start',
                   text=self._strapline))

        leftText = ["Tel:", "Mobile:", "Fax:", "Email:", "Web:"]
        leftDetails = [
            self.telephone, self.mobile, self.fax, self.email, self.web
        ]
        leftText.reverse()
        leftDetails.reverse()
        for f in range(len(leftText), 0, -1):
            g.add(
                String(x=self.borderWidth + (self.borderWidth / 5.0),
                       y=(self.borderWidth / 5.0) + ((f - 1) * (5 * 1.2)),
                       fontSize=5,
                       fillColor=self.strokeColor,
                       fontName="Helvetica",
                       textAnchor='start',
                       text=leftText[f - 1]))
            g.add(
                String(x=self.borderWidth + (self.borderWidth / 5.0) +
                       self.borderWidth,
                       y=(self.borderWidth / 5.0) + ((f - 1) * (5 * 1.2)),
                       fontSize=5,
                       fillColor=self.strokeColor,
                       fontName="Helvetica",
                       textAnchor='start',
                       text=leftDetails[f - 1]))

        rightText = self.rh_blurb_bottom
        rightText.reverse()
        for f in range(len(rightText), 0, -1):
            g.add(
                String(x=self.width - ((self.borderWidth / 5.0)),
                       y=(self.borderWidth / 5.0) + ((f - 1) * (5 * 1.2)),
                       fontSize=5,
                       fillColor=self.strokeColor,
                       fontName="Helvetica",
                       textAnchor='end',
                       text=rightText[f - 1]))

        ty = (self.height - self.borderWidth - (self.borderWidth / 5.0) + 2)
        #       g.add(Line(self.borderWidth, ty, self.borderWidth+(self.borderWidth/5.0), ty))
        #       g.add(Line(self.borderWidth+(self.borderWidth/5.0), ty, self.borderWidth+(self.borderWidth/5.0),
        #                         ty+(self.borderWidth/5.0)))
        #       g.add(Line(self.borderWidth, ty-10,
        #                         self.borderWidth+(self.borderWidth/5.0), ty-10))

        rightText = self.rh_blurb_top
        for f in range(1, (len(rightText) + 1)):
            g.add(
                String(x=self.width - (self.borderWidth / 5.0),
                       y=ty - ((f) * (5 * 1.2)),
                       fontSize=5,
                       fillColor=self.strokeColor,
                       fontName="Helvetica",
                       textAnchor='end',
                       text=rightText[f - 1]))

        g.add(
            String(x=self.borderWidth + (self.borderWidth / 5.0),
                   y=ty - 10,
                   fontSize=10,
                   fillColor=self.strokeColor,
                   fontName="Helvetica",
                   textAnchor='start',
                   text=self.name))

        ty1 = ty - 10 * 1.2

        g.add(
            String(x=self.borderWidth + (self.borderWidth / 5.0),
                   y=ty1 - 8,
                   fontSize=8,
                   fillColor=self.strokeColor,
                   fontName="Helvetica",
                   textAnchor='start',
                   text=self.position))
        if self.border:
            g.add(
                Rect(x=0,
                     y=0,
                     fillColor=None,
                     strokeColor=black,
                     width=self.width,
                     height=self.height))
        g.shift(self.x, self.y)
        return g
Beispiel #27
0
    def __init__(self,width=400,height=200,*args,**kw):
        apply(Drawing.__init__,(self,width,height)+args,kw)
        self.add(LinePlot(), name='chart')

        self.add(String(200,150,''), name='title')

        #set any shapes, fonts, colors you want here.  We'll just
        #set a title font and place the chart within the drawing.
        #pick colors for all the lines, do as many as you need
        self.chart.x = 30
        self.chart.y = 40
        self.chart.width = self.width-2*self.chart.x
        self.chart.height = self.height-2*self.chart.y
        self.chart.lines[0].strokeColor = colors.blue
        self.chart.lines[1].strokeColor = colors.green
        self.chart.lines[2].strokeColor = colors.yellow
        self.chart.lines[3].strokeColor = colors.red
        self.chart.lines[4].strokeColor = colors.black
        self.chart.lines[5].strokeColor = colors.orange
        self.chart.lines[6].strokeColor = colors.cyan
        self.chart.lines[7].strokeColor = colors.magenta
        self.chart.lines[8].strokeColor = colors.brown

        self.chart.fillColor = colors.white
        self.title.fontSize = 15
        self.chart.data = [((0, 50), (100,100), (200,200), (250,210), (300,300), (400,500))]
        self.chart.xValueAxis.labels.fontSize = 12
        self.chart.xValueAxis.forceZero = 0
        self.chart.xValueAxis.gridEnd = 115
        self.chart.xValueAxis.tickDown = 3
        self.chart.xValueAxis.visibleGrid = 1
        self.chart.yValueAxis.tickLeft = 3
        self.chart.yValueAxis.labels.fontSize = 12
        self.title.x = self.width/2
        self.title.y = self.height - 50
        self.title.textAnchor ='middle'
        self.add(Legend(),name='Legend')
        self.Legend.fontSize = 12
        self.Legend.x = self.width
        self.Legend.y = 85
        self.Legend.dxTextSpace = 5
        self.Legend.dy = 5
        self.Legend.dx = 5
        self.Legend.deltay = 5
        self.Legend.alignment ='right'
        self.add(Label(),name='XLabel')
        self.XLabel.fontSize = 12
        self.XLabel.x = 200
        self.XLabel.y = 5
        self.XLabel.textAnchor ='middle'
        #self.XLabel.height = 20
        self.XLabel._text = ""
        self.add(Label(),name='YLabel')
        self.YLabel.fontSize = 12
        self.YLabel.x = 2
        self.YLabel.y = 80
        self.YLabel.angle = 90
        self.YLabel.textAnchor ='middle'
        self.YLabel._text = ""
        self.chart.yValueAxis.forceZero = 1
        self.chart.xValueAxis.forceZero = 1
Beispiel #28
0
 def __init__(self, width=400, height=200, *args, **kw):
     Drawing.__init__(*(self, width, height) + args, **kw)
     fs = 10
     ld = 1.2 * fs
     sysL = [
         'byteorder', 'copyright', 'displayhook'
         'exec_prefix', 'executable', 'hexversion', 'maxint', 'maxunicode',
         'platform', 'prefix', 'version', 'version_info', 'warnoptions'
     ]
     n0 = 7 + len(sysL)
     self.width = 6.5 * 72
     self.height = (n0 + len(sys.path) + len(sys.argv) + len(T1SearchPath) +
                    len(TTFSearchPath)) * ld
     self._add(self,
               String(10,
                      self.height - ld,
                      'cwd="%s"' % os.getcwd(),
                      fontSize=fs),
               name=None,
               validate=None,
               desc=None)
     self._add(self,
               String(10,
                      self.height - 2 * ld,
                      'argv[0]="%s"' % sys.argv[0],
                      fontSize=fs),
               name=None,
               validate=None,
               desc=None)
     self._add(
         self,
         String(10,
                self.height - 3 * ld,
                'sample path="%s"' %
                getattr(__main__, '_guiedit_sample_path', '<unknown>'),
                fontSize=fs),
         name=None,
         validate=None,
         desc=None)
     self._add(self,
               String(10,
                      self.height - 4 * ld,
                      '_rl_embed_location="%s"' %
                      getattr(__main__, '_rl_embed_location', '<unknown>'),
                      fontSize=fs),
               name=None,
               validate=None,
               desc=None)
     self._add(self,
               String(10,
                      self.height - 5 * ld,
                      'reportlab location="%s"' %
                      os.path.dirname(reportlab.__file__),
                      fontSize=fs),
               name=None,
               validate=None,
               desc=None)
     self._add(self,
               String(10,
                      self.height - 6 * ld,
                      'reportPackages.rlextra location="%s"' %
                      os.path.dirname(reportPackages.rlextra.__file__),
                      fontSize=fs),
               name=None,
               validate=None,
               desc=None)
     if 'do error' in sys.argv:
         raise ValueError('Deliberate Error For Testing')
     for i in range(len(sysL)):
         self._add(self,
                   String(10,
                          self.height - (7 + i) * ld,
                          'sys.%s="%s"' %
                          (sysL[i], getattr(sys, sysL[i], '<missing>')),
                          fontSize=fs),
                   name=None,
                   validate=None,
                   desc=None)
     for i in range(len(sys.argv)):
         self._add(self,
                   String(10,
                          self.height - (n0 + i) * ld,
                          'sys.argv[%d]="%s"' % (i, sys.argv[i]),
                          fontSize=fs),
                   name=None,
                   validate=None,
                   desc=None)
     for i in range(len(sys.path)):
         self._add(self,
                   String(10,
                          self.height - (n0 + i + len(sys.argv)) * ld,
                          'sys.path[%d]="%s"' % (i, sys.path[i]),
                          fontSize=fs),
                   name=None,
                   validate=None,
                   desc=None)
     for i in range(len(T1SearchPath)):
         self._add(self,
                   String(10,
                          self.height - ld *
                          (n0 + i + len(sys.argv) + len(sys.path)),
                          'T1SearchPath[%d]="%s"' % (i, T1SearchPath[i]),
                          fontSize=fs),
                   name=None,
                   validate=None,
                   desc=None)
     for i in range(len(TTFSearchPath)):
         self._add(self,
                   String(10,
                          self.height - ld *
                          (n0 + i + len(sys.argv) + len(sys.path) +
                           len(T1SearchPath)),
                          'TTFSearchPath[%d]="%s"' % (i, TTFSearchPath[i]),
                          fontSize=fs),
                   name=None,
                   validate=None,
                   desc=None)
from reportlab.graphics import renderPDF
from reportlab.graphics.shapes import Drawing, String

d = Drawing(100, 100)
s = String(50, 50, 'Hello,world', textAnchor='middle')
d.add(s)
renderPDF.drawToFile(d, 'hello.pdf', 'A simple PDF file')
 def __init__(self, width=400, height=200, *args, **kw):
     Drawing.__init__(self, width, height, *args, **kw)
     self.transform = (1, 0, 0, 1, 0, 0)
     self.add(
         Rect(50,
              20,
              300,
              155,
              rx=0,
              ry=0,
              fillColor=None,
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(50,
              20,
              50,
              10,
              rx=0,
              ry=0,
              fillColor=Color(1, 0, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(50,
              66,
              300,
              10,
              rx=0,
              ry=0,
              fillColor=Color(1, 0, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(50,
              32,
              100,
              10,
              rx=0,
              ry=0,
              fillColor=Color(0, .501961, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(50,
              78,
              250,
              10,
              rx=0,
              ry=0,
              fillColor=Color(0, .501961, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(50,
              44,
              150,
              10,
              rx=0,
              ry=0,
              fillColor=Color(0, 0, 1, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(50,
              90,
              200,
              10,
              rx=0,
              ry=0,
              fillColor=Color(0, 0, 1, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(50,
              56,
              200,
              10,
              rx=0,
              ry=0,
              fillColor=Color(1, 0, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Rect(50,
              102,
              150,
              10,
              rx=0,
              ry=0,
              fillColor=Color(1, 0, 0, 1),
              fillOpacity=None,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(49,
              20,
              49,
              175,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(49,
              20,
              44,
              20,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(49,
              97.5,
              44,
              97.5,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(49,
              175,
              44,
              175,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 44, 58.75)
     v0.add(
         String(-20,
                -4,
                'Ying',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 44, 136.25)
     v0.add(
         String(-21.66,
                -4,
                'Yang',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     self.add(
         Line(50,
              20,
              350,
              20,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=0,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(50,
              20,
              50,
              15,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(125,
              20,
              125,
              15,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(200,
              20,
              200,
              15,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(275,
              20,
              275,
              15,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     self.add(
         Line(350,
              20,
              350,
              15,
              strokeColor=Color(0, 0, 0, 1),
              strokeWidth=1,
              strokeLineCap=0,
              strokeLineJoin=0,
              strokeMiterLimit=10,
              strokeDashArray=None,
              strokeOpacity=None))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 50, 15)
     v0.add(
         String(-2.5,
                -10,
                '0',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 125, 15)
     v0.add(
         String(-5,
                -10,
                '15',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 200, 15)
     v0.add(
         String(-5,
                -10,
                '30',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 275, 15)
     v0.add(
         String(-5,
                -10,
                '45',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))
     v0 = self._nn(Group())
     v0.transform = (1, 0, 0, 1, 350, 15)
     v0.add(
         String(-5,
                -10,
                '60',
                textAnchor='start',
                fontName='Times-Roman',
                fontSize=10,
                fillColor=Color(0, 0, 0, 1)))