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;
}
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;
}
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);
}
}
}
}
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;
}
Aggregations