[schema view] improve it slightly by attributing the same color to rdef of the same relation type
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 07 Jun 2010 19:17:16 +0200
changeset 5688 21658a3a386a
parent 5687 3ea39709b50e
child 5689 18d4e78b9369
[schema view] improve it slightly by attributing the same color to rdef of the same relation type
web/views/schema.py
--- a/web/views/schema.py	Mon Jun 07 19:01:21 2010 +0200
+++ b/web/views/schema.py	Mon Jun 07 19:17:16 2010 +0200
@@ -646,6 +646,7 @@
         self.visitor = visitor
         self.nextcolor = cycle( ('#ff7700', '#000000',
                                  '#ebbc69', '#888888') ).next
+        self.colors = {}
 
     def node_properties(self, eschema):
         """return DOT drawing options for an entity schema include href"""
@@ -688,7 +689,11 @@
                 kwargs['taillabel'] = s2d.CARD_MAP[rdef.cardinality[1]]
             if rdef.cardinality[0] != '1':
                 kwargs['headlabel'] = s2d.CARD_MAP[rdef.cardinality[0]]
-            kwargs['color'] = self.nextcolor()
+            try:
+                kwargs['color'] = self.colors[rschema]
+            except:
+                kwargs['color'] = self.nextcolor()
+                self.colors[rschema] = kwargs['color']
         kwargs['fontcolor'] = kwargs['color']
         # dot label decoration is just awful (1 line underlining the label
         # + 1 line going to the closest edge spline point)