Search in sources :

Example 1 with NumberIndex

use of org.cytoscape.filter.internal.widgets.autocomplete.index.NumberIndex in project cytoscape-impl by cytoscape.

the class FilterSettingPanel method getRangerSlider.

private JRangeSliderExtended getRangerSlider(NumericFilter pFilter) {
    NumberIndex theIndex = createNumberIndex(pFilter);
    if (theIndex != null) {
        pFilter.setIndex(theIndex);
    } else {
    // System.out.println("theIndex == null");
    }
    NumberRangeModel rangeModel = null;
    if (theIndex == null) {
        rangeModel = new NumberRangeModel(0, 0, 0, 0);
    } else {
        Class<?> dataType = getAttributeDataType(pFilter.getNetwork(), pFilter.getControllingAttribute(), pFilter.getIndexType());
        // Initialize the search values, lowBound and highBound
        if (pFilter.getLowBound() == null) {
            pFilter.setLowBound(theIndex.getMinimumValue());
        }
        if (pFilter.getHighBound() == null) {
            pFilter.setHighBound(theIndex.getMaximumValue());
        }
        if (dataType == Double.class) {
            Double lowB = (Double) pFilter.getLowBound();
            Double highB = (Double) pFilter.getHighBound();
            Double min = (Double) theIndex.getMinimumValue();
            Double max = (Double) theIndex.getMaximumValue();
            rangeModel = new NumberRangeModel(lowB.doubleValue(), highB.doubleValue(), min.doubleValue(), max.doubleValue());
        } else if (dataType == Integer.class) {
            rangeModel = new NumberRangeModel(pFilter.getLowBound(), pFilter.getHighBound(), theIndex.getMinimumValue(), theIndex.getMaximumValue());
        }
    }
    JRangeSliderExtended rangeSlider = new JRangeSliderExtended(rangeModel, JRangeSlider.HORIZONTAL, JRangeSlider.LEFTRIGHT_TOPBOTTOM);
    rangeSlider.setMinimumSize(new Dimension(100, 20));
    rangeSlider.setPreferredSize(new Dimension(100, 20));
    RangeSelectionListener rangeSelectionListener = new RangeSelectionListener(rangeSlider);
    rangeSlider.addChangeListener(rangeSelectionListener);
    rangeSlider.setName(pFilter.getControllingAttribute());
    RangeSlideMouseAdapter l = new RangeSlideMouseAdapter();
    rangeSlider.addMouseListener(l);
    MyMouseInputAdapter myMouseInputAdapter = new MyMouseInputAdapter();
    rangeSlider.addMouseMotionListener(myMouseInputAdapter);
    return rangeSlider;
}
Also used : NumberIndex(org.cytoscape.filter.internal.widgets.autocomplete.index.NumberIndex) NumberRangeModel(org.cytoscape.filter.internal.prefuse.data.query.NumberRangeModel) JRangeSliderExtended(org.cytoscape.filter.internal.widgets.slider.JRangeSliderExtended) Dimension(java.awt.Dimension)

Example 2 with NumberIndex

use of org.cytoscape.filter.internal.widgets.autocomplete.index.NumberIndex in project cytoscape-impl by cytoscape.

the class NumericFilter method apply.

public void apply() {
    List<CyNode> nodes_list = null;
    List<CyEdge> edges_list = null;
    int objectCount = -1;
    if (index_type == QuickFind.INDEX_NODES) {
        nodes_list = network.getNodeList();
        objectCount = nodes_list.size();
        // all the bits are false initially
        node_bits = new BitSet(objectCount);
    } else if (index_type == QuickFind.INDEX_EDGES) {
        edges_list = network.getEdgeList();
        objectCount = edges_list.size();
        // all the bits are false initially
        edge_bits = new BitSet(objectCount);
    } else {
        LoggerFactory.getLogger("org.cytoscape.application.userlog").error("StringFilter: Index_type is undefined.");
        return;
    }
    if (lowBound == null || highBound == null || network == null || !FilterUtil.hasSuchAttribute(network, controllingAttribute, index_type)) {
        return;
    }
    // If quickFind_index does not exist, build the Index
    // if (quickFind_index == null) {
    quickFind_index = FilterUtil.getQuickFindIndex(quickFind, controllingAttribute, network, index_type);
    // }
    // System.out.println(" NumberFilter.apply(): objectCount = " + objectCount);
    NumberIndex numberIndex = (NumberIndex) quickFind_index;
    List<?> list = numberIndex.getRange(lowBound, highBound);
    if (list.size() == 0) {
        return;
    }
    int index;
    if (index_type == QuickFind.INDEX_NODES) {
        for (Object obj : list) {
            index = nodes_list.lastIndexOf(obj);
            node_bits.set(index, true);
        }
    } else if (index_type == QuickFind.INDEX_EDGES) {
        for (Object obj : list) {
            index = edges_list.lastIndexOf(obj);
            edge_bits.set(index, true);
        }
    }
    if (negation) {
        if (index_type == QuickFind.INDEX_NODES) {
            node_bits.flip(0, objectCount);
        }
        if (index_type == QuickFind.INDEX_EDGES) {
            edge_bits.flip(0, objectCount);
        }
    }
}
Also used : NumberIndex(org.cytoscape.filter.internal.widgets.autocomplete.index.NumberIndex) BitSet(java.util.BitSet) CyNode(org.cytoscape.model.CyNode) CyEdge(org.cytoscape.model.CyEdge)

Example 3 with NumberIndex

use of org.cytoscape.filter.internal.widgets.autocomplete.index.NumberIndex in project cytoscape-impl by cytoscape.

the class RangeSelectionListener method onUserRangeSelection.

/**
 * Indicates that the user has selected a number range within the QuickFind
 * Range selector.
 *
 * @param network   the current CyNetwork.
 * @param lowValue  the low value of the range.
 * @param highValue the high value of the range.
 */
public void onUserRangeSelection(CyNetwork network, Number lowValue, Number highValue) {
    try {
        GenericIndex index = quickFind.getIndex(network);
        NumberIndex numberIndex = (NumberIndex) index;
        final List rangeList = numberIndex.getRange(lowValue, highValue);
        if (index.getIndexType() == QuickFind.INDEX_NODES) {
            selectNodes(network, rangeList);
        } else {
            selectEdges(network, rangeList);
        }
    } catch (IllegalArgumentException exc) {
    }
}
Also used : GenericIndex(org.cytoscape.filter.internal.widgets.autocomplete.index.GenericIndex) NumberIndex(org.cytoscape.filter.internal.widgets.autocomplete.index.NumberIndex) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with NumberIndex

use of org.cytoscape.filter.internal.widgets.autocomplete.index.NumberIndex 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 5 with NumberIndex

use of org.cytoscape.filter.internal.widgets.autocomplete.index.NumberIndex in project cytoscape-impl by cytoscape.

the class FilterSettingPanel method refreshIndicesForWidgets.

// Refresh indices for widget after network switch or Cytoscape.ATTRIBUTES_CHANGED event is received
// The method may be triggered by event of NETWORK_VIEW_FOCUSED
public void refreshIndicesForWidgets() {
    // Check if each widget has associatd index, if not, try to create one
    // System.out.println("FilterSettingpanel:refreshIndicesForWidgets()...\n");
    List<CyFilter> children = theFilter.getChildren();
    if ((children == null) || (children.size() == 0)) {
        return;
    }
    CyNetwork network = applicationManager.getCurrentNetwork();
    for (int i = 0; i < children.size(); i++) {
        CyFilter child = children.get(i);
        if (child instanceof StringFilter) {
            if (pnlCustomSettings.getComponent(i * 5 + 3) instanceof TextIndexComboBox) {
                TextIndexComboBox theBox = (TextIndexComboBox) pnlCustomSettings.getComponent(i * 5 + 3);
                if (network != null) {
                    CyNetworkView networkView = applicationManager.getCurrentNetworkView();
                    if (networkView != null) {
                        TextIndex textIndex = createTextIndex((StringFilter) child);
                        ;
                        if (textIndex != null) {
                            theBox.setTextIndex(textIndex);
                            StringFilter aFilter = (StringFilter) child;
                            aFilter.setIndex(textIndex);
                        }
                    }
                }
            }
        }
        if (child instanceof NumericFilter) {
            if (pnlCustomSettings.getComponent(i * 5 + 3) instanceof JRangeSliderExtended) {
                JRangeSliderExtended theSlider = (JRangeSliderExtended) pnlCustomSettings.getComponent(i * 5 + 3);
                if (network != null) {
                    CyNetworkView networkView = applicationManager.getCurrentNetworkView();
                    if (networkView != null) {
                        NumberIndex numIndex = createNumberIndex((NumericFilter) child);
                        ;
                        if (numIndex != null) {
                            NumberRangeModel rangeModel = (NumberRangeModel) theSlider.getModel();
                            rangeModel.setMinValue(numIndex.getMinimumValue());
                            rangeModel.setMaxValue(numIndex.getMaximumValue());
                            NumericFilter aFilter = (NumericFilter) child;
                            aFilter.setIndex(numIndex);
                        }
                    }
                }
            }
        }
    }
}
Also used : CyFilter(org.cytoscape.filter.internal.filters.model.CyFilter) TextIndexComboBox(org.cytoscape.filter.internal.widgets.autocomplete.view.TextIndexComboBox) NumberIndex(org.cytoscape.filter.internal.widgets.autocomplete.index.NumberIndex) TextIndex(org.cytoscape.filter.internal.widgets.autocomplete.index.TextIndex) NumericFilter(org.cytoscape.filter.internal.filters.model.NumericFilter) NumberRangeModel(org.cytoscape.filter.internal.prefuse.data.query.NumberRangeModel) CyNetwork(org.cytoscape.model.CyNetwork) StringFilter(org.cytoscape.filter.internal.filters.model.StringFilter) JRangeSliderExtended(org.cytoscape.filter.internal.widgets.slider.JRangeSliderExtended) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Aggregations

NumberIndex (org.cytoscape.filter.internal.widgets.autocomplete.index.NumberIndex)6 NumberRangeModel (org.cytoscape.filter.internal.prefuse.data.query.NumberRangeModel)3 GenericIndex (org.cytoscape.filter.internal.widgets.autocomplete.index.GenericIndex)3 CyNetwork (org.cytoscape.model.CyNetwork)3 JRangeSliderExtended (org.cytoscape.filter.internal.widgets.slider.JRangeSliderExtended)2 Dimension (java.awt.Dimension)1 ArrayList (java.util.ArrayList)1 BitSet (java.util.BitSet)1 List (java.util.List)1 CyFilter (org.cytoscape.filter.internal.filters.model.CyFilter)1 NumericFilter (org.cytoscape.filter.internal.filters.model.NumericFilter)1 StringFilter (org.cytoscape.filter.internal.filters.model.StringFilter)1 TaskMonitorBase (org.cytoscape.filter.internal.quickfind.util.TaskMonitorBase)1 TextIndex (org.cytoscape.filter.internal.widgets.autocomplete.index.TextIndex)1 TextIndexComboBox (org.cytoscape.filter.internal.widgets.autocomplete.view.TextIndexComboBox)1 CyEdge (org.cytoscape.model.CyEdge)1 CyNode (org.cytoscape.model.CyNode)1 CyNetworkView (org.cytoscape.view.model.CyNetworkView)1