def renderUse(self, node, group=None, clipping=None): if group is None: group = Group() xlink_href = node.attrib.get('{http://www.w3.org/1999/xlink}href') if not xlink_href: return if xlink_href[1:] not in self.definitions: # The missing definition should appear later in the file self.waiting_use_nodes[xlink_href[1:]].append((node, group)) return group if clipping: group.add(clipping) if len(node.getchildren()) == 0: # Append a copy of the referenced node as the <use> child (if not already done) node.append(copy.deepcopy(self.definitions[xlink_href[1:]])) self.renderNode(node.getchildren()[-1], parent=group) getAttr = node.getAttribute transform = getAttr("transform") x, y = map(getAttr, ("x", "y")) if x or y: transform += " translate(%s, %s)" % (x or '0', y or '0') if transform: self.shape_converter.applyTransformOnGroup(transform, group) return group
def convertPolyline(self, node): getAttr = node.getAttribute points = getAttr("points") points = points.replace(',', ' ') points = points.split() points = list(map(self.attrConverter.convertLength, points)) if len(points) % 2 != 0 or len(points) == 0: # Odd number of coordinates or no coordinates, invalid polyline return None polyline = PolyLine(points) self.applyStyleOnShape(polyline, node) has_fill = self.attrConverter.findAttr(node, 'fill') not in ('', 'none') if has_fill: # ReportLab doesn't fill polylines, so we are creating a polygon # polygon copy of the polyline, but without stroke. group = Group() polygon = Polygon(points) self.applyStyleOnShape(polygon, node) polygon.strokeColor = None group.add(polygon) group.add(polyline) return group return polyline
def makeSwatchSample(self,rowNo, x, y, width, height): styleCount = len(self.lines) styleIdx = rowNo % styleCount rowColor = self.lines[styleIdx].strokeColor if self.joinedLines: dash = getattr(self.lines[styleIdx], 'strokeDashArray', getattr(self.lines,'strokeDashArray',None)) strokeWidth= getattr(self.lines[styleIdx], 'strokeWidth', getattr(self.lines[styleIdx], 'strokeWidth',None)) L = Line(x,y,x+width,y+height,strokeColor=rowColor,strokeLineCap=0) if strokeWidth: L.strokeWidth = strokeWidth if dash: L.strokeDashArray = dash else: L = None if hasattr(self.lines[styleIdx], 'symbol'): S = self.lines[styleIdx].symbol elif hasattr(self.lines, 'symbol'): S = self.lines.symbol else: S = None if S: S = uSymbol2Symbol(S,x+width/2.,y+height/2.,rowColor) if S and L: g = Group() g.add(S) g.add(L) return g return S or L
def makeInnerTiles(self): # inner grid lines group = Group() w, h = self.width, self.height # inner grid stripes (solid rectangles) if self.useRects == 1: cols = self.stripeColors if self.orientation == 'vertical': r = self.makeLinePosList(self.x, isX=1) elif self.orientation == 'horizontal': r = self.makeLinePosList(self.y, isX=0) dist = makeDistancesList(r) i = 0 for j in range(len(dist)): if self.orientation == 'vertical': x = r[j] stripe = Rect(x, self.y, dist[j], h) elif self.orientation == 'horizontal': y = r[j] stripe = Rect(self.x, y, w, dist[j]) stripe.fillColor = cols[i % len(cols)] stripe.strokeColor = None group.add(stripe) i = i + 1 return group
def rotatedEnclosingRect(P, angle, rect): ''' given P a sequence P of x,y coordinate pairs and an angle in degrees find the centroid of P and the axis at angle theta through it find the extreme points of P wrt axis parallel distance and axis orthogonal distance. Then compute the least rectangle that will still enclose P when rotated by angle. The class R ''' from math import pi, cos, sin, tan x0, y0 = centroid(P) theta = (angle/180.)*pi s,c=sin(theta),cos(theta) def parallelAxisDist(xy,s=s,c=c,x0=x0,y0=y0): x,y = xy return (s*(y-y0)+c*(x-x0)) def orthogonalAxisDist(xy,s=s,c=c,x0=x0,y0=y0): x,y = xy return (c*(y-y0)+s*(x-x0)) L = map(parallelAxisDist,P) L.sort() a0, a1 = L[0], L[-1] L = map(orthogonalAxisDist,P) L.sort() b0, b1 = L[0], L[-1] rect.x, rect.width = a0, a1-a0 rect.y, rect.height = b0, b1-b0 g = Group(transform=(c,s,-s,c,x0,y0)) g.add(rect) return g
def getTalkRect(self, startTime, duration, trackId, text): "Return shapes for a specific talk" g = Group() y_bottom = self.scaleTime(startTime + duration) y_top = self.scaleTime(startTime) y_height = y_top - y_bottom if trackId is None: #spans all columns x = self._colLeftEdges[1] width = self.width - self._colWidths[0] else: #trackId is 1-based and these arrays have the margin info in column #zero, so no need to add 1 x = self._colLeftEdges[trackId] width = self._colWidths[trackId] lab = Label() lab.setText(text) lab.setOrigin(x + 0.5*width, y_bottom+0.5*y_height) lab.boxAnchor = 'c' lab.width = width lab.height = y_height lab.fontSize = 6 r = Rect(x, y_bottom, width, y_height, fillColor=colors.cyan) g.add(r) g.add(lab) #now for a label # would expect to color-code and add text return g
def ttf_ocr(font, key=None): gs = font.getGlyphSet() keys = [key for key in gs.keys() if key.startswith("uni")] if key is None else [key] c = [] for i, key in enumerate(keys): if key not in gs: logger.info("No this key: %s" % key) c.append("") continue pen = ReportLabPen(gs, Path(fillColor=colors.black, strokeWidth=0.01)) g = gs[key] g.draw(pen) w, h = 50, 50 g = Group(pen.path) g.translate(10, 10) g.scale(0.02, 0.02) d = Drawing(w, h) d.add(g) renderPM.drawToFile(d, png_file.name, fmt="PNG") result = os.popen("tesseract %s stdout -l chi_sim -psm 5" % png_file.name).read().strip().decode("utf-8", "ignore") if len(result) != 1: result = os.popen("tesseract %s stdout -l chi_sim -psm 8" % png_file.name).read().strip().decode("utf-8", "ignore") logger.info("key: %s, result: %s" % (key, result)) c.append(result) if key is not None: return c[0] return c
def makeCircularString(x, y, radius, angle, text, fontName, fontSize, inside=0, G=None,textAnchor='start'): '''make a group with circular text in it''' if not G: G = Group() angle %= 360 pi180 = pi/180 phi = angle*pi180 width = stringWidth(text, fontName, fontSize) sig = inside and -1 or 1 hsig = sig*0.5 sig90 = sig*90 if textAnchor!='start': if textAnchor=='middle': phi += sig*(0.5*width)/radius elif textAnchor=='end': phi += sig*float(width)/radius elif textAnchor=='numeric': phi += sig*float(numericXShift(textAnchor,text,width,fontName,fontSize,None))/radius for letter in text: width = stringWidth(letter, fontName, fontSize) beta = float(width)/radius h = Group() h.add(String(0, 0, letter, fontName=fontName,fontSize=fontSize,textAnchor="start")) h.translate(x+cos(phi)*radius,y+sin(phi)*radius) #translate to radius and angle h.rotate((phi-hsig*beta)/pi180-sig90) # rotate as needed G.add(h) #add to main group phi -= sig*beta #increment return G
def makeSwatchSample(self, rowNo, x, y, width, height): baseStyle = self.strands styleIdx = rowNo % len(baseStyle) style = baseStyle[styleIdx] strokeColor = getattr(style, 'strokeColor', getattr(baseStyle,'strokeColor',None)) fillColor = getattr(style, 'fillColor', getattr(baseStyle,'fillColor',None)) strokeDashArray = getattr(style, 'strokeDashArray', getattr(baseStyle,'strokeDashArray',None)) strokeWidth = getattr(style, 'strokeWidth', getattr(baseStyle, 'strokeWidth',0)) symbol = getattr(style, 'symbol', getattr(baseStyle, 'symbol',None)) ym = y+height/2.0 if fillColor is None and strokeColor is not None and strokeWidth>0: bg = Line(x,ym,x+width,ym,strokeWidth=strokeWidth,strokeColor=strokeColor, strokeDashArray=strokeDashArray) elif fillColor is not None: bg = Rect(x,y,width,height,strokeWidth=strokeWidth,strokeColor=strokeColor, strokeDashArray=strokeDashArray,fillColor=fillColor) else: bg = None if symbol: symbol = uSymbol2Symbol(symbol,x+width/2.,ym,color) if bg: g = Group() g.add(bg) g.add(symbol) return g return symbol or bg
def draw(self): self.qr.make() g = Group() color = self.barFillColor border = self.barBorder width = self.barWidth height = self.barHeight x = self.x y = self.y g.add(SRect(x, y, width, height, fillColor=None)) moduleCount = self.qr.getModuleCount() minwh = float(min(width, height)) boxsize = minwh / (moduleCount + border * 2.0) offsetX = (width - minwh) / 2.0 offsetY = (minwh - height) / 2.0 for r, row in enumerate(self.qr.modules): row = map(bool, row) c = 0 for t, tt in itertools.groupby(row): isDark = t count = len(list(tt)) if isDark: x = (c + border) * boxsize y = (r + border + 1) * boxsize s = SRect(offsetX + x, offsetY + height - y, count * boxsize, boxsize) g.add(s) c += count return g
def makeSwatchSample(self,rowNo, x, y, width, height): baseStyle = self.lines styleIdx = rowNo % len(baseStyle) style = baseStyle[styleIdx] color = style.strokeColor y = y+height/2. if self.joinedLines: dash = getattr(style, 'strokeDashArray', getattr(baseStyle,'strokeDashArray',None)) strokeWidth= getattr(style, 'strokeWidth', getattr(style, 'strokeWidth',None)) L = Line(x,y,x+width,y,strokeColor=color,strokeLineCap=0) if strokeWidth: L.strokeWidth = strokeWidth if dash: L.strokeDashArray = dash else: L = None if hasattr(style, 'symbol'): S = style.symbol elif hasattr(baseStyle, 'symbol'): S = baseStyle.symbol else: S = None if S: S = uSymbol2Symbol(S,x+width/2.,y,color) if S and L: g = Group() g.add(L) g.add(S) return g return S or L
def _Flag_Spain(self): s = _size g = Group() w = self._width = s*1.5 g.add(Rect(0, 0, width=w, height=s, fillColor = colors.red, strokeColor = None, strokeWidth=0)) g.add(Rect(0, (s/4), width=w, height=s/2, fillColor = colors.yellow, strokeColor = None, strokeWidth=0)) return g
def _Flag_Japan(self): s = _size g = Group() w = self._width = s*1.5 g.add(Rect(0,0,w,s,fillColor=colors.mintcream,strokeColor=None, strokeWidth=0)) g.add(Circle(cx=w/2,cy=s/2,r=0.3*w,fillColor=colors.red,strokeColor=None, strokeWidth=0)) return g
def __init__(self,width=224,height=124,*args,**kw): Drawing.__init__(self,width,height,*args,**kw) points = [122.0, 87.0, 122.0, 88.0, 123.0, 88.0, 123.0, 89.0, 124.0, 89.0, 124.0, 90.0, 126.0, 90.0, 126.0, 89.0, 128.0, 88.0, 128.0, 89.0, 129.0, 89.0, 129.0, 91.0, 128.0, 91.0, 128.0, 92.0, 130.0, 99.0, 130.0, 100.0, 129.0, 100.0, 126.0, 103.0, 125.0, 103.0, 125.0, 104.0, 126.0, 106.0, 130.0, 87.0, 129.0, 87.0, 129.0, 86.0, 126.0, 86.0, 126.0, 87.0] grp = Group(Polygon(points, fillColor=toColor('red'))) grp.scale(1, -1) grp.translate(0, -124) self.add(grp)
def annotation(self,xScale,yScale): x = xScale(xv) y = yScale(yv) g = Group() xA = xScale.im_self #the x axis g.add(Line(xA._x,y,xA._x+xA._length,y,strokeColor=strokeColor,strokeWidth=strokeWidth)) yA = yScale.im_self #the y axis g.add(Line(x,yA._y,x,yA._y+yA._length,strokeColor=strokeColor,strokeWidth=strokeWidth)) return g
def _Flag_Turkey(self): s = _size g = Group() box = Rect(0, 0, s*2, s, fillColor = colors.red, strokeColor = colors.black, strokeWidth=0) g.add(box) whitecircle = Circle(cx=((s*0.35)*2), cy=s/2, r=s*0.3, fillColor = colors.mintcream, strokeColor = None, strokeWidth=0) g.add(whitecircle) redcircle = Circle(cx=((s*0.39)*2), cy=s/2, r=s*0.24, fillColor = colors.red, strokeColor = None, strokeWidth=0) g.add(redcircle) ws = Star() ws.angle = 15 ws.size = s/5 ws.x = (s*0.5)*2+ws.size/2 ws.y = (s*0.5) ws.fillColor = colors.mintcream ws.strokeColor = None g.add(ws) return g
def _Flag_Palestine(self): s = _size g = Group() box = Rect(0, s/3, s*2, s/3, fillColor = colors.mintcream, strokeColor = None, strokeWidth=0) g.add(box) greenbox = Rect(0, 0, width=s*2, height=s/3, fillColor = colors.limegreen, strokeColor = None, strokeWidth=0) g.add(greenbox) blackbox = Rect(0, 2*s/3, width=s*2, height=s/3, fillColor = colors.black, strokeColor = None, strokeWidth=0) g.add(blackbox) redwedge = Polygon(points = [ 0, 0, 2*s/3, (s/2), 0, s], fillColor = colors.red, strokeColor = None, strokeWidth=0) g.add(redwedge) return g
def _Flag_Cuba(self): s = _size g = Group() for i in range(5): stripe = Rect(0, i*s/5, width=s*2, height=s/5, fillColor = [colors.darkblue, colors.mintcream][i%2], strokeColor = None, strokeWidth=0) g.add(stripe) redwedge = Polygon(points = [ 0, 0, 4*s/5, (s/2), 0, s], fillColor = colors.red, strokeColor = None, strokeWidth=0) g.add(redwedge) star = Star() star.x = 2.5*s/10 star.y = s/2 star.size = 3*s/10 star.fillColor = colors.white g.add(star) box = Rect(0, 0, s*2, s, fillColor = None, strokeColor = colors.black, strokeWidth=0) g.add(box) return g
def _Flag_Belgium(self): s = _size g = Group() box = Rect(0, 0, s * 2, s, fillColor=colors.black, strokeColor=colors.black, strokeWidth=0) g.add(box) box1 = Rect(0, 0, width=(s / 3.0) * 2.0, height=s, fillColor=colors.black, strokeColor=None, strokeWidth=0) g.add(box1) box2 = Rect( ((s / 3.0) * 2.0), 0, width=(s / 3.0) * 2.0, height=s, fillColor=colors.gold, strokeColor=None, strokeWidth=0, ) g.add(box2) box3 = Rect( ((s / 3.0) * 4.0), 0, width=(s / 3.0) * 2.0, height=s, fillColor=colors.red, strokeColor=None, strokeWidth=0 ) g.add(box3) return g
def _Flag_France(self): s = _size g = Group() box = Rect(0, 0, s * 2, s, fillColor=colors.navy, strokeColor=colors.black, strokeWidth=0) g.add(box) bluebox = Rect(0, 0, width=((s / 3.0) * 2.0), height=s, fillColor=colors.blue, strokeColor=None, strokeWidth=0) g.add(bluebox) whitebox = Rect( ((s / 3.0) * 2.0), 0, width=((s / 3.0) * 2.0), height=s, fillColor=colors.mintcream, strokeColor=None, strokeWidth=0, ) g.add(whitebox) redbox = Rect( ((s / 3.0) * 4.0), 0, width=((s / 3.0) * 2.0), height=s, fillColor=colors.red, strokeColor=None, strokeWidth=0, ) g.add(redbox) return g
def draw(self): P = self.points P = list(map(lambda i, P=P: (P[i], P[i + 1]), range(0, len(P), 2))) path = definePath( [("moveTo",) + P[0]] + [("lineTo",) + x for x in P[1:]] + ["closePath"], fillColor=None, strokeColor=None ) path.isClipPath = 1 g = Group() g.add(path) angle = self.angle orientation = "vertical" if angle == 180: angle = 0 elif angle in (90, 270): orientation = "horizontal" angle = 0 rect = ShadedRect(strokeWidth=0, strokeColor=None, orientation=orientation) for k in "fillColorStart", "fillColorEnd", "numShades", "cylinderMode": setattr(rect, k, getattr(self, k)) g.add(rotatedEnclosingRect(P, angle, rect)) g.add(EmptyClipPath) path = path.copy() path.isClipPath = 0 path.strokeColor = self.strokeColor path.strokeWidth = self.strokeWidth g.add(path) return g
def draw(self): P = self.points P = map(lambda i, P=P:(P[i],P[i+1]),xrange(0,len(P),2)) path = definePath([('moveTo',)+P[0]]+map(lambda x: ('lineTo',)+x,P[1:])+['closePath'], fillColor=None, strokeColor=None) path.isClipPath = 1 g = Group() g.add(path) angle = self.angle orientation = 'vertical' if angle==180: angle = 0 elif angle in (90,270): orientation ='horizontal' angle = 0 rect = ShadedRect(strokeWidth=0,strokeColor=None,orientation=orientation) for k in 'fillColorStart', 'fillColorEnd', 'numShades', 'cylinderMode': setattr(rect,k,getattr(self,k)) g.add(rotatedEnclosingRect(P, angle, rect)) g.add(EmptyClipPath) path = path.copy() path.isClipPath = 0 path.strokeColor = self.strokeColor path.strokeWidth = self.strokeWidth g.add(path) return g
def draw(self): dx = self.width / 16.0 dy = self.height / 16.0 g = Group() g.add(Rect(self.x, self.y, self.width, self.height, fillColor=None, strokeColor=colors.black)) for x in range(16): for y in range(16): charValue = y * 16 + x if charValue > 32: s = String(self.x + x * dx, self.y + (self.height - y * dy), chr(charValue)) g.add(s) return g
def makeBackground(self): g = Group() g.add(HorizontalLineChart.makeBackground(self)) valAxis = self.valueAxis valTickPositions = valAxis._tickValues for y in valTickPositions: y = valAxis.scale(y) g.add(Line(self.x, y, self.x + self.width, y, strokeColor=self.strokeColor)) return g
def _borderDraw(self,f): s = self.size # abbreviate as we will use this a lot g = Group() g.add(f) x, y, sW = self.x+self.dx, self.y+self.dy, self.strokeWidth/2. g.insert(0,Rect(-sW, -sW, width=getattr(self,'_width',2*s)+3*sW, height=getattr(self,'_height',s)+2*sW, fillColor = None, strokeColor = self.strokeColor, strokeWidth=sW*2)) g.shift(x,y) g.scale(s/_size, s/_size) return g
def getCaptcha(n=5,fontName='Courier',fontSize=14,text=None,fillColor=None): '''return n random chars in a string and in a byte string structured as a GIF image''' from reportlab.graphics.shapes import Drawing, Group, String, \ rotate, skewX, skewY, mmult, translate, Rect if not text: from random import randint, uniform text=''.join([_allowed[randint(0,_mx)] for i in range(n)]) else: uniform = lambda l,h: 0.5*(l+h) n = len(text) baseline = 0 x = 0 G0 = Group() for c in text: x += 1 A = translate(x,uniform(baseline-5,baseline+5)) A = mmult(A,rotate(uniform(-15,15))) A = mmult(A,skewX(uniform(-8,8))) A = mmult(A,skewY(uniform(-8,8))) G = Group(transform=A) G.add(String(0,0,c,fontname=fontName,fontSize=fontSize)) G0.add(G) x0,y0,x1,y1 = G0.getBounds() x = 1+x1 G0.transform=translate(2-x0,2-y0) W = 4+x1-x0 H = 4+y1-y0 D = Drawing(W,H) if fillColor: from reportlab.lib.colors import toColor D.add(Rect(0,0,W,H, fillColor = toColor(fillColor),strokeColor=None)) D.add(G0) return text, D.asString('gif')
def renderG(self, node, clipping=None, display=1): getAttr = node.getAttribute id, transform = map(getAttr, ("id", "transform")) gr = Group() if clipping: gr.add(clipping) for child in node.getchildren(): item = self.renderNode(child, parent=gr) if item and display: gr.add(item) if transform: self.shape_converter.applyTransformOnGroup(transform, gr) return gr
def __init__(self, filename): self.filename = filename self.level = 0 self.styles = {} self.mainGroup = Group() self.drawing = None self.root = None
def _Flag_Italy(self): s = _size g = Group() g.add(Rect(0,0,s*2,s,fillColor=colors.forestgreen,strokeColor=None, strokeWidth=0)) g.add(Rect((2*s)/3, 0, width=(s*4)/3, height=s, fillColor = colors.mintcream, strokeColor = None, strokeWidth=0)) g.add(Rect((4*s)/3, 0, width=(s*2)/3, height=s, fillColor = colors.red, strokeColor = None, strokeWidth=0)) return g
def draw(self): self.computeSize() g = Group() # time column g.add(Rect(self.x, self.y, self._colWidths[0], self.height - self.trackRowHeight, fillColor=colors.cornsilk)) # track headers x = self.x + self._colWidths[0] y = self.y + self.height - self.trackRowHeight for trk in range(self._trackCount): wid = self._colWidths[trk+1] r = Rect(x, y, wid, self.trackRowHeight, fillColor=colors.yellow) s = String(x + 0.5*wid, y, 'Track %d' % trk, align='middle') g.add(r) g.add(s) x = x + wid for talk in self._talksVisible: (title, speaker, trackId, day, start, duration) = talk r = self.getTalkRect(start, duration, trackId, title + '\n' + speaker) g.add(r) 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( Wedge(200, 100, 50, -147.8571, -135, 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, -160.7143, -147.8571, 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, -173.5714, -160.7143, 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, -186.4286, -173.5714, 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, -199.2857, -186.4286, 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, -212.1429, -199.2857, 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, -225, -212.1429, 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, -237.8571, -225, 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, -250.7143, -237.8571, 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, -263.5714, -250.7143, 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, -276.4286, -263.5714, 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, -289.2857, -276.4286, 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, -302.1429, -289.2857, 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, -315, -302.1429, 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, -327.8571, -315, 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, -340.7143, -327.8571, 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, -353.5714, -340.7143, 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, -366.4286, -353.5714, 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, -379.2857, -366.4286, 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, -392.1429, -379.2857, 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, -405, -392.1429, 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, -417.8571, -405, 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, -430.7143, -417.8571, 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, -443.5714, -430.7143, 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, -456.4286, -443.5714, 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, -469.2857, -456.4286, 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, -482.1429, -469.2857, 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, -495, -482.1429, 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( Line(160.9084, 68.82551, 150.4542, 65.59061, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(150.4542, 65.59061, 140, 65.59061, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(154.9516, 78.30581, 147.4758, 76.96698, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(147.4758, 76.96698, 140, 76.96698, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(151.2536, 88.87395, 145.6268, 89.64874, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(145.6268, 89.64874, 140, 89.64874, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(150, 100, 145, 103, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(145, 103, 140, 103, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(151.2536, 111.126, 145.6268, 116.3513, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(145.6268, 116.3513, 140, 116.3513, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(154.9516, 121.6942, 147.4758, 129.033, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(147.4758, 129.033, 140, 129.033, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(160.9084, 131.1745, 150.4542, 140.4094, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(150.4542, 140.4094, 140, 140.4094, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(168.8255, 139.0916, 154.4128, 149.9099, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(154.4128, 149.9099, 140, 149.9099, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(178.3058, 145.0484, 159.1529, 181.0581, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(159.1529, 181.0581, 140, 181.0581, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(188.874, 148.7464, 164.437, 173.4957, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(164.437, 173.4957, 140, 173.4957, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(200, 150, 170, 163, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(170, 163, 140, 163, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(211.126, 148.7464, 235.563, 167.4957, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(235.563, 167.4957, 260, 167.4957, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(221.6942, 145.0484, 240.8471, 157.0581, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(240.8471, 157.0581, 260, 157.0581, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(231.1745, 139.0916, 245.5872, 149.9099, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(245.5872, 149.9099, 260, 149.9099, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(239.0916, 131.1745, 249.5458, 140.4094, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(249.5458, 140.4094, 260, 140.4094, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(245.0484, 121.6942, 252.5242, 129.033, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(252.5242, 129.033, 260, 129.033, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(248.7464, 111.126, 254.3732, 116.3513, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(254.3732, 116.3513, 260, 116.3513, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(250, 100, 255, 103, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(255, 103, 260, 103, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(248.7464, 88.87395, 254.3732, 89.64874, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(254.3732, 89.64874, 260, 89.64874, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(245.0484, 78.30581, 252.5242, 76.96698, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(252.5242, 76.96698, 260, 76.96698, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(239.0916, 68.82551, 249.5458, 65.59061, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(249.5458, 65.59061, 260, 65.59061, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(231.1745, 60.90843, 245.5872, 56.09011, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(245.5872, 56.09011, 260, 56.09011, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(221.6942, 54.95156, 240.8471, 24.94187, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(240.8471, 24.94187, 260, 24.94187, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(211.126, 51.2536, 235.563, 32.50433, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(235.563, 32.50433, 260, 32.50433, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(200, 50, 230, 43, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(230, 43, 260, 43, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(188.874, 51.2536, 164.437, 38.50433, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(164.437, 38.50433, 140, 38.50433, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(178.3058, 54.95156, 159.1529, 48.94187, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(159.1529, 48.94187, 140, 48.94187, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(168.8255, 60.90843, 154.4128, 56.09011, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(154.4128, 56.09011, 140, 56.09011, strokeColor=Color(0, 0, 0, 1), strokeWidth=.5, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 140, 66.59061) v0.add( String(-38.88, -4, 'example1', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 140, 77.96698) v0.add( String(-38.88, -4, 'example2', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 140, 90.64874) v0.add( String(-38.88, -4, 'example3', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 140, 104) v0.add( String(-38.88, -4, 'example4', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 140, 117.3513) v0.add( String(-38.88, -4, 'example5', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 140, 130.033) v0.add( String(-38.88, -4, 'example6', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 140, 141.4094) v0.add( String(-38.88, -4, 'example7', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 140, 150.9099) v0.add( String(-38.88, -4, 'example8', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 140, 182.0581) v0.add( String(-38.88, -4, 'example9', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 140, 174.4957) v0.add( String(-43.88, -4, 'example10', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 140, 164) v0.add( String(-43.88, -4, 'example11', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 260, 168.4957) v0.add( String(0, -4, 'example12', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 260, 158.0581) v0.add( String(0, -4, 'example13', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 260, 150.9099) v0.add( String(0, -4, 'example14', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 260, 141.4094) v0.add( String(0, -4, 'example15', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 260, 130.033) v0.add( String(0, -4, 'example16', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 260, 117.3513) v0.add( String(0, -4, 'example17', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 260, 104) v0.add( String(0, -4, 'example18', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 260, 90.64874) v0.add( String(0, -4, 'example19', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 260, 77.96698) v0.add( String(0, -4, 'example20', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 260, 66.59061) v0.add( String(0, -4, 'example21', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 260, 57.09011) v0.add( String(0, -4, 'example22', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 260, 25.94187) v0.add( String(0, -4, 'example23', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 260, 33.50433) v0.add( String(0, -4, 'example24', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 260, 44) v0.add( String(0, -4, 'example25', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 140, 39.50433) v0.add( String(-43.88, -4, 'example26', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 140, 49.94187) v0.add( String(-43.88, -4, 'example27', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 140, 57.09011) v0.add( String(-43.88, -4, 'example28', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1)))
def makeSectors(self): # normalize slice data data = self.data multi = isListOfListOfNoneOrNumber(data) if multi: #it's a nested list, more than one sequence normData = [] n = [] for l in data: t = self.normalizeData(l) normData.append(t) n.append(len(t)) self._seriesCount = max(n) else: normData = self.normalizeData(data) n = len(normData) self._seriesCount = n #labels checkLabelOverlap = self.checkLabelOverlap L = [] L_add = L.append labels = self.labels if labels is None: labels = [] if not multi: labels = [''] * n else: for m in n: labels = list(labels) + [''] * m else: #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 not multi: i = n - len(labels) if i > 0: labels = list(labels) + [''] * i else: tlab = 0 for m in n: tlab += m i = tlab - len(labels) if i > 0: labels = list(labels) + [''] * i self.labels = labels 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() startAngle = self.startAngle #% 360 styleCount = len(self.slices) irf = self.innerRadiusFraction if multi: #multi-series doughnut ndata = len(data) if irf is None: yir = (yradius / 2.5) / ndata xir = (xradius / 2.5) / ndata else: yir = yradius * irf xir = xradius * irf ydr = (yradius - yir) / ndata xdr = (xradius - xir) / ndata for sn, series in enumerate(normData): for i, angle in enumerate(series): endAngle = (startAngle + (angle * whichWay)) #% 360 aa = abs(startAngle - endAngle) if aa < 1e-5: startAngle = endAngle continue if startAngle < endAngle: a1 = startAngle a2 = endAngle else: a1 = endAngle a2 = startAngle startAngle = endAngle #if we didn't use %stylecount here we'd end up with the later sectors #all having the default style sectorStyle = self.slices[sn, 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) yr1 = yir + sn * ydr yr = yr1 + ydr xr1 = xir + sn * xdr xr = xr1 + xdr if len(series) > 1: theSector = Wedge(cx, cy, xr, a1, a2, yradius=yr, radius1=xr1, yradius1=yr1) else: theSector = Wedge(cx, cy, xr, a1, a2, yradius=yr, radius1=xr1, yradius1=yr1, annular=True) theSector.fillColor = sectorStyle.fillColor theSector.strokeColor = sectorStyle.strokeColor theSector.strokeWidth = sectorStyle.strokeWidth theSector.strokeDashArray = sectorStyle.strokeDashArray shader = sectorStyle.shadingKind if shader: nshades = aa / float(sectorStyle.shadingAngle) if nshades > 1: shader = colors.Whiter if shader == 'lighten' else colors.Blacker nshades = 1 + int(nshades) shadingAmount = 1 - sectorStyle.shadingAmount if sectorStyle.shadingDirection == 'normal': dsh = (1 - shadingAmount) / float(nshades - 1) shf1 = shadingAmount else: dsh = (shadingAmount - 1) / float(nshades - 1) shf1 = 1 shda = (a2 - a1) / float(nshades) shsc = sectorStyle.fillColor theSector.fillColor = None for ish in range(nshades): sha1 = a1 + ish * shda sha2 = a1 + (ish + 1) * shda shc = shader(shsc, shf1 + dsh * ish) if len(series) > 1: shSector = Wedge(cx, cy, xr, sha1, sha2, yradius=yr, radius1=xr1, yradius1=yr1) else: shSector = Wedge(cx, cy, xr, sha1, sha2, yradius=yr, radius1=xr1, yradius1=yr1, annular=True) shSector.fillColor = shc shSector.strokeColor = None shSector.strokeWidth = 0 g.add(shSector) g.add(theSector) if sn == 0 and sectorStyle.visible and sectorStyle.label_visible: text = self.getSeriesName(i, '') if text: averageAngle = (a1 + a2) / 2.0 aveAngleRadians = averageAngle * pi / 180.0 labelRadius = sectorStyle.labelRadius rx = xradius * labelRadius ry = yradius * labelRadius labelX = centerx + (0.5 * self.width * cos(aveAngleRadians) * labelRadius) labelY = centery + (0.5 * self.height * sin(aveAngleRadians) * labelRadius) l = _addWedgeLabel(self, text, averageAngle, labelX, labelY, sectorStyle) if checkLabelOverlap: l._origdata = { 'x': labelX, 'y': labelY, 'angle': averageAngle, 'rx': rx, 'ry': ry, 'cx': cx, 'cy': cy, 'bounds': l.getBounds(), } L_add(l) else: #single series doughnut if irf is None: yir = yradius / 2.5 xir = xradius / 2.5 else: yir = yradius * irf xir = xradius * irf for i, angle in enumerate(normData): endAngle = (startAngle + (angle * whichWay)) #% 360 aa = abs(startAngle - endAngle) if aa < 1e-5: startAngle = endAngle continue if startAngle < endAngle: a1 = startAngle a2 = endAngle else: a1 = endAngle a2 = startAngle startAngle = endAngle #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=xir, yradius1=yir) elif n == 1: theSector = Wedge(cx, cy, xradius, a1, a2, yradius=yradius, radius1=xir, yradius1=yir, annular=True) theSector.fillColor = sectorStyle.fillColor theSector.strokeColor = sectorStyle.strokeColor theSector.strokeWidth = sectorStyle.strokeWidth theSector.strokeDashArray = sectorStyle.strokeDashArray shader = sectorStyle.shadingKind if shader: nshades = aa / float(sectorStyle.shadingAngle) if nshades > 1: shader = colors.Whiter if shader == 'lighten' else colors.Blacker nshades = 1 + int(nshades) shadingAmount = 1 - sectorStyle.shadingAmount if sectorStyle.shadingDirection == 'normal': dsh = (1 - shadingAmount) / float(nshades - 1) shf1 = shadingAmount else: dsh = (shadingAmount - 1) / float(nshades - 1) shf1 = 1 shda = (a2 - a1) / float(nshades) shsc = sectorStyle.fillColor theSector.fillColor = None for ish in range(nshades): sha1 = a1 + ish * shda sha2 = a1 + (ish + 1) * shda shc = shader(shsc, shf1 + dsh * ish) if n > 1: shSector = Wedge(cx, cy, xradius, sha1, sha2, yradius=yradius, radius1=xir, yradius1=yir) elif n == 1: shSector = Wedge(cx, cy, xradius, sha1, sha2, yradius=yradius, radius1=xir, yradius1=yir, annular=True) shSector.fillColor = shc shSector.strokeColor = None shSector.strokeWidth = 0 g.add(shSector) g.add(theSector) # now draw a label if labels[ i] and sectorStyle.visible and sectorStyle.label_visible: 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) rx = xradius * labelRadius ry = yradius * labelRadius l = _addWedgeLabel(self, labels[i], averageAngle, labelX, labelY, sectorStyle) if checkLabelOverlap: l._origdata = { 'x': labelX, 'y': labelY, 'angle': averageAngle, 'rx': rx, 'ry': ry, 'cx': cx, 'cy': cy, 'bounds': l.getBounds(), } L_add(l) if checkLabelOverlap and L: fixLabelOverlaps(L) for l in L: g.add(l) return g
def _Flag_Greece(self): s = _size g = Group() box = Rect(0, 0, s * 2, s, fillColor=colors.gold, strokeColor=colors.black, strokeWidth=0) g.add(box) for stripecounter in range(9, 0, -1): stripeheight = s / 9.0 if not (stripecounter % 2 == 0): stripecolor = colors.deepskyblue else: stripecolor = colors.mintcream blueorwhiteline = Rect(0, (s - (stripeheight * stripecounter)), width=s * 2, height=stripeheight, fillColor=stripecolor, strokeColor=None, strokeWidth=20) g.add(blueorwhiteline) bluebox1 = Rect(0, ((s) - stripeheight * 5), width=(stripeheight * 5), height=stripeheight * 5, fillColor=colors.deepskyblue, strokeColor=None, strokeWidth=0) g.add(bluebox1) whiteline1 = Rect(0, ((s) - stripeheight * 3), width=stripeheight * 5, height=stripeheight, fillColor=colors.mintcream, strokeColor=None, strokeWidth=0) g.add(whiteline1) whiteline2 = Rect((stripeheight * 2), ((s) - stripeheight * 5), width=stripeheight, height=stripeheight * 5, fillColor=colors.mintcream, strokeColor=None, strokeWidth=0) g.add(whiteline2) 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( Line(40, 30, 220, 30, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(74.54545, 30, 74.54545, 25, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(110.9091, 30, 110.9091, 25, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(147.2727, 30, 147.2727, 25, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(183.6364, 30, 183.6364, 25, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(220, 30, 220, 25, 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, 74.54545, 25) v0.add( String(-7.5, -10, '200', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 110.9091, 25) v0.add( String(-7.5, -10, '400', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 147.2727, 25) v0.add( String(-7.5, -10, '600', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 183.6364, 25) v0.add( String(-7.5, -10, '800', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 220, 25) v0.add( String(-10, -10, '1000', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( Line(40, 30, 40, 115, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(40, 34.59459, 35, 34.59459, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(40, 57.56757, 35, 57.56757, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(40, 80.54054, 35, 80.54054, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(40, 103.5135, 35, 103.5135, 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, 35, 34.59459) v0.add( String(-25.08, -4, '1e+02', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 35, 57.56757) v0.add( String(-25.08, -4, '1e+04', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 35, 80.54054) v0.add( String(-25.08, -4, '1e+06', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 35, 103.5135) v0.add( String(-25.08, -4, '1e+08', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( PolyLine(points=[ 40, 34.59459, 41.81818, 41.51015, 43.63636, 45.55549, 45.45455, 48.4257, 47.27273, 50.65201, 49.09091, 52.47104, 50.90909, 54.00901, 52.72727, 55.34126, 54.54545, 56.51638, 56.36364, 57.56757, 58.18182, 58.51848, 60, 59.3866, 61.81818, 60.18519, 63.63636, 60.92456, 65.45455, 61.61291, 67.27273, 62.25681, 69.09091, 62.86166, 70.90909, 63.43194, 72.72727, 63.97137, 74.54545, 64.48312, 76.36364, 64.9699, 78.18182, 65.43403, 80, 65.87753, 81.81818, 66.30215, 83.63636, 66.70943, 85.45455, 67.10074, 87.27273, 67.47728, 89.09091, 67.84012, 90.90909, 68.19022, 92.72727, 68.52846, 94.54545, 68.85561, 96.36364, 69.17236, 98.18182, 69.47937, 100, 69.77722, 101.8182, 70.06643, 103.6364, 70.34749, 105.4545, 70.62085, 107.2727, 70.88692, 109.0909, 71.14608, 110.9091, 71.39868, 112.7273, 71.64503, 114.5455, 71.88546, 116.3636, 72.12022, 118.1818, 72.34959, 120, 72.5738, 121.8182, 72.79309, 123.6364, 73.00765, 125.4545, 73.2177, 127.2727, 73.42342, 129.0909, 73.62499, 130.9091, 73.82256, 132.7273, 74.01629, 134.5455, 74.20634, 136.3636, 74.39283, 138.1818, 74.5759, 140, 74.75567, 141.8182, 74.93226, 143.6364, 75.10578, 145.4545, 75.27633, 147.2727, 75.44402, 149.0909, 75.60893, 150.9091, 75.77116, 152.7273, 75.9308, 154.5455, 76.08792, 156.3636, 76.2426, 158.1818, 76.39493, 160, 76.54496, 161.8182, 76.69277, 163.6364, 76.83843, 165.4545, 76.98198, 167.2727, 77.1235, 169.0909, 77.26304, 170.9091, 77.40066, 172.7273, 77.5364, 174.5455, 77.67033, 176.3636, 77.80247, 178.1818, 77.9329, 180, 78.06163, 181.8182, 78.18873, 183.6364, 78.31423, 185.4545, 78.43817, 187.2727, 78.56059, 189.0909, 78.68152, 190.9091, 78.80101, 192.7273, 78.91908, 194.5455, 79.03578, 196.3636, 79.15112, 198.1818, 79.26514, 200, 79.37788, 201.8182, 79.48935, 203.6364, 79.5996, 205.4545, 79.70864, 207.2727, 79.8165, 209.0909, 79.92321, 210.9091, 80.02879, 212.7273, 80.13326, 214.5455, 80.23665, 216.3636, 80.33898, 218.1818, 80.44027, 220, 80.54054 ], strokeColor=Color(1, 0, 0, 1), strokeWidth=.2, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( PolyLine(points=[ 40, 46.08108, 41.81818, 56.45441, 43.63636, 62.52242, 45.45455, 66.82774, 47.27273, 70.16721, 49.09091, 72.89575, 50.90909, 75.2027, 52.72727, 77.20107, 54.54545, 78.96376, 56.36364, 80.54054, 58.18182, 81.96691, 60, 83.26908, 61.81818, 84.46697, 63.63636, 85.57603, 65.45455, 86.60855, 67.27273, 87.5744, 69.09091, 88.48169, 70.90909, 89.33709, 72.72727, 90.14624, 74.54545, 90.91387, 76.36364, 91.64404, 78.18182, 92.34024, 80, 93.00549, 81.81818, 93.64241, 83.63636, 94.25334, 85.45455, 94.8403, 87.27273, 95.4051, 89.09091, 95.94936, 90.90909, 96.47453, 92.72727, 96.98188, 94.54545, 97.4726, 96.36364, 97.94774, 98.18182, 98.40825, 100, 98.85502, 101.8182, 99.28883, 103.6364, 99.71042, 105.4545, 100.1205, 107.2727, 100.5196, 109.0909, 100.9083, 110.9091, 101.2872, 112.7273, 101.6567, 114.5455, 102.0174, 116.3636, 102.3695, 118.1818, 102.7136, 120, 103.0499, 121.8182, 103.3788, 123.6364, 103.7007, 125.4545, 104.0157, 127.2727, 104.3243, 129.0909, 104.6267, 130.9091, 104.923, 132.7273, 105.2136, 134.5455, 105.4987, 136.3636, 105.7784, 138.1818, 106.053, 140, 106.3227, 141.8182, 106.5876, 143.6364, 106.8479, 145.4545, 107.1037, 147.2727, 107.3552, 149.0909, 107.6026, 150.9091, 107.8459, 152.7273, 108.0854, 154.5455, 108.3211, 156.3636, 108.5531, 158.1818, 108.7816, 160, 109.0066, 161.8182, 109.2283, 163.6364, 109.4468, 165.4545, 109.6622, 167.2727, 109.8744, 169.0909, 110.0838, 170.9091, 110.2902, 172.7273, 110.4938, 174.5455, 110.6947, 176.3636, 110.8929, 178.1818, 111.0885, 180, 111.2816, 181.8182, 111.4723, 183.6364, 111.6605, 185.4545, 111.8464, 187.2727, 112.0301, 189.0909, 112.2115, 190.9091, 112.3907, 192.7273, 112.5678, 194.5455, 112.7429, 196.3636, 112.9159, 198.1818, 113.0869, 200, 113.256, 201.8182, 113.4232, 203.6364, 113.5886, 205.4545, 113.7521, 207.2727, 113.9139, 209.0909, 114.074, 210.9091, 114.2324, 212.7273, 114.3891, 214.5455, 114.5442, 216.3636, 114.6977, 218.1818, 114.8496, 220, 115 ], strokeColor=Color(0, 0, 1, 1), strokeWidth=.2, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( PolyLine(points=[ 40, 30, 41.81818, 35.53244, 43.63636, 38.76871, 45.45455, 41.06489, 47.27273, 42.84594, 49.09091, 44.30116, 50.90909, 45.53153, 52.72727, 46.59733, 54.54545, 47.53743, 56.36364, 48.37838, 58.18182, 49.13911, 60, 49.8336, 61.81818, 50.47247, 63.63636, 51.06397, 65.45455, 51.61465, 67.27273, 52.12977, 69.09091, 52.61366, 70.90909, 53.06987, 72.72727, 53.50142, 74.54545, 53.91082, 76.36364, 54.30025, 78.18182, 54.67155, 80, 55.02635, 81.81818, 55.36604, 83.63636, 55.69187, 85.45455, 56.00492, 87.27273, 56.30614, 89.09091, 56.59642, 90.90909, 56.8765, 92.72727, 57.14709, 94.54545, 57.40881, 96.36364, 57.66222, 98.18182, 57.90782, 100, 58.1461, 101.8182, 58.37747, 103.6364, 58.60232, 105.4545, 58.821, 107.2727, 59.03386, 109.0909, 59.24119, 110.9091, 59.44326, 112.7273, 59.64035, 114.5455, 59.83269, 116.3636, 60.0205, 118.1818, 60.204, 120, 60.38337, 121.8182, 60.55879, 123.6364, 60.73045, 125.4545, 60.89849, 127.2727, 61.06306, 129.0909, 61.22431, 130.9091, 61.38237, 132.7273, 61.53736, 134.5455, 61.68939, 136.3636, 61.83859, 138.1818, 61.98504, 140, 62.12886, 141.8182, 62.27013, 143.6364, 62.40895, 145.4545, 62.54539, 147.2727, 62.67954, 149.0909, 62.81147, 150.9091, 62.94125, 152.7273, 63.06896, 154.5455, 63.19466, 156.3636, 63.31841, 158.1818, 63.44027, 160, 63.56029, 161.8182, 63.67854, 163.6364, 63.79506, 165.4545, 63.90991, 167.2727, 64.02313, 169.0909, 64.13476, 170.9091, 64.24485, 172.7273, 64.35345, 174.5455, 64.46059, 176.3636, 64.5663, 178.1818, 64.67064, 180, 64.77363, 181.8182, 64.87531, 183.6364, 64.97571, 185.4545, 65.07486, 187.2727, 65.1728, 189.0909, 65.26954, 190.9091, 65.36513, 192.7273, 65.45959, 194.5455, 65.55294, 196.3636, 65.64522, 198.1818, 65.73644, 200, 65.82663, 201.8182, 65.91581, 203.6364, 66.004, 205.4545, 66.09124, 207.2727, 66.17752, 209.0909, 66.26289, 210.9091, 66.34735, 212.7273, 66.43093, 214.5455, 66.51364, 216.3636, 66.59551, 218.1818, 66.67654, 220, 66.75676 ], strokeColor=Color(0, .501961, 0, 1), strokeWidth=.2, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None))
def makeLines(self): labelFmt = self.lineLabelFormat P = list(range(len(self._positions))) if self.reversePlotOrder: P.reverse() inFill = self.inFill assert not inFill, "inFill not supported for 3d yet" #if inFill: #inFillY = self.categoryAxis._y #inFillX0 = self.valueAxis._x #inFillX1 = inFillX0 + self.categoryAxis._length #inFillG = getattr(self,'_inFillG',g) zDepth = self.zDepth _zadjust = self._zadjust theta_x = self.theta_x theta_y = self.theta_y F = _FakeGroup() from reportlab.graphics.charts.utils3d import _make_3d_line_info tileWidth = getattr(self,'_3d_tilewidth',None) if not tileWidth and self.categoryAxis.style!='parallel_3d': tileWidth = 1 # Iterate over data rows. for rowNo in P: row = self._positions[rowNo] n = len(row) styleCount = len(self.lines) styleIdx = rowNo % styleCount rowStyle = self.lines[styleIdx] rowColor = rowStyle.strokeColor dash = getattr(rowStyle, 'strokeDashArray', None) z0 = self._calc_z0(rowNo) z1 = z0 + zDepth if hasattr(self.lines[styleIdx], 'strokeWidth'): strokeWidth = self.lines[styleIdx].strokeWidth elif hasattr(self.lines, 'strokeWidth'): strokeWidth = self.lines.strokeWidth else: strokeWidth = None # Iterate over data columns. if self.joinedLines: if n: x0, y0 = row[0] for colNo in range(1,n): x1, y1 = row[colNo] _make_3d_line_info( F, x0, x1, y0, y1, z0, z1, theta_x, theta_y, rowColor, fillColorShaded=None, tileWidth=tileWidth, strokeColor=None, strokeWidth=None, strokeDashArray=None, shading=0.1) x0, y0 = x1, y1 if hasattr(self.lines[styleIdx], 'symbol'): uSymbol = self.lines[styleIdx].symbol elif hasattr(self.lines, 'symbol'): uSymbol = self.lines.symbol else: uSymbol = None if uSymbol: for colNo in range(n): x1, y1 = row[colNo] x1, y1 = _zadjust(x1,y1,z0) symbol = uSymbol2Symbol(uSymbol,x1,y1,rowColor) if symbol: F.add((2,z0,z0,x1,y1,symbol)) # Draw item labels. for colNo in range(n): x1, y1 = row[colNo] x1, y1 = _zadjust(x1,y1,z0) L = self._innerDrawLabel(rowNo, colNo, x1, y1) if L: F.add((2,z0,z0,x1,y1,L)) F.sort() g = Group() for v in F.value(): g.add(v[-1]) return g
def makeLines(self): g = Group() labelFmt = self.lineLabelFormat P = list(range(len(self._positions))) if self.reversePlotOrder: P.reverse() inFill = self.inFill if inFill: inFillY = self.categoryAxis._y inFillX0 = self.valueAxis._x inFillX1 = inFillX0 + self.categoryAxis._length inFillG = getattr(self,'_inFillG',g) yzero = self._yzero # Iterate over data rows. for rowNo in P: row = self._positions[rowNo] styleCount = len(self.lines) styleIdx = rowNo % styleCount rowStyle = self.lines[styleIdx] rowColor = rowStyle.strokeColor dash = getattr(rowStyle, 'strokeDashArray', None) lineStyle = getattr(rowStyle,'lineStyle',None) if hasattr(rowStyle, 'strokeWidth'): strokeWidth = rowStyle.strokeWidth elif hasattr(self.lines, 'strokeWidth'): strokeWidth = self.lines.strokeWidth else: strokeWidth = None # Iterate over data columns. if lineStyle=='bar': barWidth = getattr(rowStyle,'barWidth',Percentage(50)) fillColor = getattr(rowStyle,'fillColor',rowColor) if isinstance(barWidth,Percentage): hbw = self._hngs*barWidth*0.01 else: hbw = barWidth*0.5 for colNo in range(len(row)): x,y = row[colNo] g.add(Rect(x-hbw,min(y,yzero),2*hbw,abs(y-yzero),strokeWidth=strokeWidth,strokeColor=rowColor,fillColor=fillColor)) elif self.joinedLines or lineStyle=='joinedLine': points = [] for colNo in range(len(row)): points += row[colNo] if inFill: points = points + [inFillX1,inFillY,inFillX0,inFillY] inFillG.add(Polygon(points,fillColor=rowColor,strokeColor=rowColor,strokeWidth=0.1)) else: line = PolyLine(points,strokeColor=rowColor,strokeLineCap=0,strokeLineJoin=1) if strokeWidth: line.strokeWidth = strokeWidth if dash: line.strokeDashArray = dash g.add(line) if hasattr(rowStyle, 'symbol'): uSymbol = rowStyle.symbol elif hasattr(self.lines, 'symbol'): uSymbol = self.lines.symbol else: uSymbol = None if uSymbol: for colNo in range(len(row)): x1, y1 = row[colNo] symbol = uSymbol2Symbol(uSymbol,x1,y1,rowStyle.strokeColor) if symbol: g.add(symbol) # Draw item labels. for colNo in range(len(row)): x1, y1 = row[colNo] self.drawLabel(g, rowNo, colNo, x1, y1) return g
def draw(self): g = Group() g.add(self.makeSectors()) return g
def _Flag_USA(self): s = _size # abbreviate as we will use this a lot g = Group() box = Rect(0, 0, s * 2, s, fillColor=colors.mintcream, strokeColor=colors.black, strokeWidth=0) g.add(box) for stripecounter in range(13, 0, -1): stripeheight = s / 13.0 if not (stripecounter % 2 == 0): stripecolor = colors.red else: stripecolor = colors.mintcream redorwhiteline = Rect(0, (s - (stripeheight * stripecounter)), width=s * 2, height=stripeheight, fillColor=stripecolor, strokeColor=None, strokeWidth=20) g.add(redorwhiteline) bluebox = Rect(0, (s - (stripeheight * 7)), width=0.8 * s, height=stripeheight * 7, fillColor=colors.darkblue, strokeColor=None, strokeWidth=0) g.add(bluebox) lss = s * 0.045 lss2 = lss / 2 s9 = s / 9 s7 = s / 7 for starxcounter in range(5): for starycounter in range(4): ls = Star() ls.size = lss ls.x = 0 - s / 22 + lss / 2 + s7 + starxcounter * s7 ls.fillColor = colors.mintcream ls.y = s - (starycounter + 1) * s9 + lss2 g.add(ls) for starxcounter in range(6): for starycounter in range(5): ls = Star() ls.size = lss ls.x = 0 - (s / 22) + lss / 2 + s / 14 + starxcounter * s7 ls.fillColor = colors.mintcream ls.y = s - (starycounter + 1) * s9 + (s / 18) + lss2 g.add(ls) return g
def _Flag_UK(self): s = _size g = Group() w = s * 2 g.add( Rect(0, 0, w, s, fillColor=colors.navy, strokeColor=colors.black, strokeWidth=0)) g.add( Polygon([ 0, 0, s * .225, 0, w, s * (1 - .1125), w, s, w - s * .225, s, 0, s * .1125 ], fillColor=colors.mintcream, strokeColor=None, strokeWidth=0)) g.add( Polygon([ 0, s * (1 - .1125), 0, s, s * .225, s, w, s * .1125, w, 0, w - s * .225, 0 ], fillColor=colors.mintcream, strokeColor=None, strokeWidth=0)) g.add( Polygon([ 0, s - (s / 15), (s - ((s / 10) * 4)), (s * 0.65), (s - (s / 10) * 3), (s * 0.65), 0, s ], fillColor=colors.red, strokeColor=None, strokeWidth=0)) g.add( Polygon([ 0, 0, (s - ((s / 10) * 3)), (s * 0.35), (s - ((s / 10) * 2)), (s * 0.35), (s / 10), 0 ], fillColor=colors.red, strokeColor=None, strokeWidth=0)) g.add( Polygon([ w, s, (s + ((s / 10) * 3)), (s * 0.65), (s + ((s / 10) * 2)), (s * 0.65), w - (s / 10), s ], fillColor=colors.red, strokeColor=None, strokeWidth=0)) g.add( Polygon([ w, (s / 15), (s + ((s / 10) * 4)), (s * 0.35), (s + ((s / 10) * 3)), (s * 0.35), w, 0 ], fillColor=colors.red, strokeColor=None, strokeWidth=0)) g.add( Rect(((s * 0.42) * 2), 0, width=(0.16 * s) * 2, height=s, fillColor=colors.mintcream, strokeColor=None, strokeWidth=0)) g.add( Rect(0, (s * 0.35), width=w, height=s * 0.3, fillColor=colors.mintcream, strokeColor=None, strokeWidth=0)) g.add( Rect(((s * 0.45) * 2), 0, width=(0.1 * s) * 2, height=s, fillColor=colors.red, strokeColor=None, strokeWidth=0)) g.add( Rect(0, (s * 0.4), width=w, height=s * 0.2, fillColor=colors.red, strokeColor=None, strokeWidth=0)) return g
def convertPath(self, node): d = node.getAttribute('d') if not d: return None normPath = normalise_svg_path(d) path = Path() points = path.points # Track subpaths needing to be closed later unclosed_subpath_pointers = [] subpath_start = [] lastop = '' for i in range(0, len(normPath), 2): op, nums = normPath[i:i+2] if op in ('m', 'M') and i > 0 and path.operators[-1] != _CLOSEPATH: unclosed_subpath_pointers.append(len(path.operators)) # moveto absolute if op == 'M': path.moveTo(*nums) subpath_start = points[-2:] # lineto absolute elif op == 'L': path.lineTo(*nums) # moveto relative elif op == 'm': if len(points) >= 2: if lastop in ('Z', 'z'): starting_point = subpath_start else: starting_point = points[-2:] xn, yn = starting_point[0] + nums[0], starting_point[1] + nums[1] path.moveTo(xn, yn) else: path.moveTo(*nums) subpath_start = points[-2:] # lineto relative elif op == 'l': xn, yn = points[-2] + nums[0], points[-1] + nums[1] path.lineTo(xn, yn) # horizontal/vertical line absolute elif op == 'H': path.lineTo(nums[0], points[-1]) elif op == 'V': path.lineTo(points[-2], nums[0]) # horizontal/vertical line relative elif op == 'h': path.lineTo(points[-2] + nums[0], points[-1]) elif op == 'v': path.lineTo(points[-2], points[-1] + nums[0]) # cubic bezier, absolute elif op == 'C': path.curveTo(*nums) elif op == 'S': x2, y2, xn, yn = nums if len(points) < 4 or lastop not in {'c', 'C', 's', 'S'}: xp, yp, x0, y0 = points[-2:] * 2 else: xp, yp, x0, y0 = points[-4:] xi, yi = x0 + (x0 - xp), y0 + (y0 - yp) path.curveTo(xi, yi, x2, y2, xn, yn) # cubic bezier, relative elif op == 'c': xp, yp = points[-2:] x1, y1, x2, y2, xn, yn = nums path.curveTo(xp + x1, yp + y1, xp + x2, yp + y2, xp + xn, yp + yn) elif op == 's': x2, y2, xn, yn = nums if len(points) < 4 or lastop not in {'c', 'C', 's', 'S'}: xp, yp, x0, y0 = points[-2:] * 2 else: xp, yp, x0, y0 = points[-4:] xi, yi = x0 + (x0 - xp), y0 + (y0 - yp) path.curveTo(xi, yi, x0 + x2, y0 + y2, x0 + xn, y0 + yn) # quadratic bezier, absolute elif op == 'Q': x0, y0 = points[-2:] x1, y1, xn, yn = nums (x0, y0), (x1, y1), (x2, y2), (xn, yn) = \ convert_quadratic_to_cubic_path((x0, y0), (x1, y1), (xn, yn)) path.curveTo(x1, y1, x2, y2, xn, yn) elif op == 'T': if len(points) < 4: xp, yp, x0, y0 = points[-2:] * 2 else: xp, yp, x0, y0 = points[-4:] xi, yi = x0 + (x0 - xp), y0 + (y0 - yp) xn, yn = nums (x0, y0), (x1, y1), (x2, y2), (xn, yn) = \ convert_quadratic_to_cubic_path((x0, y0), (xi, yi), (xn, yn)) path.curveTo(x1, y1, x2, y2, xn, yn) # quadratic bezier, relative elif op == 'q': x0, y0 = points[-2:] x1, y1, xn, yn = nums x1, y1, xn, yn = x0 + x1, y0 + y1, x0 + xn, y0 + yn (x0, y0), (x1, y1), (x2, y2), (xn, yn) = \ convert_quadratic_to_cubic_path((x0, y0), (x1, y1), (xn, yn)) path.curveTo(x1, y1, x2, y2, xn, yn) elif op == 't': if len(points) < 4: xp, yp, x0, y0 = points[-2:] * 2 else: xp, yp, x0, y0 = points[-4:] x0, y0 = points[-2:] xn, yn = nums xn, yn = x0 + xn, y0 + yn xi, yi = x0 + (x0 - xp), y0 + (y0 - yp) (x0, y0), (x1, y1), (x2, y2), (xn, yn) = \ convert_quadratic_to_cubic_path((x0, y0), (xi, yi), (xn, yn)) path.curveTo(x1, y1, x2, y2, xn, yn) # elliptical arc elif op in ('A', 'a'): rx, ry, phi, fA, fS, x2, y2 = nums x1, y1 = points[-2:] if op == 'a': x2 += x1 y2 += y1 if abs(rx) <= 1e-10 or abs(ry) <= 1e-10: path.lineTo(x2, y2) else: bp = bezier_arc_from_end_points(x1, y1, rx, ry, phi, fA, fS, x2, y2) for _, _, x1, y1, x2, y2, xn, yn in bp: path.curveTo(x1, y1, x2, y2, xn, yn) # close path elif op in ('Z', 'z'): path.closePath() else: logger.debug("Suspicious path operator: %s" % op) lastop = op gr = Group() self.applyStyleOnShape(path, node) if path.operators[-1] != _CLOSEPATH: unclosed_subpath_pointers.append(len(path.operators)) if unclosed_subpath_pointers and path.fillColor is not None: # ReportLab doesn't fill unclosed paths, so we are creating a copy # of the path with all subpaths closed, but without stroke. # https://bitbucket.org/rptlab/reportlab/issues/99/ closed_path = NoStrokePath(copy_from=path) for pointer in reversed(unclosed_subpath_pointers): closed_path.operators.insert(pointer, _CLOSEPATH) gr.add(closed_path) path.fillColor = None gr.add(path) return gr
def __init__(self, width=400, height=200, *args, **kw): Drawing.__init__(self, width, height, *args, **kw) self.transform = (1, 0, 0, 1, 0, 0) 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))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 45, 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, 45, 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, 45, 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, 45, 167.1875) v0.add( String(-10, -4, '40', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1)))
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( 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(110, 50, 110, 45, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(170, 50, 170, 45, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(200, 50, 200, 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(290, 50, 290, 45, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(350, 50, 350, 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, 110, 45) v0.add( String(-6.25, -10, '1.0', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 170, 45) v0.add( String(-6.25, -10, '2.0', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 200, 45) v0.add( String(-6.25, -10, '2.5', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 230, 45) v0.add( String(-6.25, -10, '3.0', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 290, 45) v0.add( String(-6.25, -10, '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, 350, 45) v0.add( String(-6.25, -10, '5.0', 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, 67.85714, 45, 67.85714, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(50, 85.71429, 45, 85.71429, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(50, 103.5714, 45, 103.5714, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(50, 139.2857, 45, 139.2857, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(50, 157.1429, 45, 157.1429, 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, 67.85714) v0.add( String(-5, -4, '1', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 45, 85.71429) v0.add( String(-5, -4, '2', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 45, 103.5714) v0.add( String(-5, -4, '3', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 45, 139.2857) v0.add( String(-5, -4, '5', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 45, 157.1429) v0.add( String(-5, -4, '6', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( PolyLine(points=[ 110, 67.85714, 170, 85.71429, 200, 67.85714, 230, 103.5714, 290, 139.2857 ], strokeColor=Color(1, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( PolyLine(points=[ 110, 85.71429, 170, 103.5714, 200, 85.71429, 260, 139.2857, 290, 157.1429 ], strokeColor=Color(0, 0, 1, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=1, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Circle(110, 67.85714, 2.5, 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( Circle(170, 85.71429, 2.5, 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( Circle(200, 67.85714, 2.5, 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( Circle(230, 103.5714, 2.5, 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( Circle(290, 139.2857, 2.5, 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)) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 110, 77.85714) v0.add( String(-3.75, -4, ' 1', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 170, 95.71429) v0.add( String(-3.75, -4, ' 2', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 200, 77.85714) v0.add( String(-3.75, -4, ' 1', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 230, 113.5714) v0.add( String(-3.75, -4, ' 3', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 290, 149.2857) v0.add( String(-3.75, -4, ' 5', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) self.add( Circle(110, 85.71429, 2.5, 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( Circle(170, 103.5714, 2.5, 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( Circle(200, 85.71429, 2.5, 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( Circle(260, 139.2857, 2.5, 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( Circle(290, 157.1429, 2.5, 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)) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 110, 95.71429) v0.add( String(-3.75, -4, ' 2', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 170, 113.5714) v0.add( String(-3.75, -4, ' 3', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 200, 95.71429) v0.add( String(-3.75, -4, ' 2', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 260, 149.2857) v0.add( String(-3.75, -4, ' 5', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 290, 167.1429) v0.add( String(-3.75, -4, ' 6', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1)))
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(200, 50, 200, 175, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(200, 50, 195, 50, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(200, 81.25, 195, 81.25, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(200, 112.5, 195, 112.5, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(200, 143.75, 195, 143.75, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(200, 175, 195, 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, 195, 65.625) v0.add( String(-18.88, -4, 'Beer', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 195, 96.875) v0.add( String(-21.66, -4, 'Wine', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 195, 128.125) v0.add( String(-20.55, -4, 'Meat', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) v0 = self._nn(Group()) v0.transform = (1, 0, 0, 1, 195, 159.375) v0.add( String(-43.89, -4, 'Cannelloni', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1)))
def draw(self): g = Group() gAdd = g.add barWidth = self.barWidth width = self.width barHeight = self.barHeight x = self.x y = self.y gAdd( Rect(x, y, width, barHeight, fillColor=None, strokeColor=None, strokeWidth=0)) s = self.value + self._checkdigit(self.value) self._lquiet = lquiet = self._calc_quiet(self.lquiet) rquiet = self._calc_quiet(self.rquiet) b = [lquiet * '0', self._tail] #the signal string a = b.append self._encode_left(s, a) a(self._sep) z = ord('0') _right = self._right for c in s[self._start_right:]: a(_right[ord(c) - z]) a(self._tail) a(rquiet * '0') fontSize = self.fontSize barFillColor = self.barFillColor barStrokeWidth = self.barStrokeWidth barStrokeColor = self.barStrokeColor fth = fontSize * 1.2 b = ''.join(b) lrect = None for i, c in enumerate(b): if c == "1": dh = self._short_bar(i) and fth or 0 yh = y + dh if lrect and lrect.y == yh: lrect.width += barWidth else: lrect = Rect(x, yh, barWidth, barHeight - dh, fillColor=barFillColor, strokeWidth=barStrokeWidth, strokeColor=barStrokeColor) gAdd(lrect) else: lrect = None x += barWidth if self.humanReadable: self._add_human_readable(s, gAdd) return g
def draw(self): # normalize slice data g = self.makeBackground() or Group() xradius = self.width/2.0 yradius = self.height/2.0 self._radius = radius = min(xradius, yradius) cx = self.x + xradius cy = self.y + yradius data = self.normalizeData() self._seriesCount = len(data) n = len(data[0]) #labels if self.labels is None: labels = [''] * n else: labels = self.labels #there's no point in raising errors for less than enough errors if #we silently create all for the extreme case of no labels. i = n-len(labels) if i>0: labels = labels + ['']*i S = [] STRANDS = [] STRANDAREAS = [] syms = [] labs = [] csa = [] angle = self.startAngle*pi/180 direction = self.direction == "clockwise" and -1 or 1 angleBetween = direction*(2 * pi)/float(n) spokes = self.spokes spokeLabels = self.spokeLabels for i in xrange(n): car = cos(angle)*radius sar = sin(angle)*radius csa.append((car,sar,angle)) si = self.spokes[i] if si.visible: spoke = Line(cx, cy, cx + car, cy + sar, strokeWidth = si.strokeWidth, strokeColor=si.strokeColor, strokeDashArray=si.strokeDashArray) S.append(spoke) sli = spokeLabels[i] text = sli._text if not text: text = labels[i] if text: S.append(_setupLabel(WedgeLabel, text, si.labelRadius, cx, cy, angle, car, sar, sli)) angle += angleBetween # now plot the polygons rowIdx = 0 strands = self.strands strandLabels = self.strandLabels for row in data: # series plot rsty = strands[rowIdx] points = [] car, sar = csa[-1][:2] r = row[-1] points.append(cx+car*r) points.append(cy+sar*r) for i in xrange(n): car, sar, angle = csa[i] r = row[i] points.append(cx+car*r) points.append(cy+sar*r) L = self._innerDrawLabel(strandLabels[(rowIdx,i)], r, cx, cy, angle, car, sar, labelClass=StrandLabel) if L: labs.append(L) sty = strands[(rowIdx,i)] uSymbol = sty.symbol # put in a marker, if it needs one if uSymbol: s_x = cx+car*r s_y = cy+sar*r s_fillColor = sty.fillColor s_strokeColor = sty.strokeColor s_strokeWidth = sty.strokeWidth s_angle = 0 s_size = sty.symbolSize if type(uSymbol) is type(''): symbol = makeMarker(uSymbol, size = s_size, x = s_x, y = s_y, fillColor = s_fillColor, strokeColor = s_strokeColor, strokeWidth = s_strokeWidth, angle = s_angle, ) else: symbol = uSymbol2Symbol(uSymbol,s_x,s_y,s_fillColor) for k,v in (('size', s_size), ('fillColor', s_fillColor), ('x', s_x), ('y', s_y), ('strokeColor',s_strokeColor), ('strokeWidth',s_strokeWidth), ('angle',s_angle),): if getattr(symbol,k,None) is None: try: setattr(symbol,k,v) except: pass syms.append(symbol) # make up the 'strand' if rsty.fillColor: strand = Polygon(points) strand.fillColor = rsty.fillColor strand.strokeColor = None strand.strokeWidth = 0 STRANDAREAS.append(strand) if rsty.strokeColor and rsty.strokeWidth: strand = PolyLine(points) strand.strokeColor = rsty.strokeColor strand.strokeWidth = rsty.strokeWidth strand.strokeDashArray = rsty.strokeDashArray STRANDS.append(strand) rowIdx += 1 map(g.add,STRANDAREAS+STRANDS+syms+S+labs) 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( Line(50, 100, 350, 100, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(50, 100, 50, 95, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(143.75, 100, 143.75, 95, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(237.5, 100, 237.5, 95, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(331.25, 100, 331.25, 95, 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, 95) 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, 95) 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, 95) 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, 95) v0.add( String(-5, -10, '40', 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, 89.0625, 45, 89.0625, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(50, 128.125, 45, 128.125, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(50, 167.1875, 45, 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, 45, 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, 45, 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, 45, 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, 45, 167.1875) v0.add( String(-10, -4, '40', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1)))
def draw(self): "Draws itself." vA, cA = self.valueAxis, self.categoryAxis vA.setPosition(self.x, self.y, self.height) if vA: vA.joinAxis = cA if cA: cA.joinAxis = vA vA.configure(self.data) # If zero is in chart, put x axis there, otherwise # use bottom. xAxisCrossesAt = vA.scale(0) if ((xAxisCrossesAt > self.y + self.height) or (xAxisCrossesAt < self.y)): y = self.y else: y = xAxisCrossesAt cA.setPosition(self.x, y, self.width) cA.configure(self.data) self.calcPositions() g = Group() g.add(self.makeBackground()) if self.inFill: self._inFillG = Group() g.add(self._inFillG) g.add(cA) g.add(vA) cAdgl = getattr(cA,'drawGridLast',False) vAdgl = getattr(vA,'drawGridLast',False) if not cAdgl: cA.makeGrid(g,parent=self,dim=vA.getGridDims) if not vAdgl: vA.makeGrid(g,parent=self,dim=cA.getGridDims) g.add(self.makeLines()) if cAdgl: cA.makeGrid(g,parent=self,dim=vA.getGridDims) if vAdgl: vA.makeGrid(g,parent=self,dim=cA.getGridDims) for a in getattr(self,'annotations',()): g.add(a(self,cA.scale,vA.scale)) return g
def _Flag_Norway(self): s = _size g = Group() self._width = s * 1.4 box = Rect(0, 0, self._width, s, fillColor=colors.red, strokeColor=colors.black, strokeWidth=0) g.add(box) box = Rect(0, 0, self._width, s, fillColor=colors.red, strokeColor=colors.black, strokeWidth=0) g.add(box) whiteline1 = Rect(((s * 0.2) * 2), 0, width=s * 0.2, height=s, fillColor=colors.ghostwhite, strokeColor=None, strokeWidth=0) g.add(whiteline1) whiteline2 = Rect(0, (s * 0.4), width=self._width, height=s * 0.2, fillColor=colors.ghostwhite, strokeColor=None, strokeWidth=0) g.add(whiteline2) blueline1 = Rect(((s * 0.225) * 2), 0, width=0.1 * s, height=s, fillColor=colors.darkblue, strokeColor=None, strokeWidth=0) g.add(blueline1) blueline2 = Rect(0, (s * 0.45), width=self._width, height=s * 0.1, fillColor=colors.darkblue, strokeColor=None, strokeWidth=0) g.add(blueline2) 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(350, 60.41667, -45, 41.66667, 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(350, 122.9167, -150, 41.66667, 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, 50, 49, 175, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(49, 50, 44, 50, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(49, 112.5, 44, 112.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, 81.25) 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, 143.75) v0.add( String(-21.66, -4, 'Yang', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) 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(275, 50, 275, 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(-6.665, -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, 45) v0.add( String(-6.665, -10, '-15', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1)))
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 * 1.0)) 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 * 1.0)) 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) for s in S: 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
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 checkLabelOverlap = self.checkLabelOverlap L = [] L_add = L.append 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 += 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() 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 sn, series in enumerate(normData): for i, angle in enumerate(series): endAngle = (startAngle + (angle * whichWay)) #% 360 if abs(startAngle - endAngle) < 1e-5: startAngle = endAngle continue if startAngle < endAngle: a1 = startAngle a2 = endAngle else: a1 = endAngle a2 = startAngle startAngle = endAngle #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) if sn == 0: text = self.getSeriesName(i, '') if text: averageAngle = (a1 + a2) / 2.0 aveAngleRadians = averageAngle * pi / 180.0 labelRadius = sectorStyle.labelRadius rx = xradius * labelRadius ry = yradius * labelRadius labelX = centerx + (0.5 * self.width * cos(aveAngleRadians) * labelRadius) labelY = centery + (0.5 * self.height * sin(aveAngleRadians) * labelRadius) l = _addWedgeLabel(self, text, averageAngle, labelX, labelY, sectorStyle) if checkLabelOverlap: l._origdata = { 'x': labelX, 'y': labelY, 'angle': averageAngle, 'rx': rx, 'ry': ry, 'cx': cx, 'cy': cy, 'bounds': l.getBounds(), } L_add(l) else: #single series doughnut iradius = self.height / 5.0 for i, angle in enumerate(normData): endAngle = (startAngle + (angle * whichWay)) #% 360 if abs(startAngle - endAngle) < 1e-5: startAngle = endAngle continue if startAngle < endAngle: a1 = startAngle a2 = endAngle else: a1 = endAngle a2 = startAngle startAngle = endAngle #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) rx = xradius * labelRadius ry = yradius * labelRadius l = _addWedgeLabel(self, labels[i], averageAngle, labelX, labelY, sectorStyle) if checkLabelOverlap: l._origdata = { 'x': labelX, 'y': labelY, 'angle': averageAngle, 'rx': rx, 'ry': ry, 'cx': cx, 'cy': cy, 'bounds': l.getBounds(), } L_add(l) if checkLabelOverlap and L: fixLabelOverlaps(L) for l in L: g.add(l) 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(230, 54, 24, 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(230, 78, -57, 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(230, 102, 20, 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(230, 126, 50, 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(230, 150, 92, 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(230, 62, 6, 8, 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, 86, -49, 8, 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, 110, -30, 8, 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, 134, 40, 8, 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, 158, 68, 8, 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)))
def draw(self): fillColor = self.fillColor strokeColor = self.strokeColor g = Group() bg = self.background bd = self.border bdw = self.borderWidth shadow = self.shadow x, y = self.x, self.y if bg: if shadow is not None and 0 <= shadow < 1: shadow = Color(bg.red * shadow, bg.green * shadow, bg.blue * shadow) self._paintLogo(g, dy=-2.5, dx=2, fillColor=shadow) self._paintLogo(g, fillColor=fillColor, strokeColor=strokeColor, _ocolors=getattr(self, '_ocolors', None), _pagecolors=getattr(self, '_pagecolors', None)) g.skew(kx=self.skewX, ky=self.skewY) g.shift(self._dx, self._dy) G = Group() G.add(g) _w, _h = 130, 86 w, h = self.width, self.height if bg or (bd and bdw): G.insert( 0, Rect(0, 0, _w, _h, fillColor=bg, strokeColor=bd, strokeWidth=bdw)) if w != _w or h != _h: G.scale(w / float(_w), h / float(_h)) angle = self.angle if self.angle: w, h = w / 2., h / 2. G.shift(-w, -h) G.rotate(angle) G.shift(w, h) xFlip = getattr(self, 'xFlip', 0) and -1 or 0 yFlip = getattr(self, 'yFlip', 0) and -1 or 0 if xFlip or yFlip: sx = xFlip or 1 sy = yFlip or 1 G.shift(sx * x + w * xFlip, sy * y + yFlip * h) G = Group(G, transform=(sx, 0, 0, sy, 0, 0)) else: G.shift(x, y) return G
def draw(self): sx = 0.5 fillColor = self.fillColor strokeColor = self.strokeColor shadow = Color(fillColor.red * sx, fillColor.green * sx, fillColor.blue * sx) g = Group() g2 = Group() g.add( Rect(fillColor=fillColor, strokeColor=fillColor, x=0, y=0, width=self._w, height=self._h)) sx = (self._w - 2) / self._sw() g2.scale(sx, 1) self._addPage(g2, strokeWidth=3, dx=2, dy=-2.5, color=shadow) self._addPage(g2, strokeWidth=3, color=strokeColor) g2.scale(1 / sx, 1) g2.add(self._getText(x=1, y=0, color=shadow)) g2.add(self._getText(x=0, y=1, color=strokeColor)) g2.scale(sx, 1) g2.skew(kx=10, ky=0) g2.shift(0, 38) g.add(g2) g.scale(self.width / self._w, self.height / self._h) g.shift(self.x, self.y) return g
def _rawDraw(self): _text = self._text self._text = _text or '' self.computeSize() self._text = _text g = Group() g.translate(self.x + self.dx, self.y + self.dy) g.rotate(self.angle) y = self._top - self._leading * self._baselineRatio textAnchor = self._getTextAnchor() if textAnchor == 'start': x = self._left elif textAnchor == 'middle': x = self._left + self._ewidth * 0.5 else: x = self._right # paint box behind text just in case they # fill it if self.boxFillColor or (self.boxStrokeColor and self.boxStrokeWidth): g.add( Rect(self._left - self.leftPadding, self._bottom - self.bottomPadding, self._width, self._height, strokeColor=self.boxStrokeColor, strokeWidth=self.boxStrokeWidth, fillColor=self.boxFillColor)) fillColor, fontName, fontSize = self.fillColor, self.fontName, self.fontSize strokeColor, strokeWidth, leading = self.strokeColor, self.strokeWidth, self._leading svgAttrs = getattr(self, '_svgAttrs', {}) if strokeColor: for line in self._lines: s = _text2Path(line, x, y, fontName, fontSize, textAnchor) s.fillColor = fillColor s.strokeColor = strokeColor s.strokeWidth = strokeWidth g.add(s) y -= leading else: for line in self._lines: s = String(x, y, line, _svgAttrs=svgAttrs) s.textAnchor = textAnchor s.fontName = fontName s.fontSize = fontSize s.fillColor = fillColor g.add(s) y -= leading return g
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])) 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
def makeCircularString(x, y, radius, angle, text, fontName, fontSize, inside=0, G=None, textAnchor='start'): '''make a group with circular text in it''' if not G: G = Group() angle %= 360 pi180 = pi / 180 phi = angle * pi180 width = stringWidth(text, fontName, fontSize) sig = inside and -1 or 1 hsig = sig * 0.5 sig90 = sig * 90 if textAnchor != 'start': if textAnchor == 'middle': phi += sig * (0.5 * width) / radius elif textAnchor == 'end': phi += sig * float(width) / radius elif textAnchor == 'numeric': phi += sig * float( numericXShift(textAnchor, text, width, fontName, fontSize, None)) / radius for letter in text: width = stringWidth(letter, fontName, fontSize) beta = float(width) / radius h = Group() h.add( String(0, 0, letter, fontName=fontName, fontSize=fontSize, textAnchor="start")) h.translate(x + cos(phi) * radius, y + sin(phi) * radius) #translate to radius and angle h.rotate((phi - hsig * beta) / pi180 - sig90) # rotate as needed G.add(h) #add to main group phi -= sig * beta #increment return G
def makeBackground(self): if self.background is not None: BG = self.background if isinstance(BG,Group): g = BG for bg in g.contents: bg.x = self.x bg.y = self.y bg.width = self.width bg.height = self.height else: g = Group() if type(BG) not in (type(()),type([])): BG=(BG,) for bg in BG: bg.x = self.x bg.y = self.y bg.width = self.width bg.height = self.height g.add(bg) return g else: strokeColor,strokeWidth,fillColor=self.strokeColor, self.strokeWidth, self.fillColor if (strokeWidth and strokeColor) or fillColor: g = Group() _3d_dy = getattr(self,'_3d_dy',None) x = self.x y = self.y h = self.height w = self.width if _3d_dy is not None: _3d_dx = self._3d_dx if fillColor and not strokeColor: from reportlab.lib.colors import Blacker c = Blacker(fillColor, getattr(self,'_3d_blacken',0.7)) else: c = strokeColor if not strokeWidth: strokeWidth = 0.5 if fillColor or strokeColor or c: bg = Polygon([x,y,x,y+h,x+_3d_dx,y+h+_3d_dy,x+w+_3d_dx,y+h+_3d_dy,x+w+_3d_dx,y+_3d_dy,x+w,y], strokeColor=strokeColor or c or grey, strokeWidth=strokeWidth, fillColor=fillColor) g.add(bg) g.add(Line(x,y,x+_3d_dx,y+_3d_dy, strokeWidth=0.5, strokeColor=c)) g.add(Line(x+_3d_dx,y+_3d_dy, x+_3d_dx,y+h+_3d_dy,strokeWidth=0.5, strokeColor=c)) fc = Blacker(c, getattr(self,'_3d_blacken',0.8)) g.add(Polygon([x,y,x+_3d_dx,y+_3d_dy,x+w+_3d_dx,y+_3d_dy,x+w,y], strokeColor=strokeColor or c or grey, strokeWidth=strokeWidth, fillColor=fc)) bg = Line(x+_3d_dx,y+_3d_dy, x+w+_3d_dx,y+_3d_dy,strokeWidth=0.5, strokeColor=c) else: bg = None else: bg = Rect(x, y, w, h, strokeColor=strokeColor, strokeWidth=strokeWidth, fillColor=fillColor) if bg: g.add(bg) return g else: return 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(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(50, 52.97619, 50, 11.90476, 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, 115.4762, 300, 11.90476, 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, 67.85714, 100, 11.90476, 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, 130.3571, 250, 11.90476, 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, 82.7381, 150, 11.90476, 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, 145.2381, 200, 11.90476, 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, 97.61905, 200, 11.90476, 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, 160.119, 150, 11.90476, 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, 50, 49, 175, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=0, strokeDashArray=None, strokeOpacity=None)) self.add( Line(49, 50, 44, 50, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(49, 112.5, 44, 112.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, 81.25) 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, 143.75) v0.add( String(-21.66, -4, 'Yang', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1))) 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(125, 50, 125, 45, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(200, 50, 200, 45, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(275, 50, 275, 45, strokeColor=Color(0, 0, 0, 1), strokeWidth=1, strokeLineCap=0, strokeLineJoin=0, strokeMiterLimit=10, strokeDashArray=None, strokeOpacity=None)) self.add( Line(350, 50, 350, 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(-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, 45) 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, 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, 275, 45) 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, 45) v0.add( String(-5, -10, '60', textAnchor='start', fontName='Times-Roman', fontSize=10, fillColor=Color(0, 0, 0, 1)))
def _Flag_Portugal(self): return Group()