Search in sources :

Example 1 with MappingFunctionFactoryManager

use of org.cytoscape.view.vizmap.gui.MappingFunctionFactoryManager in project cytoscape-impl by cytoscape.

the class MappingFunctionFactoryProxy method getMappingFactories.

public Set<VisualMappingFunctionFactory> getMappingFactories() {
    final SortedSet<VisualMappingFunctionFactory> set = new TreeSet<VisualMappingFunctionFactory>(new Comparator<VisualMappingFunctionFactory>() {

        @Override
        public int compare(final VisualMappingFunctionFactory f1, final VisualMappingFunctionFactory f2) {
            // Locale-specific sorting
            final Collator collator = Collator.getInstance(Locale.getDefault());
            collator.setStrength(Collator.PRIMARY);
            return collator.compare(f1.toString(), f2.toString());
        }
    });
    final MappingFunctionFactoryManager mappingFactoryMgr = servicesUtil.get(MappingFunctionFactoryManager.class);
    set.addAll(mappingFactoryMgr.getFactories());
    if (currentColumnName != null && currentTargetDataType != null) {
        // Remove the factories that don't make sense for the current column type
        final CyApplicationManager appMgr = servicesUtil.get(CyApplicationManager.class);
        final CyNetwork net = appMgr.getCurrentNetwork();
        if (net != null) {
            final CyTable table = net.getTable(currentTargetDataType, CyNetwork.DEFAULT_ATTRS);
            final CyColumn column = table.getColumn(currentColumnName);
            if (column != null && !Number.class.isAssignableFrom(column.getType()))
                set.remove(mappingFactoryMgr.getFactory(ContinuousMapping.class));
        }
    }
    return set;
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyTable(org.cytoscape.model.CyTable) MappingFunctionFactoryManager(org.cytoscape.view.vizmap.gui.MappingFunctionFactoryManager) VisualMappingFunctionFactory(org.cytoscape.view.vizmap.VisualMappingFunctionFactory) TreeSet(java.util.TreeSet) CyColumn(org.cytoscape.model.CyColumn) CyNetwork(org.cytoscape.model.CyNetwork) Collator(java.text.Collator)

Aggregations

Collator (java.text.Collator)1 TreeSet (java.util.TreeSet)1 CyApplicationManager (org.cytoscape.application.CyApplicationManager)1 CyColumn (org.cytoscape.model.CyColumn)1 CyNetwork (org.cytoscape.model.CyNetwork)1 CyTable (org.cytoscape.model.CyTable)1 VisualMappingFunctionFactory (org.cytoscape.view.vizmap.VisualMappingFunctionFactory)1 MappingFunctionFactoryManager (org.cytoscape.view.vizmap.gui.MappingFunctionFactoryManager)1