Help request: programmatically creating boxes where node labels are.

73 views
Skip to first unread message

gerardo huck

unread,
Nov 9, 2012, 6:23:37 PM11/9/12
to cytoscap...@googlegroups.com
Hi all, 

I'm trying to develop a plugin which will analyze 'how good' a certain layout is, and I need some help.

One of the functionalities I'm looking for is, given a network (and a network view), construct a new network view with (possible a subset of) the original elements, plus rectangles in the place of node labels. Those rectangles will be painted red or green, depending on whether they intersect (bad layout!) or not (good!) another object.

I've already succeeded in programmatically creating a new network view with the same visual characteristics as the current one, with only the desired objects in it, but I'm stuck trying to create the rectangles. Concretely, I don't know how to: 

1- Get the size (width, height) of a given label. 
I've only found the method "NodeView.getLabelWidth", which I'm not certain that gives the actual (used) width, and no reference on how to get the heigh of a label.

2- Be able to 'draw' a rectangle at a given position. Since they will replace labels, my guess is that it's possible to add them as custom node graphics and use a passthrough mapping to set its position, but I haven't been able to do so. 


BTW, I'm working on 2.8.3, since I already have some of the layout algorithms that I want to study programmed in this version (it was done as part of Google Summer of Code 2010).

I would greatly appreciate any help you can provide. 

Thanks in advance!
Gerardo

Scooter Morris

unread,
Nov 15, 2012, 12:12:35 PM11/15/12
to cytoscap...@googlegroups.com
Hi Gerardo,
  What you would need to do is to programmatically figure out where the node label is being displayed.  This information should be available in the visual mapping stuff, but it would be tricky to pull out.  Once you know where it's being written, you can create a custom graphic to draw your box.  The custom graphic would have to set the Bounding Box appropriately.  If you give me more information about what you've got we can talk about how you might go about doing the custom graphic.

-- scooter

gerardo huck

unread,
Nov 19, 2012, 9:28:15 PM11/19/12
to cytoscap...@googlegroups.com
Hi Scooter, 

forst of all, thanks for the reply!

Secondly, sorry for the delay, but I was quite busy the past few days...

I'll try to explain better what I'm trying to achieve. I have started to do a little research (that I hope will become my master thesis in computer science) in graph layout. More specifically, I'm interested in finding practical automatic label layouts. This work is actually inspired in my previous experience in this area as part of Google Summer of Code 2010, where helped by Mike Smoot I added to Cytoscape layouts the possibility of easily managing labels.

To study different graph layouts, I need to create some sort of framework, and for that purpose I'm writing a plugin that will take a graph layout an perform several analysis over it, calculating statistics and metrics in an attempt of quantify how good a layout is.

This plugin will also create a new view of the network in which the overlap between nodes and labels will be show by painting them red, while non overlapping elements will be painted green. This will give the user a change of classify layouts as 'good' or 'bad' at a glance. 

To achieve this goals, I'm facing the difficulties that I mentioned before:


1- Be able to retrieve the exact coordinates of a given label, as well as its dimensions. 

2- Be able to replace labels (in the new network) with red or green rectangles, of exactly the same size and position of the label in the original graph view. 

I've been quite stuck with this 2 issues for a while, so any help will be greatly appreciated!


Thanks in advance!
Gerardo


PS: Of course, I intend to make freely available this plugin when it's finished (I was thinking of releasing it under GPL v3).







--
You received this message because you are subscribed to the Google Groups "cytoscape-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cytoscape-discuss/-/XqLrHvnE8vIJ.
To post to this group, send email to cytoscap...@googlegroups.com.
To unsubscribe from this group, send email to cytoscape-disc...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cytoscape-discuss?hl=en.

Scooter Morris

unread,
Dec 14, 2012, 11:33:19 PM12/14/12
to cytoscap...@googlegroups.com, gerardo huck
Hi Gerardo,
    OK, now I understand what you're trying to do.  Unfortunately, I can't think of any way to deal with #1.  If you could get the bounding box of the label, then you could use the new annotations capability in Cytoscape 3 to draw your rectangles.

-- scooter
Reply all
Reply to author
Forward
0 new messages