/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/Model/classification.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/Model/classification.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 378 by jonathan, Tue Jan 28 12:13:28 2003 UTC revision 385 by jonathan, Mon Feb 3 11:43:56 2003 UTC
# Line 21  on the mapping algorithm. Line 21  on the mapping algorithm.
21  """  """
22        
23  from Thuban import _  from Thuban import _
24    from Thuban.Model.color import Color
25    
26    from wxPython.wx import *
27    
28  # constants  # constants
29  RANGE_MIN  = 0  RANGE_MIN  = 0
# Line 58  class Classification: Line 61  class Classification:
61    
62          self.NullData = data          self.NullData = data
63    
64        def getNull(self):
65            return self.NullData
66    
67      def addRange(self, min, max, data):      def addRange(self, min, max, data):
68          """Add a new range to the classification.          """Add a new range to the classification.
69    
# Line 118  class Classification: Line 124  class Classification:
124    
125          return self.NullData          return self.NullData
126    
127        def TreeInfo(self):
128            items = []
129    
130            #
131            # shouldn't print anything if there are no classifications
132            #
133    
134            
135            def color_string(color):
136                if color is None:
137                    return "None"
138                return "(%.3f, %.3f, %.3f)" % (color.red, color.green, color.blue)
139    
140            if self.NullData is not None:
141                i = []
142                for key, value in self.NullData.items():
143                    if isinstance(value, Color):
144                        i.append((_("%s: %s") % (key, color_string(value)), value))
145                    else:
146                        i.append(_("%s: %s") % (key, value))
147                items.append((_("'NULL'"), i))
148    
149            for name, data in self.points.items():
150                i = []
151                for key, value in data.items():
152                    if isinstance(value, Color):
153                        i.append((_("%s: %s") % (key, color_string(value)), value))
154                    else:
155                        i.append(_("%s: %s") % (key, value))
156                items.append((_("%s") % name, i))
157    
158            for p in self.ranges:
159                i = []
160                data = p[RANGE_DATA]
161                for key, value in data.items():
162                    if isinstance(value, Color):
163                        i.append((_("%s: %s") % (key, color_string(value)), value))
164                    else:
165                        i.append(_("%s: %s") % (key, value))
166                items.append((_("%s-%s") % (p[RANGE_MIN], p[RANGE_MAX], i)))
167          
168            return (_("Classifications"), items)
169    

Legend:
Removed from v.378  
changed lines
  Added in v.385

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26