Vizmapper color gradient bug

48 views
Skip to first unread message

James Grammatikos

unread,
Apr 30, 2013, 1:16:00 PM4/30/13
to cytoscap...@googlegroups.com
Hello,

I am having a problem with color gradients in the Vizmapper Task in my plugin. I have a class of nodes that I want to be grayed out (the hexagons in the attached picture) and the rest should be in a gradient from blue to yellow to red. I have assigned a value to the hexagonal nodes equal to just below the minimum value of all the colored nodes. When I apply the visual style, however, all of the gray nodes turn blue, and some of the colored nodes have the wrong color (see picture with blue nodes). If I go into the Vizmapper panel in Cytoscape and click on the color mapping, as soon as I touch any of the handles, the coloring resets to exactly the way I want it (see picture with gray nodes). Does anybody have an idea why this is? I have included all the code associated with the gradient. Sorry I can't get it to un-double-space. All the other mappings are working fine. Additionally, it appears that the color of the minimum boundary value of the point that I add to the mapping first is the color that gets printed over everything. So if I were to (val5, brv5) first, everything turns yellow instead of blue.

Thanks for any help you guys can offer,
James


ContinuousMapping<Double,Paint> cPaintMapping = (ContinuousMapping<Double,Paint>) continuous.createVisualMappingFunction("value", Double.class, BasicVisualLexicon.NODE_FILL_COLOR); 


Double val1 = min;

BoundaryRangeValues<Paint> brv1 = new BoundaryRangeValues<Paint>(Color.gray, Color.BLUE, Color.BLUE);

Double val3 = 2 / 3.;

BoundaryRangeValues<Paint> brv3 = new BoundaryRangeValues<Paint>(Color.BLUE, Color.GREEN, Color.YELLOW);

Double val4 = 1.;

BoundaryRangeValues<Paint> brv4 = new BoundaryRangeValues<Paint>(Color.GREEN, Color.YELLOW, Color.ORANGE);

Double val5 = 1.5;

BoundaryRangeValues<Paint> brv5 = new BoundaryRangeValues<Paint>(Color.YELLOW, Color.ORANGE, Color.RED);

 

cPaintMapping.addPoint(val3, brv3);

cPaintMapping.addPoint(val1, brv1);

cPaintMapping.addPoint(val5, brv5);

cPaintMapping.addPoint(val4, brv4);







Screen shot 2013-04-30 at 12.55.35 PM.png
Screen shot 2013-04-30 at 12.55.17 PM.png

Alexander Pico

unread,
May 2, 2013, 6:37:51 PM5/2/13
to cytoscap...@googlegroups.com
Right. The order matters. Try the code below. Assuming your "min" is always ess than val3, then this should result in:

 * below val1 = gray
 * at val1 = blue
 * between val1 and val3 = gradient blue-green
 * at va3 = green
 * between val3 and val4 = gradient green-yellow
 * at val4 = yellow
 * between val4 and val5 = gradient yellow-orange
 * at val5 = orange

 * above val5 = red


Double val1 = min;

BoundaryRangeValues<Paint> brv1 = new BoundaryRangeValues<Paint>(Color.GRAY, Color.BLUE, Color.BLUE);


Double val3 = 2 / 3.;

BoundaryRangeValues<Paint> brv3 = new BoundaryRangeValues<Paint>(Color.GREEN, Color.GREEN, Color.GREEN);


Double val4 = 1.;

BoundaryRangeValues<Paint> brv4 = new BoundaryRangeValues<Paint>(Color.YELLOW, Color.YELLOW, Color.YELLOW);


Double val5 = 1.5;

BoundaryRangeValues<Paint> brv5 = new BoundaryRangeValues<Paint>(Color.ORANGE, Color.ORANGE, Color.RED);

 

cPaintMapping.addPoint(val1, brv1);

cPaintMapping.addPoint(val3, brv3);

cPaintMapping.addPoint(val4, brv4);

cPaintMapping.addPoint(val5, brv5);

James Grammatikos

unread,
May 15, 2013, 3:18:57 PM5/15/13
to cytoscap...@googlegroups.com
Alex, that's what I was hoping to get, and what I was actually getting after I clicked on any of the mapping nodes in the node color mapping editor. But initially it would give me the picture above where everything was blue. I was hoping to skip the manual adjustment every single time I use the plugin (it kind of defeats the point of automating it).

I figured out the source of the bug. I have boundary values in this example spanning from .66 to 1.5. If my data does not span that range (e.g. all data is less than 1.2), the vizmapper will mishandle this and paint everything blue until I go in manually and adjust. I know I could manually go through the network and check the range of values and only apply the proper mapping points, but I was wondering if any of you guys had a better idea of how to deal with this. 
Reply all
Reply to author
Forward
0 new messages