Questions about visuals (CyNodeView, etc)

26 views
Skip to first unread message

T_even

unread,
Sep 20, 2007, 10:45:19 AM9/20/07
to cytoscape-discuss
1) I was trying to create more views 1) I was trying to create more
views that are associated to the same network but all do i can create
a new view for an existing network (CyNetworkView
view2=Cytoscape.createNetworkView(network); ) i didn't find anyway of
displaying that new view to the user, i would like to know how to do
that.

2)When i change a node (single specific node) fillColor or/and shape
it works fine but when i call the method view.redrawGraph(true,false);
or in any other combination or when the user change any information
(like the canonicalName ) of a node i lose the shape and color that i
have specified to a node, is a way to stop that behavior of
cytoscape ??

WLigt...@gmail.com

unread,
Sep 21, 2007, 2:51:45 AM9/21/07
to cytoscape-discuss
If you want to change the colour or shape of the node, you should
specify a new VisualStyle.
In that way everything will get visualized in the way you want when
redrawGraph is being called.
What you do now, seems that you manually set the colour ans shape.
Then everytime Cytoscape visualizes the network anew, it will call
upon the calculators of the VisualStyle to calculate the colours and
shapes. (and they are still the same)

See http://www.cytoscape.org/cgi-bin/moin.cgi/Visual_Mapping_System_Guide
For how to change visualization from within a plugin.
Or http://www.cytoscape.org/cgi-bin/moin.cgi/Cytoscape_User_Manual/Visual_Styles
For how to change visualization from within cytoscape.

Cheers,

Willem Ligtenberg

T_even

unread,
Sep 21, 2007, 6:53:21 AM9/21/07
to cytoscape-discuss
Thx for the help but what you posted doesn't work, all the methods to
change something on the node/edges are deprecated and when i try to
search for getAttrNameBypass() (supposed a new method to change node
fill color, etc) i can't find (eclipse search) any class that uses
that method.

On Sep 21, 8:51 am, "WLigtenb...@gmail.com" <WLigtenb...@gmail.com>
wrote:


> If you want to change the colour or shape of the node, you should
> specify a new VisualStyle.
> In that way everything will get visualized in the way you want when
> redrawGraph is being called.
> What you do now, seems that you manually set the colour ans shape.
> Then everytime Cytoscape visualizes the network anew, it will call
> upon the calculators of the VisualStyle to calculate the colours and
> shapes. (and they are still the same)
>

> Seehttp://www.cytoscape.org/cgi-bin/moin.cgi/Visual_Mapping_System_Guide


> For how to change visualization from within a plugin.

> Orhttp://www.cytoscape.org/cgi-bin/moin.cgi/Cytoscape_User_Manual/Visua...

Svetlana Pacifico

unread,
Sep 21, 2007, 10:39:58 AM9/21/07
to cytoscap...@googlegroups.com
Here is my code for changing default shape of the node:

private void createNodeShape() {
VisualStyle v_style = view.getVisualStyle();

NodeAppearanceCalculator node_calc = v_style.getNodeAppearanceCalculator();
Appearance dap = node_calc.getDefaultAppearance();
dap.set(VisualPropertyType.NODE_SHAPE, NodeShape.DIAMOND);
}

Let me know if it worked for you.

Lana Pacifico

Keiichiro Ono

unread,
Sep 21, 2007, 2:06:49 PM9/21/07
to cytoscap...@googlegroups.com
Hi.
Basically, you need to create a new visual style if you want to keep
the appearance. Direct modification to the node/edge appearance is
just a temporally change. They will be overridden by Visual Style.

So, it's better to create a new VS first, then create
Node/EdgeAppearenceCalcs, and apply it to the network you are working.

Thanks.
Kei

2007/9/21, T_even <grys...@gmail.com>:


--
Keiichiro Ono ko...@ucsd.edu

Cytoscape Core Developer Team: http://www.cytoscape.org/
UCSD Bioengineering Ideker Lab: http://chianti.ucsd.edu/idekerlab/

T_even

unread,
Sep 25, 2007, 10:29:29 AM9/25/07
to cytoscape-discuss
The code you posted worked very well,i still have to find a way to
just change the apparency of a single node.

Svetlana Pacifico

unread,
Sep 25, 2007, 11:15:00 AM9/25/07
to cytoscap...@googlegroups.com
I would like to know it too. If you find out, please post it in the discussion.

Lana

Keiichiro Ono

unread,
Sep 25, 2007, 12:33:17 PM9/25/07
to cytoscap...@googlegroups.com
Hi.
If you need to set the appearance of a single node or edge, you need
to create a visual style controlled by ID (or maybe other attributes
like canonicalName). This code segment:

NodeAppearanceCalculator node_calc = v_style.getNodeAppearanceCalculator();
Appearance dap = node_calc.getDefaultAppearance();
dap.set(VisualPropertyType.NODE_SHAPE, NodeShape.DIAMOND);
}

defines overall (default) appearance and not individual appearance of node/edge.

Thanks.
Kei

2007/9/25, T_even <grys...@gmail.com>:

Mike Smoot

unread,
Sep 25, 2007, 12:36:11 PM9/25/07
to cytoscap...@googlegroups.com
VisualStyles are used to define the visualization for all nodes based on attributes, however you can also override this visualization by right-clicking on a node and then selecting the Visual Mapping Bypass menu item, and then manually changing the attribute you're interested in.  The way that the bypass works is by creating a specially named attribute.  For example, for node color, the attribute name is " node.fillColor" and value for that attribute for that node is set to a string that encodes the RGB value for a color.  When a bypass attribute is set for a given node (or edge), that attribute will be used instead of the VisualStyle. 

To create bypass attributes programmatically, you just need to define an attribute with the proper name and then set the value for that attribute for the given node.  To find out the bypass attribute names, your best bet is to try the override from cytoscape to see what new attributes are created. The definitions are found in VisualPropertyType.java. This should also give you an idea of how the attribute string should be formatted. So, the code would look something like this:

CyAttributes nodeAtts = Cytoscape.getNodeAttributes ();
nodeAtts.setAttribute(yourNodeID,"node.fillColor","25,25,125");

Let me know if you have any questions.

Mike
--
____________________________________________________________
Michael Smoot, Ph.D.               Bioengineering Department
tel: 858-822-4756         University of California San Diego

T_even

unread,
Sep 26, 2007, 10:28:47 AM9/26/07
to cytoscape-discuss
That worked very well, now i can change colors of single nodes.
Thx for the help.

On Sep 25, 6:36 pm, "Mike Smoot" <msm...@ucsd.edu> wrote:
> VisualStyles are used to define the visualization for all nodes based on
> attributes, however you can also override this visualization by
> right-clicking on a node and then selecting the Visual Mapping Bypass menu
> item, and then manually changing the attribute you're interested in. The
> way that the bypass works is by creating a specially named attribute. For
> example, for node color, the attribute name is "node.fillColor" and value
> for that attribute for that node is set to a string that encodes the RGB
> value for a color. When a bypass attribute is set for a given node (or
> edge), that attribute will be used instead of the VisualStyle.
>
> To create bypass attributes programmatically, you just need to define an
> attribute with the proper name and then set the value for that attribute for
> the given node. To find out the bypass attribute names, your best bet is to
> try the override from cytoscape to see what new attributes are created. The
> definitions are found in VisualPropertyType.java. This should also give you
> an idea of how the attribute string should be formatted. So, the code would
> look something like this:
>
> CyAttributes nodeAtts = Cytoscape.getNodeAttributes();
> nodeAtts.setAttribute(yourNodeID,"node.fillColor","25,25,125");
>
> Let me know if you have any questions.
>
> Mike
>

> tel: 858-822-4756 University of California San Diego- Hide quoted text -
>
> - Show quoted text -

Reply all
Reply to author
Forward
0 new messages