Tutorial:Create a Bundle App Using IDE
本文使用的Eclipse版本是:eclipse-rcp-juno-SR1-win32.zip
Cytoscape 版本:Cytoscape 3.1.0-snapshot
一:在Eclipse中使用Maven Archetype创建cytoscape app.
- 选择 File → New → Other...
- 选择 Maven → Maven Project and click Next
- Click Next again
- 配置Cytoscape 3 Remote Archetype Catalog, 点击 "Configure..." and add the following remote catalog (and press "Ok" and "Apply" at the end): (看下图)
- Cytoscape archrtype Catolog: http://code.cytoscape.org/nexus/service/local/repositories/snapshots/content/archetype-catalog.xml
二:选择 刚配置好的Cytoscape Remote Catalog and 选中 Include snapshot archetypes. Then select cyaction-app ,然后,点击Next。(从下图中可以看到有很多版本的cyaction-app, 这里必须选择对应的Cytoscape 版本,我使用的是3.1.0)
三:按自己的风格填写信息:如下图
四:点击完成后,大概30s后,可看到刚创建的项目,项目名称为:上面填写的Artifact name。
这里必须使用JDK的jre。
五:右键项目名称,选择Run As - Maven install 构建项目。
六:将这个项目部署到Cytoscape3中
1:将项目目录中的target目录中的.jar文件拷贝到:C:/Documents and Settings/Administrator(你自己的用户名称)/CytoscapeConfiguration/3/apps/installed/
七:在控制台中运行Cytoscape 3.
1:开始- 运行- cmd: 打开控制台
2:进入Cytoscape 3 的安装目录(cd 命令)
3:运行cytoscape.bat 文件
4 From command line, type 'list'. This command displays bundles running on the current OSGi runtime. Make sure your bundle is running.
5 Type 'ls -a YOUR_BUNDLE_ID'. This indicates that your new app bundle is running and exporting an OSGi service! The template generates a very simple app template to create an instance of a class and export it as an OSGi service.
八:增加功能:实现隐藏图中的孤立节点。
1:增加依赖关系,打开pom.xml
2:编辑MenuAction.java, 输入一下代码。
import java.awt.event.ActionEvent;
import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.model.CyEdge;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNode;
import org.cytoscape.view.model.CyNetworkView;
import org.cytoscape.view.presentation.property.BasicVisualLexicon;
/**
* Creates a new menu item under Apps menu section.
*
*/
public class MenuAction extends AbstractCyAction {
private final CyApplicationManager manager;
public MenuAction(CyApplicationManager cyApplicationManager, final String menuTitle) {
//menuTitle为菜单项的名称
super(menuTitle, cyApplicationManager, null, null);
this.manager = cyApplicationManager;
setPreferredMenu("Select");//设置此Action显示在Cytoscape中Select下拉菜单中
}
public void actionPerformed(ActionEvent e) {
final CyNetworkView currentNetworkView = manager.getCurrentNetworkView();
if (currentNetworkView == null)
return;
// View is always associated with its model.
final CyNetwork network = currentNetworkView.getModel();
for (CyNode node : network.getNodeList()) {
if (network.getNeighborList(node,CyEdge.Type.ANY).isEmpty()) {
currentNetworkView.getNodeView(node).setVisualProperty(BasicVisualLexicon.NODE_VISIBLE, false);
}
}
currentNetworkView.updateView();
}
}
3:编辑CyActivator.java.替换字符串“Hello World App”为“Hide unconnected nodes”。这个名称将会出现在Cytoscape的Select下拉菜单中。这是因为上面代码setPreferredMenu("Select")设定的;
九:再次构建:Run As - Maven install。
1:将target 目录下的.jar文件拷贝到Cytoscape的installed目录中(具体目录见步骤六)
2:在控制台中运行Cytoscape,双击Cytoscape.exe也可运行
原文地址:http://opentutorials.cgl.ucsf.edu/index.php/Tutorial:Create_a_Bundle_App_Using_IDE