<commit_before>"""
Package diagram item.
"""

from gaphas.util import text_align, text_extents, text_set_font
from gaphor import UML
from gaphor.diagram.nameditem import NamedItem
import font

class PackageItem(NamedItem):

    __uml__ = UML.Package, UML.Profile
    __stereotype__ = {
        'profile': UML.Profile,
    }
    __style__ = {
        'name-padding': (25, 10, 5, 10),
        'tab-x': 50,
        'tab-y': 20,
    }

    def pre_update(self, context):
        cr = context.cairo
        w, h = text_extents(cr, self.subject.name)
        self.min_width = w + 60
        self.min_height = h + 30 + self.style.tab_y
        if self.stereotype:
            s_w, s_h = text_extents(cr, self.stereotype)
            self.min_width = max(self.min_width, s_w)
            self.min_height += s_h

        super(PackageItem, self).pre_update(context)

    def draw(self, context):
        cr = context.cairo
        o = 0.0
        h = self.height
        w = self.width
        x = self.style.tab_x
        y = self.style.tab_y
        cr.move_to(x, y)
        cr.line_to(x, o)
        cr.line_to(o, o)
        cr.line_to(o, h)
        cr.line_to(w, h)
        cr.line_to(w, y)
        cr.line_to(o, y)
        cr.stroke()
        if self.stereotype:
            y += 10
            text_align(cr, w / 2, y, self.stereotype)
            y += 10

        if self.subject and self.subject.name:
            text_align(cr, w / 2, y + 10, self.subject.name)


# vim:sw=4:et<commit_msg>- leave drawing of name and stereotype to super classes<commit_after>"""
Package diagram item.
"""

from gaphas.util import text_align, text_extents, text_set_font
from gaphor import UML
from gaphor.diagram.nameditem import NamedItem
import font

class PackageItem(NamedItem):

    __uml__ = UML.Package, UML.Profile
    __stereotype__ = {
        'profile': UML.Profile,
    }
    __style__ = {
        'name-padding': (25, 10, 5, 10),
        'tab-x': 50,
        'tab-y': 20,
    }

    def draw(self, context):
        cr = context.cairo
        o = 0.0
        h = self.height
        w = self.width
        x = self.style.tab_x
        y = self.style.tab_y
        cr.move_to(x, y)
        cr.line_to(x, o)
        cr.line_to(o, o)
        cr.line_to(o, h)
        cr.line_to(w, h)
        cr.line_to(w, y)
        cr.line_to(o, y)
        cr.stroke()
        super(PackageItem, self).draw(context)


# vim:sw=4:et
{'fraction_non_alphanumeric': 0.12043189368770764, 'fraction_numerical': 0.016611295681063124, 'mean_word_length': 1.9024096385542169, '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': '1519834', 'n_tokens_mistral': 917, 'n_tokens_neox': 870, 'n_words': 198}