Esempio n. 1
0
        def __init__(self, node, metrics=None):
            super(NationalFlagImage, self).__init__(node, metrics)

            self.textalign = 'left'
            self.image_path = image_path

            box = metrics.cell(node).box
            bounded = (box[2] - box[0], box[3] - box[1])
            size = images.get_image_size(image_path)
            size = images.calc_image_size(size, bounded)

            pt = metrics.cell(node).center
            self.image_box = Box(pt.x - size[0] / 2, pt.y - size[1] / 2,
                                 pt.x + size[0] / 2, pt.y + size[1] / 2)

            width = metrics.node_width / 2 - size[0] / 2 + metrics.cellsize
            self.textbox = Box(pt.x + size[0] / 2, pt.y - size[1] / 2,
                               pt.x + size[0] / 2 + width, pt.y + size[1] / 2)

            size = self.metrics.textsize(node.label,
                                         self.metrics.font_for(None),
                                         self.textbox.width)

            self.connectors[0] = XY(pt.x, self.image_box[1])
            self.connectors[1] = XY(
                self.image_box.x2 + size.width + self.metrics.node_padding,
                pt.y)
            self.connectors[2] = XY(pt.x, self.image_box[3])
            self.connectors[3] = XY(self.image_box[0], pt.y)
Esempio n. 2
0
    def __init__(self, node, metrics):
        self.node = node
        self.metrics = metrics

        m = self.metrics.cell(self.node)
        self.textalign = 'center'
        self.connectors = [m.top, m.right, m.bottom, m.left]

        if node.icon is None:
            self.iconbox = None
            self.textbox = m.box
        else:
            image_size = images.get_image_size(node.icon)
            if image_size is None:
                iconsize = (0, 0)
            else:
                boundedbox = [metrics.node_width // 2, metrics.node_height]
                iconsize = images.calc_image_size(image_size, boundedbox)

            vmargin = (metrics.node_height - iconsize[1]) // 2
            self.iconbox = Box(m.topleft.x,
                               m.topleft.y + vmargin,
                               m.topleft.x + iconsize[0],
                               m.topleft.y + vmargin + iconsize[1])

            self.textbox = Box(self.iconbox[2], m.top.y,
                               m.bottomright.x, m.bottomright.y)
Esempio n. 3
0
    def __init__(self, node, metrics):
        self.node = node
        self.metrics = metrics

        m = self.metrics.cell(self.node)
        self.textalign = 'center'
        self.connectors = [m.top, m.right, m.bottom, m.left]

        if node.icon is None:
            self.iconbox = None
            self.textbox = m.box
        else:
            image_size = images.get_image_size(node.icon)
            if image_size is None:
                iconsize = (0, 0)
            else:
                boundedbox = [metrics.node_width // 2, metrics.node_height]
                iconsize = images.calc_image_size(image_size, boundedbox)

            vmargin = (metrics.node_height - iconsize[1]) // 2
            self.iconbox = Box(m.topleft.x, m.topleft.y + vmargin,
                               m.topleft.x + iconsize[0],
                               m.topleft.y + vmargin + iconsize[1])

            self.textbox = Box(self.iconbox[2], m.top.y, m.bottomright.x,
                               m.bottomright.y)
Esempio n. 4
0
    def __init__(self, node, metrics=None):
        super(TextBox, self).__init__(node, metrics)

        if self.node.background:
            size = images.get_image_size(self.node.background)
            size = images.calc_image_size(size, self.textbox.size)

            pt = self.textbox.center
            self.textbox = Box(pt.x - size[0] // 2, pt.y - size[1] // 2,
                               pt.x + size[0] // 2, pt.y + size[1] // 2)

            self.connectors[0] = XY(pt.x, self.textbox[1])
            self.connectors[1] = XY(self.textbox[2], pt.y)
            self.connectors[2] = XY(pt.x, self.textbox[3])
            self.connectors[3] = XY(self.textbox[0], pt.y)

        if self.node.icon:
            self.connectors[3] = XY(self.iconbox[0], pt.y)
Esempio n. 5
0
    def __init__(self, node, metrics=None):
        super(TextBox, self).__init__(node, metrics)

        if self.node.background:
            size = images.get_image_size(self.node.background)
            size = images.calc_image_size(size, self.textbox.size)

            pt = self.textbox.center
            self.textbox = Box(pt.x - size[0] // 2, pt.y - size[1] // 2,
                               pt.x + size[0] // 2, pt.y + size[1] // 2)

            self.connectors[0] = XY(pt.x, self.textbox[1])
            self.connectors[1] = XY(self.textbox[2], pt.y)
            self.connectors[2] = XY(pt.x, self.textbox[3])
            self.connectors[3] = XY(self.textbox[0], pt.y)

        if self.node.icon:
            self.connectors[3] = XY(self.iconbox[0], pt.y)