Changeset 1071
- Timestamp:
- 11/13/06 17:36:06 (2 years ago)
- Files:
-
- gaphor/branches/new-canvas/doc/items.tex (modified) (4 diffs)
- gaphor/branches/new-canvas/gaphor/diagram/classifier.py (modified) (3 diffs)
- gaphor/branches/new-canvas/gaphor/diagram/diagramitem.py (modified) (1 diff)
- gaphor/branches/new-canvas/gaphor/diagram/elementitem.py (modified) (1 diff)
- gaphor/branches/new-canvas/gaphor/diagram/nameditem.py (modified) (4 diffs)
- gaphor/branches/new-canvas/gaphor/diagram/style.py (modified) (1 diff)
- gaphor/branches/new-canvas/gaphor/diagram/usecase.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gaphor/branches/new-canvas/doc/items.tex
r1048 r1071 172 172 named element item should set position of name depending on styles. 173 173 174 \section{Styles} 175 Class \rclass{ElementItem} defined below should define following styles 176 \begin{description} 177 \item[min--size] minimal size of an item; minimal width and height are 178 initialized using this style information 179 \end{description} 180 174 181 \section{Classes} 175 182 \rclass{DiagramItem} class is a basic, abstract class for all items. Every … … 189 196 \iattr{\_\_uml\_\_}{UML class associated with item} 190 197 \iattr{\_\_stereotype\_\_}{item static stereotype} 191 \iattr{\_\_style\_\_}{ item stylesinformation}192 \iattr{style}{ item style information}198 \iattr{\_\_style\_\_}{used to define new and override item style information} 199 \iattr{style}{used to obtain item style information, also information derived from base classes} 193 200 \end{attrs} 194 201 \begin{entitydesc} … … 212 219 \iattr{head}{reference to head handle of a line} 213 220 \iattr{tail}{reference to tail handle of a line} 214 \iattr{s\_align}{stereotype align}215 221 \end{attrs} 216 222 \begin{entitydesc} … … 220 226 221 227 \begin{class}{ElementItem} 228 \begin{attrs} 229 \iattr{min\_width}{minimal item width} 230 \iattr{min\_height}{minimal item height} 231 \end{attrs} 222 232 \begin{entitydesc} 223 233 Canvas element based items like class, component, lifeline, 224 234 comment, activity nodes, etc. 235 236 Minimal width and height are initialized from minimal size style 237 information. These two values can change during item lifecycle (i.e.\ name 238 can be expanded or shrinked), therefore minimal size style information 239 guards initial minimal dimensions of element item. 225 240 \end{entitydesc} 226 241 \end{class} gaphor/branches/new-canvas/gaphor/diagram/classifier.py
r1070 r1071 79 79 80 80 class ClassifierItem(NamedItem): 81 """This item visualizes a Class instance. 81 """ 82 This item visualizes a Class instance. 82 83 83 84 A ClassifierItem is a superclass for (all) Classifier like objects, … … 108 109 109 110 __style__ = { 110 'icon-size': (20, 20), 111 'min-size': (100, 50), 112 'icon-size': (20, 20), 111 113 'compartment-margin': (5, 5, 5, 5), # (top, right, bottom, left) 112 }114 } 113 115 # Default size for small icons 114 116 ICON_WIDTH = 15 … … 118 120 NAME_COMPARTMENT_HEIGHT = 35 119 121 120 def __init__(self, id = None , width = 100, height = 50):121 NamedItem.__init__(self, id , width, height)122 def __init__(self, id = None): 123 NamedItem.__init__(self, id) 122 124 self._compartments = [] 123 125 self._from = None # (from ...) text gaphor/branches/new-canvas/gaphor/diagram/diagramitem.py
r1070 r1071 14 14 15 15 class DiagramItem(Presentation, Element): 16 """Basic functionality for all model elements (lines and elements!). 16 """ 17 Basic functionality for all model elements (lines and elements!). 17 18 18 19 This class contains common functionallity for model elements and gaphor/branches/new-canvas/gaphor/diagram/elementitem.py
r1066 r1071 12 12 13 13 class ElementItem(gaphas.Element, DiagramItem): 14 __style__ = { 15 'min-size': (0, 0), 16 } 14 17 15 18 def __init__(self, id=None): 16 19 gaphas.Element.__init__(self) 17 20 DiagramItem.__init__(self, id) 21 22 self.min_width = self.style.min_size[0] 23 self.min_height = self.style.min_size[1] 18 24 self.auto_resize = 0 19 25 gaphor/branches/new-canvas/gaphor/diagram/nameditem.py
r1060 r1071 14 14 15 15 __style__ = { 16 'min-size' : (120, 60), 16 17 'name-align' : (ALIGN_CENTER, ALIGN_TOP), 17 18 'name-padding': (5, 10, 5, 10), … … 26 27 ) 27 28 28 def __init__(self, id = None, width = 120, height = 60):29 def __init__(self, id=None): 29 30 """ 30 31 Create named item. 31 32 Width, height and minimum size is set to default values determined33 by class level @C{WIDTH} and @C{HEIGHT} variables.34 32 """ 35 33 ElementItem.__init__(self, id) 36 34 37 self.min_width = width 38 self.min_height = height 39 self.width = self.min_width 40 self.height = self.min_height 41 self.name_x = 0 42 self.name_y = 0 35 self.width = self.min_width 36 self.height = self.min_height 37 self.name_x = 0 38 self.name_y = 0 43 39 44 40 … … 51 47 if text and not self.style.name_outside: 52 48 width, height = text_extents(cr, text) 49 53 50 self.min_width, self.min_height = get_min_size(width, height, 51 self.style.min_size, 54 52 self.style.name_padding) 53 55 54 super(NamedItem, self).pre_update(context) 56 55 … … 64 63 if text: 65 64 width, height = text_extents(cr, text) 65 66 66 self.name_x, self.name_y = get_text_point(text_extents(cr, text), 67 67 self.width, self.height, 68 68 self.style.name_align, self.style.name_padding, 69 69 self.style.name_outside) 70 70 71 super(NamedItem, self).update(context) 71 72 gaphor/branches/new-canvas/gaphor/diagram/style.py
r1059 r1071 49 49 50 50 51 def get_min_size(width, height, padding):51 def get_min_size(width, height, min_size, padding): 52 52 """ 53 Get minimum size of an object using padding information. 53 Get minimal size of an object using padding information. Calculated 54 size cannot be smaller than specified minimal size. 54 55 55 @param width: object width 56 @param height: object height 57 @param padding: padding information as a tuple 56 @param width: object width 57 @param height: object height 58 @param min_size: minimal size 59 @param padding: padding information as a tuple 58 60 (top, right, bottom, left) 59 61 """ 60 return width + padding[PADDING_LEFT] + padding[PADDING_RIGHT], \ 61 height + padding[PADDING_TOP] + padding[PADDING_BOTTOM] 62 width += padding[PADDING_LEFT] + padding[PADDING_RIGHT] 63 height += padding[PADDING_TOP] + padding[PADDING_BOTTOM] 64 if width < min_size[0]: 65 width = min_size[0] 66 if height < min_size[1]: 67 height = min_size[1] 68 return width, height 62 69 63 70 gaphor/branches/new-canvas/gaphor/diagram/usecase.py
r1059 r1071 1 ''' 2 Use case diagram item 3 ''' 4 # vim:sw=4 1 """ 2 Use case diagram item. 3 """ 5 4 6 5 from math import pi … … 11 10 12 11 class UseCaseItem(ClassifierItem): 13 """Presentation of gaphor.UML.UseCase. 12 """ 13 Presentation of gaphor.UML.UseCase. 14 14 """ 15 15 __uml__ = UML.UseCase 16 16 __style__ = { 17 'name-align' : (ALIGN_CENTER, ALIGN_MIDDLE), 17 'min-size': (50, 30), 18 'name-align': (ALIGN_CENTER, ALIGN_MIDDLE), 18 19 } 19 20 20 def __init__(self, id ):21 ClassifierItem.__init__(self, id , 50, 30)21 def __init__(self, id=None): 22 ClassifierItem.__init__(self, id) 22 23 self.drawing_style = -1 23 24
