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();
}
}
}
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;
}
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);
}
}
}
}
}
}
}
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();
}
Aggregations