Search in sources :

Example 1 with TaskMonitorBase

use of org.cytoscape.filter.internal.quickfind.util.TaskMonitorBase in project cytoscape-impl by cytoscape.

the class RangeSelectionListener method handleNetworkModified.

private void handleNetworkModified(final CyNetwork cyNetwork) {
    if (!networkManager.networkExists(cyNetwork.getSUID()))
        return;
    if (cyNetwork.getNodeCount() > 0) {
        // this can happen if an empty network was added
        if (quickFind.getIndex(cyNetwork) == null) {
            // Run Indexer in separate background daemon thread.
            Thread thread = new Thread() {

                public void run() {
                    quickFind.addNetwork(cyNetwork, new TaskMonitorBase());
                }
            };
            thread.start();
        } else // very large networks.
        if (cyNetwork.getNodeCount() < QuickFindApp.REINDEX_THRESHOLD) {
            // Run Indexer in separate background daemon thread.
            Thread thread = new Thread() {

                public void run() {
                    GenericIndex index = quickFind.getIndex(cyNetwork);
                    quickFind.reindexNetwork(cyNetwork, index.getIndexType(), index.getControllingAttribute(), new TaskMonitorBase());
                }
            };
            thread.start();
        }
    }
}
Also used : GenericIndex(org.cytoscape.filter.internal.widgets.autocomplete.index.GenericIndex) TaskMonitorBase(org.cytoscape.filter.internal.quickfind.util.TaskMonitorBase)

Example 2 with TaskMonitorBase

use of org.cytoscape.filter.internal.quickfind.util.TaskMonitorBase in project cytoscape-impl by cytoscape.

the class FilterSettingPanel method createNumberIndex.

private NumberIndex createNumberIndex(NumericFilter pNumericFilter) {
    CyNetwork currentNetwork = applicationManager.getCurrentNetwork();
    if (currentNetwork == null)
        return null;
    int indexType = pNumericFilter.getIndexType();
    quickFind.reindexNetwork(currentNetwork, indexType, pNumericFilter.getControllingAttribute(), new TaskMonitorBase());
    GenericIndex currentIndex = quickFind.getIndex(currentNetwork);
    if (currentIndex == null || !(currentIndex instanceof NumberIndex)) {
        return null;
    }
    return (NumberIndex) currentIndex;
}
Also used : GenericIndex(org.cytoscape.filter.internal.widgets.autocomplete.index.GenericIndex) NumberIndex(org.cytoscape.filter.internal.widgets.autocomplete.index.NumberIndex) CyNetwork(org.cytoscape.model.CyNetwork) TaskMonitorBase(org.cytoscape.filter.internal.quickfind.util.TaskMonitorBase)

Example 3 with TaskMonitorBase

use of org.cytoscape.filter.internal.quickfind.util.TaskMonitorBase in project cytoscape-impl by cytoscape.

the class FilterSettingPanel method getAtomicFilterFromStr.

private AtomicFilter getAtomicFilterFromStr(String pCtrlAttribute, int pIndexType) {
    AtomicFilter retFilter = null;
    // quickFind.addNetwork(cyNetwork, new TaskMonitorBase());
    // index_by_UniqueIdentification = (TextIndex) quickFind.getIndex(cyNetwork);
    CyNetwork cyNetwork = applicationManager.getCurrentNetwork();
    quickFind.reindexNetwork(cyNetwork, pIndexType, pCtrlAttribute, new TaskMonitorBase());
    Class<?> attributeType = null;
    if (pIndexType == QuickFind.INDEX_NODES) {
        if (cyNetwork.getNodeCount() > 0) {
            attributeType = cyNetwork.getDefaultNodeTable().getColumn(pCtrlAttribute).getType();
        }
    } else if (pIndexType == QuickFind.INDEX_EDGES) {
        if (cyNetwork.getEdgeCount() > 0) {
            attributeType = cyNetwork.getDefaultEdgeTable().getColumn(pCtrlAttribute).getType();
        }
    }
    if ((attributeType == Integer.class) || (attributeType == Double.class)) {
        retFilter = new NumericFilter(quickFind);
        retFilter.setControllingAttribute(pCtrlAttribute);
        retFilter.setIndexType(pIndexType);
        // NumberIndex index_by_thisAttr = (NumberIndex) quickFind.getIndex(Cytoscape.getCurrentNetwork());
        retFilter.setIndex(quickFind.getIndex(cyNetwork));
    } else if ((attributeType == String.class || (attributeType == List.class || (attributeType == Boolean.class)))) {
        retFilter = new StringFilter(quickFind);
        retFilter.setControllingAttribute(pCtrlAttribute);
        retFilter.setIndexType(pIndexType);
        // TextIndex index_by_thisAttr = (TextIndex) quickFind.getIndex(Cytoscape.getCurrentNetwork());
        retFilter.setIndex(quickFind.getIndex(cyNetwork));
    } else {
        logger.error("AttributeType is not numeric/string/list/boolean.");
    }
    if (retFilter != null) {
        retFilter.setNetwork(cyNetwork);
    }
    return retFilter;
}
Also used : NumericFilter(org.cytoscape.filter.internal.filters.model.NumericFilter) CyNetwork(org.cytoscape.model.CyNetwork) StringFilter(org.cytoscape.filter.internal.filters.model.StringFilter) AtomicFilter(org.cytoscape.filter.internal.filters.model.AtomicFilter) List(java.util.List) TaskMonitorBase(org.cytoscape.filter.internal.quickfind.util.TaskMonitorBase)

Example 4 with TaskMonitorBase

use of org.cytoscape.filter.internal.quickfind.util.TaskMonitorBase in project cytoscape-impl by cytoscape.

the class FilterSettingPanel method createTextIndex.

private TextIndex createTextIndex(StringFilter pFilter) {
    CyNetwork cyNetwork = applicationManager.getCurrentNetwork();
    quickFind.reindexNetwork(cyNetwork, pFilter.getIndexType(), pFilter.getControllingAttribute(), new TaskMonitorBase());
    return (TextIndex) quickFind.getIndex(cyNetwork);
}
Also used : TextIndex(org.cytoscape.filter.internal.widgets.autocomplete.index.TextIndex) CyNetwork(org.cytoscape.model.CyNetwork) TaskMonitorBase(org.cytoscape.filter.internal.quickfind.util.TaskMonitorBase)

Aggregations

TaskMonitorBase (org.cytoscape.filter.internal.quickfind.util.TaskMonitorBase)4 CyNetwork (org.cytoscape.model.CyNetwork)3 GenericIndex (org.cytoscape.filter.internal.widgets.autocomplete.index.GenericIndex)2 List (java.util.List)1 AtomicFilter (org.cytoscape.filter.internal.filters.model.AtomicFilter)1 NumericFilter (org.cytoscape.filter.internal.filters.model.NumericFilter)1 StringFilter (org.cytoscape.filter.internal.filters.model.StringFilter)1 NumberIndex (org.cytoscape.filter.internal.widgets.autocomplete.index.NumberIndex)1 TextIndex (org.cytoscape.filter.internal.widgets.autocomplete.index.TextIndex)1