F:/thesis_austausch/dissertation/code_docu_doxygen/Visualiser/utils.py

Go to the documentation of this file.
00001 # Small utility methods that are used by the Graphs.py class
00002 # Taken from Grayson's Tkinter book.
00003 #
00004 # Adil Hasan March/2003
00005 
00006 def minCoordinate(clist):
00007     if len(clist) < 2: return clist[0]
00008     try:
00009         x,  y  = clist[0]
00010         for x1, y1 in clist[1:]:
00011             if x1 <= x or y1 <= y:
00012                 x, y = x1, y1
00013     except:
00014         x, y = 0, 0
00015 
00016     return x,y
00017 
00018 def maxCoordinate(clist):
00019     if len(clist) < 2: return clist[0]
00020     try:
00021         x,  y  = clist[0]
00022         for x1, y1 in clist[1:]:
00023             if x1 >= x or y1 >= y:
00024                 x, y = x1, y1
00025     except:
00026         x, y = 0, 0
00027 
00028     return x,y
00029 
00030 def minBound(clist):
00031     x = 10000000
00032     y = 10000000
00033     for x1, y1 in clist:
00034         if x1 < x: x = x1
00035         if y1 < y: y = y1        
00036     return x,y
00037 
00038 def maxBound(clist):
00039     x = -10000000
00040     y = -10000000
00041     for x1, y1 in clist:
00042         if x1 > x: x = x1
00043         if y1 > y: y = y1        
00044     return x,y
00045 
00046 if __name__ == '__main__':
00047 
00048     tlist = [ (5,5), (3,6), (3,3), (-2,5), (100,100),
00049               (100,-100), (100,101) ]
00050 
00051     print minCoordinate(tlist)
00052     print maxCoordinate(tlist)
00053     print maxCoordinate([(3,3), (10,-1)])

Generated on Sun Mar 5 23:04:01 2006 for Virtualiser by  doxygen 1.4.6-NO