| 1 |
''' |
|---|
| 2 |
eseCaseItempango diagram item |
|---|
| 3 |
''' |
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
from __future__ import generators |
|---|
| 7 |
|
|---|
| 8 |
import gobject |
|---|
| 9 |
import pango |
|---|
| 10 |
import diacanvas |
|---|
| 11 |
import gaphor.UML as UML |
|---|
| 12 |
from gaphor.diagram import initialize_item |
|---|
| 13 |
from classifier import ClassifierItem |
|---|
| 14 |
|
|---|
| 15 |
class UseCaseItem(ClassifierItem): |
|---|
| 16 |
MARGIN_X=60 |
|---|
| 17 |
MARGIN_Y=30 |
|---|
| 18 |
|
|---|
| 19 |
def __init__(self, id=None): |
|---|
| 20 |
ClassifierItem.__init__(self, id) |
|---|
| 21 |
self.set(height=50, width=100) |
|---|
| 22 |
self._border = diacanvas.shape.Ellipse() |
|---|
| 23 |
self._border.set_line_width(2.0) |
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
def on_update(self, affine): |
|---|
| 28 |
|
|---|
| 29 |
w, h = self.get_name_size() |
|---|
| 30 |
self.set(min_width=w + UseCaseItem.MARGIN_X, |
|---|
| 31 |
min_height=h + UseCaseItem.MARGIN_Y) |
|---|
| 32 |
self.update_name(x=0, y=(self.height - h) / 2, |
|---|
| 33 |
width=self.width, height=h) |
|---|
| 34 |
|
|---|
| 35 |
ClassifierItem.on_update(self, affine) |
|---|
| 36 |
|
|---|
| 37 |
self._border.ellipse(center=(self.width / 2, self.height / 2), |
|---|
| 38 |
width=self.width, height=self.height) |
|---|
| 39 |
self.expand_bounds(1.0) |
|---|
| 40 |
|
|---|
| 41 |
def on_shape_iter(self): |
|---|
| 42 |
yield self._border |
|---|
| 43 |
for s in ClassifierItem.on_shape_iter(self): |
|---|
| 44 |
yield s |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
initialize_item(UseCaseItem, UML.UseCase) |
|---|