RE: CAPI question again: edegs colors in graph-panes
Marco Antoniotti wrote:
> I need to draw edges in different colors in a graph pane.
> How can you do this? More specifically, I need to change
> the color of a selected edge.
In my application I have domain-level node and link
objects, and I link the domain objects to the display
using an implementation of the observer pattern. When
there is a change in domain data, the display objects
are redrawn.
To set up the observer dependencies for pinboard objects
in graph panes, I do the following:
- The children-function, as well as returning child nodes,
stores (from-node to-node link) triplets in a list. (The
things in that triplet are /domain/ nodes and a /domain/
link.)
- The edge-pane-function searches this list to find the
appropriate link.
- Both the edge-pane-function and the node-pane-function
set up the association between the domain object and
the display object that they return.
Since the display objects have a way of finding their
corresponding domain object, the drawing functions can
choose colors, line styles, etc that depend on the state
of domain data.
____
If it was the case that there could be more than one
link between the same two nodes, my approach would fail.
(FWIW, of course, for two links between the same two nodes to
be seen, they cannot both be straight lines.)
____
I'm not sure that I've fully thought this out, but maybe
it would be simpler if the CAPI were modified so that a
children-function could return links as well as nodes,
and an alternative edge-pane-function function (taking
a link as argument rather than two nodes) were called
in that case.
HTH,
Simon