Search in sources :

Example 1 with JRangeSliderExtended

use of org.cytoscape.filter.internal.widgets.slider.JRangeSliderExtended in project cytoscape-impl by cytoscape.

the class FilterSettingPanel method hidePopupForRangeSlider.

private void hidePopupForRangeSlider() {
    if (pnlCustomSettings.getComponentCount() == 0) {
        return;
    }
    int cmpCount = pnlCustomSettings.getComponentCount();
    for (int i = 0; i < cmpCount; i++) {
        Component theCmp = pnlCustomSettings.getComponent(i);
        if (theCmp instanceof JRangeSliderExtended) {
            JRangeSliderExtended theSlider = (JRangeSliderExtended) theCmp;
            theSlider.resetPopup();
        }
    }
}
Also used : JRangeSliderExtended(org.cytoscape.filter.internal.widgets.slider.JRangeSliderExtended) Component(java.awt.Component) JTextComponent(javax.swing.text.JTextComponent)

Example 2 with JRangeSliderExtended

use of org.cytoscape.filter.internal.widgets.slider.JRangeSliderExtended 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 3 with JRangeSliderExtended

use of org.cytoscape.filter.internal.widgets.slider.JRangeSliderExtended 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)

Example 4 with JRangeSliderExtended

use of org.cytoscape.filter.internal.widgets.slider.JRangeSliderExtended 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

JRangeSliderExtended (org.cytoscape.filter.internal.widgets.slider.JRangeSliderExtended)4 NumericFilter (org.cytoscape.filter.internal.filters.model.NumericFilter)2 StringFilter (org.cytoscape.filter.internal.filters.model.StringFilter)2 NumberRangeModel (org.cytoscape.filter.internal.prefuse.data.query.NumberRangeModel)2 NumberIndex (org.cytoscape.filter.internal.widgets.autocomplete.index.NumberIndex)2 Component (java.awt.Component)1 Dimension (java.awt.Dimension)1 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 JCheckBox (javax.swing.JCheckBox)1 JComboBox (javax.swing.JComboBox)1 JLabel (javax.swing.JLabel)1 JTextComponent (javax.swing.text.JTextComponent)1 AtomicFilter (org.cytoscape.filter.internal.filters.model.AtomicFilter)1 CyFilter (org.cytoscape.filter.internal.filters.model.CyFilter)1 TextIndex (org.cytoscape.filter.internal.widgets.autocomplete.index.TextIndex)1 TextIndexComboBox (org.cytoscape.filter.internal.widgets.autocomplete.view.TextIndexComboBox)1