/[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 677 by jonathan, Thu Apr 10 17:55:57 2003 UTC revision 678 by jonathan, Tue Apr 15 19:21:26 2003 UTC
# Line 449  class ClassGroupProperties: Line 449  class ClassGroupProperties:
449                    
450      def GetLineColor(self):      def GetLineColor(self):
451          """Return the line color as a Color object."""          """Return the line color as a Color object."""
452          return self.stroke          return self.__stroke
453    
454      def SetLineColor(self, color):      def SetLineColor(self, color):
455          """Set the line color.          """Set the line color.
# Line 458  class ClassGroupProperties: Line 458  class ClassGroupProperties:
458          """          """
459    
460          assert isinstance(color, Color)          assert isinstance(color, Color)
461          self.stroke = color          self.__stroke = color
462    
463      def GetLineWidth(self):      def GetLineWidth(self):
464          """Return the line width."""          """Return the line width."""
465          return self.strokeWidth          return self.__strokeWidth
466    
467      def SetLineWidth(self, lineWidth):      def SetLineWidth(self, lineWidth):
468          """Set the line width.          """Set the line width.
# Line 473  class ClassGroupProperties: Line 473  class ClassGroupProperties:
473          if (lineWidth < 1):          if (lineWidth < 1):
474              raise ValueError(_("lineWidth < 1"))              raise ValueError(_("lineWidth < 1"))
475    
476          self.strokeWidth = lineWidth          self.__strokeWidth = lineWidth
477    
478      def GetFill(self):      def GetFill(self):
479          """Return the fill color as a Color object."""          """Return the fill color as a Color object."""
480          return self.fill          return self.__fill
481    
482      def SetFill(self, fill):      def SetFill(self, fill):
483          """Set the fill color.          """Set the fill color.
# Line 486  class ClassGroupProperties: Line 486  class ClassGroupProperties:
486          """          """
487    
488          assert isinstance(fill, Color)          assert isinstance(fill, Color)
489          self.fill = fill          self.__fill = fill
490    
491      def __eq__(self, other):      def __eq__(self, other):
492          """Return true if 'props' has the same attributes as this class"""          """Return true if 'props' has the same attributes as this class"""
493    
494            #
495            # using 'is' over '==' results in a huge performance gain
496            # in the renderer
497            #
498          return isinstance(other, ClassGroupProperties)   \          return isinstance(other, ClassGroupProperties)   \
499              and self.stroke      == other.GetLineColor() \              and (self.__stroke is other.__stroke or      \
500              and self.strokeWidth == other.GetLineWidth() \                   self.__stroke == other.__stroke)        \
501              and self.fill        == other.GetFill()              and (self.__fill is other.__fill or          \
502                     self.__fill == other.__fill)            \
503                and self.__strokeWidth == other.__strokeWidth
504    
505      def __ne__(self, other):      def __ne__(self, other):
506          return not self.__eq__(other)          return not self.__eq__(other)
# Line 605  class ClassGroupSingleton(ClassGroup): Line 611  class ClassGroupSingleton(ClassGroup):
611    
612      def GetValue(self):      def GetValue(self):
613          """Return the associated value."""          """Return the associated value."""
614          return self.value          return self.__value
615    
616      def SetValue(self, value):      def SetValue(self, value):
617          """Associate this Group with the given value."""          """Associate this Group with the given value."""
618          self.value = value          self.__value = value
619    
620      def Matches(self, value):      def Matches(self, value):
621          """Determine if the given value matches the associated Group value."""          """Determine if the given value matches the associated Group value."""
622    
623          """Returns True if the value matches, False otherwise."""          """Returns True if the value matches, False otherwise."""
624    
625          return self.value == value          return self.__value == value
626    
627      def GetDisplayText(self):      def GetDisplayText(self):
628          label = self.GetLabel()          label = self.GetLabel()
# Line 628  class ClassGroupSingleton(ClassGroup): Line 634  class ClassGroupSingleton(ClassGroup):
634      def __eq__(self, other):      def __eq__(self, other):
635          return ClassGroup.__eq__(self, other) \          return ClassGroup.__eq__(self, other) \
636              and isinstance(other, ClassGroupSingleton) \              and isinstance(other, ClassGroupSingleton) \
637              and self.GetValue() == other.GetValue()              and self.__value == other.__value
638    
639  class ClassGroupDefault(ClassGroup):  class ClassGroupDefault(ClassGroup):
640      """The default Group. When values do not match any other      """The default Group. When values do not match any other
# Line 688  class ClassGroupRange(ClassGroup): Line 694  class ClassGroupRange(ClassGroup):
694    
695          ClassGroup.__init__(self, label, props, group)          ClassGroup.__init__(self, label, props, group)
696    
697          self.min = self.max = 0          self.__min = self.__max = 0
698    
699          self.SetRange(min, max)          self.SetRange(min, max)
700    
# Line 705  class ClassGroupRange(ClassGroup): Line 711  class ClassGroupRange(ClassGroup):
711    
712      def GetMin(self):      def GetMin(self):
713          """Return the range's minimum value."""          """Return the range's minimum value."""
714          return self.min          return self.__min
715    
716      def SetMin(self, min):      def SetMin(self, min):
717          """Set the range's minimum value.          """Set the range's minimum value.
# Line 714  class ClassGroupRange(ClassGroup): Line 720  class ClassGroupRange(ClassGroup):
720                 maximum value. Use SetRange() to change both min and max values.                 maximum value. Use SetRange() to change both min and max values.
721          """          """
722            
723          self.SetRange(min, self.max)          self.SetRange(min, self.__max)
724    
725      def GetMax(self):      def GetMax(self):
726          """Return the range's maximum value."""          """Return the range's maximum value."""
# Line 726  class ClassGroupRange(ClassGroup): Line 732  class ClassGroupRange(ClassGroup):
732          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
733                 minimum value. Use SetRange() to change both min and max values.                 minimum value. Use SetRange() to change both min and max values.
734          """          """
735          self.SetRange(self.min, max)          self.SetRange(self.__min, max)
736    
737      def SetRange(self, min, max):      def SetRange(self, min, max):
738          """Set a new range.          """Set a new range.
# Line 740  class ClassGroupRange(ClassGroup): Line 746  class ClassGroupRange(ClassGroup):
746          if min >= max:          if min >= max:
747              raise ValueError(_("ClassGroupRange: %i(min) >= %i(max)!") %              raise ValueError(_("ClassGroupRange: %i(min) >= %i(max)!") %
748                               (min, max))                               (min, max))
749          self.min = min          self.__min = min
750          self.max = max          self.__max = max
751    
752      def GetRange(self):      def GetRange(self):
753          """Return the range as a tuple (min, max)"""          """Return the range as a tuple (min, max)"""
754          return (self.min, self.max)          return (self.__min, self.__max)
755    
756      def Matches(self, value):      def Matches(self, value):
757          """Determine if the given value lies with the current range.          """Determine if the given value lies with the current range.
# Line 753  class ClassGroupRange(ClassGroup): Line 759  class ClassGroupRange(ClassGroup):
759          The following check is used: min <= value < max.          The following check is used: min <= value < max.
760          """          """
761    
762          return self.min <= value < self.max          return self.__min <= value < self.__max
763    
764      def GetDisplayText(self):      def GetDisplayText(self):
765          label = self.GetLabel()          label = self.GetLabel()
# Line 765  class ClassGroupRange(ClassGroup): Line 771  class ClassGroupRange(ClassGroup):
771      def __eq__(self, other):      def __eq__(self, other):
772          return ClassGroup.__eq__(self, other) \          return ClassGroup.__eq__(self, other) \
773              and isinstance(other, ClassGroupRange) \              and isinstance(other, ClassGroupRange) \
774              and self.GetRange() == other.GetRange()              and self.__min == other.__min \
775                and self.__max == other.__max
776    
777  class ClassGroupMap(ClassGroup):  class ClassGroupMap(ClassGroup):
778      """Currently, this class is not used."""      """Currently, this class is not used."""

Legend:
Removed from v.677  
changed lines
  Added in v.678

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26