Search in sources :

Example 1 with AtomicFilter

use of org.cytoscape.filter.internal.filters.model.AtomicFilter 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 2 with AtomicFilter

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

the class FilterSettingPanel method addNewWidget.

public void addNewWidget(Object pObj) {
    // It can be either (1) a string with prefix "node."/"edge." (2) a CompositeFilter object
    if (pObj instanceof CompositeFilter) {
        if (pObj == theFilter) {
            // Ignore if try to add self
            return;
        }
        CompositeFilter theCompositeFilter = (CompositeFilter) pObj;
        addWidgetRow(theCompositeFilter, theFilter.getChildren().size() * 2);
        // Update theFilter object
        theFilter.addChild(theCompositeFilter, new Boolean(false));
        // determine the filter selection type
        if (theCompositeFilter.getAdvancedSetting().isNodeChecked()) {
            theFilter.getAdvancedSetting().setNode(true);
        }
        if (theCompositeFilter.getAdvancedSetting().isEdgeChecked()) {
            theFilter.getAdvancedSetting().setEdge(true);
        }
    } else {
        // (pObj instanceof String)
        String tmpObj = (String) pObj;
        String ctrlAttribute = tmpObj.substring(5);
        int indexType = QuickFind.INDEX_NODES;
        if (tmpObj.startsWith("edge.")) {
            indexType = QuickFind.INDEX_EDGES;
            // determine the filter selection type
            theFilter.getAdvancedSetting().setEdge(true);
        } else {
            theFilter.getAdvancedSetting().setNode(true);
        }
        AtomicFilter newChildFilter = getAtomicFilterFromStr(ctrlAttribute, indexType);
        addWidgetRow(newChildFilter, theFilter.getChildren().size() * 2);
        // Update theFilter object
        theFilter.addChild(newChildFilter);
    }
    // Update selection type of the filter setting
    updateSelectionType();
    // Update the selection on screen
    doSelection();
}
Also used : CompositeFilter(org.cytoscape.filter.internal.filters.model.CompositeFilter) AtomicFilter(org.cytoscape.filter.internal.filters.model.AtomicFilter)

Example 3 with AtomicFilter

use of org.cytoscape.filter.internal.filters.model.AtomicFilter 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 AtomicFilter

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

the class FilterSettingPanel method addWidgetRow.

private void addWidgetRow(CyFilter pFilter, int pGridY) {
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    if (pGridY > 0) {
        // add a row to indicate the relationship between the widgets
        String relationStr = "AND";
        if (theFilter.getAdvancedSetting().getRelation() == Relation.OR) {
            relationStr = "OR";
        }
        // Col 2 ---> Label to indicate relationship between widgets
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = pGridY - 1;
        JLabel lbRelation = new JLabel(relationStr);
        lbRelation.setName("RelationLabel");
        pnlCustomSettings.add(lbRelation, gridBagConstraints);
    }
    // Col 0 -- label with attributeName/Filter
    JLabel theLabel_col0 = new JLabel();
    if (pFilter instanceof AtomicFilter) {
        AtomicFilter atomicFilter = (AtomicFilter) pFilter;
        theLabel_col0.setText(atomicFilter.getControllingAttribute());
    } else {
        theLabel_col0.setText("Filter");
    }
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridy = pGridY;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    // gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 10);
    pnlCustomSettings.add(theLabel_col0, gridBagConstraints);
    // Col 1 ---> chk box -- NOT
    final JCheckBox chkNot = new JCheckBox("Not");
    chkNot.setName(Integer.toString(pGridY));
    chkNot.setSelected(pFilter.getNegation());
    chkNot.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateNegationStatus(chkNot);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridy = pGridY;
    // gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
    pnlCustomSettings.add(chkNot, gridBagConstraints);
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    // Col 2 ---> Widget if atomicFilter
    if (pFilter instanceof StringFilter) {
        JComboBox aBox = getTextIndexComboBox((StringFilter) pFilter);
        pnlCustomSettings.add(aBox, gridBagConstraints);
    } else if (pFilter instanceof NumericFilter) {
        JRangeSliderExtended theSlider = getRangerSlider((NumericFilter) pFilter);
        pnlCustomSettings.add(theSlider, gridBagConstraints);
    } else {
        // CompositeFilter
        gridBagConstraints.fill = java.awt.GridBagConstraints.NONE;
        // gridBagConstraints.weightx = 0.0;
        // gridBagConstraints.anchor = java.awt.GridBagConstraints.
        pnlCustomSettings.add(new JLabel(pFilter.getName()), gridBagConstraints);
    }
    gridBagConstraints.weightx = 0.0;
    // Col 3 ---> label (a trash can) for delete of the row
    JLabel theDelLabel = new JLabel();
    theDelLabel.setIcon(delIcon);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridy = pGridY;
    // gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
    pnlCustomSettings.add(theDelLabel, gridBagConstraints);
    theDelLabel.setName(Integer.toString(pGridY));
    theDelLabel.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            removeFilterWidget(e);
        }
    });
    this.validate();
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) MouseEvent(java.awt.event.MouseEvent) JComboBox(javax.swing.JComboBox) NumericFilter(org.cytoscape.filter.internal.filters.model.NumericFilter) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) AtomicFilter(org.cytoscape.filter.internal.filters.model.AtomicFilter) JRangeSliderExtended(org.cytoscape.filter.internal.widgets.slider.JRangeSliderExtended) GridBagConstraints(java.awt.GridBagConstraints) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) StringFilter(org.cytoscape.filter.internal.filters.model.StringFilter)

Aggregations

AtomicFilter (org.cytoscape.filter.internal.filters.model.AtomicFilter)4 CompositeFilter (org.cytoscape.filter.internal.filters.model.CompositeFilter)2 NumericFilter (org.cytoscape.filter.internal.filters.model.NumericFilter)2 StringFilter (org.cytoscape.filter.internal.filters.model.StringFilter)2 GridBagConstraints (java.awt.GridBagConstraints)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 List (java.util.List)1 JCheckBox (javax.swing.JCheckBox)1 JComboBox (javax.swing.JComboBox)1 JLabel (javax.swing.JLabel)1 CyFilter (org.cytoscape.filter.internal.filters.model.CyFilter)1 TaskMonitorBase (org.cytoscape.filter.internal.quickfind.util.TaskMonitorBase)1 JRangeSliderExtended (org.cytoscape.filter.internal.widgets.slider.JRangeSliderExtended)1 CyNetwork (org.cytoscape.model.CyNetwork)1