/[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 1351 by jonathan, Tue Jul 1 16:17:02 2003 UTC revision 1353 by jonathan, Wed Jul 2 09:36:54 2003 UTC
# Line 659  class ClassGroupRange(ClassGroup): Line 659  class ClassGroupRange(ClassGroup):
659      """A Group that represents a range of values that map to the same      """A Group that represents a range of values that map to the same
660         set of properties."""         set of properties."""
661    
662      def __init__(self, min = 0, max = 1, props = None, label = "", group=None):      def __init__(self, _range = (0,1), props = None, label = "", group=None):
663          """Constructor.          """Constructor.
664    
665          The minumum value must be strictly less than the maximum.          The minumum value must be strictly less than the maximum.
666    
667          min -- the minimum range value          _range -- either a tuple (min, max) where min < max or
668                      a Range object
         max -- the maximum range value  
669    
670          prop -- a ClassGroupProperites object. If prop is None a default          prop -- a ClassGroupProperites object. If prop is None a default
671                   set of properties is created.                   set of properties is created.
# Line 679  class ClassGroupRange(ClassGroup): Line 678  class ClassGroupRange(ClassGroup):
678          #self.__min = self.__max = 0          #self.__min = self.__max = 0
679          #self.__range = Range("[" + repr(float(min)) + ";" +          #self.__range = Range("[" + repr(float(min)) + ";" +
680                                     #repr(float(max)) + "[")                                     #repr(float(max)) + "[")
681          self.SetRange(min, max)          self.SetRange(_range)
682    
683      def __copy__(self):      def __copy__(self):
684          return ClassGroupRange(min = self.__range,          return ClassGroupRange(self.__range,
                                max = None,  
685                                 props = self.GetProperties(),                                 props = self.GetProperties(),
686                                 label = self.GetLabel())                                 label = self.GetLabel())
687    
688      def __deepcopy__(self, memo):      def __deepcopy__(self, memo):
689          return ClassGroupRange(min = copy.copy(self.__range),          return ClassGroupRange(copy.copy(self.__range),
                                max = copy.copy(self.GetMax()),  
690                                 group = self)                                 group = self)
691    
692      def GetMin(self):      def GetMin(self):
# Line 703  class ClassGroupRange(ClassGroup): Line 700  class ClassGroupRange(ClassGroup):
700                 maximum value. Use SetRange() to change both min and max values.                 maximum value. Use SetRange() to change both min and max values.
701          """          """
702            
703          self.SetRange(min, self.__range.GetRange()[2])          self.SetRange((min, self.__range.GetRange()[2]))
704    
705      def GetMax(self):      def GetMax(self):
706          """Return the range's maximum value."""          """Return the range's maximum value."""
# Line 715  class ClassGroupRange(ClassGroup): Line 712  class ClassGroupRange(ClassGroup):
712          max -- the new maximum. Note that this must be greater than the current          max -- the new maximum. Note that this must be greater than the current
713                 minimum value. Use SetRange() to change both min and max values.                 minimum value. Use SetRange() to change both min and max values.
714          """          """
715          self.SetRange(self.__range.GetRange()[1], max)          self.SetRange((self.__range.GetRange()[1], max))
716    
717      def SetRange(self, min, max = None):      def SetRange(self, _range):
718          """Set a new range.          """Set a new range.
719    
720          Note that min must be strictly less than max.          _range -- Either a tuple (min, max) where min < max or
721                      a Range object.
722    
723          min -- the new minimum value          Raises ValueError on error.
         min -- the new maximum value  
724          """          """
725    
726          if isinstance(min, Range):          if isinstance(_range, Range):
727              self.__range = min              self.__range = _range
728            elif isinstance(_range, types.TupleType) and len(_range) == 2:
729                self.__range = Range(("[", _range[0], _range[1], "["))
730          else:          else:
731              if max is None:              raise ValueError()
                 raise ValueError()  
   
             self.__range = Range(("[", min, max, "["))  
732    
733      def GetRange(self):      def GetRange(self):
734          """Return the range as a string"""          """Return the range as a string"""

Legend:
Removed from v.1351  
changed lines
  Added in v.1353

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26