use of org.cytoscape.view.vizmap.VisualStyle in project cytoscape-impl by cytoscape.
the class RemoveVisualMappingsTaskFactory method createTaskIterator.
@Override
public TaskIterator createTaskIterator() {
final VisualStyle style = servicesUtil.get(VisualMappingManager.class).getCurrentVisualStyle();
final Set<VisualMappingFunction<?, ?>> mappings = new HashSet<VisualMappingFunction<?, ?>>();
final VizMapGUI gui = servicesUtil.get(VizMapGUI.class);
if (gui instanceof VizMapperMainPanel) {
final VisualPropertySheet vpSheet = ((VizMapperMainPanel) gui).getSelectedVisualPropertySheet();
final Set<VisualPropertySheetItem<?>> selectedItems = vpSheet.getSelectedItems();
for (VisualPropertySheetItem<?> item : selectedItems) {
if (item.getModel().getVisualMappingFunction() != null)
mappings.add(item.getModel().getVisualMappingFunction());
}
}
return new TaskIterator(new RemoveVisualMappingsTask(mappings, style, servicesUtil));
}
use of org.cytoscape.view.vizmap.VisualStyle in project cytoscape-impl by cytoscape.
the class RemoveVisualMappingsCommand method execute.
@Override
@SuppressWarnings("unchecked")
public void execute(final INotification notification) {
final Set<VisualMappingFunction<?, ?>> set = (Set<VisualMappingFunction<?, ?>>) notification.getBody();
final VizMapperProxy proxy = (VizMapperProxy) getFacade().retrieveProxy(VizMapperProxy.NAME);
final VisualStyle style = proxy.getCurrentVisualStyle();
final TaskIterator iterator = new TaskIterator(new RemoveVisualMappingsTask(set, style, servicesUtil));
final DialogTaskManager taskManager = servicesUtil.get(DialogTaskManager.class);
taskManager.execute(iterator);
}
use of org.cytoscape.view.vizmap.VisualStyle in project cytoscape-impl by cytoscape.
the class NetworkViewMediator method findStylesWithMappedColumn.
private Set<VisualStyle> findStylesWithMappedColumn(final String columnName) {
final Set<VisualStyle> styles = new HashSet<>();
if (columnName != null) {
final CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
final RenderingEngineManager engineMgr = serviceRegistrar.getService(RenderingEngineManager.class);
final RenderingEngine<CyNetwork> renderer = appMgr.getCurrentRenderingEngine();
final VisualLexicon lexicon = renderer != null ? renderer.getVisualLexicon() : engineMgr.getDefaultVisualLexicon();
final Set<VisualProperty<?>> properties = lexicon.getAllVisualProperties();
final VisualMappingManager vmm = serviceRegistrar.getService(VisualMappingManager.class);
for (final VisualStyle vs : vmm.getAllVisualStyles()) {
for (final VisualProperty<?> vp : properties) {
// Check VisualMappingFunction
final VisualMappingFunction<?, ?> fn = vs.getVisualMappingFunction(vp);
if (fn != null && fn.getMappingColumnName().equalsIgnoreCase(columnName)) {
styles.add(vs);
break;
}
// Check MappableVisualPropertyValue
final Object defValue = vs.getDefaultValue(vp);
if (defValue instanceof MappableVisualPropertyValue) {
((MappableVisualPropertyValue) defValue).update();
styles.add(vs);
break;
}
}
}
}
return styles;
}
use of org.cytoscape.view.vizmap.VisualStyle in project cytoscape-impl by cytoscape.
the class NetworkViewMediator method handleEvent.
@Override
public void handleEvent(final RowsSetEvent e) {
if (loadingSession || getNetworkViewMainPanel().isEmpty())
return;
final CyTable tbl = e.getSource();
final CyNetworkTableManager netTblMgr = serviceRegistrar.getService(CyNetworkTableManager.class);
final CyNetwork net = netTblMgr.getNetworkForTable(tbl);
final CyNetworkViewManager netViewMgr = serviceRegistrar.getService(CyNetworkViewManager.class);
// And if there is no related view, nothing needs to be done
if (net != null && netViewMgr.viewExists(net)) {
// Update Network View Title
final Collection<RowSetRecord> nameRecords = e.getColumnRecords(CyNetwork.NAME);
if (!nameRecords.isEmpty())
updateNetworkViewTitle(nameRecords, tbl);
if (tbl.equals(net.getDefaultNodeTable()) || tbl.equals(net.getDefaultEdgeTable())) {
final Collection<CyNetworkView> networkViews = netViewMgr.getNetworkViews(net);
// Update node/edge selection info
final Collection<RowSetRecord> selectedRecords = e.getColumnRecords(CyNetwork.SELECTED);
if (!selectedRecords.isEmpty()) {
for (final CyNetworkView view : networkViews) getNetworkViewMainPanel().updateSelectionInfo(view);
}
// Update views with styles affected by this RowsSetEvent
final Set<CyNetworkView> viewsToUpdate = new HashSet<>();
for (String columnName : e.getColumns()) {
// Reapply locked values that map to changed columns
final boolean lockedValuesApplyed = reapplyLockedValues(columnName, networkViews);
if (lockedValuesApplyed)
viewsToUpdate.addAll(networkViews);
// Find views that had their styles affected by the RowsSetEvent
final Set<VisualStyle> styles = findStylesWithMappedColumn(columnName);
viewsToUpdate.addAll(findNetworkViewsWithStyles(styles));
}
// Update views
for (final CyNetworkView view : viewsToUpdate) updateView(view, null);
}
}
}
use of org.cytoscape.view.vizmap.VisualStyle 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