本文整理匯總了Python中reportlab.graphics.shapes.Wedge類的典型用法代碼示例。如果您正苦於以下問題:Python Wedge類的具體用法?Python Wedge怎麽用?Python Wedge使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Wedge類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _draw_segment
def _draw_segment(self, cur_drawing):
"""Draw a half circle representing the end of a linear chromosome.
"""
# set the coordinates of the segment -- it'll take up the MIDDLE part
# of the space we have.
width = (self.end_x_position - self.start_x_position) \
* self.chr_percent
height = self.start_y_position - self.end_y_position
center_x = 0.5 * (self.end_x_position + self.start_x_position)
start_x = center_x - 0.5 * width
if self._inverted:
center_y = self.start_y_position
start_angle = 180
end_angle = 360
else:
center_y = self.end_y_position
start_angle = 0
end_angle = 180
cap_wedge = Wedge(center_x, center_y, width / 2,
start_angle, end_angle, height)
cap_wedge.strokeColor = None
cap_wedge.fillColor = self.fill_color
cur_drawing.add(cap_wedge)
# Now draw an arc for the curved edge of the wedge,
# omitting the flat end.
cap_arc = ArcPath()
cap_arc.addArc(center_x, center_y, width / 2,
start_angle, end_angle, height)
cur_drawing.add(cap_arc)
示例2: _draw_segment
def _draw_segment(self, cur_drawing):
"""Draw a half circle representing the end of a linear chromosome.
"""
# set the coordinates of the segment -- it'll take up the left part
# of the space we have.
width = (self.end_x_position - self.start_x_position) \
* self.chr_percent
height = self.start_y_position - self.end_y_position
center_x = self.start_x_position + width / 2
if self._inverted:
center_y = self.start_y_position
start_angle = 180
end_angle = 360
else:
center_y = self.end_y_position
start_angle = 0
end_angle = 180
cap_wedge = Wedge(center_x, center_y, width / 2,
start_angle, end_angle, height / 2)
cap_wedge.fillColor = self.fill_color
cur_drawing.add(cap_wedge)
# draw a line to cover up the the bottom part of the wedge
if self._inverted:
cover_line = Line(self.start_x_position, self.start_y_position,
self.start_x_position + width,
self.start_y_position)
else:
cover_line = Line(self.start_x_position, self.end_y_position,
self.start_x_position + width,
self.end_y_position)
if self.fill_color is not None:
cover_color = self.fill_color
else:
cover_color = colors.white
cover_line.strokeColor = cover_color
cur_drawing.add(cover_line)
示例3: makeWedges
def makeWedges(self):
# normalize slice data
normData = self.normalizeData()
n = len(normData)
labels = _fixLabels(self.labels,n)
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()
i = 0
styleCount = len(self.slices)
startAngle = self.startAngle #% 360
for angle in normData:
endAngle = (startAngle + (angle * whichWay)) #% 360
if abs(startAngle-endAngle)>=1e-5:
if startAngle < endAngle:
a1 = startAngle
a2 = endAngle
else:
a1 = endAngle
a2 = startAngle
#if we didn't use %stylecount here we'd end up with the later wedges
#all having the default style
wedgeStyle = self.slices[i%styleCount]
# is it a popout?
cx, cy = centerx, centery
if wedgeStyle.popout <> 0:
# pop out the wedge
averageAngle = (a1+a2)/2.0
aveAngleRadians = averageAngle * pi/180.0
popdistance = wedgeStyle.popout
cx = centerx + popdistance * cos(aveAngleRadians)
cy = centery + popdistance * sin(aveAngleRadians)
if n > 1:
theWedge = Wedge(cx, cy, xradius, a1, a2, yradius=yradius)
elif n==1:
theWedge = Ellipse(cx, cy, xradius, yradius)
theWedge.fillColor = wedgeStyle.fillColor
theWedge.strokeColor = wedgeStyle.strokeColor
theWedge.strokeWidth = wedgeStyle.strokeWidth
theWedge.strokeDashArray = wedgeStyle.strokeDashArray
g.add(theWedge)
text = labels[i]
if text:
averageAngle = (a1+a2)/2.0
aveAngleRadians = averageAngle*pi/180.0
labelRadius = wedgeStyle.labelRadius
labelX = cx + (0.5 * self.width * cos(aveAngleRadians) * labelRadius)
labelY = cy + (0.5 * self.height * sin(aveAngleRadians) * labelRadius)
_addWedgeLabel(self,text,g.add,averageAngle,labelX,labelY,wedgeStyle)
startAngle = endAngle
i = i + 1
return g
示例4: sample1
def sample1():
"Make up something from the individual Sectors"
d = Drawing(400, 400)
g = Group()
s1 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=0, endangledegrees=120, radius1=100)
s1.fillColor = colors.red
s1.strokeColor = None
d.add(s1)
s2 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=120, endangledegrees=240, radius1=100)
s2.fillColor = colors.green
s2.strokeColor = None
d.add(s2)
s3 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=240, endangledegrees=260, radius1=100)
s3.fillColor = colors.blue
s3.strokeColor = None
d.add(s3)
s4 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=260, endangledegrees=360, radius1=100)
s4.fillColor = colors.gray
s4.strokeColor = None
d.add(s4)
return d
示例5: makeSectors
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))
else:
normData = self.normalizeData(self.data)
n = len(normData)
# labels
if self.labels is None:
labels = []
if type(n) not in (ListType, TupleType):
labels = [""] * n
else:
for m in n:
labels = list(labels) + [""] * m
else:
labels = self.labels
# there's no point in raising errors for less than enough errors if
# we silently create all for the extreme case of no labels.
if type(n) not in (ListType, TupleType):
i = n - len(labels)
if i > 0:
labels = list(labels) + [""] * i
else:
tlab = 0
for m in n:
tlab = tlab + m
i = tlab - len(labels)
if i > 0:
labels = list(labels) + [""] * i
xradius = self.width / 2.0
yradius = self.height / 2.0
centerx = self.x + xradius
centery = self.y + yradius
if self.direction == "anticlockwise":
whichWay = 1
else:
whichWay = -1
g = Group()
i = 0
sn = 0
startAngle = self.startAngle #% 360
if type(self.data[0]) in (ListType, TupleType):
# multi-series doughnut
styleCount = len(self.slices)
iradius = (self.height / 5.0) / len(self.data)
for series in normData:
for angle in series:
endAngle = startAngle + (angle * whichWay) #% 360
if abs(startAngle - endAngle) >= 1e-5:
if startAngle < endAngle:
a1 = startAngle
a2 = endAngle
else:
a1 = endAngle
a2 = startAngle
# if we didn't use %stylecount here we'd end up with the later sectors
# all having the default style
sectorStyle = self.slices[i % styleCount]
# is it a popout?
cx, cy = centerx, centery
if sectorStyle.popout != 0:
# pop out the sector
averageAngle = (a1 + a2) / 2.0
aveAngleRadians = averageAngle * pi / 180.0
popdistance = sectorStyle.popout
cx = centerx + popdistance * cos(aveAngleRadians)
cy = centery + popdistance * sin(aveAngleRadians)
if type(n) in (ListType, TupleType):
theSector = Wedge(
cx,
cy,
xradius + (sn * iradius) - iradius,
a1,
a2,
yradius=yradius + (sn * iradius) - iradius,
radius1=yradius + (sn * iradius) - (2 * iradius),
)
else:
theSector = Wedge(cx, cy, xradius, a1, a2, yradius=yradius, radius1=iradius)
theSector.fillColor = sectorStyle.fillColor
theSector.strokeColor = sectorStyle.strokeColor
theSector.strokeWidth = sectorStyle.strokeWidth
theSector.strokeDashArray = sectorStyle.strokeDashArray
#.........這裏部分代碼省略.........
示例6: makeSectors
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)
#.........這裏部分代碼省略.........
示例7: makeWedges
def makeWedges(self):
angles = self.makeAngles()
n = len(angles)
labels = _fixLabels(self.labels,n)
self._seriesCount = n
styleCount = len(self.slices)
plMode = self.pointerLabelMode
if plMode:
checkLabelOverlap = False
PL=self.makePointerLabels(angles,plMode)
xradius = PL.xradius
yradius = PL.yradius
centerx = PL.centerx
centery = PL.centery
PL_data = PL.data
gSN = lambda i: ''
else:
xradius = self.width*0.5
yradius = self.height*0.5
centerx = self.x + xradius
centery = self.y + yradius
if self.xradius: xradius = self.xradius
if self.yradius: yradius = self.yradius
if self.sameRadii: xradius=yradius=min(xradius,yradius)
checkLabelOverlap = self.checkLabelOverlap
gSN = lambda i: self.getSeriesName(i,'')
g = Group()
g_add = g.add
if checkLabelOverlap:
L = []
L_add = L.append
else:
L_add = g_add
for i,(a1,a2) in angles:
if a2 is None: continue
#if we didn't use %stylecount here we'd end up with the later wedges
#all having the default style
wedgeStyle = self.slices[i%styleCount]
if not wedgeStyle.visible: continue
# is it a popout?
cx, cy = centerx, centery
text = gSN(i)
popout = wedgeStyle.popout
if text or popout:
averageAngle = (a1+a2)/2.0
aveAngleRadians = averageAngle/_180_pi
cosAA = cos(aveAngleRadians)
sinAA = sin(aveAngleRadians)
if popout:
# pop out the wedge
cx = centerx + popout*cosAA
cy = centery + popout*sinAA
if n > 1:
theWedge = Wedge(cx, cy, xradius, a1, a2, yradius=yradius)
elif n==1:
theWedge = Ellipse(cx, cy, xradius, yradius)
theWedge.fillColor = wedgeStyle.fillColor
theWedge.strokeColor = wedgeStyle.strokeColor
theWedge.strokeWidth = wedgeStyle.strokeWidth
theWedge.strokeDashArray = wedgeStyle.strokeDashArray
g_add(theWedge)
if wedgeStyle.label_visible:
if text:
labelRadius = wedgeStyle.labelRadius
rx = xradius*labelRadius
ry = yradius*labelRadius
labelX = cx + rx*cosAA
labelY = cy + ry*sinAA
_addWedgeLabel(self,text,L_add,averageAngle,labelX,labelY,wedgeStyle)
if checkLabelOverlap:
l = L[-1]
l._origdata = { 'x': labelX, 'y':labelY, 'angle': averageAngle,
'rx': rx, 'ry':ry, 'cx':cx, 'cy':cy,
'bounds': l.getBounds(),
}
elif plMode and PL_data:
l = PL_data[i]
if l:
data = l._origdata
sinM = data['smid']
cosM = data['cmid']
lX = cx + xradius*cosM
lY = cy + yradius*sinM
lpel = wedgeStyle.label_pointer_elbowLength
lXi = lX + lpel*cosM
lYi = lY + lpel*sinM
L_add(PolyLine((lX,lY,lXi,lYi,l.x,l.y),
strokeWidth=wedgeStyle.label_pointer_strokeWidth,
strokeColor=wedgeStyle.label_pointer_strokeColor))
L_add(l)
if checkLabelOverlap and L:
#.........這裏部分代碼省略.........