<commit_before># -*- coding: utf-8 -*-
from blockdiag.noderenderer import install_renderer
from blockdiag.utils import renderer
from blockdiag.utils.XY import XY
import blockdiag.DiagramMetrix


def render_node(drawer, format, node, metrix, **kwargs):
    outline = kwargs.get('outline')
    font = kwargs.get('font')
    fill = kwargs.get('fill')
    badgeFill = kwargs.get('badgeFill')

    m = metrix.cell(node)
    r = metrix.cellSize
    box = (m.top().x - r, m.top().y + metrix.nodeHeight / 2 - r,
           m.top().x + r, m.top().y + metrix.nodeHeight / 2 + r)

    drawer.ellipse(box, outline=outline,
                   fill=node.color, style=node.style)

    textbox = (m.top().x, m.top().y, m.right().x, m.right().y)
    drawer.textarea(textbox, node.label, fill=fill, halign="left",
                    font=font, fontsize=metrix.fontSize,
                    lineSpacing=metrix.lineSpacing)


def render_shadow(drawer, format, node, metrix, fill):
    m = metrix.cell(node)
    r = metrix.cellSize
    box = (m.top().x - r, m.top().y + metrix.nodeHeight / 2 - r,
           m.top().x + r, m.top().y + metrix.nodeHeight / 2 + r)

    shadow = renderer.shift_box(box, metrix.shadowOffsetX,
                                metrix.shadowOffsetY)

    drawer.ellipse(shadow, fill=fill, filter='transp-blur')


class NodeMetrix(object):
    def __init__(self, node, metrix):
        self.metrix = metrix
        top = metrix.cell(node).top()

        self.radius = self.metrix.cellSize
        self.center = XY(top.x, top.y + metrix.nodeHeight / 2)

    def top(self):
        return XY(self.center.x, self.center.y - self.radius)

    def left(self):
        return XY(self.center.x - self.radius, self.center.y)

    def right(self):
        return XY(self.center.x + self.radius, self.center.y)

    def bottom(self):
        return XY(self.center.x, self.center.y + self.radius)


def setup(self):
    install_renderer('endpoint', self)
<commit_msg> * Change to new style noderenderer: endpoint<commit_after># -*- coding: utf-8 -*-
from blockdiag.noderenderer import NodeShape
from blockdiag.noderenderer import install_renderer
from blockdiag.utils.XY import XY


class EndPoint(NodeShape):
    def __init__(self, node, metrix=None):
        super(EndPoint, self).__init__(node, metrix)

        self.radius = metrix.cellSize
        self.center = metrix.cell(node).center()

    def render_shape(self, drawer, format, **kwargs):
        outline = kwargs.get('outline')
        font = kwargs.get('font')
        fill = kwargs.get('fill')

        # draw outline
        r = self.radius
        box = (self.center.x - r, self.center.y - r,
               self.center.x + r, self.center.y + r)
        if kwargs.get('shadow'):
            box = self.shift_shadow(box)
            drawer.ellipse(box, fill=fill, outline=fill, filter='transp-blur')
        else:
            drawer.ellipse(box, fill=self.node.color, outline=outline,
                           style=self.node.style)

        # draw label
        if not kwargs.get('shadow'):
            m = self.metrix.cell(self.node)
            textbox = (m.top().x, m.top().y, m.right().x, m.right().y)
            drawer.textarea(textbox, self.node.label, fill=fill, halign="left",
                            font=font, fontsize=self.metrix.fontSize,
                            lineSpacing=self.metrix.lineSpacing)

    def top(self):
        return XY(self.center.x, self.center.y - self.radius)

    def left(self):
        return XY(self.center.x - self.radius, self.center.y)

    def right(self):
        return XY(self.center.x + self.radius, self.center.y)

    def bottom(self):
        return XY(self.center.x, self.center.y + self.radius)


def setup(self):
    install_renderer('endpoint', EndPoint)

{'fraction_non_alphanumeric': 0.1405505558496559, 'fraction_numerical': 0.0018528321863419798, 'mean_word_length': 2.3620996441281137, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5614253', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1238, 'n_words': 257}