Source code for visgraph.renderers
'''
Home of the code which knows how to actually *draw* a graph which
has been layed out.
'''
[docs]class GraphRenderer:
'''
Only a "renderer" knows how big each node will end up based on metadata
in the graph which is specific to the renderer.
All renderers should be able to set the (x,y) "size" tuple
'''
def __init__(self, graph):
self._vg_graph = graph
self._vg_layout = None
self._vg_rendering = False
self._vg_canvas_width = 0
self._vg_canvas_height = 0
[docs] def beginRender(self, width, height):
self._vg_rendering = True
self._vg_canvas_width = width
self._vg_canvas_height = height
[docs] def endRender(self):
self._vg_rendering = False
[docs] def setNodeSizes(self, graph):
'''
Calculate the sizes for each node based on graph metadata (or defaults)
'''
raise Exception('%s must implement setNodeSizes!' % self.__class__.__name__)
[docs] def renderNode(self, nid, ninfo, xpos, ypos):
'''
Render the given node at the specified position.
'''
raise Exception('%s must implement renderNode!' % self.__class__.__name__)
[docs] def renderEdge(self, eid, einfo, points):
'''
Render an edge in the graph by drawing lines between all the listed
points (as (x,y) tuples...)
'''
raise Exception('%s must implement renderNode!' % self.__class__.__name__)