imccrum / canviz

Automatically exported from code.google.com/p/canviz
0 stars 0 forks source link

Keep graph in memory in object form #27

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently Canviz parses the xdot file and stores all _*draw_ commands in a flat 
array, which is 
later drawn to the canvas. Franck Tabary suggested that the graph 
representation should persist 
in memory as JavaScript objects.

http://groups.google.com/group/canviz/browse_thread/thread/9d2c3626bef5fb3f/1bf4
6c265f
0ce778

The suggestion was based on the misperception that Canviz does the graph layout 
itself; in fact 
Graphviz does the layout, encodes node positions and sizes and draw commands 
into the xdot 
file, and Canviz just dumbly reads that and draws what the file says to draw. 
But having the 
graph representation in memory is still a good idea because:

 * all the attributes would be there in memory, which those writing a graph editor would 
probably need
 * we could take advantage of attributes which aren't encoded into the _*draw_ commands, like 
the colorscheme attribute; that would let us fix issue #13
 * we would have a structure in memory which lets us associate e.g. node URLs with the draw 
commands used to draw the node; that would get us further on issue #11
 * it's probably a necessary first step to being able to do animated transitions between graph 
states; see issue #26

Original issue reported on code.google.com by ryandesi...@gmail.com on 21 Oct 2008 at 5:52

GoogleCodeExporter commented 9 years ago
r131 should help a little. Now we actually know what type of entity each draw 
command deals with. From here 
we should be able to move to creating objects for each of those entities fairly 
easily.

Original comment by ryandesi...@gmail.com on 21 Oct 2008 at 6:20

GoogleCodeExporter commented 9 years ago

Original comment by ryandesi...@gmail.com on 23 Oct 2008 at 11:10

GoogleCodeExporter commented 9 years ago
As of r142, the graph is now kept in memory in a nested structure. The draw 
commands
are stored in a separate drawAttrs variable in each entity, but the draw() 
method
doesn't make use of this yet.

Original comment by ryandesi...@gmail.com on 23 Oct 2008 at 10:41

GoogleCodeExporter commented 9 years ago
Safari didn't like r142. Fixed it in r148.

Original comment by ryandesi...@gmail.com on 24 Oct 2008 at 9:50

GoogleCodeExporter commented 9 years ago
As of r188 the draw() method does use the drawAttrs in each entity. Now each 
entity is called upon to draw itself.

In r191 I added the Entity.getAttr() method which can be used to get an 
attribute from an entity. If the entity itself 
doesn't define that attribute, then getAttr() looks at the default values in 
each parent graph until the specified 
attribute is found. This allowed me to fix issue #13 in r193.

So I think I can close this ticket as fixed. The graph structure does exist in 
memory in canvizobj.graphs[0], Canviz 
uses it, and you can use it in your apps if you need info about the graph.

Original comment by ryandesi...@gmail.com on 1 Nov 2008 at 7:46