Search in sources :

Example 1 with MappableVisualPropertyValue

use of org.cytoscape.view.presentation.property.values.MappableVisualPropertyValue in project cytoscape-impl by cytoscape.

the class RowsSetViewUpdater method isStyleAffected.

/**
 * Check if the columnName is used by any property of the passed Visual Style.
 * @param vs
 * @param columnName
 * @return
 */
private static boolean isStyleAffected(final VisualStyle vs, final String columnName, RenderingEngine<CyNetwork> renderer, CyColumnIdentifierFactory columnIdentifierFactory) {
    boolean result = false;
    if (renderer != null) {
        final CyColumnIdentifier colId = columnIdentifierFactory.createColumnIdentifier(columnName);
        final Set<VisualProperty<?>> properties = renderer.getVisualLexicon().getAllVisualProperties();
        for (final VisualProperty<?> vp : properties) {
            final VisualMappingFunction<?, ?> f = vs.getVisualMappingFunction(vp);
            if (f != null && f.getMappingColumnName().equalsIgnoreCase(columnName)) {
                result = true;
                break;
            }
            final Object defValue = vs.getDefaultValue(vp);
            if (defValue instanceof MappableVisualPropertyValue) {
                final Set<CyColumnIdentifier> mappedColIds = ((MappableVisualPropertyValue) defValue).getMappedColumns();
                if (mappedColIds.contains(colId)) {
                    result = true;
                    break;
                }
            }
        }
    }
    return result;
}
Also used : MappableVisualPropertyValue(org.cytoscape.view.presentation.property.values.MappableVisualPropertyValue) VisualProperty(org.cytoscape.view.model.VisualProperty) CyColumnIdentifier(org.cytoscape.view.presentation.property.values.CyColumnIdentifier)

Example 2 with MappableVisualPropertyValue

use of org.cytoscape.view.presentation.property.values.MappableVisualPropertyValue 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 3 with MappableVisualPropertyValue

use of org.cytoscape.view.presentation.property.values.MappableVisualPropertyValue 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)

Example 4 with MappableVisualPropertyValue

use of org.cytoscape.view.presentation.property.values.MappableVisualPropertyValue in project cytoscape-impl by cytoscape.

the class NetworkViewMediator method reapplyLockedValues.

@SuppressWarnings({ "rawtypes", "unchecked" })
private boolean reapplyLockedValues(final String columnName, final Collection<CyNetworkView> networkViews) {
    boolean result = false;
    final CyColumnIdentifierFactory colIdfFactory = serviceRegistrar.getService(CyColumnIdentifierFactory.class);
    final CyColumnIdentifier colId = colIdfFactory.createColumnIdentifier(columnName);
    final Map<MappedVisualPropertyValueInfo, Set<View<?>>> mvpInfoMap = mappedValuesMap.get(colId);
    if (mvpInfoMap != null) {
        for (final MappedVisualPropertyValueInfo mvpInfo : mvpInfoMap.keySet()) {
            if (networkViews == null || !networkViews.contains(mvpInfo.getNetworkView()))
                continue;
            final MappableVisualPropertyValue value = mvpInfo.getValue();
            final VisualProperty vp = mvpInfo.getVisualProperty();
            final Set<View<?>> viewSet = mvpInfoMap.get(mvpInfo);
            for (final View<?> view : viewSet) {
                if (view.isDirectlyLocked(vp) && value.equals(view.getVisualProperty(vp))) {
                    value.update();
                    view.setLockedValue(vp, value);
                    result = true;
                }
            }
        }
    }
    return result;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) MappableVisualPropertyValue(org.cytoscape.view.presentation.property.values.MappableVisualPropertyValue) CyColumnIdentifierFactory(org.cytoscape.view.presentation.property.values.CyColumnIdentifierFactory) VisualProperty(org.cytoscape.view.model.VisualProperty) CyColumnIdentifier(org.cytoscape.view.presentation.property.values.CyColumnIdentifier) View(org.cytoscape.view.model.View) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Aggregations

MappableVisualPropertyValue (org.cytoscape.view.presentation.property.values.MappableVisualPropertyValue)4 HashSet (java.util.HashSet)3 LinkedHashSet (java.util.LinkedHashSet)3 VisualProperty (org.cytoscape.view.model.VisualProperty)3 CyColumnIdentifier (org.cytoscape.view.presentation.property.values.CyColumnIdentifier)3 Set (java.util.Set)2 CyNetworkView (org.cytoscape.view.model.CyNetworkView)2 View (org.cytoscape.view.model.View)2 CyApplicationManager (org.cytoscape.application.CyApplicationManager)1 CyNetwork (org.cytoscape.model.CyNetwork)1 VisualLexicon (org.cytoscape.view.model.VisualLexicon)1 RenderingEngineManager (org.cytoscape.view.presentation.RenderingEngineManager)1 BasicVisualLexicon (org.cytoscape.view.presentation.property.BasicVisualLexicon)1 CyColumnIdentifierFactory (org.cytoscape.view.presentation.property.values.CyColumnIdentifierFactory)1 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)1 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)1