Lisp HUG Maillist Archive

CAPI question again: edegs colors in graph-panes

Hi

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.

I know this is a FAQ from me, but I still do not know how to do it.

Thanks

Marco

--
Marco Antoniotti					http://bioinformatics.nyu.edu/~marcoxa
NYU Courant Bioinformatics Group		tel. +1 - 212 - 998 3488
715 Broadway 10th FL				fax. +1 - 212 - 998 3484
New York, NY, 10003, U.S.A.


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



RE: CAPI question again: edegs colors in graph-panes

I wrote:
> Sent: 26 November 2005 15:40
> To: 'Lisp Hug Lispworks'
> Subject: 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.

[snip]

> - 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.

[snip]

> If it was the case that there could be more than one
> link between the same two nodes, my approach would fail.

Actually, it can be made to work: when the
edge-pane-function finds a link it can remove the entry
from the list of triples, so the next search of the
list will find a different link.

(And, FWIW, a list is probably not good; an EQUAL hash
table keyed on the nodes and with the link as value would
be better.)

Simon



Re: CAPI question again: edegs colors in graph-panes

Hello Marco,

| 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.

The :edge-pinboard-args initarg for capi:graph-pane should do the trick,
e.g.

(defclass my-graph (capi:graph-pane)
 ()
 (:default-initargs
  :children-function 'my-node-children
  :edge-pinboard-class 'capi:right-angle-line-pinboard-object
  :edge-pinboard-args '(:foreground :red)
  ...))

IIRC, it did not work in all cases in LW 4.3, and I have not experimentid
with LW 4.4 yet.

In any version, this must work
    (setf (capi:pinboard-object-graphics-args line) '(:foreground :red))
after you find the line pinboard object corresponding to an edge.
--
Sincerely,
Dmitriy Ivanov
lisp.ystok.ru


Updated at: 2020-12-10 08:50 UTC