Author: Christian Lopes
Date: 2011-06-01 15:18:01 -0700 (Wed, 01 Jun 2011)
New Revision: 25617
Modified:
core3/session-impl/trunk/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
core3/session-impl/trunk/src/main/java/org/cytoscape/session/internal/CysessionFactory.java
Log:
It now adds the NetworkTree and documentVersion to Cysession when saving a
session.
Modified:
core3/session-impl/trunk/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
===================================================================
---
core3/session-impl/trunk/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
2011-06-01 22:10:28 UTC (rev 25616)
+++
core3/session-impl/trunk/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
2011-06-01 22:18:01 UTC (rev 25617)
@@ -42,9 +42,9 @@
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
+import java.util.Map.Entry;
import org.cytoscape.event.CyEventHelper;
import org.cytoscape.model.CyNetwork;
@@ -76,218 +76,223 @@
*/
public class CySessionManagerImpl implements CySessionManager {
- private String currentFileName;
- private CySession currentSession;
+ private String currentFileName;
+ private CySession currentSession;
- private final CyEventHelper cyEventHelper;
- private final CyNetworkManager netMgr;
- private final CyTableManager tblMgr;
- private final VisualMappingManager vmMgr;
- private final VisualStyleSerializer vsSer;
- private final CyNetworkViewManager nvMgr;
+ private final CyEventHelper cyEventHelper;
+ private final CyNetworkManager netMgr;
+ private final CyTableManager tblMgr;
+ private final VisualMappingManager vmMgr;
+ private final VisualStyleSerializer vsSer;
+ private final CyNetworkViewManager nvMgr;
- private final CyProperty<Properties> properties;
- private final CyProperty<Bookmarks> bookmarks;
+ private final CyProperty<Properties> properties;
+ private final CyProperty<Bookmarks> bookmarks;
- private static final Logger logger =
LoggerFactory.getLogger(CySessionManagerImpl.class);
+ private static final Logger logger =
LoggerFactory.getLogger(CySessionManagerImpl.class);
- public CySessionManagerImpl(CyEventHelper cyEventHelper,
- CyNetworkManager netMgr,
- CyTableManager tblMgr,
- VisualMappingManager vmMgr,
- VisualStyleSerializer vsSer,
- CyNetworkViewManager nvMgr,
- CyProperty<Properties> props,
- CyProperty<Bookmarks> bkmarks) {
- this.cyEventHelper = cyEventHelper;
- this.netMgr = netMgr;
- this.tblMgr = tblMgr;
- this.vmMgr = vmMgr;
- this.vsSer = vsSer;
- this.nvMgr = nvMgr;
- this.properties = props;
- this.bookmarks = bkmarks;
- }
+ public CySessionManagerImpl(CyEventHelper cyEventHelper,
+
CyNetworkManager netMgr,
+ CyTableManager
tblMgr,
+
VisualMappingManager vmMgr,
+
VisualStyleSerializer vsSer,
+
CyNetworkViewManager nvMgr,
+
CyProperty<Properties> props,
+
CyProperty<Bookmarks> bkmarks) {
+ this.cyEventHelper = cyEventHelper;
+ this.netMgr = netMgr;
+ this.tblMgr = tblMgr;
+ this.vmMgr = vmMgr;
+ this.vsSer = vsSer;
+ this.nvMgr = nvMgr;
+ this.properties = props;
+ this.bookmarks = bkmarks;
+ }
- public CySession getCurrentSession() {
- // Plugins who want to save anything to a session will have to listen
- // for this event
- // and will then be responsible for adding files through
- // SessionAboutToBeSavedEvent.addPluginFiles(..)
- SessionAboutToBeSavedEvent savingEvent = new
SessionAboutToBeSavedEvent(this);
- cyEventHelper.fireSynchronousEvent(savingEvent);
+ public CySession getCurrentSession() {
+ // Plugins who want to save anything to a session will have to
listen for this event
+ // and will then be responsible for adding files through
SessionAboutToBeSavedEvent.addPluginFiles(..)
+ SessionAboutToBeSavedEvent savingEvent = new
SessionAboutToBeSavedEvent(this);
+ cyEventHelper.fireSynchronousEvent(savingEvent);
- CysessionFactory cysessFactory = new CysessionFactory();
- Cysession cysess =
cysessFactory.createCysession(savingEvent.getDesktop(),
savingEvent.getCytopanels(), null);
+ CysessionFactory cysessFactory = new CysessionFactory(netMgr,
nvMgr, vmMgr);
- Map<String, List<File>> pluginMap = savingEvent.getPluginFileListMap();
+ Set<CyNetworkView> netViews = nvMgr.getNetworkViewSet();
- Set<CyTableMetadata> tables = tblMgr.getAllTables(true);
- Set<CyNetworkView> netViews = nvMgr.getNetworkViewSet();
+ // Visual Styles Map
+ Map<CyNetworkView, String> stylesMap = new
HashMap<CyNetworkView, String>();
- Set<VisualStyle> allStyles = vmMgr.getAllVisualStyles();
- Vizmap vizmap = vsSer.createVizmap(allStyles);
+ if (netViews != null) {
+ for (CyNetworkView nv : netViews) {
+ VisualStyle style = vmMgr.getVisualStyle(nv);
- Map<CyNetworkView, String> stylesMap = new HashMap<CyNetworkView,
String>();
+ if (style != null) {
+ stylesMap.put(nv, style.getTitle());
+ }
+ }
+ }
- if (netViews != null) {
- for (CyNetworkView nv : netViews) {
- VisualStyle style = vmMgr.getVisualStyle(nv);
+ // Cysession
+ Cysession cysess =
cysessFactory.createCysession(savingEvent.getDesktop(),
savingEvent.getCytopanels(), null);
- if (style != null) {
- logger.debug(" NetView=" + nv + " :: Style=" +
style.getTitle());
- stylesMap.put(nv, style.getTitle());
- }
- }
- }
+ Map<String, List<File>> pluginMap =
savingEvent.getPluginFileListMap();
- Properties props = properties != null ? properties.getProperties() :
null;
- Bookmarks bkmarks = bookmarks != null ? bookmarks.getProperties() :
null;
+ Set<CyTableMetadata> tables = tblMgr.getAllTables(true);
- CySession sess = new
CySession.Builder().cytoscapeProperties(props).bookmarks(bkmarks).cysession(cysess)
-
.pluginFileListMap(pluginMap).tables(tables).networkViews(netViews).vizmap(vizmap)
- .viewVisualStyleMap(stylesMap).build();
+ Set<VisualStyle> allStyles = vmMgr.getAllVisualStyles();
+ Vizmap vizmap = vsSer.createVizmap(allStyles);
- return sess;
- }
+ // Properties and Bookmarks
+ Properties props = properties != null ?
properties.getProperties() : null;
+ Bookmarks bkmarks = bookmarks != null ?
bookmarks.getProperties() : null;
- public void setCurrentSession(CySession sess, String fileName) {
- boolean emptySession = sess == null;
+ // Build the session
+ CySession sess = new
CySession.Builder().cytoscapeProperties(props).bookmarks(bkmarks).cysession(cysess)
+
.pluginFileListMap(pluginMap).tables(tables).networkViews(netViews).vizmap(vizmap)
+ .viewVisualStyleMap(stylesMap).build();
- // Always remove the current session first
- disposeCurrentSession(!emptySession);
+ return sess;
+ }
- if (emptySession) {
- logger.debug("Creating empty session...");
- Set<VisualStyle> allStyles = vmMgr.getAllVisualStyles();
- Vizmap vizmap = vsSer.createVizmap(allStyles);
- Cysession cysess = new CysessionFactory().createDefaultCysession();
+ public void setCurrentSession(CySession sess, String fileName) {
+ boolean emptySession = sess == null;
- // TODO: set default properties again
- Properties props = properties != null ? properties.getProperties()
: new Properties();
- // TODO: set default bookmarks again
- Bookmarks bkmarks = bookmarks != null ? bookmarks.getProperties()
: new Bookmarks();
+ // Always remove the current session first
+ disposeCurrentSession(!emptySession);
- sess = new
CySession.Builder().cytoscapeProperties(props).bookmarks(bkmarks).cysession(cysess)
- .vizmap(vizmap).build();
- } else {
- logger.debug("Restoring the session...");
+ if (emptySession) {
+ logger.debug("Creating empty session...");
+ Set<VisualStyle> allStyles = vmMgr.getAllVisualStyles();
+ Vizmap vizmap = vsSer.createVizmap(allStyles);
- // Restore tables
- //
------------------------------------------------------------------------------
- // TODO: add tables that are not associated with networks
- // logger.debug("Restoring unattached tables...");
- // Set<CyTable> tables = sess.getTables();
- //
- // for (CyTable tbl : tables) {
- // CyTableFactory.createTable();
- // }
+ // Cysession info
+ Cysession cysess = new CysessionFactory(netMgr, nvMgr,
vmMgr).createDefaultCysession();
- // Restore networks
- logger.debug("Restoring networks...");
- Set<CyNetworkView> netViews = sess.getNetworkViews();
+ // TODO: set default properties again
+ Properties props = properties != null ?
properties.getProperties() : new Properties();
+ // TODO: set default bookmarks again
+ Bookmarks bkmarks = bookmarks != null ?
bookmarks.getProperties() : new Bookmarks();
- for (CyNetworkView nv : netViews) {
- netMgr.addNetwork(nv.getModel());
- nvMgr.addNetworkView(nv);
- }
+ sess = new
CySession.Builder().cytoscapeProperties(props).bookmarks(bkmarks).cysession(cysess)
+ .vizmap(vizmap).build();
+ } else {
+ logger.debug("Restoring the session...");
- // Restore visual styles
- logger.debug("Restoring visual styles...");
- Vizmap vizmap = sess.getVizmap();
- Collection<VisualStyle> allStyles =
vsSer.createVisualStyles(vizmap);
- Map<String, VisualStyle> stylesMap = new HashMap<String,
VisualStyle>();
+ // Restore tables
+ //
------------------------------------------------------------------------------
+ // TODO: add tables that are not associated with
networks
+ // logger.debug("Restoring unattached tables...");
+ // Set<CyTable> tables = sess.getTables();
+ //
+ // for (CyTable tbl : tables) {
+ // CyTableFactory.createTable();
+ // }
- if (allStyles != null) {
- for (VisualStyle vs : allStyles) {
- vmMgr.addVisualStyle(vs);
- stylesMap.put(vs.getTitle(), vs);
- // TODO: what if a style with the same name already exits?
- }
- }
+ // Restore networks
+ logger.debug("Restoring networks...");
+ Set<CyNetworkView> netViews = sess.getNetworkViews();
- // Get network frames info
- Cysession cysess = sess.getCysession();
+ for (CyNetworkView nv : netViews) {
+ netMgr.addNetwork(nv.getModel());
+ nvMgr.addNetworkView(nv);
+ }
- if (cysess.getSessionState().getDesktop().getNetworkFrames() !=
null) {
- List<NetworkFrame> frames =
cysess.getSessionState().getDesktop().getNetworkFrames().getNetworkFrame();
- Map<String, NetworkFrame> framesLookup = new Hashtable<String,
NetworkFrame>();
+ // Restore visual styles
+ logger.debug("Restoring visual styles...");
+ Vizmap vizmap = sess.getVizmap();
+ Collection<VisualStyle> allStyles =
vsSer.createVisualStyles(vizmap);
+ Map<String, VisualStyle> stylesMap = new
HashMap<String, VisualStyle>();
- for (NetworkFrame nf : frames) {
- framesLookup.put(nf.getFrameID(), nf);
- }
+ if (allStyles != null) {
+ for (VisualStyle vs : allStyles) {
+ vmMgr.addVisualStyle(vs);
+ stylesMap.put(vs.getTitle(), vs);
+ // TODO: what if a style with the same
name already exits?
+ }
+ }
- // Set visual styles to network views
- Map<CyNetworkView, String> netStyleMap =
sess.getViewVisualStyleMap();
+ // Get network frames info
+ Cysession cysess = sess.getCysession();
- for (Entry<CyNetworkView, String> entry :
netStyleMap.entrySet()) {
- CyNetworkView netView = entry.getKey();
- String stName = entry.getValue();
- VisualStyle vs = stylesMap.get(stName);
+ if
(cysess.getSessionState().getDesktop().getNetworkFrames() != null) {
+ List<NetworkFrame> frames =
cysess.getSessionState().getDesktop().getNetworkFrames().getNetworkFrame();
+ Map<String, NetworkFrame> framesLookup = new
Hashtable<String, NetworkFrame>();
- if (vs != null) {
- vmMgr.setVisualStyle(vs, netView);
- vs.apply(netView);
- }
+ for (NetworkFrame nf : frames) {
+ framesLookup.put(nf.getFrameID(), nf);
+ }
- // Set network width/height
- String name =
netView.getModel().getCyRow().get(CyNetwork.NAME, String.class);
+ // Set visual styles to network views
+ Map<CyNetworkView, String> netStyleMap =
sess.getViewVisualStyleMap();
- if (name != null && name.length() > 0) {
- NetworkFrame nf = framesLookup.get(name);
+ for (Entry<CyNetworkView, String> entry :
netStyleMap.entrySet()) {
+ CyNetworkView netView = entry.getKey();
+ String stName = entry.getValue();
+ VisualStyle vs = stylesMap.get(stName);
- if (nf != null) {
- BigInteger w = nf.getWidth();
- BigInteger h = nf.getHeight();
+ if (vs != null) {
+ vmMgr.setVisualStyle(vs,
netView);
+ vs.apply(netView);
+ }
- if (w != null)
-
netView.setVisualProperty(MinimalVisualLexicon.NETWORK_WIDTH, w.doubleValue());
- if (h != null)
-
netView.setVisualProperty(MinimalVisualLexicon.NETWORK_HEIGHT, h.doubleValue());
- }
- }
+ // Set network width/height
+ String name =
netView.getModel().getCyRow().get(CyNetwork.NAME, String.class);
- netView.updateView();
- }
- }
- }
+ if (name != null && name.length() > 0) {
+ NetworkFrame nf =
framesLookup.get(name);
- currentSession = sess;
- currentFileName = fileName;
+ if (nf != null) {
+ BigInteger w =
nf.getWidth();
+ BigInteger h =
nf.getHeight();
- cyEventHelper.fireSynchronousEvent(new SessionLoadedEvent(this,
currentSession, getCurrentSessionFileName()));
- }
+ if (w != null)
+
netView.setVisualProperty(MinimalVisualLexicon.NETWORK_WIDTH, w.doubleValue());
+ if (h != null)
+
netView.setVisualProperty(MinimalVisualLexicon.NETWORK_HEIGHT, h.doubleValue());
+ }
+ }
- public String getCurrentSessionFileName() {
- return currentFileName;
- }
+ netView.updateView();
+ }
+ }
+ }
- private void disposeCurrentSession(boolean removeVisualStyles) {
- logger.debug("Disposing current session...");
+ currentSession = sess;
+ currentFileName = fileName;
- // Destroy network views and models
- Set<CyNetworkView> netViews = nvMgr.getNetworkViewSet();
+ cyEventHelper.fireSynchronousEvent(new SessionLoadedEvent(this,
currentSession, getCurrentSessionFileName()));
+ }
- for (CyNetworkView nv : netViews) {
- nvMgr.destroyNetworkView(nv);
- netMgr.destroyNetwork(nv.getModel());
- }
+ public String getCurrentSessionFileName() {
+ return currentFileName;
+ }
- // Destroy styles
- if (removeVisualStyles) {
- logger.debug("Removing current visual styles...");
- VisualStyle defaultStyle = vmMgr.getDefaultVisualStyle();
- List<VisualStyle> allStyles = new
ArrayList<VisualStyle>(vmMgr.getAllVisualStyles());
+ private void disposeCurrentSession(boolean removeVisualStyles) {
+ logger.debug("Disposing current session...");
- for (int i = 0; i < allStyles.size(); i++) {
- VisualStyle vs = allStyles.get(i);
+ // Destroy network views and models
+ Set<CyNetworkView> netViews = nvMgr.getNetworkViewSet();
- if (!vs.equals(defaultStyle)) {
- vmMgr.removeVisualStyle(vs);
- }
- }
- }
+ for (CyNetworkView nv : netViews) {
+ nvMgr.destroyNetworkView(nv);
+ netMgr.destroyNetwork(nv.getModel());
+ }
- // TODO: destroy unattached tables--how?
- }
+ // Destroy styles
+ if (removeVisualStyles) {
+ logger.debug("Removing current visual styles...");
+ VisualStyle defaultStyle =
vmMgr.getDefaultVisualStyle();
+ List<VisualStyle> allStyles = new
ArrayList<VisualStyle>(vmMgr.getAllVisualStyles());
+
+ for (int i = 0; i < allStyles.size(); i++) {
+ VisualStyle vs = allStyles.get(i);
+
+ if (!vs.equals(defaultStyle)) {
+ vmMgr.removeVisualStyle(vs);
+ }
+ }
+ }
+
+ // TODO: destroy unattached tables--how?
+ }
}
Modified:
core3/session-impl/trunk/src/main/java/org/cytoscape/session/internal/CysessionFactory.java
===================================================================
---
core3/session-impl/trunk/src/main/java/org/cytoscape/session/internal/CysessionFactory.java
2011-06-01 22:10:28 UTC (rev 25616)
+++
core3/session-impl/trunk/src/main/java/org/cytoscape/session/internal/CysessionFactory.java
2011-06-01 22:18:01 UTC (rev 25617)
@@ -35,7 +35,11 @@
package org.cytoscape.session.internal;
import java.util.List;
+import java.util.Set;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNetworkManager;
+import org.cytoscape.model.subnetwork.CySubNetwork;
import org.cytoscape.property.session.Cysession;
import org.cytoscape.property.session.Cytopanel;
import org.cytoscape.property.session.Cytopanels;
@@ -44,20 +48,33 @@
import org.cytoscape.property.session.NetworkTree;
import org.cytoscape.property.session.ObjectFactory;
import org.cytoscape.property.session.OntologyServer;
+import org.cytoscape.property.session.Parent;
import org.cytoscape.property.session.Server;
import org.cytoscape.property.session.SessionState;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.model.CyNetworkViewManager;
+import org.cytoscape.view.vizmap.VisualMappingManager;
+import org.cytoscape.view.vizmap.model.VisualStyle;
+public class CysessionFactory {
-public class CysessionFactory {
-
private static final String DEFAULT_SESSION_NOTE = "You can add note
for this session here.";
+ private static final String CYSESSION_VERSION = "3.0";
+ private final CyNetworkManager netMgr;
+ private final CyNetworkViewManager nvMgr;
+ private final VisualMappingManager vmMgr;
private final ObjectFactory factory;
-
- public CysessionFactory() {
+
+ public CysessionFactory(final CyNetworkManager netMgr,
+ final
CyNetworkViewManager nvMgr,
+ final
VisualMappingManager vmMgr) {
+ this.netMgr = netMgr;
+ this.nvMgr = nvMgr;
+ this.vmMgr = vmMgr;
this.factory = new ObjectFactory();
}
-
+
public Cysession createDefaultCysession() {
return createCysession(null, null, null);
}
@@ -67,32 +84,30 @@
*/
public Cysession createCysession(Desktop desktop, List<Cytopanel>
cytopanels, String note) {
Cysession session = null;
-
+
// Initialize objects for the marshaller:
session = factory.createCysession();
-
+ session.setDocumentVersion(CYSESSION_VERSION);
+
if (note == null) note = DEFAULT_SESSION_NOTE;
session.setSessionNote(note);
- NetworkTree tree = factory.createNetworkTree();
-
SessionState sState = factory.createSessionState();
-
+ session.setSessionState(sState);
+
if (desktop == null) desktop = factory.createDesktop();
sState.setDesktop(desktop);
-
- session.setSessionState(sState);
+
Cytopanels cps = getCytoPanelStates(cytopanels);
-
- // TODO?
- List<Network> netList = tree.getNetwork();
-
sState.setCytopanels(cps);
sState.setServer(getServerState());
-
+
+ NetworkTree netTree = getNetworkTree();
+ session.setNetworkTree(netTree);
+
return session;
}
-
+
/**
* Check loaded ontologies and save those states in cysession.xml.
* @return Server object
@@ -103,21 +118,21 @@
// We've omitted the concept of Ontology from the core api in
3.0,
// so that code will exist in the future as a plugin (although
with a public API)
-// Set<String> ontoNames =
Cytoscape.getOntologyServer().getOntologyNames();
-// Map<String, URL> sources =
Cytoscape.getOntologyServer().getOntologySources();
-//
-// for (String name : ontoNames) {
-// Ontology onto = factory.createOntology();
-// onto.setName(name);
-// onto.setHref(sources.get(name).toString());
-// os.getOntology().add(onto);
-// }
+ // Set<String> ontoNames =
Cytoscape.getOntologyServer().getOntologyNames();
+ // Map<String, URL> sources =
Cytoscape.getOntologyServer().getOntologySources();
+ //
+ // for (String name : ontoNames) {
+ // Ontology onto =
factory.createOntology();
+ // onto.setName(name);
+ //
onto.setHref(sources.get(name).toString());
+ // os.getOntology().add(onto);
+ // }
server.setOntologyServer(os);
return server;
}
-
+
/**
* Extract states of the 3 Cytopanels.
*
@@ -128,71 +143,88 @@
private Cytopanels getCytoPanelStates(List<Cytopanel> cytopanels) {
Cytopanels cps = factory.createCytopanels();
List<Cytopanel> cytoPanelList = cps.getCytopanel();
-
+
if (cytopanels != null) {
- for (Cytopanel panel : cytopanels)
cytoPanelList.add(panel);
+ for (Cytopanel panel : cytopanels)
+ cytoPanelList.add(panel);
}
-// TODO: cleanup. This should be done by the swing related plugin
-// String[] cytopanelStates = new String[CYTOPANEL_COUNT + 1];
-// int[] selectedPanels = new int[CYTOPANEL_COUNT + 1];
-//
-// // Extract states of 3 panels.
-// cytopanelStates[1] =
application.getCytoPanel(CytoPanelName.WEST).getState().toString();
-// selectedPanels[1] =
application.getCytoPanel(CytoPanelName.WEST).getSelectedIndex();
-// cytopanelStates[2] =
application.getCytoPanel(CytoPanelName.SOUTH).getState().toString();
-// selectedPanels[2] =
application.getCytoPanel(CytoPanelName.SOUTH).getSelectedIndex();
-// cytopanelStates[3] =
application.getCytoPanel(CytoPanelName.EAST).getState().toString();
-// selectedPanels[3] =
application.getCytoPanel(CytoPanelName.EAST).getSelectedIndex();
-//
-// // Number of Cytopanels. Currently, we have 3 panels.
-// final int CYTOPANEL_COUNT = 3;
-
-// for (int i = 1; i < (CYTOPANEL_COUNT + 1); i++) {
-// Panels internalPanels = factory.createPanels();
-// List<Panel> iPanelList = internalPanels.getPanel();
-// Panel iPanel = factory.createPanel();
-// iPanel.setId("test");
-//
-// iPanelList.add(iPanel);
-//
-// Cytopanel curCp = factory.createCytopanel();
-// curCp.setId("CytoPanel" + i);
-// curCp.setPanelState(cytopanelStates[i]);
-//
curCp.setSelectedPanel(Integer.toString(selectedPanels[i]));
-// curCp.setPanels(internalPanels);
-// cytoPanelList.add(curCp);
-// }
+ // TODO: cleanup. This should be done by the swing related
plugin
+ // String[] cytopanelStates = new
String[CYTOPANEL_COUNT + 1];
+ // int[] selectedPanels = new int[CYTOPANEL_COUNT
+ 1];
+ //
+ // // Extract states of 3 panels.
+ // cytopanelStates[1] =
application.getCytoPanel(CytoPanelName.WEST).getState().toString();
+ // selectedPanels[1] =
application.getCytoPanel(CytoPanelName.WEST).getSelectedIndex();
+ // cytopanelStates[2] =
application.getCytoPanel(CytoPanelName.SOUTH).getState().toString();
+ // selectedPanels[2] =
application.getCytoPanel(CytoPanelName.SOUTH).getSelectedIndex();
+ // cytopanelStates[3] =
application.getCytoPanel(CytoPanelName.EAST).getState().toString();
+ // selectedPanels[3] =
application.getCytoPanel(CytoPanelName.EAST).getSelectedIndex();
+ //
+ // // Number of Cytopanels. Currently, we have 3
panels.
+ // final int CYTOPANEL_COUNT = 3;
+ // for (int i = 1; i < (CYTOPANEL_COUNT + 1); i++)
{
+ // Panels internalPanels =
factory.createPanels();
+ // List<Panel> iPanelList =
internalPanels.getPanel();
+ // Panel iPanel = factory.createPanel();
+ // iPanel.setId("test");
+ //
+ // iPanelList.add(iPanel);
+ //
+ // Cytopanel curCp =
factory.createCytopanel();
+ // curCp.setId("CytoPanel" + i);
+ // curCp.setPanelState(cytopanelStates[i]);
+ //
curCp.setSelectedPanel(Integer.toString(selectedPanels[i]));
+ // curCp.setPanels(internalPanels);
+ // cytoPanelList.add(curCp);
+ // }
+
return cps;
}
-// TODO: cleanup. This should be done by the swing related plugin
-// private void setDesktopStates(SessionState sState) {
-// DesktopSize dSize = factory.createDesktopSize();
-// NetworkFrames frames = factory.createNetworkFrames();
-//
-// // TODO
-// Component[] networkFrames =
Cytoscape.getDesktop().getNetworkViewManager().getDesktopPane().getComponents();
-//
-// for (int i = 0; i < networkFrames.length; i++) {
-// if(networkFrames[i] instanceof JInternalFrame) {
-// JInternalFrame networkFrame = (JInternalFrame)
networkFrames[i];
-// NetworkFrame frame =
factory.createNetworkFrame();
-// frame.setFrameID(networkFrame.getTitle());
-//
frame.setWidth(BigInteger.valueOf(networkFrame.getWidth()));
-//
frame.setHeight(BigInteger.valueOf(networkFrame.getHeight()));
-//
frame.setX(BigInteger.valueOf(networkFrame.getX()));
-//
frame.setY(BigInteger.valueOf(networkFrame.getY()));
-// frames.getNetworkFrame().add(frame);
-// }
-// }
-//
-//
dSize.setHeight(BigInteger.valueOf(application.getJFrame().getSize().height));
-//
dSize.setWidth(BigInteger.valueOf(application.getJFrame().getSize().width));
-//
-// Desktop desktop = factory.createDesktop();
-// desktop.setDesktopSize(dSize);
-// desktop.setNetworkFrames(frames);
-// sState.setDesktop(desktop);
-// }
+ private NetworkTree getNetworkTree() {
+ NetworkTree tree = factory.createNetworkTree();
+ Set<CyNetwork> networks = netMgr.getNetworkSet();
+
+ if (networks != null) {
+ final String DEF_STYLE_NAME =
vmMgr.getDefaultVisualStyle().getTitle();
+
+ for (CyNetwork cyNet : networks) {
+ String name =
cyNet.getCyRow().get(CyNetwork.NAME, String.class);
+ String styleName = DEF_STYLE_NAME;
+
+ CyNetworkView cyNetView =
nvMgr.getNetworkView(cyNet.getSUID());
+
+ if (cyNetView != null) {
+ org.cytoscape.view.vizmap.VisualStyle
style = vmMgr.getVisualStyle(cyNetView);
+ if (style != null) styleName =
style.getTitle();
+ }
+
+ Network net = new Network();
+ net.setId(name);
+ net.setFilename(name + ".xgmml");
+ net.setVisualStyle(styleName);
+
net.setViewAvailable(nvMgr.getNetworkView(cyNet.getSUID()) != null);
+ net.setVisualStyle(styleName);
+
+ if (cyNet instanceof CySubNetwork) {
+ CySubNetwork cysSubNet = (CySubNetwork)
cyNet;
+ String parentName =
cysSubNet.getRootNetwork().getCyRow().get(CyNetwork.NAME, String.class);
+
+ Parent parent = new Parent();
+ parent.setId(parentName);
+
+ net.setParent(parent);
+ }
+
+ // We don't need to save selected nodes/edges
anymore, because this info is saved in the CyTables now!
+ //
net.setSelectedNodes(selNodes);
+ //
net.setSelectedEdges(selEdges);
+
+ tree.getNetwork().add(net);
+ }
+ }
+
+ return tree;
+ }
}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.