private void applySelectionToNetwork() {
    CyNetwork network = Cytoscape.getCurrentNetwork();
    network.unselectAllNodes();
    network.unselectAllEdges();

    Set<String> selection = new HashSet<String>();
    for (int i : currentTable.getSelectedRows()) {
      selection.add(currentTable.getValueAt(i, 0).toString());
    }

    NetworkData networkData =
        MetScapePlugin.getPluginData().getNetworkData(Networks.getUUID(network));
    if (networkData == null) return;
    NetworkType networkType = networkData.getNetworkType();

    if (networkType == NetworkType.CREG) applySelectionToCREGNetwork(network, selection);
    else if (networkType == NetworkType.COMPOUND_REACTION)
      applySelectionToCRNetwork(network, selection);
    else if (networkType == NetworkType.COMPOUND_GENE)
      applySelectionToCGNetwork(network, selection);
    else if (networkType == NetworkType.COMPOUND)
      applySelectionToCompoundNetwork(network, selection);

    CyNetworkView view = Cytoscape.getNetworkView(network.getIdentifier());
    if (view != null && initialized) view.redrawGraph(true, true);
    else if (!initialized) initialized = true;
  }
  public void actionPerformed(ActionEvent e) {

    // sum of coordinates
    double sx = 0;
    double sy = 0;

    // coordinates of center of graph
    double cx = 0;
    double cy = 0;

    // coordinates with graph centered at (0,0)
    double nx;
    double ny;

    CyNetworkView parent = Cytoscape.getCurrentNetworkView();
    // loop through each node to add up all x and all y coordinates
    for (Iterator i = parent.getNodeViewsIterator(); i.hasNext(); ) {
      NodeView nodeView = (NodeView) i.next();
      // get coordinates of node
      double ax = nodeView.getXPosition();
      double ay = nodeView.getYPosition();
      // sum up coordinates of all the nodes
      sx += ax;
      sy += ay;
    }

    // set new coordinates of each node at center (0,0), shrink, then return to
    // original center at (cx, cy)
    for (Iterator i = parent.getNodeViewsIterator(); i.hasNext(); ) {
      NodeView nodeView = (NodeView) i.next();
      nodeView.setXPosition(m * ((nodeView.getXPosition()) - cx) + cx);
      nodeView.setYPosition(m * ((nodeView.getYPosition()) - cy) + cy);
    }

    // remove bends
    for (Iterator i = parent.getEdgeViewsIterator(); i.hasNext(); ) {
      EdgeView edgeView = (EdgeView) i.next();
      edgeView.getBend().removeAllHandles();
    }
  } // Action Performed