Changeset 1697

Show
Ignore:
Timestamp:
12/16/06 07:29:42 (2 years ago)
Author:
eblot
Message:

RevtreePlugin:

  • Fix up an issue with info box placement
  • Changeset color is now based on the branch name (pseudo random: a branch
    is always assigned the same color)
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • revtreeplugin/0.10/revtree/htdocs/js/svgtip.js

    r1696 r1697  
    4848  } 
    4949     
    50   if(hasArea>((params['width']*1)+75)){ 
     50  if(hasArea>((params['width']*1)+box.w)){ 
    5151     var arrowOffset = box.w + 11; 
    5252     var clickElementx = box.x + arrowOffset + 3; 
  • revtreeplugin/0.10/revtree/svgview.py

    r1696 r1697  
    1515import SVGdraw as SVG 
    1616import os 
     17import md5 
    1718 
    1819from colorsys import rgb_to_hsv, hsv_to_rgb 
     
    6465                 'orange':      (0xff,0x9f,0) } 
    6566     
    66     def __init__(self, value=None): 
     67    def __init__(self, value=None, name=None): 
    6768        if value is not None: 
    6869            if isinstance(value, SvgColor): 
     
    7879            else: 
    7980                raise AssertionError, "unsupportedcolor: %s" % value 
    80         else: 
    81             # FIXME: use some kind of checksum-based colorization 
    82             # i.e. branchname -> checksum -> color for permanent branch-color 
    83             # mapping (persistence over graph generation) 
     81        elif name is not None: 
     82            self._color = SvgColor.from_name(name) 
     83        else: 
    8484            self._color = SvgColor.random() 
    8585             
     
    121121                128+14*int(rand[2])) 
    122122    random = staticmethod(random) 
     123     
     124    def from_name(name): 
     125        dig = md5.new(name).digest() 
     126        vr = 14*(int(ord(dig[0]))%10) 
     127        vg = 14*(int(ord(dig[1]))%10) 
     128        vb = 14*(int(ord(dig[2]))%10) 
     129        return (128+vr, 128+vg, 128+vb) 
     130    from_name = staticmethod(from_name) 
    123131     
    124132    def invert(self): 
     
    391399             
    392400    def _get_color(self, name, trunks): 
    393         """Generates a random pastel color and returns it as a string, 
    394            or returns a predefined color if the branch is a trunk""" 
     401        """Creates a random pastel color based on the branch name  
     402        or returns a predefined color if the branch is a trunk""" 
    395403        if name in trunks: 
    396404            return SvgColor(self._parent.env.config.get('revtree',  
     
    398406                                                        '#cfcfcf')) 
    399407        else: 
    400             return SvgColor(
     408            return SvgColor(name=name
    401409                       
    402410    def build(self, position):