use of org.cytoscape.work.util.ListSingleSelection in project cytoscape-impl by cytoscape.
the class CyGroupAggregationSettings method getAttrType.
@Tunable(description = "Attribute Type:", groups = { "Attribute Aggregation Settings", "Aggregation Overrides" }, dependsOn = "enableAttributeAggregation=true", listenForChange = { "AttrSelection" }, gravity = 21.0)
public String getAttrType() {
if (currentNetwork == null || attrSelection == null || attrSelection.getSelectedValue() == null || attrSelection.getSelectedValue().length() == 0) {
if (aggregationType != null)
aggregationType.setPossibleValues(cyAggManager.getAggregators(NoneAggregator.class));
else
aggregationType = new ListSingleSelection<Aggregator<?>>(cyAggManager.getAggregators(NoneAggregator.class));
return "-- No Network --";
}
// Get the attribute from the selection
String columnName = attrSelection.getSelectedValue();
CyTable nodeTable = currentNetwork.getDefaultNodeTable();
CyColumn column = nodeTable.getColumn(columnName);
if (column == null)
return "-- No Such Column -- ";
if (aggregationType != null) {
if (column.getType().equals(List.class))
aggregationType.setPossibleValues(cyAggManager.getListAggregators(column.getListElementType()));
else
aggregationType.setPossibleValues(cyAggManager.getAggregators(column.getType()));
} else {
if (column.getType().equals(List.class))
aggregationType = new ListSingleSelection<Aggregator<?>>(cyAggManager.getListAggregators(column.getListElementType()));
else
aggregationType = new ListSingleSelection<Aggregator<?>>(cyAggManager.getAggregators(column.getType()));
}
// if (aggregationType.getSelectedValue() == null) {
if (group == null) {
Aggregator<?> type = settings.getOverrideAggregation(column);
if (type != null)
aggregationType.setSelectedValue(type);
} else {
Aggregator<?> type = settings.getOverrideAggregation(group, column);
if (type != null)
aggregationType.setSelectedValue(type);
}
// }
// Get it's type
String t = column.getType().getSimpleName();
if (column.getType().equals(List.class))
t += " of " + column.getListElementType().getSimpleName() + "s";
return t;
}
use of org.cytoscape.work.util.ListSingleSelection in project cytoscape-impl by cytoscape.
the class FilterIO method applyParameter.
@SuppressWarnings({ "unchecked", "rawtypes" })
private static void applyParameter(String name, Object value, Transformer<?, ?> transformer, Map<String, PropertyInfo> properties) {
PropertyInfo info = properties.get(name);
if (info == null) {
return;
}
if (value == null) {
info.set(transformer, value);
return;
}
Class<?> targetType = info.type;
Class<?> sourceType = value.getClass();
if (targetType == ListSingleSelection.class) {
ListSingleSelection list = (ListSingleSelection) info.get(transformer);
if (list != null) {
list.setSelectedValue(value);
}
} else if (targetType == ListMultipleSelection.class && value instanceof List) {
ListMultipleSelection list = (ListMultipleSelection) info.get(transformer);
if (list != null) {
list.setSelectedValues((List) value);
}
} else {
Object convertedValue = convertValue(name, value, sourceType, targetType);
info.set(transformer, convertedValue);
}
}
use of org.cytoscape.work.util.ListSingleSelection in project clusterMaker2 by RBVI.
the class HairCutContext method setNetwork.
public void setNetwork(CyNetwork network) {
if (this.network != null && this.network.equals(network))
// Nothing to see here....
return;
this.network = network;
List<String> integerColumns = super.getClusterAttributeList(network);
if (integerColumns != null) {
clusterAttribute = new ListSingleSelection(integerColumns);
String defaultAttribute = super.getDefaultAttribute(network);
if (integerColumns.contains(defaultAttribute))
clusterAttribute.setSelectedValue(defaultAttribute);
}
}
use of org.cytoscape.work.util.ListSingleSelection in project cytoscape-api by cytoscape.
the class AbstractCyNetworkReader method init.
private void init() {
name2RootMap = getRootNetworkMap();
nodeMap = new HashMap<>(10000);
// initialize the network Collection
final List<String> rootNames = new ArrayList<>();
rootNames.addAll(name2RootMap.keySet());
if (!rootNames.isEmpty()) {
sort(rootNames);
rootNames.add(0, CREATE_NEW_COLLECTION_STRING);
}
final ListSingleSelection<String> rootNetList = new ListSingleSelection<>(rootNames);
final CyNetwork net = cyApplicationManager != null ? cyApplicationManager.getCurrentNetwork() : null;
final CyRootNetwork rootNet = net != null ? cyRootNetworkManager.getRootNetwork(net) : null;
final String name = rootNet != null ? rootNet.getRow(rootNet).get(CyRootNetwork.NAME, String.class) : CREATE_NEW_COLLECTION_STRING;
if (rootNames.contains(name))
rootNetList.setSelectedValue(name);
else if (rootNames.contains(CREATE_NEW_COLLECTION_STRING))
rootNetList.setSelectedValue(CREATE_NEW_COLLECTION_STRING);
setRootNetworkList(rootNetList);
// initialize renderer list
final List<NetworkViewRenderer> renderers = new ArrayList<>();
NetworkViewRenderer defViewRenderer = null;
if (cyApplicationManager != null) {
final Set<NetworkViewRenderer> rendererSet = cyApplicationManager.getNetworkViewRendererSet();
// so the combo-box does not appear to the user, since there is nothing to select anyway.
if (rendererSet.size() > 1) {
renderers.addAll(rendererSet);
Collections.sort(renderers, new Comparator<NetworkViewRenderer>() {
@Override
public int compare(NetworkViewRenderer r1, NetworkViewRenderer r2) {
return r1.toString().compareToIgnoreCase(r2.toString());
}
});
}
defViewRenderer = cyApplicationManager.getDefaultNetworkViewRenderer();
}
rendererList = new ListSingleSelection<>(renderers);
if (defViewRenderer != null && renderers.contains(defViewRenderer))
rendererList.setSelectedValue(defViewRenderer);
}
Aggregations