Changeset 1696

Show
Ignore:
Timestamp:
12/15/06 19:22:48 (2 years ago)
Author:
eblot
Message:

RevtreePlugin:

  • Add LogEnhancer? as a (demo) plugin
  • Fix up Javascript issues with augmented 'circle' changesets
  • All revtree changesets are now defined as SVG groups
  • Add mark_first and mark_last changesets methods
  • Change the default color of termination changesets
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • revtreeplugin/0.10/revtree/enhancer.py

    r1694 r1696  
    5757            # changeset(from another branch) 
    5858            if firstchgset and firstchgset.clone: 
    59                 # tweak the color appearance of this changeset .. 
    60                 svgbranch.svgchangeset(firstchgset).invert_color() 
     59                # tweak the appearance of this changeset .. 
     60                svgbranch.svgchangeset(firstchgset).mark_first() 
    6161                (rev, path) = branch.source() 
    6262                srcchg = enhancer.repos.changeset(rev) 
     
    7070                if lastchgset.last: 
    7171                    # tweak the color of this changeset 
    72                     svgbranch.svgchangeset(lastchgset).kill() 
     72                    svgbranch.svgchangeset(lastchgset).mark_last() 
    7373        return enhancer 
    7474 
  • revtreeplugin/0.10/revtree/htdocs/js/svgtip.js

    r1675 r1696  
    55 * JTip is built on top of the very light weight jquery library. 
    66 * 
    7  * Badly hacked & tweaked to support XHTML/XML and SVG <emmanuel.blot@free.fr> 
     7 * Badly hacked & tweaked to support XHTML/XML and SVG for the RevtreePlugin 
     8 *   <emmanuel.blot@free.fr> 
    89 */ 
    910 
     
    4243  var params = parseQuery( queryString ); 
    4344  if(params['width'] === undefined){params['width'] = 250}; 
    44   if(params['link'] !== undefined){ 
     45  if(params['link'] !== undefined){      
    4546  $(object).bind('click',function(){window.location = params['link']}); 
    4647  //$(object).css('cursor','pointer'); 
     
    99100   var elem; 
    100101        for ( var n = 0; n < cnodes.length; n++ ) { 
    101       if ( cnodes[n].tagName == "circle" ) { 
     102      if ( cnodes[n].tagName == "g" ) { 
    102103         elem = cnodes[n] 
    103          break; 
    104       }  
    105       if ( cnodes[n].tagName == "rect" ) { 
    106          box = cnodes[n]; 
    107104         break; 
    108105      }  
  • revtreeplugin/0.10/revtree/svgview.py

    r1694 r1696  
    5454     
    5555    colormap = { 'black':       (0,0,0), 
     56                 'white':       (0xff,0xff,0xff), 
    5657                 'darkred':     (0x7f,0,0), 
    5758                 'darkgreen':   (0,0x7f,0), 
     
    195196        self._strokecolor = self._parent.strokecolor() 
    196197        self._textcolor = SvgColor('black') 
     198        self._classes = ['svgchangeset'] 
    197199         
    198200    def set_shape(self, shape): 
     201        """Define the shape of the svg changeset [circle,square,hexa]. 
     202           If the first letter is uppercase, the shape is augmented with 
     203           fancy lines. 
     204        """ 
    199205        self._shape = shape.lower() 
    200206        self._enhance = shape[0] != self._shape[0] 
    201207         
    202     def invert_color(self): 
     208    def mark_first(self): 
     209        """Marks the changeset as the first of the branch. 
     210           Inverts the background and the foreground color""" 
    203211        (self._fillcolor, self._strokecolor) = \ 
    204212            (self._strokecolor, self._fillcolor) 
    205213        self._textcolor.invert() 
    206          
    207     def kill(self): 
    208         self._strokecolor = SvgColor('red') 
     214        self._classes.append('firstchangeset') 
     215         
     216    def mark_last(self): 
     217        """Mark the changeset as the latest of the branch""" 
     218        self._fillcolor = SvgColor('black') 
     219        self._textcolor = SvgColor('white') 
     220        self._classes.append('lastchangeset') 
    209221 
    210222    def build(self): 
    211223        SvgBaseChangeset.build(self) 
     224        widgets = [] 
    212225        if self._shape == 'circle': 
    213             self._widget = SVG.circle(self._position[0], self._position[1], 
     226            widgets.append(SVG.circle(self._position[0], self._position[1], 
    214227                                      self._radius,  
    215228                                      self._fillcolor, 
    216229                                      self._strokecolor, 
    217                                       self._parent.strokewidth()) 
     230                                      self._parent.strokewidth())) 
    218231            if self._enhance: 
    219232                (x,y) = self._position 
    220233                (d,hr) = (self._radius*SQRT3/2, self._radius/2) 
    221                 lt = SVG.line(x-d,y-hr,x+d,y-hr,  
    222                               self._strokecolor, 
    223                               self._parent.strokewidth()) 
    224                 lb = SVG.line(x-d,y+hr,x+d,y+hr,  
    225                               self._strokecolor, 
    226                               self._parent.strokewidth()) 
    227                 g = SVG.group('grp%d' % self._revision, 
    228                               elements=[self._widget, lt, lb]) 
    229                 self._widget = g 
     234                widgets.append(SVG.line(x-d,y-hr,x+d,y-hr,  
     235                                        self._strokecolor, 
     236                                        self._parent.strokewidth())) 
     237                widgets.append(SVG.line(x-d,y+hr,x+d,y+hr,  
     238                                        self._strokecolor, 
     239                                        self._parent.strokewidth())) 
    230240                               
    231241        elif self._shape == 'square': 
    232             size = self._radius-UNIT/6 
    233             self._widget = SVG.rect(self._position[0]-size,  
     242            r = UNIT/6 
     243            size = self._radius-r 
     244            widgets.append(SVG.rect(self._position[0]-size,  
    234245                                    self._position[1]-size, 
    235246                                    2*size, 2*size,  
    236247                                    self._fillcolor, 
    237248                                    self._strokecolor, 
    238                                     self._parent.strokewidth()) 
     249                                    self._parent.strokewidth())) 
     250            outline.attributes['rx'] = r 
     251            outline.attributes['ry'] = r         
     252             
    239253        elif self._shape == 'hexa': 
    240254            (x,y) = self._position 
     
    248262            pd.line(x-r,y-hr) 
    249263            pd.line(x,y-r) 
    250             self._widget = SVG.path(pd, self._parent.fillcolor(),  
    251                                         self._parent.strokecolor(),  
    252                                         self._parent.strokewidth()) 
     264            widgets.append(SVG.path(pd, self._parent.fillcolor(),  
     265                                    self._parent.strokecolor(),  
     266                                    self._parent.strokewidth())) 
    253267        else: 
    254268            raise AssertionError, \ 
    255269                  "unsupported changeset shape (%d)" % self._revision 
    256270                   
    257         self._text = SVG.text(self._position[0] - self._htw,  
    258                               self._position[1] + UNIT/6, 
    259                               str(self._revision), FONT_SIZE, FONT_NAME) 
    260         self._text.attributes['style'] = 'fill:%s' % self._textcolor.rgb() 
     271        title = SVG.text(self._position[0] - self._htw,  
     272                         self._position[1] + UNIT/6, 
     273                         str(self._revision), FONT_SIZE, FONT_NAME) 
     274        title.attributes['style'] = 'fill:%s' % self._textcolor.rgb() 
     275        widgets.append(title) 
     276 
     277        g = SVG.group('grp%d' % self._revision, elements=widgets) 
    261278         
    262279        link = "%s/revtree_log/?rev=%d&link=%s/changeset/%d" \ 
    263280            % (self._parent.urlbase(), self._revision,  
    264281               self._parent.urlbase(), self._revision) 
    265         self._link = SVG.link(link, elements=[self._widget, self._text]) 
     282        self._link = SVG.link(link, elements=[g]) 
    266283        if self._revision: 
    267284            self._link.attributes['id'] = 'rev%d' % self._revision 
    268285            self._link.attributes['title'] = 'Changeset %d' % self._revision 
    269             self._link.attributes['class'] = 'svgtip' 
     286            self._link.attributes['class'] = ' '.join(self._classes) 
    270287                     
    271288    def visible(self): 
     
    596613       (such as a switch/branch creation, a merge operation, ...)""" 
    597614        
    598     def __init__(self, parent, srcChg, dstChg, color='black'): 
     615    def __init__(self, parent, srcChg, dstChg, color='black', classes=[]): 
    599616        self._parent = parent 
    600617        self._source = srcChg 
    601618        self._dest = dstChg 
    602619        self._color = SvgColor(color) 
     620        self._classes = classes 
    603621 
    604622    def build(self): 
     
    710728        self._widget.attributes['marker-%s' % (head and 'start' or 'end') ] = \ 
    711729            self._parent.svgarrow(self._color, head) 
     730        if self._classes: 
     731            self._widget.attributes['class'] = ' '.join(self._classes) 
    712732 
    713733    def extent(self): 
  • revtreeplugin/0.10/setup.py

    r1694 r1696  
    1515from setuptools import setup, find_packages 
    1616 
    17 PACKAGE = 'RevtreePlugin' 
    18 VERSION = '0.4.3
     17PACKAGE = 'TracRevtreePlugin' 
     18VERSION = '0.4.4
    1919 
    2020setup ( 
     
    2727    url='http://trac-hacks.org/wiki/RevtreePlugin', 
    2828    keywords = "trac revision svg graphical tree browser", 
    29     packages = find_packages(exclude=['ez_setup', '*.tests*']), 
     29    packages = find_packages(exclude=['ez_setup', '*.tests*', '*.enhancers.*']), 
    3030    package_data={ 
    3131        'revtree': [