Search in sources :

Example 21 with View

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);
    }
}
Also used : DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager) View(org.cytoscape.view.model.View) CyNetworkView(org.cytoscape.view.model.CyNetworkView) VizMapperProxy(org.cytoscape.view.vizmap.gui.internal.model.VizMapperProxy) RemoveLockedValuesTask(org.cytoscape.view.vizmap.gui.internal.task.RemoveLockedValuesTask) TaskIterator(org.cytoscape.work.TaskIterator) LockedValuesVO(org.cytoscape.view.vizmap.gui.internal.model.LockedValuesVO) VisualProperty(org.cytoscape.view.model.VisualProperty) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyIdentifiable(org.cytoscape.model.CyIdentifiable) HashSet(java.util.HashSet)

Example 22 with View

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);
    }
}
Also used : SetLockedValuesTask(org.cytoscape.view.vizmap.gui.internal.task.SetLockedValuesTask) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager) View(org.cytoscape.view.model.View) CyNetworkView(org.cytoscape.view.model.CyNetworkView) VizMapperProxy(org.cytoscape.view.vizmap.gui.internal.model.VizMapperProxy) TaskIterator(org.cytoscape.work.TaskIterator) LockedValuesVO(org.cytoscape.view.vizmap.gui.internal.model.LockedValuesVO) VisualProperty(org.cytoscape.view.model.VisualProperty) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyIdentifiable(org.cytoscape.model.CyIdentifiable) HashSet(java.util.HashSet)

Example 23 with View

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, ""));
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) CyNode(org.cytoscape.model.CyNode) NetworkViewTestSupport(org.cytoscape.ding.NetworkViewTestSupport) CyEdge(org.cytoscape.model.CyEdge) CyNetworkView(org.cytoscape.view.model.CyNetworkView) View(org.cytoscape.view.model.View) CyNetworkView(org.cytoscape.view.model.CyNetworkView) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 24 with View

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();
    }
}
Also used : CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyNetworkView(org.cytoscape.view.model.CyNetworkView) View(org.cytoscape.view.model.View)

Example 25 with View

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);
            }
        }
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) CyColumnIdentifier(org.cytoscape.view.presentation.property.values.CyColumnIdentifier) View(org.cytoscape.view.model.View) CyNetworkView(org.cytoscape.view.model.CyNetworkView) MappableVisualPropertyValue(org.cytoscape.view.presentation.property.values.MappableVisualPropertyValue) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Aggregations

CyNetworkView (org.cytoscape.view.model.CyNetworkView)35 View (org.cytoscape.view.model.View)35 CyNode (org.cytoscape.model.CyNode)24 CyEdge (org.cytoscape.model.CyEdge)17 CyNetwork (org.cytoscape.model.CyNetwork)15 ArrayList (java.util.ArrayList)12 HashSet (java.util.HashSet)11 VisualProperty (org.cytoscape.view.model.VisualProperty)8 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)8 List (java.util.List)7 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)6 HashMap (java.util.HashMap)5 Set (java.util.Set)5 CyEventHelper (org.cytoscape.event.CyEventHelper)5 BasicVisualLexicon (org.cytoscape.view.presentation.property.BasicVisualLexicon)5 Paint (java.awt.Paint)4 CyApplicationManager (org.cytoscape.application.CyApplicationManager)4 CyIdentifiable (org.cytoscape.model.CyIdentifiable)4 VisualLexicon (org.cytoscape.view.model.VisualLexicon)4 Collectors (java.util.stream.Collectors)3