use of org.cytoscape.view.model.View in project cytoscape-impl by cytoscape.
the class RemoveLockedValuesCommand method execute.
@Override
public void execute(final INotification notification) {
final LockedValuesVO vo = (LockedValuesVO) notification.getBody();
final Set<VisualProperty<?>> visualProperties = vo.getVisualProperties();
if (visualProperties == null)
return;
CyNetworkView netView = vo.getNetworkView();
Set<View<? extends CyIdentifiable>> views = vo.getViews();
final VizMapperProxy vmProxy = (VizMapperProxy) getFacade().retrieveProxy(VizMapperProxy.NAME);
if (netView == null)
netView = vmProxy.getCurrentNetworkView();
if (netView != null && views == null) {
// Get the selected views
final Set<Class<? extends CyIdentifiable>> targetDataTypes = new HashSet<Class<? extends CyIdentifiable>>();
for (final VisualProperty<?> vp : visualProperties) targetDataTypes.add(vp.getTargetDataType());
views = new HashSet<View<? extends CyIdentifiable>>();
if (targetDataTypes.contains(CyNode.class))
views.addAll(vmProxy.getSelectedNodeViews(netView));
if (targetDataTypes.contains(CyEdge.class))
views.addAll(vmProxy.getSelectedEdgeViews(netView));
if (targetDataTypes.contains(CyNetwork.class))
views.add(netView);
}
if (views != null) {
final TaskIterator iterator = new TaskIterator(new RemoveLockedValuesTask(visualProperties, views, netView, servicesUtil));
final DialogTaskManager taskManager = servicesUtil.get(DialogTaskManager.class);
taskManager.execute(iterator);
}
}
use of org.cytoscape.view.model.View in project cytoscape-impl by cytoscape.
the class SetLockedValuesCommand method execute.
@Override
public void execute(final INotification notification) {
final LockedValuesVO vo = (LockedValuesVO) notification.getBody();
final Map<VisualProperty<?>, Object> values = vo.getValues();
if (values == null)
return;
CyNetworkView netView = vo.getNetworkView();
Set<View<? extends CyIdentifiable>> views = vo.getViews();
final VizMapperProxy vmProxy = (VizMapperProxy) getFacade().retrieveProxy(VizMapperProxy.NAME);
if (netView == null)
netView = vmProxy.getCurrentNetworkView();
if (netView != null && views == null) {
// Get the selected views
final Set<Class<? extends CyIdentifiable>> targetDataTypes = new HashSet<Class<? extends CyIdentifiable>>();
for (final VisualProperty<?> vp : values.keySet()) targetDataTypes.add(vp.getTargetDataType());
views = new HashSet<View<? extends CyIdentifiable>>();
if (targetDataTypes.contains(CyNode.class))
views.addAll(vmProxy.getSelectedNodeViews(netView));
if (targetDataTypes.contains(CyEdge.class))
views.addAll(vmProxy.getSelectedEdgeViews(netView));
if (targetDataTypes.contains(CyNetwork.class))
views.add(netView);
}
if (views != null) {
final TaskIterator iterator = new TaskIterator(new SetLockedValuesTask(values, views, netView, servicesUtil));
final DialogTaskManager taskManager = servicesUtil.get(DialogTaskManager.class);
taskManager.execute(iterator);
}
}
use of org.cytoscape.view.model.View in project cytoscape-impl by cytoscape.
the class AbstractLayoutAlgorithmTest method testIsReady.
@Test
public void testIsReady() {
// Create network with two nodes and one edge.
final NetworkViewTestSupport support = new NetworkViewTestSupport();
final CyNetwork network = support.getNetworkFactory().createNetwork();
CyNode source = network.addNode();
CyNode target = network.addNode();
CyEdge edge = network.addEdge(source, target, true);
final CyNetworkView networkView = support.getNetworkViewFactory().createNetworkView(network);
Object layoutContext = layout.createLayoutContext();
Set<View<CyNode>> nodesToLayOut = new HashSet<View<CyNode>>();
nodesToLayOut.add(networkView.getNodeView(source));
nodesToLayOut.add(networkView.getNodeView(target));
assertFalse(layout.isReady(null, null, null, null));
assertFalse(layout.isReady(null, layoutContext, null, ""));
Set<View<CyNode>> emptySet = new HashSet<View<CyNode>>();
CyNetworkView emptyView = support.getNetworkView();
assertFalse(layout.isReady(emptyView, layoutContext, emptySet, "asdf"));
// Valid case
assertTrue(layout.isReady(networkView, layoutContext, nodesToLayOut, ""));
}
use of org.cytoscape.view.model.View in project cytoscape-impl by cytoscape.
the class AbstractControlAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
final CyNetworkView view = appMgr.getCurrentNetworkView();
final List<View<CyNode>> selectedNodeViews = view != null ? Util.findSelectedNodes(view) : null;
if (selectedNodeViews != null && !selectedNodeViews.isEmpty()) {
computeDimensions(selectedNodeViews);
control(selectedNodeViews);
view.updateView();
}
}
use of org.cytoscape.view.model.View in project cytoscape-impl by cytoscape.
the class NetworkViewMediator method handleEvent.
@Override
public void handleEvent(final ViewChangedEvent<?> e) {
final CyNetworkView netView = e.getSource();
// Ask the Views Panel to update the thumbnail for the affected network view
invokeOnEDT(() -> {
if (!getNetworkViewMainPanel().isGridVisible()) {
getNetworkViewMainPanel().update(netView);
}
});
// Look for MappableVisualPropertyValue objects, so they can be saved for future reference
for (final ViewChangeRecord<?> record : e.getPayloadCollection()) {
if (!record.isLockedValue())
continue;
final View<?> view = record.getView();
final Object value = record.getValue();
if (value instanceof MappableVisualPropertyValue) {
final Set<CyColumnIdentifier> columnIds = ((MappableVisualPropertyValue) value).getMappedColumns();
if (columnIds == null)
continue;
final VisualProperty<?> vp = record.getVisualProperty();
for (final CyColumnIdentifier colId : columnIds) {
Map<MappedVisualPropertyValueInfo, Set<View<?>>> mvpInfoMap = mappedValuesMap.get(colId);
if (mvpInfoMap == null)
mappedValuesMap.put(colId, mvpInfoMap = new HashMap<>());
final MappedVisualPropertyValueInfo mvpInfo = new MappedVisualPropertyValueInfo((MappableVisualPropertyValue) value, vp, netView);
Set<View<?>> viewSet = mvpInfoMap.get(mvpInfo);
if (viewSet == null)
mvpInfoMap.put(mvpInfo, viewSet = new HashSet<View<?>>());
viewSet.add(view);
}
}
}
}
Aggregations