use of org.cytoscape.internal.view.NetworkViewGrid.ThumbnailPanel in project cytoscape-impl by cytoscape.
the class NetworkViewMainPanel method createNetworkViewGrid.
private NetworkViewGrid createNetworkViewGrid() {
final NetworkViewGrid nvg = new NetworkViewGrid(gridViewToggleModel, viewComparator, serviceRegistrar);
nvg.getDetachSelectedViewsButton().addActionListener(evt -> {
final List<ThumbnailPanel> selectedItems = networkViewGrid.getSelectedItems();
if (selectedItems != null) {
// Get the current view first
final CyNetworkView currentView = getCurrentNetworkView();
// Detach the views
for (ThumbnailPanel tp : selectedItems) {
if (getNetworkViewCard(tp.getNetworkView()) != null)
detachNetworkView(tp.getNetworkView());
}
// Set the original current view by bringing its frame to front, if it is detached
final NetworkViewFrame frame = getNetworkViewFrame(currentView);
if (frame != null)
frame.toFront();
}
});
nvg.getReattachAllViewsButton().addActionListener(evt -> {
final Collection<NetworkViewFrame> allFrames = new ArrayList<>(viewFrames.values());
for (NetworkViewFrame f : allFrames) reattachNetworkView(f.getNetworkView());
});
nvg.getDestroySelectedViewsButton().addActionListener(evt -> {
final List<CyNetworkView> selectedViews = getSelectedNetworkViews();
if (selectedViews != null && !selectedViews.isEmpty()) {
final DialogTaskManager taskMgr = serviceRegistrar.getService(DialogTaskManager.class);
final DestroyNetworkViewTaskFactory taskFactory = serviceRegistrar.getService(DestroyNetworkViewTaskFactory.class);
taskMgr.execute(taskFactory.createTaskIterator(selectedViews));
}
});
return nvg;
}
use of org.cytoscape.internal.view.NetworkViewGrid.ThumbnailPanel in project cytoscape-impl by cytoscape.
the class NetworkViewMediator method initComponents.
@SuppressWarnings("unchecked")
private void initComponents() {
final NetworkViewMainPanel viewMainPanel = getNetworkViewMainPanel();
final NetworkViewGrid vg = viewMainPanel.getNetworkViewGrid();
gridViewToggleModel.addPropertyChangeListener("mode", (PropertyChangeEvent e) -> {
final Mode mode = (Mode) e.getNewValue();
if (mode == Mode.GRID) {
final Component currentCard = viewMainPanel.getCurrentCard();
if (currentCard instanceof NetworkViewComparisonPanel)
viewMainPanel.endComparison((NetworkViewComparisonPanel) currentCard);
viewMainPanel.showGrid(true);
vg.requestFocusInWindow();
} else if (mode == Mode.VIEW) {
final Set<CyNetworkView> selectedViews = new LinkedHashSet<>(viewMainPanel.getSelectedNetworkViews());
if (selectedViews.size() > 1) {
viewMainPanel.showComparisonPanel(selectedViews);
} else {
final CyNetworkView currentView = vg.getCurrentNetworkView();
NetworkViewContainer viewContainer = null;
if (currentView != null) {
viewContainer = viewMainPanel.showViewContainer(currentView);
if (viewContainer != null) {
viewMainPanel.setCurrentNetworkView(viewContainer.getNetworkView());
viewContainer.getContentPane().requestFocusInWindow();
}
} else {
final CyNetwork currentNet = networkMediator.getCurrentNetwork();
viewMainPanel.showNullViewContainer(currentNet);
}
}
}
});
vg.addPropertyChangeListener("currentNetworkView", (PropertyChangeEvent e) -> {
final CyNetworkView targetView = (CyNetworkView) e.getNewValue();
final CyNetworkViewManager netViewMgr = serviceRegistrar.getService(CyNetworkViewManager.class);
if (targetView != null) {
if (netViewMgr.getNetworkViewSet().contains(targetView)) {
if (viewUpdateRequired.contains(targetView)) {
viewUpdateRequired.remove(targetView);
final VisualMappingManager vmm = serviceRegistrar.getService(VisualMappingManager.class);
final VisualStyle style = vmm.getVisualStyle(targetView);
style.apply(targetView);
targetView.updateView();
}
}
}
});
vg.addPropertyChangeListener("thumbnailPanels", (PropertyChangeEvent e) -> {
final Collection<ThumbnailPanel> thumbnails = (Collection<ThumbnailPanel>) e.getNewValue();
for (ThumbnailPanel tp : thumbnails) {
addMouseListeners(tp, tp, tp.getTitleLabel(), tp.getCurrentLabel(), tp.getImagePanel().getGlassPane());
}
});
}
Aggregations