|
Revision 2176, 1.5 kB
(checked in by wrobe..@pld-linux.org, 11 months ago)
|
- artifact icon was not displayed after gaphor's Item.{pre,post}_update
changes
|
- Property svn:eol-style set to
native
- Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 |
""" |
|---|
| 2 |
Artifact item. |
|---|
| 3 |
""" |
|---|
| 4 |
|
|---|
| 5 |
from gaphor import UML |
|---|
| 6 |
from gaphor.diagram.classifier import ClassifierItem |
|---|
| 7 |
|
|---|
| 8 |
class ArtifactItem(ClassifierItem): |
|---|
| 9 |
|
|---|
| 10 |
__uml__ = UML.Artifact |
|---|
| 11 |
__icon__ = True |
|---|
| 12 |
|
|---|
| 13 |
__style__ = { |
|---|
| 14 |
'name-padding': (10, 25, 10, 10), |
|---|
| 15 |
} |
|---|
| 16 |
|
|---|
| 17 |
ICON_HEIGHT = 20 |
|---|
| 18 |
|
|---|
| 19 |
def __init__(self, id=None): |
|---|
| 20 |
ClassifierItem.__init__(self, id) |
|---|
| 21 |
self.height = 50 |
|---|
| 22 |
self.width = 120 |
|---|
| 23 |
|
|---|
| 24 |
self.drawing_style = self.DRAW_COMPARTMENT_ICON |
|---|
| 25 |
self._line = [] |
|---|
| 26 |
|
|---|
| 27 |
def pre_update_compartment_icon(self, context): |
|---|
| 28 |
super(ArtifactItem, self).pre_update_compartment_icon(context) |
|---|
| 29 |
w = self.ICON_WIDTH |
|---|
| 30 |
h = self.ICON_HEIGHT |
|---|
| 31 |
ix, iy = self.get_icon_pos() |
|---|
| 32 |
ear = 5 |
|---|
| 33 |
self._line = ( |
|---|
| 34 |
(ix + w - ear, iy + ear), |
|---|
| 35 |
(ix + w, iy + ear), |
|---|
| 36 |
(ix + w - ear, iy), |
|---|
| 37 |
(ix, iy), |
|---|
| 38 |
(ix, iy + h), |
|---|
| 39 |
(ix + w, iy + h), |
|---|
| 40 |
(ix + w, iy + ear)) |
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
def draw_compartment_icon(self, context): |
|---|
| 44 |
cr = context.cairo |
|---|
| 45 |
cr.save() |
|---|
| 46 |
self.draw_compartment(context) |
|---|
| 47 |
cr.restore() |
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
w = self.ICON_WIDTH |
|---|
| 51 |
h = self.ICON_HEIGHT |
|---|
| 52 |
ix, iy = self.get_icon_pos() |
|---|
| 53 |
ear = 5 |
|---|
| 54 |
cr.set_line_width(1.0) |
|---|
| 55 |
cr.move_to(ix + w - ear, iy) |
|---|
| 56 |
for x, y in self._line: |
|---|
| 57 |
cr.line_to(x, y) |
|---|
| 58 |
cr.stroke() |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|