use of org.cytoscape.group.data.Aggregator in project cytoscape-impl by cytoscape.
the class CyGroupSettingsTask method run.
// Our "Task" is to read the information from our settings sub-objects
// and set the context object
public void run(TaskMonitor taskMonitor) {
// Update view settings
settings.setDoubleClickAction(group, viewSettings.getDoubleClickAction());
settings.setUseNestedNetworks(group, viewSettings.useNestedNetworks());
settings.setGroupViewType(group, viewSettings.getGroupViewType());
// settings.setGroupNodeOpacity(group, viewSettings.getGroupNodeOpacity());
// Update aggregation settings (more complicated)
boolean enabled = aggregationSettings.getAttributeAggregationEnabled();
settings.setEnableAttributeAggregation(group, enabled);
if (!enabled)
return;
// Get the default values for each class we've registered
for (Class<?> c : cyAggManager.getSupportedClasses()) {
Aggregator<?> a = aggregationSettings.getDefaultAggregator(c);
if (group != null)
settings.setDefaultAggregation(group, c, a);
else
settings.setDefaultAggregation(c, a);
}
for (Class<?> c : cyAggManager.getSupportedListClasses()) {
Aggregator<?> a = aggregationSettings.getDefaultListAggregator(c);
if (group != null)
settings.setDefaultListAggregation(group, c, a);
else
settings.setDefaultListAggregation(c, a);
}
// Get any overrides
Map<CyColumn, Aggregator<?>> overrides = aggregationSettings.getOverrideMap();
for (CyColumn column : overrides.keySet()) {
if (group != null)
settings.setOverrideAggregation(group, column, overrides.get(column));
else
settings.setOverrideAggregation(column, overrides.get(column));
}
}
use of org.cytoscape.group.data.Aggregator in project cytoscape-impl by cytoscape.
the class CyGroupSettingsImpl method handleEvent.
// Update all of our maps when we add a new group
public void handleEvent(GroupAddedEvent e) {
CyGroup addedGroup = e.getGroup();
Map<Class<?>, Aggregator<?>> defMap = new HashMap<>();
Map<Class<?>, Aggregator<?>> defListMap = new HashMap<>();
CyNetwork network = appMgr.getCurrentNetwork();
if (network == null || !addedGroup.isInNetwork(network)) {
for (CyNetwork net : addedGroup.getNetworkSet()) {
network = net;
break;
}
}
synchronized (lock) {
for (Class<?> cKey : allGroupDefaultMap.keySet()) defMap.put(cKey, allGroupDefaultMap.get(cKey));
for (Class<?> cKey : allGroupListDefaultMap.keySet()) defListMap.put(cKey, allGroupListDefaultMap.get(cKey));
Map<CyColumn, Aggregator<?>> ovMap = new HashMap<CyColumn, Aggregator<?>>();
for (CyColumn cKey : allGroupOverrideMap.keySet()) ovMap.put(cKey, allGroupOverrideMap.get(cKey));
groupMap.put(addedGroup, new GroupSpecificMaps(defMap, defListMap, ovMap));
}
// Now override these with any settings from the table
// Flag to indicate that we don't want to trigger visualization changes
loadingNewGroup = true;
try {
loadSettingsFromTable(addedGroup, network);
} catch (Exception ex) {
ex.printStackTrace();
}
loadingNewGroup = false;
}
use of org.cytoscape.group.data.Aggregator in project cytoscape-impl by cytoscape.
the class CyGroupSettingsImpl method updateSettingsInTable.
/**
*************************************************************************
* Group-specific settings serialization/deserialization *
*************************************************************************
*/
/**
* Update the settings for a specific group
*/
public void updateSettingsInTable(CyGroup group) {
CyNetwork network = appMgr.getCurrentNetwork();
if (network == null || !group.isInNetwork(network)) {
for (CyNetwork net : group.getNetworkSet()) {
network = net;
break;
}
}
List<String> viewSettings = new ArrayList<>();
// Update all of our view settings as a list
createColumnIfNeeded(network, group.getGroupNode(), VIEW_SETTINGS, List.class, String.class);
addViewSetting(viewSettings, DOUBLE_CLICK_ACTION, getDoubleClickAction(group).toString());
addViewSetting(viewSettings, USE_NESTED_NETWORKS, "" + getUseNestedNetworks(group));
addViewSetting(viewSettings, GROUP_VIEW_TYPE, "" + getGroupViewType(group));
addViewSetting(viewSettings, GROUP_NODE_OPACITY, "" + getGroupNodeOpacity(group));
// currentNetwork.getRow(group.getGroupNode(), CyNetwork.HIDDEN_ATTRS).set(VIEW_SETTINGS, viewSettings);
network.getRow(group.getGroupNode()).set(VIEW_SETTINGS, viewSettings);
// Update default aggregations
createColumnIfNeeded(network, group.getGroupNode(), AGGREGATION_SETTINGS, List.class, String.class);
List<String> aggrSettings = new ArrayList<>();
aggrSettings.add(AGG_ENABLED + "=" + getEnableAttributeAggregation(group));
addAggregationSetting(group, DEFAULT_INT_AGGREGATION, Integer.class, null, aggrSettings);
addAggregationSetting(group, DEFAULT_LONG_AGGREGATION, Long.class, null, aggrSettings);
addAggregationSetting(group, DEFAULT_DOUBLE_AGGREGATION, Double.class, null, aggrSettings);
addAggregationSetting(group, DEFAULT_STRING_AGGREGATION, String.class, null, aggrSettings);
addAggregationSetting(group, DEFAULT_BOOLEAN_AGGREGATION, Boolean.class, null, aggrSettings);
addAggregationSetting(group, DEFAULT_STRING_LIST_AGGREGATION, List.class, String.class, aggrSettings);
addAggregationSetting(group, DEFAULT_INTEGER_LIST_AGGREGATION, List.class, Integer.class, aggrSettings);
addAggregationSetting(group, DEFAULT_LONG_LIST_AGGREGATION, List.class, Long.class, aggrSettings);
addAggregationSetting(group, DEFAULT_DOUBLE_LIST_AGGREGATION, List.class, Double.class, aggrSettings);
// currentNetwork.getRow(group.getGroupNode(), CyNetwork.HIDDEN_ATTRS).set(AGGREGATION_SETTINGS, aggrSettings);
network.getRow(group.getGroupNode()).set(AGGREGATION_SETTINGS, aggrSettings);
if (groupMap.containsKey(group)) {
// Update overrides
createColumnIfNeeded(network, group.getGroupNode(), AGGREGATION_OVERRIDE_SETTINGS, List.class, String.class);
List<String> aggrOverrideSettings = new ArrayList<>();
GroupSpecificMaps gsm = groupMap.get(group);
Map<CyColumn, Aggregator<?>> overrides = groupMap.get(group).getOverrides();
if (overrides == null || overrides.size() == 0)
return;
for (CyColumn column : overrides.keySet()) {
aggrOverrideSettings.add(column.getName() + "=" + overrides.get(column).toString());
}
// currentNetwork.getRow(group.getGroupNode(), CyNetwork.HIDDEN_ATTRS).set(AGGREGATION_OVERRIDE_SETTINGS, aggrOverrideSettings);
network.getRow(group.getGroupNode()).set(AGGREGATION_OVERRIDE_SETTINGS, aggrOverrideSettings);
}
}
Aggregations