当前位置: 首页>>代码示例>>Python>>正文


Python String.fontName方法代码示例

本文整理汇总了Python中reportlab.graphics.shapes.String.fontName方法的典型用法代码示例。如果您正苦于以下问题:Python String.fontName方法的具体用法?Python String.fontName怎么用?Python String.fontName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在reportlab.graphics.shapes.String的用法示例。


在下文中一共展示了String.fontName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _draw_labels

# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontName [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)
开发者ID:BingW,项目名称:biopython,代码行数:61,代码来源:BasicChromosome.py

示例2: _draw_title

# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontName [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)
开发者ID:vincentdavis,项目名称:biopython,代码行数:10,代码来源:Distribution.py

示例3: _rawDraw

# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontName [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
开发者ID:hutton,项目名称:calcon,代码行数:57,代码来源:textlabels.py

示例4: _draw_label

# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontName [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)
开发者ID:BioGeek,项目名称:biopython,代码行数:13,代码来源:BasicChromosome.py

示例5: _draw_label

# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontName [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)
开发者ID:nuin,项目名称:biopython,代码行数:14,代码来源:BasicChromosome.py

示例6: draw

# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontName [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
开发者ID:uestcheng,项目名称:odoo,代码行数:55,代码来源:textlabels.py

示例7: _draw_label

# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontName [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)
开发者ID:sip958,项目名称:biopython,代码行数:22,代码来源:BasicChromosome.py

示例8: _addWedgeLabel

# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontName [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
开发者ID:SongJLG,项目名称:johan-doc,代码行数:41,代码来源:piecharts.py

示例9: makeSectors

# 需要导入模块: from reportlab.graphics.shapes import String [as 别名]
# 或者: from reportlab.graphics.shapes.String import fontName [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)
                    cy = centery + popdistance * sin(aveAngleRadians)

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

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

                g.add(theSector)

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

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

                    g.add(theLabel)

                startAngle = endAngle
                i = i + 1

        return g
开发者ID:eaudeweb,项目名称:naaya,代码行数:104,代码来源:doughnut.py


注:本文中的reportlab.graphics.shapes.String.fontName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。