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

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

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

revision 1524 by jonathan, Wed Jul 16 13:21:59 2003 UTC revision 1525 by jonathan, Wed Jul 30 15:42:56 2003 UTC
# Line 377  def calculate_quantiles(_list, percents, Line 377  def calculate_quantiles(_list, percents,
377  class CustomRamp:  class CustomRamp:
378    
379      def __init__(self, prop1, prop2):      def __init__(self, prop1, prop2):
380            """Create a ramp between prop1 and prop2."""
381          self.prop1 = prop1          self.prop1 = prop1
382          self.prop2 = prop2          self.prop2 = prop2
383    
384      def GetRamp(self):      def GetRamp(self):
385            """Return this ramp."""
386          return self          return self
387    
388      def GetProperties(self, index):      def GetProperties(self, index):
# Line 410  class CustomRamp: Line 412  class CustomRamp:
412          return newProps          return newProps
413    
414      def __SetProperty(self, color1, color2, index, setf):      def __SetProperty(self, color1, color2, index, setf):
415            """Use setf to set the appropriate property for the point
416            index percent between color1 and color2. setf is a function
417            to call that accepts a Color object or Transparent.
418            """
419    
420          if color1 is Transparent and color2 is Transparent:          if color1 is Transparent and color2 is Transparent:
421              setf(Transparent)              setf(Transparent)
# Line 430  class CustomRamp: Line 436  class CustomRamp:
436                  (color2.blue  - color1.blue)  * index + color1.blue))                  (color2.blue  - color1.blue)  * index + color1.blue))
437    
438  class MonochromaticRamp(CustomRamp):  class MonochromaticRamp(CustomRamp):
439        """Helper class to make ramps between two colors."""
440    
441      def __init__(self, start, end):      def __init__(self, start, end):
442            """Create a Monochromatic Ramp.
443    
444            start -- starting Color
445    
446            end -- ending Color
447            """
448          sp = ClassGroupProperties()          sp = ClassGroupProperties()
449          sp.SetLineColor(start)          sp.SetLineColor(start)
450          sp.SetFill(start)          sp.SetFill(start)
# Line 441  class MonochromaticRamp(CustomRamp): Line 455  class MonochromaticRamp(CustomRamp):
455    
456          CustomRamp.__init__(self, sp, ep)          CustomRamp.__init__(self, sp, ep)
457    
458  GreyRamp       = MonochromaticRamp(Color(1, 1, 1),  Color(0, 0, 0))  grey_ramp         = MonochromaticRamp(Color(1, 1, 1),  Color(0, 0, 0))
459  RedRamp        = MonochromaticRamp(Color(1, 1, 1),  Color(.8, 0, 0))  red_ramp          = MonochromaticRamp(Color(1, 1, 1),  Color(.8, 0, 0))
460  GreenRamp      = MonochromaticRamp(Color(1, 1, 1),  Color(0, .8, 0))  green_ramp        = MonochromaticRamp(Color(1, 1, 1),  Color(0, .8, 0))
461  BlueRamp       = MonochromaticRamp(Color(1, 1, 1),  Color(0, 0, .8))  blue_ramp         = MonochromaticRamp(Color(1, 1, 1),  Color(0, 0, .8))
462  GreenToRedRamp = MonochromaticRamp(Color(0, .8, 0), Color(1, 0, 0))  green_to_red_ramp = MonochromaticRamp(Color(0, .8, 0), Color(1, 0, 0))
463    
464  class HotToColdRamp:  class HotToColdRamp:
465        """A ramp that generates properties with colors ranging from
466        'hot' colors (e.g. red, orange) to 'cold' colors (e.g. green, blue)
467        """
468    
469      def GetRamp(self):      def GetRamp(self):
470            """Return this ramp."""
471          return self          return self
472    
473      def GetProperties(self, index):      def GetProperties(self, index):
# Line 498  class FixedRamp: Line 516  class FixedRamp:
516          self.ramp = ramp          self.ramp = ramp
517    
518      def GetRamp(self):      def GetRamp(self):
519            """Return this ramp."""
520          return self          return self
521    
522      def GetProperties(self, index):      def GetProperties(self, index):
523            """Return a ClassGroupProperties object whose properties
524            represent a point at 'index' between the properties in
525            the ramp that initialized this FixedRamp.
526    
527            index -- a value such that 0 <= index <= 1
528            """
529    
530          props = self.ramp.GetProperties(index)          props = self.ramp.GetProperties(index)
531          if self.fixes[0] is not None: props.SetLineColor(self.fixes[0])          if self.fixes[0] is not None: props.SetLineColor(self.fixes[0])
532          if self.fixes[1] is not None: props.SetLineWidth(self.fixes[1])          if self.fixes[1] is not None: props.SetLineWidth(self.fixes[1])

Legend:
Removed from v.1524  
changed lines
  Added in v.1525

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26