Search in sources :

Example 1 with SessionXGMMLNetworkViewReader

use of org.cytoscape.io.internal.read.xgmml.SessionXGMMLNetworkViewReader in project cytoscape-impl by cytoscape.

the class Cy3SessionReaderImpl method extractNetworkView.

private void extractNetworkView(InputStream is, String entryName) throws Exception {
    // Get the token which identifies the network
    Matcher matcher = NETWORK_VIEW_PATTERN.matcher(entryName);
    Long oldNetId = null;
    if (matcher.matches()) {
        String netViewToken = matcher.group(2);
        matcher = NETWORK_VIEW_NAME_PATTERN.matcher(netViewToken);
        if (matcher.matches()) {
            try {
                oldNetId = Long.valueOf(matcher.group(1));
            } catch (NumberFormatException nfe) {
                logger.error("Cannot extract network view SUID from: " + netViewToken);
            }
        }
    }
    if (oldNetId != null) {
        final CyNetwork network = cache.getNetwork(oldNetId);
        if (network != null && !cancelled) {
            // Create the view
            final CyNetworkReader reader = networkReaderMgr.getReader(is, entryName);
            reader.run(taskMonitor);
            final CyNetworkView view = reader.buildCyNetworkView(network);
            networkViews.add(view);
            // Get its visual style name
            if (reader instanceof SessionXGMMLNetworkViewReader) {
                final String vsName = ((SessionXGMMLNetworkViewReader) reader).getVisualStyleName();
                if (vsName != null && !vsName.isEmpty())
                    this.visualStyleMap.put(view, vsName);
            }
        }
    } else {
        logger.error("The network view will cannot be recreated. The network view entry is invalid: " + entryName);
    }
}
Also used : SessionXGMMLNetworkViewReader(org.cytoscape.io.internal.read.xgmml.SessionXGMMLNetworkViewReader) CyNetworkReader(org.cytoscape.io.read.CyNetworkReader) Matcher(java.util.regex.Matcher) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Aggregations

Matcher (java.util.regex.Matcher)1 SessionXGMMLNetworkViewReader (org.cytoscape.io.internal.read.xgmml.SessionXGMMLNetworkViewReader)1 CyNetworkReader (org.cytoscape.io.read.CyNetworkReader)1 CyNetwork (org.cytoscape.model.CyNetwork)1 CyNetworkView (org.cytoscape.view.model.CyNetworkView)1