jan: thuban/Thuban/Model classification.py,1.38,1.39

cvs@intevation.de cvs at intevation.de
Sun Oct 3 23:01:33 CEST 2004


Author: jan

Update of /thubanrepository/thuban/Thuban/Model
In directory doto:/tmp/cvs-serv5430

Modified Files:
	classification.py 
Log Message:
Removed some trailing whitespaces.
(ClassGroupProperties.__init__): Set default size.
(ClassGroupProperties.SetProperties): Set the size.
(ClassGroupProperties.GetSize): New. Return the size.
(ClassGroupProperties.SetSize): New. Set the size.
(ClassGroupProperties__eq__): Compare also size.
(ClassGroupProperties__repr__): Print also size.


Index: classification.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/Model/classification.py,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- classification.py	3 Nov 2003 13:55:41 -0000	1.38
+++ classification.py	3 Oct 2004 21:01:31 -0000	1.39
@@ -315,7 +315,7 @@
             items.append(build_item(p, p.GetDisplayText()))
 
         return (_("Classification"), items)
- 
+
 class ClassIterator:
     """Allows the Groups in a Classifcation to be interated over.
 
@@ -327,11 +327,11 @@
         """Constructor.
 
         default -- the default group
- 
+
         points -- a list of singleton groups
 
         ranges -- a list of range groups
- 
+
         maps -- a list of map groups
         """
 
@@ -350,19 +350,22 @@
             d = self.data[self.data_index]
             self.data_index += 1
             return d
-        
+
 class ClassGroupProperties:
     """Represents the properties of a single Classification Group.
-  
+
     These are used when rendering a layer."""
 
+    # TODO: Actually, size is only relevant for point objects.
+    # Eventually it should be spearated, e.g. when introducing symbols.
+
     def __init__(self, props = None):
         """Constructor.
 
         props -- a ClassGroupProperties object. The class is copied if
                  prop is not None. Otherwise, a default set of properties
                  is created such that: line color = Black, line width = 1,
-                 and fill color = Transparent
+                 size = 5 and fill color = Transparent
         """
 
         if props is not None:
@@ -370,6 +373,7 @@
         else:
             self.SetLineColor(Black)
             self.SetLineWidth(1)
+            self.SetSize(5)
             self.SetFill(Transparent)
 
     def SetProperties(self, props):
@@ -378,8 +382,9 @@
         assert isinstance(props, ClassGroupProperties)
         self.SetLineColor(props.GetLineColor())
         self.SetLineWidth(props.GetLineWidth())
+        self.SetSize(props.GetSize())
         self.SetFill(props.GetFill())
-        
+
     def GetLineColor(self):
         """Return the line color as a Color object."""
         return self.__stroke
@@ -407,10 +412,25 @@
 
         self.__strokeWidth = lineWidth
 
+    def GetSize(self):
+        """Return the size."""
+        return self.__size
+
+    def SetSize(self, size):
+        """Set the size.
+
+        size -- the new size. This must be > 0.
+        """
+        assert isinstance(size, types.IntType)
+        if (size < 1):
+            raise ValueError(_("size < 1"))
+
+        self.__size = size
+
     def GetFill(self):
         """Return the fill color as a Color object."""
         return self.__fill
- 
+
     def SetFill(self, fill):
         """Set the fill color.
 
@@ -431,7 +451,8 @@
                  self.__stroke == other.__stroke)        \
             and (self.__fill is other.__fill or          \
                  self.__fill == other.__fill)            \
-            and self.__strokeWidth == other.__strokeWidth
+            and self.__strokeWidth == other.__strokeWidth\
+            and self.__size == other.__size
 
     def __ne__(self, other): 
         return not self.__eq__(other)
@@ -443,7 +464,8 @@
         return ClassGroupProperties(self)
 
     def __repr__(self):
-        return repr((self.__stroke, self.__strokeWidth, self.__fill))
+        return repr((self.__stroke, self.__strokeWidth, self.__size,
+                    self.__fill))
 
 class ClassGroup:
     """A base class for all Groups within a Classification"""
@@ -466,7 +488,7 @@
     def GetLabel(self):
         """Return the Group's label."""
         return self.label
- 
+
     def SetLabel(self, label):
         """Set the Group's label.
 





More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)