本文整理汇总了Python中reportlab.graphics.shapes.String.fontSize方法的典型用法代码示例。如果您正苦于以下问题:Python String.fontSize方法的具体用法?Python String.fontSize怎么用?Python String.fontSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reportlab.graphics.shapes.String
的用法示例。
在下文中一共展示了String.fontSize方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _draw_labels
# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontSize [as 别名]
def _draw_labels(self, cur_drawing, left_labels, right_labels):
"""Layout and draw sub-feature labels for the chromosome.
Tries to place each label at the same vertical position as the
feature it applies to, but will adjust the positions to avoid or
at least reduce label overlap.
Draws the label text and a coloured line linking it to the
location (i.e. feature) it applies to.
"""
if not self._sub_components:
return
color_label = self._color_labels
segment_width = (self.end_x_position - self.start_x_position) \
* self.chr_percent
label_sep = (self.end_x_position - self.start_x_position) \
* self.label_sep_percent
segment_x = self.start_x_position \
+ 0.5 * (self.end_x_position - self.start_x_position - segment_width)
y_limits = []
for sub_component in self._sub_components:
y_limits.extend((sub_component.start_y_position, sub_component.end_y_position))
y_min = min(y_limits)
y_max = max(y_limits)
del y_limits
#Now do some label placement magic...
#from reportlab.pdfbase import pdfmetrics
#font = pdfmetrics.getFont('Helvetica')
#h = (font.face.ascent + font.face.descent) * 0.90
h = self.label_size
left_labels = _place_labels(left_labels, y_min, y_max, h)
right_labels = _place_labels(right_labels, y_min, y_max, h)
x1 = segment_x
x2 = segment_x - label_sep
for (y1, y2, color, name) in left_labels:
cur_drawing.add(Line(x1, y1, x2, y2,
strokeColor = color,
strokeWidth = 0.25))
label_string = String(x2, y2, name,
textAnchor="end")
label_string.fontName = 'Helvetica'
label_string.fontSize = self.label_size
if color_label:
label_string.fillColor = color
cur_drawing.add(label_string)
x1 = segment_x + segment_width
x2 = segment_x + segment_width + label_sep
for (y1, y2, color, name) in right_labels:
cur_drawing.add(Line(x1, y1, x2, y2,
strokeColor = color,
strokeWidth = 0.25))
label_string = String(x2, y2, name)
label_string.fontName = 'Helvetica'
label_string.fontSize = self.label_size
if color_label:
label_string.fillColor = color
cur_drawing.add(label_string)
示例2: _draw_title
# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontSize [as 别名]
def _draw_title(self, cur_drawing, title, width, height):
"""Add the title of the figure to the drawing (PRIVATE)."""
title_string = String(width / 2, height - inch, title)
title_string.fontName = "Helvetica-Bold"
title_string.fontSize = self.title_size
title_string.textAnchor = "middle"
cur_drawing.add(title_string)
示例3: _rawDraw
# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontSize [as 别名]
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
示例4: _draw_label
# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontSize [as 别名]
def _draw_label(self, cur_drawing, label_name):
"""Draw a label for the chromosome."""
x_position = 0.5 * (self.start_x_position + self.end_x_position)
y_position = self.end_y_position
label_string = String(x_position, y_position, label_name)
label_string.fontName = 'Times-BoldItalic'
label_string.fontSize = self.title_size
label_string.textAnchor = 'middle'
cur_drawing.add(label_string)
示例5: _draw_label
# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontSize [as 别名]
def _draw_label(self, cur_drawing, label_name):
"""Draw a label for the chromosome.
"""
x_position = self.start_x_position
y_position = self.end_y_position
label_string = String(x_position, y_position, label_name)
label_string.fontName = "Times-BoldItalic"
label_string.fontSize = self.title_size
label_string.textAnchor = "start"
cur_drawing.add(label_string)
示例6: draw
# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontSize [as 别名]
def draw(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.fontSize
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 or 1.2 * fontSize)
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 = y - leading
else:
for line in self._lines:
s = String(x, y, line)
s.textAnchor = textAnchor
s.fontName = fontName
s.fontSize = fontSize
s.fillColor = fillColor
g.add(s)
y = y - leading
return g
示例7: _draw_label
# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontSize [as 别名]
def _draw_label(self, cur_drawing):
"""Add a label to the chromosome segment.
The label will be applied to the right of the segment.
This may be overlapped by any sub-feature labels on other segments!
"""
if self.label is not None:
label_x = 0.5 * (self.start_x_position + self.end_x_position) + \
(self.chr_percent + 0.05) * (self.end_x_position -
self.start_x_position)
label_y = ((self.start_y_position - self.end_y_position) / 2 +
self.end_y_position)
label_string = String(label_x, label_y, self.label)
label_string.fontName = 'Helvetica'
label_string.fontSize = self.label_size
cur_drawing.add(label_string)
示例8: _addWedgeLabel
# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontSize [as 别名]
def _addWedgeLabel(self,text,angle,labelX,labelY,wedgeStyle,labelClass=WedgeLabel):
# now draw a label
if self.simpleLabels:
theLabel = String(labelX, labelY, text)
theLabel.textAnchor = "middle"
theLabel._pmv = angle
theLabel._simple_pointer = 0
else:
theLabel = labelClass()
theLabel._pmv = angle
theLabel.x = labelX
theLabel.y = labelY
theLabel.dx = wedgeStyle.label_dx
theLabel.dy = wedgeStyle.label_dy
theLabel.angle = wedgeStyle.label_angle
theLabel.boxAnchor = wedgeStyle.label_boxAnchor
theLabel.boxStrokeColor = wedgeStyle.label_boxStrokeColor
theLabel.boxStrokeWidth = wedgeStyle.label_boxStrokeWidth
theLabel.boxFillColor = wedgeStyle.label_boxFillColor
theLabel.strokeColor = wedgeStyle.label_strokeColor
theLabel.strokeWidth = wedgeStyle.label_strokeWidth
_text = wedgeStyle.label_text
if _text is None: _text = text
theLabel._text = _text
theLabel.leading = wedgeStyle.label_leading
theLabel.width = wedgeStyle.label_width
theLabel.maxWidth = wedgeStyle.label_maxWidth
theLabel.height = wedgeStyle.label_height
theLabel.textAnchor = wedgeStyle.label_textAnchor
theLabel.visible = wedgeStyle.label_visible
theLabel.topPadding = wedgeStyle.label_topPadding
theLabel.leftPadding = wedgeStyle.label_leftPadding
theLabel.rightPadding = wedgeStyle.label_rightPadding
theLabel.bottomPadding = wedgeStyle.label_bottomPadding
theLabel._simple_pointer = wedgeStyle.label_simple_pointer
theLabel.fontSize = wedgeStyle.fontSize
theLabel.fontName = wedgeStyle.fontName
theLabel.fillColor = wedgeStyle.fontColor
return theLabel
示例9: __init__
# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontSize [as 别名]
def __init__(self, barcode_value, width=200, height=320, fontSize=30):
barcode = BarcodeGen(barcode_value)
barcode.translate((width-barcode.width)/2, 0)
Drawing.__init__(self, width, height)
self.add(barcode, name='barcode')
box = Box.objects.get(barcode=barcode_value)
box_category = String(10, 275, box.box_category.letter)
box_category.fontSize = 55
box_id = String(10, 230, box.box_id)
box_id.fontSize = 55
expiration = String(12, 195, "Exp: " + box.get_printable_expiration())
expiration.fontSize = 30
category = String(12, 165, box.box_category.name)
category.fontSize = 15
weight = String(12, 150, "Weight: " + "%.1f" % box.weight + ' lbs.')
weight.fontSize = 15
contents = String(12, 135, "Contents:")
contents.fontSize = 15
count = 120
for content in box.contents_set.all():
item = String(17, count, content.item.name)
item.fontSize = 15
self.add(item, "item")
count = count - 15
self.add(box_category, "box_category")
self.add(box_id, "boxId")
self.add(category, "category")
self.add(expiration, "expiration")
self.add(weight, "weight")
self.add(contents, name="contents_of_box")
示例10: makeSectors
# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontSize [as 别名]
#.........这里部分代码省略.........
cx = centerx + popdistance * cos(aveAngleRadians)
cy = centery + popdistance * sin(aveAngleRadians)
if type(n) in (ListType, TupleType):
theSector = Wedge(
cx,
cy,
xradius + (sn * iradius) - iradius,
a1,
a2,
yradius=yradius + (sn * iradius) - iradius,
radius1=yradius + (sn * iradius) - (2 * iradius),
)
else:
theSector = Wedge(cx, cy, xradius, a1, a2, yradius=yradius, radius1=iradius)
theSector.fillColor = sectorStyle.fillColor
theSector.strokeColor = sectorStyle.strokeColor
theSector.strokeWidth = sectorStyle.strokeWidth
theSector.strokeDashArray = sectorStyle.strokeDashArray
g.add(theSector)
startAngle = endAngle
if labels[i] != "":
averageAngle = (a1 + a2) / 2.0
aveAngleRadians = averageAngle * pi / 180.0
labelRadius = sectorStyle.labelRadius
labelX = centerx + (0.5 * self.width * cos(aveAngleRadians) * labelRadius)
labelY = centery + (0.5 * self.height * sin(aveAngleRadians) * labelRadius)
theLabel = String(labelX, labelY, labels[i])
theLabel.textAnchor = "middle"
theLabel.fontSize = sectorStyle.fontSize
theLabel.fontName = sectorStyle.fontName
theLabel.fillColor = sectorStyle.fontColor
g.add(theLabel)
i = i + 1
sn = sn + 1
else:
# single series doughnut
styleCount = len(self.slices)
iradius = self.height / 5.0
for angle in normData:
endAngle = startAngle + (angle * whichWay) #% 360
if abs(startAngle - endAngle) >= 1e-5:
if startAngle < endAngle:
a1 = startAngle
a2 = endAngle
else:
a1 = endAngle
a2 = startAngle
# if we didn't use %stylecount here we'd end up with the later sectors
# all having the default style
sectorStyle = self.slices[i % styleCount]
# is it a popout?
cx, cy = centerx, centery
if sectorStyle.popout != 0:
# pop out the sector
averageAngle = (a1 + a2) / 2.0
aveAngleRadians = averageAngle * pi / 180.0
popdistance = sectorStyle.popout
cx = centerx + popdistance * cos(aveAngleRadians)
示例11: make_graphs
# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontSize [as 别名]
#.........这里部分代码省略.........
for key in self.framework.keys():
plot_dxdy.lines[key].strokeColor = None
plot_dxdy.lines[key].symbol = makeMarker('Circle')
plot_dxdy.lines[key].symbol.strokeColor = None
plot_dxdy.lines[key].symbol.fillColor = self.framework[key]["color"]
plot_dxdy.lines[key].symbol.size = 1.2
plot_dxdy.lines[3].strokeColor = None
plot_dxdy.lines[3].symbol = makeMarker('Circle')
plot_dxdy.lines[3].symbol.strokeColor = colors.blue
plot_dxdy.lines[3].symbol.fillColor = None
plot_dxdy.lines[3].symbol.strokeWidth = 0.6
plot_dxdy.lines[3].symbol.size = plot_dim*(self.sqrtr2)
#print plot_dxdy.lines[3].symbol.getProperties()
plot_dxdy.width = plot_dim
plot_dxdy.height = plot_dim
plot_dxdy.xValueAxis.valueMax = 1.0
plot_dxdy.xValueAxis.valueMin = -1.0
plot_dxdy.xValueAxis.joinAxis = plot_dxdy.yValueAxis
plot_dxdy.xValueAxis.joinAxisMode = 'value'
plot_dxdy.xValueAxis.joinAxisPos = -1.0
plot_dxdy.yValueAxis.valueMax = 1.0
plot_dxdy.yValueAxis.valueMin = -1.0
d_dxdy = Drawing(plot_dim,plot_dim)
d_dxdy.add(plot_dxdy)
# construct cdf plot
plot_cdf_pos = (left_margin*inch, height - 2.0*(plot_dim + 0.5*inch))
plot_cdf = LinePlot()
plot_cdf.data = self.plot_cdf_data
plot_cdf.lines[0].strokeColor = colors.blue
for key in std_colors.keys():
plot_cdf.lines[key+1].strokeColor = None
plot_cdf.lines[key+1].symbol = makeMarker('Circle')
plot_cdf.lines[key+1].symbol.strokeColor = None
plot_cdf.lines[key+1].symbol.fillColor = std_colors[key]
plot_cdf.lines[key+1].symbol.size = 1.2
if (len(self.plot_cdf_data) == 5):
plot_cdf.lines[4].strokeColor = colors.green
plot_cdf.width = plot_dim
plot_cdf.height = plot_dim
plot_cdf.xValueAxis.valueMax = 1.0
plot_cdf.xValueAxis.valueMin = 0.0
plot_cdf.yValueAxis.valueMax = 1.0
plot_cdf.yValueAxis.valueMin = 0.0
d_cdf = Drawing(plot_dim,plot_dim)
d_cdf.add(plot_cdf)
# construct pdf plot
plot_pdf_pos = (left_margin*inch, height - 3.0*(plot_dim + 0.5*inch))
plot_pdf = LinePlot()
plot_pdf.data = self.plot_pdf_data
plot_pdf.lines[1].strokeColor = colors.blue
plot_pdf.lines[0].strokeColor = None
plot_pdf.lines[0].symbol = makeMarker('Circle')
plot_pdf.lines[0].symbol.strokeColor = colors.red
plot_pdf.lines[0].symbol.size = 1
plot_pdf.width = plot_dim
plot_pdf.height = plot_dim
plot_pdf.xValueAxis.valueMax = 1.0
plot_pdf.xValueAxis.valueMin = 0.0
d_pdf = Drawing(2*plot_dim,plot_dim)
d_pdf.add(plot_pdf)
# add legend
legend = Legend()
legend.alignment = 'right'
legend.colorNamePairs = [(std_colors[0],'Inliers (%d'%int(self.fraction*100.0) + '% used for fit)'),
(std_colors[1],'Other inliers'),
(std_colors[2],'Outliers, reject next round'),]
for key in self.framework.keys():
legend.colorNamePairs.append( (self.framework[key]["color"], "%s"%self.framework[key]["status"] ) )
legend.x = plot_dim - 1.0*inch
legend.y = plot_dim
legend.columnMaximum = 8
d_pdf.add(legend)
# add titles
title_pos = (plot_dim/2.0,plot_dim + 0.25*inch)
title_dxdy = String(title_pos[0],title_pos[1],'dx vs. dy (all)')
title_dxdy.fontSize = 15
title_dxdy.textAnchor = 'middle'
d_dxdy.add(title_dxdy)
title_cdf = String(title_pos[0],title_pos[1],'cdf (good)')
title_cdf.fontSize = 15
title_cdf.textAnchor = 'middle'
d_cdf.add(title_cdf)
title_pdf = String(title_pos[0],title_pos[1],'pdf (good)')
title_pdf.fontSize = 15
title_pdf.textAnchor = 'middle'
d_pdf.add(title_pdf)
# draw everything
renderPDF.draw(d_dxdy,canvas,plot_dxdy_pos[0],plot_dxdy_pos[1])
renderPDF.draw(d_cdf,canvas,plot_cdf_pos[0],plot_cdf_pos[1])
renderPDF.draw(d_pdf,canvas,plot_pdf_pos[0],plot_pdf_pos[1])