Search in sources :

Example 1 with EdgeInteractionFilter

use of org.cytoscape.filter.internal.filters.model.EdgeInteractionFilter in project cytoscape-impl by cytoscape.

the class FilterMainPanel method createNewFilter.

private void createNewFilter(String pFilterName, String pFilterType) {
    // Create an empty filter, add it to the current filter list
    CompositeFilter newFilter = null;
    if (pFilterType.equalsIgnoreCase("Topology")) {
        newFilter = new TopologyFilter(applicationManager);
        newFilter.getAdvancedSetting().setEdge(false);
        newFilter.setName(pFilterName);
    } else if (pFilterType.equalsIgnoreCase("NodeInteraction")) {
        newFilter = new NodeInteractionFilter(applicationManager);
        // newFilter.getAdvancedSetting().setEdge(false);
        newFilter.setName(pFilterName);
    } else if (pFilterType.equalsIgnoreCase("EdgeInteraction")) {
        newFilter = new EdgeInteractionFilter(applicationManager);
        // newFilter.getAdvancedSetting().setEdge(false);
        newFilter.setName(pFilterName);
    } else {
        newFilter = new CompositeFilter(pFilterName);
    }
    newFilter.setNetwork(applicationManager.getCurrentNetwork());
    modelLocator.addFilter(newFilter);
    FilterSettingPanel newFilterSettingPanel = new FilterSettingPanel(quickFind, this, newFilter, modelLocator, applicationManager, eventHelper);
    filter2SettingPanelMap.put(newFilter, newFilterSettingPanel);
    if (pFilterType.equalsIgnoreCase("Composite")) {
        updateCMBAttributes();
    }
}
Also used : CompositeFilter(org.cytoscape.filter.internal.filters.model.CompositeFilter) NodeInteractionFilter(org.cytoscape.filter.internal.filters.model.NodeInteractionFilter) EdgeInteractionFilter(org.cytoscape.filter.internal.filters.model.EdgeInteractionFilter) TopologyFilter(org.cytoscape.filter.internal.filters.model.TopologyFilter)

Example 2 with EdgeInteractionFilter

use of org.cytoscape.filter.internal.filters.model.EdgeInteractionFilter in project cytoscape-impl by cytoscape.

the class FilterReader method getFilterFromStrList.

private CompositeFilter getFilterFromStrList(List<String> strList, Collection<CompositeFilter> filters) {
    boolean isTopologyFilter = false;
    boolean isInteractionFilter = false;
    if (strList.get(0).startsWith("<TopologyFilter>")) {
        isTopologyFilter = true;
    }
    if (strList.get(0).startsWith("<InteractionFilter>")) {
        isInteractionFilter = true;
    }
    List<String> advSettingStrVect = new ArrayList<String>();
    List<String> filterStrVect = new ArrayList<String>();
    // Seperate AdvancedSetting from the rest
    int startIndex = -1, endIndex = -1;
    String line = null;
    for (int i = 0; i < strList.size(); i++) {
        line = strList.get(i);
        if (line.startsWith("<AdvancedSetting>")) {
            startIndex = i;
        }
        if (line.startsWith("</AdvancedSetting>")) {
            endIndex = i;
            break;
        }
    }
    advSettingStrVect.addAll(strList.subList(startIndex + 1, endIndex));
    filterStrVect.addAll(strList.subList(1, startIndex));
    filterStrVect.addAll(strList.subList(endIndex + 1, strList.size()));
    CompositeFilter retFilter = new CompositeFilter(ServicesUtil.cyApplicationManagerServiceRef);
    retFilter.setAdvancedSetting(getAdvancedSettingFromStr(advSettingStrVect));
    if (isTopologyFilter) {
        retFilter = new TopologyFilter(ServicesUtil.cyApplicationManagerServiceRef);
        retFilter.setAdvancedSetting(getAdvancedSettingFromStr(advSettingStrVect));
        getTopologyFilterFromStr((TopologyFilter) retFilter, filterStrVect, filters);
        return retFilter;
    }
    if (isInteractionFilter) {
        AdvancedSetting advSetting = getAdvancedSettingFromStr(advSettingStrVect);
        if (advSetting.isNodeChecked()) {
            retFilter = new NodeInteractionFilter(ServicesUtil.cyApplicationManagerServiceRef);
        } else {
            // advSetting.isEdgeChecked() == true
            retFilter = new EdgeInteractionFilter(ServicesUtil.cyApplicationManagerServiceRef);
        }
        retFilter.setAdvancedSetting(advSetting);
        getInteractionFilterFromStr((InteractionFilter) retFilter, filterStrVect, filters);
        return retFilter;
    }
    Collection<CompositeFilter> allFilters = new LinkedHashSet<CompositeFilter>();
    for (int i = 0; i < filterStrVect.size(); i++) {
        line = filterStrVect.get(i);
        if (line.startsWith("name=")) {
            String name = line.substring(5);
            retFilter.setName(name);
        }
        if (line.startsWith("Negation=true")) {
            retFilter.setNegation(true);
        }
        if (line.startsWith("Negation=false")) {
            retFilter.setNegation(false);
        }
        if (line.startsWith("StringFilter=")) {
            String _stringFilterValue = line.substring(13);
            String[] _values = _stringFilterValue.split(":");
            // controllingAttribute+":" + negation+ ":"+searchStr+":"+index_type;
            StringFilter _strFilter = new StringFilter(quickFind);
            _strFilter.setParent(retFilter);
            _strFilter.setControllingAttribute(_values[0]);
            _strFilter.setNegation((new Boolean(_values[1])).booleanValue());
            // handle the case where ':' is part of the search string
            String _searchStr = _stringFilterValue.substring(_values[0].length() + _values[1].length() + 2, _stringFilterValue.length() - _values[_values.length - 1].length() - 1);
            _strFilter.setSearchStr(_searchStr);
            _strFilter.setIndexType((new Integer(_values[_values.length - 1])).intValue());
            retFilter.addChild(_strFilter);
        }
        if (line.startsWith("NumericFilter=")) {
            String[] _values = line.substring(14).split(":");
            // controllingAttribute + ":" + negation+ ":"+lowBound+":" +
            // highBound+ ":"+index_type;
            // Determine data type of the attribute
            String dataType = "int";
            if (_values[2].indexOf(".") >= 0 || _values[2].indexOf("E") >= 0 || _values[3].indexOf(".") >= 0 || _values[3].indexOf("E") >= 0) {
                dataType = "double";
            }
            if (dataType.equalsIgnoreCase("double")) {
                NumericFilter<Double> _numFilter = new NumericFilter<Double>(quickFind);
                _numFilter.setParent(retFilter);
                _numFilter.setControllingAttribute(_values[0]);
                _numFilter.setNegation((new Boolean(_values[1])).booleanValue());
                _numFilter.setLowBound(Double.valueOf(_values[2]));
                _numFilter.setHighBound(Double.valueOf(_values[3]));
                _numFilter.setIndexType((new Integer(_values[4])).intValue());
                retFilter.addChild(_numFilter);
            } else {
                // dataType = "int"
                NumericFilter<Integer> _numFilter = new NumericFilter<Integer>(quickFind);
                _numFilter.setParent(retFilter);
                _numFilter.setControllingAttribute(_values[0]);
                _numFilter.setNegation((new Boolean(_values[1])).booleanValue());
                _numFilter.setLowBound(Integer.valueOf(_values[2]));
                _numFilter.setHighBound(Integer.valueOf(_values[3]));
                _numFilter.setIndexType((new Integer(_values[4])).intValue());
                retFilter.addChild(_numFilter);
            }
        }
        if (line.startsWith("CompositeFilter=")) {
            // e.g. CompositeFilter=AAA:true
            String[] _values = line.substring(16).split(":");
            String name = _values[0].trim();
            String notValue = _values[1].trim();
            // get the reference CompositeFilter
            CompositeFilter cmpFilter = null;
            for (CompositeFilter cf : allFilters) {
                if (cf.getName().equalsIgnoreCase(name)) {
                    cmpFilter = cf;
                    break;
                }
            }
            if (cmpFilter != null) {
                retFilter.addChild(cmpFilter, (new Boolean(notValue)).booleanValue());
            }
        }
        if (line.startsWith("TopologyFilter=")) {
            // e.g. TopologyFilter=AAA:true
            String[] _values = line.substring(15).split(":");
            String name = _values[0].trim();
            String notValue = _values[1].trim();
            // get the reference TopologyFilter
            TopologyFilter topoFilter = null;
            for (CompositeFilter cf : allFilters) {
                if (cf.getName().equalsIgnoreCase(name)) {
                    topoFilter = (TopologyFilter) cf;
                    break;
                }
            }
            if (topoFilter != null) {
                retFilter.addChild(topoFilter, (new Boolean(notValue)).booleanValue());
            }
        }
        if (line.startsWith("InteractionFilter=")) {
            // e.g. InteractionFilter=AAA:true
            String[] _values = line.substring(15).split(":");
            String name = _values[0].trim();
            String notValue = _values[1].trim();
            // get the reference InteractionFilter
            InteractionFilter interactionFilter = null;
            for (CompositeFilter cf : allFilters) {
                if (cf.getName().equalsIgnoreCase(name)) {
                    interactionFilter = (InteractionFilter) cf;
                    break;
                }
            }
            if (interactionFilter != null) {
                retFilter.addChild(interactionFilter, (new Boolean(notValue)).booleanValue());
            }
        }
    }
    return retFilter;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CompositeFilter(org.cytoscape.filter.internal.filters.model.CompositeFilter) NumericFilter(org.cytoscape.filter.internal.filters.model.NumericFilter) ArrayList(java.util.ArrayList) EdgeInteractionFilter(org.cytoscape.filter.internal.filters.model.EdgeInteractionFilter) AdvancedSetting(org.cytoscape.filter.internal.filters.model.AdvancedSetting) NodeInteractionFilter(org.cytoscape.filter.internal.filters.model.NodeInteractionFilter) InteractionFilter(org.cytoscape.filter.internal.filters.model.InteractionFilter) EdgeInteractionFilter(org.cytoscape.filter.internal.filters.model.EdgeInteractionFilter) NodeInteractionFilter(org.cytoscape.filter.internal.filters.model.NodeInteractionFilter) StringFilter(org.cytoscape.filter.internal.filters.model.StringFilter) TopologyFilter(org.cytoscape.filter.internal.filters.model.TopologyFilter)

Aggregations

CompositeFilter (org.cytoscape.filter.internal.filters.model.CompositeFilter)2 EdgeInteractionFilter (org.cytoscape.filter.internal.filters.model.EdgeInteractionFilter)2 NodeInteractionFilter (org.cytoscape.filter.internal.filters.model.NodeInteractionFilter)2 TopologyFilter (org.cytoscape.filter.internal.filters.model.TopologyFilter)2 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 AdvancedSetting (org.cytoscape.filter.internal.filters.model.AdvancedSetting)1 InteractionFilter (org.cytoscape.filter.internal.filters.model.InteractionFilter)1 NumericFilter (org.cytoscape.filter.internal.filters.model.NumericFilter)1 StringFilter (org.cytoscape.filter.internal.filters.model.StringFilter)1