use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.
the class NullNetworkViewPanel method update.
private void update() {
if (networkView != null) {
getInfoIconLabel().setText(ICON_EXTERNAL_LINK_SQUARE);
getInfoIconLabel().setToolTipText("This view is detached");
} else if (network != null) {
getInfoIconLabel().setText(ICON_SHARE_ALT);
getInfoIconLabel().setToolTipText(network instanceof CySubNetwork ? "This network has no views" : "A network collection cannot have views");
} else {
getInfoIconLabel().setText(null);
getInfoIconLabel().setToolTipText(null);
}
getInfoIconLabel().setVisible(networkView != null || network != null);
getInfoLabel().setVisible(network == null && networkView == null);
getCreateViewButton().setVisible(networkView == null && network instanceof CySubNetwork);
getReattachViewButton().setVisible(networkView != null);
sep2.setVisible(networkView != null);
if (networkView != null)
getTitleLabel().setText(ViewUtil.getTitle(networkView));
else if (network != null)
getTitleLabel().setText(ViewUtil.getName(network));
else
getTitleLabel().setText(null);
final Dimension d = new Dimension(1, network != null && networkView == null ? getCreateViewButton().getPreferredSize().height : 0);
getGapLabel().setPreferredSize(d);
getGapLabel().setMinimumSize(d);
getGapLabel().setMaximumSize(d);
getGapLabel().setSize(d);
getToolBar().updateUI();
}
use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.
the class NetworkViewMainPanel method init.
private void init() {
setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, UIManager.getColor("Separator.foreground")));
setLayout(new BorderLayout());
add(getContentPane(), BorderLayout.CENTER);
// Add Listeners
nullViewPanel.getCreateViewButton().addActionListener(evt -> {
if (nullViewPanel.getNetwork() instanceof CySubNetwork) {
final CreateNetworkViewTaskFactory factory = serviceRegistrar.getService(CreateNetworkViewTaskFactory.class);
final DialogTaskManager taskManager = serviceRegistrar.getService(DialogTaskManager.class);
taskManager.execute(factory.createTaskIterator(Collections.singleton(nullViewPanel.getNetwork())));
}
});
nullViewPanel.getInfoIconLabel().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (!e.isPopupTrigger() && nullViewPanel.getNetworkView() != null) {
final NetworkViewFrame frame = getNetworkViewFrame(nullViewPanel.getNetworkView());
if (frame != null)
showViewFrame(frame);
}
}
});
nullViewPanel.getReattachViewButton().addActionListener(evt -> {
if (nullViewPanel.getNetworkView() != null)
reattachNetworkView(nullViewPanel.getNetworkView());
});
networkViewGrid.addPropertyChangeListener("selectedNetworkViews", evt -> {
// Just fire the same event
firePropertyChange("selectedNetworkViews", evt.getOldValue(), evt.getNewValue());
});
networkViewGrid.addPropertyChangeListener("currentNetworkView", evt -> {
final CyNetworkView curView = (CyNetworkView) evt.getNewValue();
for (NetworkViewContainer vc : getAllNetworkViewContainers()) vc.setCurrent(vc.getNetworkView().equals(curView));
});
Toolkit.getDefaultToolkit().addAWTEventListener(mousePressedAWTEventListener, MouseEvent.MOUSE_EVENT_MASK);
// Update
updateGrid();
}
use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.
the class CyNetworkAutoDeleteTest method testUndoDeletedEdge.
@Test
public void testUndoDeletedEdge() {
CyNetwork network1 = TestCyNetworkFactory.getInstance();
CyRootNetwork rootNetwork = ((CySubNetwork) network1).getRootNetwork();
CyNode n1 = network1.addNode();
CyNode n2 = network1.addNode();
CyNode n3 = network1.addNode();
CyEdge e1 = network1.addEdge(n1, n2, false);
CyEdge e2 = network1.addEdge(n2, n3, false);
CyNetwork network2 = rootNetwork.addSubNetwork(Arrays.asList(n1, n2, n3), Arrays.asList(e1, e2));
network1.removeNodes(Collections.singleton(n1));
network2.removeNodes(Collections.singleton(n1));
assertFalse(rootNetwork.containsEdge(e1));
assertFalse(rootNetwork.containsNode(n1));
// restoring the edge should automatically restore its source and target nodes as well
((CySubNetwork) network1).addEdge(e1);
assertTrue(rootNetwork.containsNode(n1));
assertTrue(network1.containsNode(n1));
assertFalse(network2.containsNode(n1));
assertTrue(rootNetwork.containsEdge(e1));
assertTrue(network1.containsEdge(e1));
assertFalse(network2.containsEdge(e1));
}
use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.
the class CyNetworkAutoDeleteTest method testRestoreEdge.
@Test
public void testRestoreEdge() {
CyNetwork network1 = TestCyNetworkFactory.getInstance();
CyRootNetwork rootNetwork = ((CySubNetwork) network1).getRootNetwork();
CyNode n1 = network1.addNode();
CyNode n2 = network1.addNode();
CyNode n3 = network1.addNode();
CyEdge e1 = network1.addEdge(n1, n2, false);
CyEdge e2 = network1.addEdge(n2, n3, false);
CyNetwork network2 = rootNetwork.addSubNetwork(Arrays.asList(n1, n2, n3), Arrays.asList(e1, e2));
network1.removeEdges(Arrays.asList(e1));
network2.removeEdges(Arrays.asList(e1));
assertFalse(rootNetwork.containsEdge(e1));
rootNetwork.restoreEdge(e1);
assertTrue(rootNetwork.containsEdge(e1));
}
use of org.cytoscape.model.subnetwork.CySubNetwork in project cytoscape-impl by cytoscape.
the class CyNetworkAutoDeleteTest method testSubnetworkWorkaround.
@Test
public void testSubnetworkWorkaround() {
CyNetwork network1 = TestCyNetworkFactory.getInstance();
CyRootNetwork rootNetwork = ((CySubNetwork) network1).getRootNetwork();
CyNode n1 = network1.addNode();
CyNode n2 = network1.addNode();
CyNode n3 = network1.addNode();
CyNode n4 = network1.addNode();
CyEdge e1 = network1.addEdge(n1, n2, false);
CyEdge e2 = network1.addEdge(n2, n3, false);
CyNetwork network2 = rootNetwork.addSubNetwork(Arrays.asList(n1, n2, n3, n4), Arrays.asList(e1, e2));
// will also cause n2 to be saved because its attached to e1
rootNetwork.addSubNetwork(Arrays.asList(n1), Arrays.asList(e1));
network1.removeEdges(Arrays.asList(e1));
network2.removeEdges(Arrays.asList(e1));
// additional subnetwork keeps e1 alive
assertTrue(rootNetwork.containsEdge(e1));
assertTrue(rootNetwork.containsNode(n1));
assertTrue(rootNetwork.containsNode(n2));
assertTrue(rootNetwork.containsNode(n3));
assertTrue(rootNetwork.containsNode(n4));
assertTrue(rootNetwork.containsEdge(e2));
rootNetwork.removeSubNetwork((CySubNetwork) network1);
rootNetwork.removeSubNetwork((CySubNetwork) network2);
// should flush nodes/edges not in the additional subnetwork
assertTrue(rootNetwork.containsEdge(e1));
assertTrue(rootNetwork.containsNode(n1));
assertTrue(rootNetwork.containsNode(n2));
assertFalse(rootNetwork.containsNode(n3));
assertFalse(rootNetwork.containsNode(n4));
assertFalse(rootNetwork.containsEdge(e2));
}
Aggregations