BundleContext for Cytoscape 3 app development

110 views
Skip to first unread message

lindfo...@gmail.com

unread,
May 14, 2014, 11:54:47 AM5/14/14
to cytoscape...@googlegroups.com

Hi all,

Cytoscape 3 App Cookbook (http://wiki.cytoscape.org/Cytoscape_3/AppDeveloper/Cytoscape_3_App_Cookbook) contains code snippets in which org.osgi.framework.BundleContext is used.

Can anyone specify in which java library (i.e. jar file) this class is included?

From what I understand the Cytoscape 3 application development tutorial (http://opentutorials.cgl.ucsf.edu/index.php/Tutorial:Creating_a_Simple_Cytoscape_3_App) says the following libraries are needed for Cytoscape 3 application development 
* JDK 1.6 (or later)
* http://chianti.ucsd.edu/cytoscape-3.1.0/cytoscape-swing-app-api-3.1.0.jar

At least to me it seems the BundleContext is in neither of these libraries.

Thanks in advance,
Erno Lindfors

Jason Montojo

unread,
May 14, 2014, 1:09:13 PM5/14/14
to cytoscape...@googlegroups.com
Hi Erno,

BundleContext is only available when you're writing a bundle app.  If you want to do something similar with Simple Apps, you can use CyServiceRegistrar.  For example:

CySwingAppAdapter adapter = ...;
CyServiceRegistrar registrar = adapter.getCyServiceRegistrar();

registrar.getService(...);
registrar.registerService(...);


Hope this helps,
Jason


--
You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpd...@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at http://groups.google.com/group/cytoscape-helpdesk.
For more options, visit https://groups.google.com/d/optout.

Tim Hull

unread,
May 14, 2014, 1:12:19 PM5/14/14
to cytoscape...@googlegroups.com
Also, in case you're wondering, when you're creating a bundle app (which has BundleContext), you will depend on the OSGi library, which is included with Cytoscape.

Tim

Scooter Morris

unread,
May 14, 2014, 1:14:36 PM5/14/14
to cytoscape...@googlegroups.com
Just to add my 2¢, you are probably better off never using the BundleContext outside of your CyActivator and using the CyServiceRegistrar instead.  In hindsight, exposing the OSGi BundleContext was probably not the best move on our part...

-- scooter

Carline J Romain

unread,
May 14, 2014, 4:05:33 PM5/14/14
to cytoscape...@googlegroups.com
Hi Jason,

Would you be able to help my student figure out how to set up Cytoscape for her Nodes-Edges Network project? The contact is 646-450-1526.

Thanks.

Jason Montojo

unread,
May 14, 2014, 5:57:22 PM5/14/14
to cytoscape...@googlegroups.com
Hi Carline,

Sure, I'd be more than happy to help, though I'd prefer to do so over email.  It's easier to send links that way.  Can you send me her contact information?

Thanks,
Jason


--

lindfo...@gmail.com

unread,
May 15, 2014, 10:09:45 AM5/15/14
to cytoscape...@googlegroups.com
Hi all,

Thanks all for the responses!

I have now another question.
Can anyone provide me a code snippet for creating an empty network in Cytoscape 3.x application in static manner without using a bundle app if possible?

More specifically, I am porting a Cytoscape plugin from 2.x to 3.x.
Below is a code snippet I have successfully used to make it in Cytoscape 2.x plugin in static manner and would like to make the same in Cytoscape 3.x app.
CyNetwork myNetwork = Cytoscape.createNetwork("My Network", false);

I have tried to make it in the following way in Cytoscape 3.x app.
CyNetwork myNetwork = CyNetworkFactory.createNetwork();

But I am getting the following java compilation error.
Cannot make a static reference to the non-static method createNetwork() from the type CyNetworkFactory

From what I understand the issue is that the CyNetworkFactory.createNetwork is a non-static method.
Interestingly the corresponding method in Cytoscape 2.x (Cytoscape.createNetwork) is static.

I am sorry maybe I am asking a very trivial question but this is the first time I am writing a Cytoscape 3.x app.

Thanks again,
Erno

Jason Montojo

unread,
May 15, 2014, 10:17:24 AM5/15/14
to cytoscape...@googlegroups.com
Hi Erno,

You'll need to grab an instance of CyNetworkFactory, like this:

CyNetworkFactory networkFactory = adapter.getCyNetworkFactory();
CyNetwork network = networkFactory.createNetwork();
network.getRow(network).set(CyNetwork.NAME, "My Network");

Hope this helps,
Jason


--

Jason Montojo

unread,
May 15, 2014, 10:19:06 AM5/15/14
to cytoscape...@googlegroups.com
Hi Erno,

You'll need to grab an instance of CyNetworkFactory, like this:

CyNetworkFactory networkFactory = adapter.getCyNetworkFactory();
CyNetwork network = networkFactory.createNetwork();
network.getRow(network).set(CyNetwork.NAME, "My Network");

Hope this helps,
Jason
On Thu, May 15, 2014 at 10:09 AM, <lindfo...@gmail.com> wrote:

--

lindfo...@gmail.com

unread,
May 15, 2014, 10:37:55 AM5/15/14
to cytoscape...@googlegroups.com
Hi Jason,

Your code snippet indeed works, thanks for your help, much appreciated!

Thanks,
Erno

On Wednesday, May 14, 2014 5:54:47 PM UTC+2, lindfo...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages