<commit_before>"""
Artifact item.
"""

from gaphor import UML
from gaphor.diagram.classifier import ClassifierItem

class ArtifactItem(ClassifierItem):

    __uml__  = UML.Artifact
    __icon__ = True

    __style__ = {
            'name-padding': (10, 25, 10, 10),
    }

    ICON_HEIGHT = 20

    def __init__(self, id=None):
        ClassifierItem.__init__(self, id)
        self.height = 50
        self.width = 120
        # Set drawing style to compartment w/ small icon
        self.drawing_style = self.DRAW_COMPARTMENT_ICON
        self._line = []
        
    def update_compartment_icon(self, context):
        super(ArtifactItem, self).update_compartment_icon(context)
        w = self.ICON_WIDTH
        h = self.ICON_HEIGHT
        ix, iy = self.get_icon_pos()
        ear = 5
        self._line = (
                (ix + w - ear, iy + ear),
                (ix + w, iy + ear),
                (ix + w - ear, iy),
                (ix, iy),
                (ix, iy + h),
                (ix + w, iy + h),
                (ix + w, iy + ear))


    def draw_compartment_icon(self, context):
        cr = context.cairo
        cr.save()

        # draw icon
        w = self.ICON_WIDTH
        h = self.ICON_HEIGHT
        ix, iy = self.get_icon_pos()
        ear = 5
        cr.set_line_width(1.0)
        cr.move_to(ix + w - ear, iy)
        for x, y in self._line:
            cr.line_to(x, y)
        cr.stroke()

        cr.restore()
        self.draw_compartment(context)

# vim:sw=4:et
<commit_msg>- artifact icon was not displayed after gaphor's Item.{pre,post}_update   changes<commit_after>"""
Artifact item.
"""

from gaphor import UML
from gaphor.diagram.classifier import ClassifierItem

class ArtifactItem(ClassifierItem):

    __uml__  = UML.Artifact
    __icon__ = True

    __style__ = {
            'name-padding': (10, 25, 10, 10),
    }

    ICON_HEIGHT = 20

    def __init__(self, id=None):
        ClassifierItem.__init__(self, id)
        self.height = 50
        self.width = 120
        # Set drawing style to compartment w/ small icon
        self.drawing_style = self.DRAW_COMPARTMENT_ICON
        self._line = []
        
    def pre_update_compartment_icon(self, context):
        super(ArtifactItem, self).pre_update_compartment_icon(context)
        w = self.ICON_WIDTH
        h = self.ICON_HEIGHT
        ix, iy = self.get_icon_pos()
        ear = 5
        self._line = (
                (ix + w - ear, iy + ear),
                (ix + w, iy + ear),
                (ix + w - ear, iy),
                (ix, iy),
                (ix, iy + h),
                (ix + w, iy + h),
                (ix + w, iy + ear))


    def draw_compartment_icon(self, context):
        cr = context.cairo
        cr.save()
        self.draw_compartment(context)
        cr.restore()

        # draw icon
        w = self.ICON_WIDTH
        h = self.ICON_HEIGHT
        ix, iy = self.get_icon_pos()
        ear = 5
        cr.set_line_width(1.0)
        cr.move_to(ix + w - ear, iy)
        for x, y in self._line:
            cr.line_to(x, y)
        cr.stroke()



# vim:sw=4:et

{'fraction_non_alphanumeric': 0.10943031863533956, 'fraction_numerical': 0.012874155133569359, 'mean_word_length': 1.6406117247238743, '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': '4008237', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1044, 'n_words': 247}