[Zope3-checkins] CVS: zopeproducts/pypgsqlda/interfaces - geometric.py:1.3

Christian 'Tiran' Heimes heimes@faho.rwth-aachen.de
Wed, 19 Mar 2003 05:16:03 -0500


Update of /cvs-repository/zopeproducts/pypgsqlda/interfaces
In directory cvs.zope.org:/tmp/cvs-serv32031

Modified Files:
	geometric.py 
Log Message:
interfaces renamed (Point -> IPoint)
some more implementation on IPoint


=== zopeproducts/pypgsqlda/interfaces/geometric.py 1.2 => 1.3 ===
--- zopeproducts/pypgsqlda/interfaces/geometric.py:1.2	Tue Mar 18 17:56:46 2003
+++ zopeproducts/pypgsqlda/interfaces/geometric.py	Wed Mar 19 05:16:03 2003
@@ -18,11 +18,12 @@
 
 from zope.interface import Interface, Attribute
 
-class Point(Interface):
+class IPoint(Interface):
     """A 2 dimensional point in cartesian representation."""
 
     x = Attribute("x coordinate as float")
     y = Attribute("y coordinate as float")
+    coord = Attribute("x/y as tuple, input may be more")
     
     def getX():
         """Gets x coordinate
@@ -40,34 +41,109 @@
         """Sets y coordinate
         """
 
-    def setCoord(xOrTuple, y):
+    def getCoord():
+        """Gets x/y coordinate as tuple of floats
+        """
+
+    def setCoord(x, y = None):
         """Sets x/y coordinate
         
-        The first argument maybe a tuple with two elemets
+        The first argument can be:
+            * a number, y must be given as number, too
+            * a tuple with two elements
+            * a list with two elements
+            * a dictionary with two keys named 'x' and 'y'
+            * a string '(x,y)' or '(x/y)'
+        """
+        
+    def __str__():
+        """Prints coordinate as '(x,y)'
+        """
+
+    def __len__():
+        """Distance from 0/0
+        
+        Return distance from 0/0 in euclidic norm:
+            
+            sqrt(x**2 + y**2)
+        
+        """
+        
+    def __cmp__(other):
+        """Compare point with other points or length
+        
+        * Compare distance from 0/0 if other is a number
+        * Compare distance using __len__() if other is a point
+        """
+        
+    def __rcmp__(other):
+        """See __cmp__
         """
 
-class Shape(Interface):
+class IShape(Interface):
     """An abstract interface for geometric shapes."""
 
-    def area():
-        pass
+    area = Attribute("area of the shape as float (ro)")
+    circumference = Attribute("circumference of the shape as float (ro)")
+
+    def getArea():
+        """Return size of containing area
+        
+        Must be overwritten by shape
+        """
+        
+    def getCircumference():
+        """Return lenght of circumference
         
-    def circumference():
-        pass
+        Must be overwritten by shape
+        """
+
+    def __len__():
+        """Return area as size of shape
+        """
     
+    def __cmp__(other):
+        """compare area to number or other shape
+        """
+        
+    def _rcmp__(other):
+        """
+        """
+        
+    def __str__():
+        """
+        """
 
-class Circle(Shape):
+class ICircle(IShape):
     """A circle. It is represented as a center point and a radius."""
 
     center = Attribute("center as point coordinate")
     radius = Attribute("radius as float")
+    circle = Attribute("center point and radius together")
+    
+    def getCenter():
+        """
+        """
+        
+    def setCenter():
+        """
+        """
+        
+    def getRadius():
+        """
+        """
+        
+    def setRadius():
+        """
+        """
 
-class Box(Shape):
+class IBox(IShape):
 
     upperRight = Attribute("Upper right point of the box as point coordinate")
     lowerLeft = Attribute("Lower left point of the box as point coordinate")
+    corners = Attribute("upper right and lower left point together")
 
-class Path(Interface):
+class IPath(Interface):
     """A path is an ordered set of points. A path can be closed, which means
        that the end point is connected to the start point. A special kind of
        path is the line, which only has to points and is open."""