Package visgraph :: Package renderers
[hide private]
[frames] | no frames]

Source Code for Package visgraph.renderers

 1  ''' 
 2  Home of the code which knows how to actually *draw* a graph which 
 3  has been layed out. 
 4  ''' 
 5   
6 -class GraphRenderer:
7 ''' 8 Only a "renderer" knows how big each node will end up based on metadata 9 in the graph which is specific to the renderer. 10 11 All renderers should be able to set the (x,y) "size" tuple 12 '''
13 - def __init__(self, graph):
14 self._vg_graph = graph 15 self._vg_layout = None 16 17 self._vg_rendering = False 18 self._vg_canvas_width = 0 19 self._vg_canvas_height = 0
20
21 - def beginRender(self, width, height):
22 self._vg_rendering = True 23 self._vg_canvas_width = width 24 self._vg_canvas_height = height
25
26 - def endRender(self):
27 self._vg_rendering = False
28
29 - def setNodeSizes(self, graph):
30 ''' 31 Calculate the sizes for each node based on graph metadata (or defaults) 32 ''' 33 raise Exception('%s must implement setNodeSizes!' % self.__class__.__name__)
34
35 - def renderNode(self, nid, ninfo, xpos, ypos):
36 ''' 37 Render the given node at the specified position. 38 ''' 39 raise Exception('%s must implement renderNode!' % self.__class__.__name__)
40
41 - def renderEdge(self, eid, einfo, points):
42 ''' 43 Render an edge in the graph by drawing lines between all the listed 44 points (as (x,y) tuples...) 45 ''' 46 raise Exception('%s must implement renderNode!' % self.__class__.__name__)
47