Search in sources :

Example 76 with VisualStyle

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));
}
Also used : VisualMappingFunction(org.cytoscape.view.vizmap.VisualMappingFunction) VisualPropertySheet(org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheet) VizMapGUI(org.cytoscape.view.vizmap.gui.VizMapGUI) TaskIterator(org.cytoscape.work.TaskIterator) VizMapperMainPanel(org.cytoscape.view.vizmap.gui.internal.view.VizMapperMainPanel) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) VisualPropertySheetItem(org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheetItem) HashSet(java.util.HashSet)

Example 77 with VisualStyle

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);
}
Also used : VizMapperProxy(org.cytoscape.view.vizmap.gui.internal.model.VizMapperProxy) Set(java.util.Set) TaskIterator(org.cytoscape.work.TaskIterator) VisualMappingFunction(org.cytoscape.view.vizmap.VisualMappingFunction) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) RemoveVisualMappingsTask(org.cytoscape.view.vizmap.gui.internal.task.RemoveVisualMappingsTask) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager)

Example 78 with VisualStyle

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;
}
Also used : BasicVisualLexicon(org.cytoscape.view.presentation.property.BasicVisualLexicon) VisualLexicon(org.cytoscape.view.model.VisualLexicon) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager) CyNetwork(org.cytoscape.model.CyNetwork) CyApplicationManager(org.cytoscape.application.CyApplicationManager) MappableVisualPropertyValue(org.cytoscape.view.presentation.property.values.MappableVisualPropertyValue) VisualProperty(org.cytoscape.view.model.VisualProperty) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 79 with VisualStyle

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);
        }
    }
}
Also used : CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) RowSetRecord(org.cytoscape.model.events.RowSetRecord) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) CyNetwork(org.cytoscape.model.CyNetwork) CyTable(org.cytoscape.model.CyTable) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) CyNetworkView(org.cytoscape.view.model.CyNetworkView) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 80 with VisualStyle

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());
        }
    });
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) Mode(org.cytoscape.internal.view.GridViewToggleModel.Mode) CyNetwork(org.cytoscape.model.CyNetwork) ThumbnailPanel(org.cytoscape.internal.view.NetworkViewGrid.ThumbnailPanel) Collection(java.util.Collection) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) Component(java.awt.Component) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Aggregations

VisualStyle (org.cytoscape.view.vizmap.VisualStyle)100 CyNetworkView (org.cytoscape.view.model.CyNetworkView)42 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)37 CyNetwork (org.cytoscape.model.CyNetwork)35 CyNode (org.cytoscape.model.CyNode)30 CyEdge (org.cytoscape.model.CyEdge)24 CyEventHelper (org.cytoscape.event.CyEventHelper)14 HashSet (java.util.HashSet)13 VisualProperty (org.cytoscape.view.model.VisualProperty)12 DiscreteMapping (org.cytoscape.view.vizmap.mappings.DiscreteMapping)12 Paint (java.awt.Paint)11 HashMap (java.util.HashMap)11 CyApplicationManager (org.cytoscape.application.CyApplicationManager)11 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)11 Color (java.awt.Color)10 ArrayList (java.util.ArrayList)10 RenderingEngineManager (org.cytoscape.view.presentation.RenderingEngineManager)9 BasicVisualLexicon (org.cytoscape.view.presentation.property.BasicVisualLexicon)9 ContinuousMapping (org.cytoscape.view.vizmap.mappings.ContinuousMapping)9 View (org.cytoscape.view.model.View)8