Search in sources :

Example 6 with CompositeFilter

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

the class TopoFilterPanel method buildCMBmodel.

private void buildCMBmodel() {
    // Create an empty filter, add to the top of the filter list in the combobox
    CompositeFilter emptyFilter = new CompositeFilter("None");
    Vector<CompositeFilter> tmpVect = new Vector<CompositeFilter>();
    tmpVect.add(emptyFilter);
    Vector<CompositeFilter> allFilters = modelLocator.getFilters();
    tmpVect.addAll(allFilters);
    PassFilterWidestStringComboBoxModel pfwscbm = new PassFilterWidestStringComboBoxModel(tmpVect);
    cmbPassFilter.setModel(pfwscbm);
    if (theFilter.getPassFilter() != null) {
        cmbPassFilter.setSelectedIndex(0);
        cmbPassFilter.setSelectedItem(theFilter.getPassFilter());
    }
}
Also used : CompositeFilter(org.cytoscape.filter.internal.filters.model.CompositeFilter) Vector(java.util.Vector)

Example 7 with CompositeFilter

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

the class FilterSettingPanel method updateNegationStatus.

// user Clicked CheckBox_Not left-side of the child filter
private void updateNegationStatus(JCheckBox _chk) {
    int widgetGridY = (new Integer(_chk.getName())).intValue();
    int childIndex = widgetGridY / 2;
    CyFilter childFilter = theFilter.getChildren().get(childIndex);
    if (childFilter instanceof CompositeFilter) {
        CompositeFilter tmpFilter = (CompositeFilter) childFilter;
        theFilter.setNotTable(tmpFilter, new Boolean(_chk.isSelected()));
    } else {
        // it is an AtomiCFilter
        childFilter.setNegation(_chk.isSelected());
    }
    // Update the selection on screen
    doSelection();
}
Also used : CyFilter(org.cytoscape.filter.internal.filters.model.CyFilter) CompositeFilter(org.cytoscape.filter.internal.filters.model.CompositeFilter)

Example 8 with CompositeFilter

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

the class FilterSettingPanel method updateSelectionType.

private void updateSelectionType() {
    boolean selectNode = false;
    boolean selectEdge = false;
    List<CyFilter> childFilters = theFilter.getChildren();
    for (int i = 0; i < childFilters.size(); i++) {
        CyFilter child = childFilters.get(i);
        if (child instanceof AtomicFilter) {
            AtomicFilter tmp = (AtomicFilter) child;
            if (tmp.getIndexType() == QuickFind.INDEX_NODES) {
                selectNode = true;
            }
            if (tmp.getIndexType() == QuickFind.INDEX_EDGES) {
                selectEdge = true;
            }
        } else if (child instanceof CompositeFilter) {
            CompositeFilter tmp = (CompositeFilter) child;
            if (tmp.getAdvancedSetting().isNodeChecked()) {
                selectNode = true;
            }
            if (tmp.getAdvancedSetting().isEdgeChecked()) {
                selectEdge = true;
            }
        }
    }
    // end of for loop
    theFilter.getAdvancedSetting().setNode(selectNode);
    theFilter.getAdvancedSetting().setEdge(selectEdge);
}
Also used : CyFilter(org.cytoscape.filter.internal.filters.model.CyFilter) CompositeFilter(org.cytoscape.filter.internal.filters.model.CompositeFilter) AtomicFilter(org.cytoscape.filter.internal.filters.model.AtomicFilter)

Example 9 with CompositeFilter

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

the class FilterApp method loadDefaultFilters.

private Collection<CompositeFilter> loadDefaultFilters() {
    Collection<CompositeFilter> filters = null;
    InputStream is = null;
    try {
        // Load global filters from CyProperty.DEFAULT_PROPS_CONFIG_DIR  directory.
        final File file = getGlobalFilterFile();
        if (file.exists()) {
            try {
                is = new FileInputStream(file);
            } catch (Exception e) {
                logger.error("Cannot load default filter from config directory.", e);
            }
        }
        // If there is no global filters, load a default one
        if (is == null) {
            // note: "/" works for both Mac and Windows, File.separator does not work on Windows
            String fileName = "/" + FilterUtil.DEFAULT_FILE_NAME;
            try {
                is = getClass().getResourceAsStream(fileName);
            } catch (Exception e) {
                logger.error("Cannot load default filters from jar.", e);
            }
        }
        if (is != null)
            filters = reader.read(is);
        else
            logger.warn("could not find resource: " + file.getAbsolutePath());
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException ioe) {
            }
            is = null;
        }
    }
    return filters;
}
Also used : CompositeFilter(org.cytoscape.filter.internal.filters.model.CompositeFilter) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException)

Example 10 with CompositeFilter

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

the class FilterApp method saveGlobalFilters.

private void saveGlobalFilters() {
    // Get current global filters
    Set<CompositeFilter> globalFilters = new LinkedHashSet<CompositeFilter>();
    for (CompositeFilter cf : modelLocator.getFilters()) {
        if (cf.getAdvancedSetting().isGlobalChecked())
            globalFilters.add(cf);
    }
    // Save global filters in the CyProperty.DEFAULT_PROPS_CONFIG_DIR  directory
    final File file = getGlobalFilterFile();
    writer.saveGlobalPropFile(globalFilters, file);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CompositeFilter(org.cytoscape.filter.internal.filters.model.CompositeFilter) File(java.io.File)

Aggregations

CompositeFilter (org.cytoscape.filter.internal.filters.model.CompositeFilter)25 ArrayList (java.util.ArrayList)5 File (java.io.File)4 IOException (java.io.IOException)4 LinkedHashSet (java.util.LinkedHashSet)4 Vector (java.util.Vector)3 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)3 EdgeInteractionFilter (org.cytoscape.filter.internal.filters.model.EdgeInteractionFilter)3 NodeInteractionFilter (org.cytoscape.filter.internal.filters.model.NodeInteractionFilter)3 TopologyFilter (org.cytoscape.filter.internal.filters.model.TopologyFilter)3 CyNetwork (org.cytoscape.model.CyNetwork)3 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 InputStream (java.io.InputStream)2 AdvancedSetting (org.cytoscape.filter.internal.filters.model.AdvancedSetting)2 AtomicFilter (org.cytoscape.filter.internal.filters.model.AtomicFilter)2 CyFilter (org.cytoscape.filter.internal.filters.model.CyFilter)2 InteractionFilter (org.cytoscape.filter.internal.filters.model.InteractionFilter)2 BufferedReader (java.io.BufferedReader)1 BufferedWriter (java.io.BufferedWriter)1