Changeset 1071

Show
Ignore:
Timestamp:
11/13/06 17:36:06 (2 years ago)
Author:
wrobell
Message:

- minimal size style information support added to initialize minimal width

and height and also guard minimal size (i.e. use case item should not be
shrinked below specific size)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphor/branches/new-canvas/doc/items.tex

    r1048 r1071  
    172172named element item should set position of name depending on styles. 
    173173 
     174\section{Styles} 
     175Class \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 
    174181\section{Classes} 
    175182\rclass{DiagramItem} class is a basic, abstract class for all items. Every 
     
    189196\iattr{\_\_uml\_\_}{UML class associated with item} 
    190197\iattr{\_\_stereotype\_\_}{item static stereotype} 
    191 \iattr{\_\_style\_\_}{item styles information} 
    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
    193200\end{attrs} 
    194201\begin{entitydesc} 
     
    212219\iattr{head}{reference to head handle of a line} 
    213220\iattr{tail}{reference to tail handle of a line} 
    214 \iattr{s\_align}{stereotype align} 
    215221\end{attrs} 
    216222\begin{entitydesc} 
     
    220226 
    221227\begin{class}{ElementItem} 
     228\begin{attrs} 
     229\iattr{min\_width}{minimal item width} 
     230\iattr{min\_height}{minimal item height} 
     231\end{attrs} 
    222232\begin{entitydesc} 
    223233Canvas element based items like class, component, lifeline, 
    224234comment, activity nodes, etc. 
     235 
     236Minimal width and height are initialized from minimal size style 
     237information. These two values can change during item lifecycle (i.e.\ name 
     238can be expanded or shrinked), therefore minimal size style information 
     239guards initial minimal dimensions of element item. 
    225240\end{entitydesc} 
    226241\end{class} 
  • gaphor/branches/new-canvas/gaphor/diagram/classifier.py

    r1070 r1071  
    7979 
    8080class ClassifierItem(NamedItem): 
    81     """This item visualizes a Class instance. 
     81    """ 
     82    This item visualizes a Class instance. 
    8283 
    8384    A ClassifierItem is a superclass for (all) Classifier like objects, 
     
    108109 
    109110    __style__ = { 
    110         'icon-size': (20, 20), 
     111        'min-size':           (100, 50), 
     112        'icon-size':          (20, 20), 
    111113        'compartment-margin': (5, 5, 5, 5), # (top, right, bottom, left) 
    112        
     114   
    113115    # Default size for small icons 
    114116    ICON_WIDTH    = 15 
     
    118120    NAME_COMPARTMENT_HEIGHT = 35 
    119121 
    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
    122124        self._compartments = [] 
    123125        self._from = None # (from ...) text 
  • gaphor/branches/new-canvas/gaphor/diagram/diagramitem.py

    r1070 r1071  
    1414 
    1515class DiagramItem(Presentation, Element): 
    16     """Basic functionality for all model elements (lines and elements!). 
     16    """ 
     17    Basic functionality for all model elements (lines and elements!). 
    1718 
    1819    This class contains common functionallity for model elements and 
  • gaphor/branches/new-canvas/gaphor/diagram/elementitem.py

    r1066 r1071  
    1212 
    1313class ElementItem(gaphas.Element, DiagramItem): 
     14    __style__ = { 
     15        'min-size': (0, 0), 
     16    } 
    1417 
    1518    def __init__(self, id=None): 
    1619        gaphas.Element.__init__(self) 
    1720        DiagramItem.__init__(self, id) 
     21 
     22        self.min_width   = self.style.min_size[0] 
     23        self.min_height  = self.style.min_size[1] 
    1824        self.auto_resize = 0 
    1925 
  • gaphor/branches/new-canvas/gaphor/diagram/nameditem.py

    r1060 r1071  
    1414 
    1515    __style__ = { 
     16        'min-size'    : (120, 60), 
    1617        'name-align'  : (ALIGN_CENTER, ALIGN_TOP), 
    1718        'name-padding': (5, 10, 5, 10), 
     
    2627    ) 
    2728 
    28     def __init__(self, id = None, width = 120, height = 60): 
     29    def __init__(self, id=None): 
    2930        """ 
    3031        Create named item. 
    31  
    32         Width, height and minimum size is set to default values determined 
    33         by class level @C{WIDTH} and @C{HEIGHT} variables. 
    3432        """ 
    3533        ElementItem.__init__(self, id) 
    3634 
    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 
    4339 
    4440 
     
    5147        if text and not self.style.name_outside: 
    5248            width, height = text_extents(cr, text) 
     49 
    5350            self.min_width, self.min_height = get_min_size(width, height, 
     51                    self.style.min_size, 
    5452                    self.style.name_padding) 
     53 
    5554        super(NamedItem, self).pre_update(context) 
    5655 
     
    6463        if text: 
    6564            width, height = text_extents(cr, text) 
     65 
    6666            self.name_x, self.name_y = get_text_point(text_extents(cr, text), 
    6767                    self.width, self.height, 
    6868                    self.style.name_align, self.style.name_padding, 
    6969                    self.style.name_outside) 
     70 
    7071        super(NamedItem, self).update(context) 
    7172 
  • gaphor/branches/new-canvas/gaphor/diagram/style.py

    r1059 r1071  
    4949 
    5050 
    51 def get_min_size(width, height, padding): 
     51def get_min_size(width, height, min_size, padding): 
    5252    """ 
    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. 
    5455 
    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 
    5860        (top, right, bottom, left) 
    5961    """ 
    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 
    6269 
    6370 
  • gaphor/branches/new-canvas/gaphor/diagram/usecase.py

    r1059 r1071  
    1 ''' 
    2 Use case diagram item 
    3 ''' 
    4 # vim:sw=4 
     1""" 
     2Use case diagram item. 
     3""" 
    54 
    65from math import pi 
     
    1110 
    1211class UseCaseItem(ClassifierItem): 
    13     """Presentation of gaphor.UML.UseCase. 
     12    """ 
     13    Presentation of gaphor.UML.UseCase. 
    1414    """ 
    1515    __uml__ = UML.UseCase 
    1616    __style__ = { 
    17         'name-align'  : (ALIGN_CENTER, ALIGN_MIDDLE), 
     17        'min-size':   (50, 30), 
     18        'name-align': (ALIGN_CENTER, ALIGN_MIDDLE), 
    1819    } 
    1920 
    20     def __init__(self, id): 
    21         ClassifierItem.__init__(self, id, 50, 30
     21    def __init__(self, id=None): 
     22        ClassifierItem.__init__(self, id
    2223        self.drawing_style = -1 
    2324