Changeset 1575
- Timestamp:
- 07/05/07 01:57:49 (1 year ago)
- Files:
-
- gaphor/trunk/gaphor/diagram/activitynodes.py (modified) (6 diffs)
- gaphor/trunk/gaphor/ui/diagramtoolbox.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gaphor/trunk/gaphor/diagram/activitynodes.py
r1571 r1575 5 5 import math 6 6 7 from gaphas.util import path_ellipse , text_align7 from gaphas.util import path_ellipse 8 8 from gaphas.state import observed, reversible_property 9 from gaphas.item import NW, SE, NE, SW, Handle 10 from gaphas.solver import Variable, STRONG 9 from gaphas.item import Handle, Item 11 10 from gaphas.constraint import EqualsConstraint, LessThanConstraint 12 11 13 12 from gaphor import UML 14 13 from gaphor.core import inject 14 from gaphor.diagram.diagramitem import DiagramItem 15 15 from gaphor.diagram.nameditem import NamedItem 16 16 from gaphor.diagram.style import ALIGN_LEFT, ALIGN_CENTER, ALIGN_TOP, \ 17 17 ALIGN_RIGHT, ALIGN_BOTTOM 18 from gaphor.diagram.style import get_text_point 18 19 19 20 … … 188 189 189 190 190 class ForkNodeItem( ForkDecisionNodeItem):191 class ForkNodeItem(Item, DiagramItem): 191 192 """ 192 193 Representation of fork and join node. 193 194 """ 195 __namedelement__ = True 194 196 195 197 element_factory = inject('element_factory') 196 198 197 __uml__ = UML.JoinNode 198 #__uml__ = UML.ForkNode 199 __uml__ = UML.ForkNode 199 200 200 201 __style__ = { 201 202 'min-size': (6, 45), 202 203 'name-align': (ALIGN_CENTER, ALIGN_BOTTOM), 204 'name-padding': (2, 2, 2, 2), 205 'name-outside': True, 203 206 } 204 207 … … 209 212 210 213 def __init__(self, id=None): 211 ForkDecisionNodeItem.__init__(self, id) 212 213 self._join_spec=self.add_text('joinSpec.value', 214 Item.__init__(self) 215 DiagramItem.__init__(self, id) 216 217 self._handles.extend((Handle(), Handle())) 218 219 self._constraints = [] 220 221 self._join_spec = self.add_text('joinSpec.value', 214 222 pattern='{ joinSpec = %s }', 215 223 style=self.STYLE_TOP, 216 224 visible=self.is_join_spec_visible) 217 225 218 # disable Element handles 219 for h in self._handles: 220 h.movable = False 221 #h.visible = False 222 223 # add vertical handles 224 self._handles.append(Handle(strength=STRONG+1)) 225 self._handles.append(Handle(strength=STRONG+1)) 226 227 def setup_canvas(self): 228 Item.setup_canvas(self) 229 230 h1, h2 = self._handles 231 cadd = self.canvas.solver.add_constraint 232 c1 = EqualsConstraint(a=h1.x, b=h2.x) 233 c2 = LessThanConstraint(smaller=h1.y, bigger=h2.y, delta=30) 234 self._constraints.extend((cadd(c1), cadd(c2))) 235 236 237 def teardown_canvas(self): 238 super(Item, self).teardown_canvas() 239 for c in self._constraints: 240 self.canvas.solver.remove_constraint(c) 226 241 227 242 … … 231 246 """ 232 247 return isinstance(self.subject, UML.JoinNode) \ 248 and self.subject.joinSpec is not None \ 233 249 and self.subject.joinSpec.value != DEFAULT_JOIN_SPEC 234 250 235 251 236 def setup_canvas(self): 237 super(ForkNodeItem, self).setup_canvas() 238 cadd = self.canvas.solver.add_constraint 239 # h1, h2 = self._handles[4:] 240 # h_nw = self._handles[NW] 241 # h_sw = self._handles[SW] 242 # h1.y = h_nw.y 243 # h2.y = h_sw.y 244 # c1 = EqualsConstraint(a=h_nw.y, b=h1.y) 245 # c2 = EqualsConstraint(a=h_sw.y, b=h2.y) 246 # w = Variable(self.width / 2.0, STRONG+2) 247 # h1.x = h2.x = w 248 # c3 = EqualsConstraint(a=h1.x, b=w) 249 # c4 = EqualsConstraint(a=h2.x, b=w) 250 # c5 = LessThanConstraint(smaller=h1.y, bigger=h2.y) 251 # cadd(c1) 252 # cadd(c2) 253 # cadd(c3) 254 # cadd(c4) 255 # cadd(c5) 256 # self._constraints.append(c1) 257 # self._constraints.append(c2) 258 # self._constraints.append(c3) 259 # self._constraints.append(c4) 260 # self._constraints.append(c5) 252 def text_align(self, extents, align, padding, outside): 253 h1, h2 = self._handles 254 w, _ = self.style.min_size 255 h = h2.y - h1.y 256 x, y = get_text_point(extents, w, h, align, padding, outside) 257 258 return x, y 259 260 261 def pre_update(self, context): 262 self.update_stereotype() 263 Item.pre_update(self, context) 264 DiagramItem.pre_update(self, context) 265 266 267 def update(self, context): 268 Item.update(self, context) 269 DiagramItem.update(self, context) 261 270 262 271 … … 266 275 specification is also drawn above the item. 267 276 """ 268 cr = context.cairo 277 Item.draw(self, context) 278 DiagramItem.draw(self, context) 279 280 cr = context.cairo 281 269 282 cr.set_line_width(6) 270 h1, h2 = self._handles[4:] 271 cr.move_to(h1.x, 0) 272 cr.line_to(h2.x, self.height) 273 274 cr.stroke() 275 super(ForkNodeItem, self).draw(context) 283 h1, h2 = self._handles 284 cr.move_to(h1.x, h1.y) 285 cr.line_to(h2.x, h2.y) 286 287 cr.stroke() 288 289 290 def point(self, x, y): 291 return DiagramItem.point(self, x, y) 276 292 277 293 … … 283 299 text element. 284 300 """ 285 ForkDecisionNodeItem.on_subject_notify(self, pspec,301 DiagramItem.on_subject_notify(self, pspec, 286 302 ('joinSpec', 'joinSpec.value') + notifiers) 287 303 self.set_join_spec(DEFAULT_JOIN_SPEC) gaphor/trunk/gaphor/ui/diagramtoolbox.py
r1524 r1575 274 274 item_factory=self._item_factory(items.ForkNodeItem, 275 275 UML.JoinNode), 276 handle_index= SE,276 handle_index=1, 277 277 after_handler=self._after_handler) 278 278
