/[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 491 by jonathan, Mon Mar 10 10:44:42 2003 UTC revision 544 by jonathan, Thu Mar 20 09:43:48 2003 UTC
# Line 60  class Classification: Line 60  class Classification:
60          self.fieldType = None          self.fieldType = None
61          self.groups = []          self.groups = []
62    
63            self.__setLayerLock = False
64    
65          self.SetDefaultGroup(ClassGroupDefault())          self.SetDefaultGroup(ClassGroupDefault())
66    
67          self.SetLayer(layer)          self.SetLayer(layer)
# Line 137  class Classification: Line 139  class Classification:
139             field type mismatch the information in the layer's table.             field type mismatch the information in the layer's table.
140          """          """
141    
142            # prevent infinite recursion when calling SetClassification()
143            if self.__setLayerLock: return
144    
145            self.__setLayerLock = True
146    
147          if layer is None:          if layer is None:
148              if self.layer is not None:              if self.layer is not None:
149                  l = self.layer                  l = self.layer
# Line 145  class Classification: Line 152  class Classification:
152          else:          else:
153              assert(isinstance(layer, Thuban.Model.layer.Layer))              assert(isinstance(layer, Thuban.Model.layer.Layer))
154    
             # prevent infinite recursion when calling SetClassification()  
             if layer == self.layer:  
                 return  
               
155              old_layer = self.layer              old_layer = self.layer
156    
157              self.layer = layer              self.layer = layer
# Line 157  class Classification: Line 160  class Classification:
160                  self.SetField(self.GetField()) # this sync's the fieldType                  self.SetField(self.GetField()) # this sync's the fieldType
161              except ValueError:              except ValueError:
162                  self.layer = old_layer                  self.layer = old_layer
163                    self.__setLayerLock = False
164                  raise ValueError                  raise ValueError
165              else:              else:
166                  self.layer.SetClassification(self)                  self.layer.SetClassification(self)
167    
168            self.__setLayerLock = False
169    
170      def GetLayer(self):      def GetLayer(self):
171          """Return the parent layer."""          """Return the parent layer."""
172          return self.layer          return self.layer
# Line 470  class ClassGroup: Line 476  class ClassGroup:
476          assert(isinstance(label, StringType))          assert(isinstance(label, StringType))
477          self.label = label          self.label = label
478    
479        def GetDisplayText(self):
480            assert(False, "GetDisplay must be overridden by subclass!")
481            return ""
482    
483      def Matches(self, value):      def Matches(self, value):
484          """Determines if this Group is associated with the given value.          """Determines if this Group is associated with the given value.
485    
486          Returns False. This needs to be overridden by all subclasses.          Returns False. This needs to be overridden by all subclasses.
487          """          """
488            assert(False, "GetMatches must be overridden by subclass!")
489          return False          return False
490    
491      def GetProperties(self):      def GetProperties(self):
# Line 482  class ClassGroup: Line 493  class ClassGroup:
493    
494          Returns None. This needs to be overridden by all subclasses.          Returns None. This needs to be overridden by all subclasses.
495          """          """
496            assert(False, "GetProperties must be overridden by subclass!")
497          return None          return None
498    
499            
# Line 547  class ClassGroupSingleton(ClassGroup): Line 559  class ClassGroupSingleton(ClassGroup):
559          assert(isinstance(prop, ClassGroupProperties))          assert(isinstance(prop, ClassGroupProperties))
560          self.prop = prop          self.prop = prop
561    
562        def GetDisplayText(self):
563            label = self.GetLabel()
564    
565            if label != "": return label
566    
567            return str(self.GetValue())
568    
569      def __eq__(self, other):      def __eq__(self, other):
570          return isinstance(other, ClassGroupSingleton) \          return isinstance(other, ClassGroupSingleton) \
571              and self.GetProperties() == other.GetProperties() \              and self.GetProperties() == other.GetProperties() \
# Line 597  class ClassGroupDefault(ClassGroup): Line 616  class ClassGroupDefault(ClassGroup):
616          assert(isinstance(prop, ClassGroupProperties))          assert(isinstance(prop, ClassGroupProperties))
617          self.prop = prop          self.prop = prop
618    
619        def GetDisplayText(self):
620            label = self.GetLabel()
621    
622            if label != "": return label
623    
624            return "DEFAULT"
625    
626      def __eq__(self, other):      def __eq__(self, other):
627          return isinstance(other, ClassGroupDefault) \          return isinstance(other, ClassGroupDefault) \
628              and self.GetProperties() == other.GetProperties()              and self.GetProperties() == other.GetProperties()
# Line 709  class ClassGroupRange(ClassGroup): Line 735  class ClassGroupRange(ClassGroup):
735          assert(isinstance(prop, ClassGroupProperties))          assert(isinstance(prop, ClassGroupProperties))
736          self.prop = prop          self.prop = prop
737    
738        def GetDisplayText(self):
739            label = self.GetLabel()
740    
741            if label != "": return label
742    
743            return _("%s - %s") % (self.GetMin(), self.GetMax())
744    
745      def __eq__(self, other):      def __eq__(self, other):
746          return isinstance(other, ClassGroupRange) \          return isinstance(other, ClassGroupRange) \
747              and self.GetProperties() == other.GetProperties() \              and self.GetProperties() == other.GetProperties() \
# Line 740  class ClassGroupMap(ClassGroup): Line 773  class ClassGroupMap(ClassGroup):
773      def GetPropertiesFromValue(self, value):      def GetPropertiesFromValue(self, value):
774          pass          pass
775    
776        def GetDisplayText(self):
777            return "Map: " + self.map_type
778    
779      #      #
780      # built-in mappings      # built-in mappings
781      #      #

Legend:
Removed from v.491  
changed lines
  Added in v.544

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26