use of org.cytoscape.filter.internal.prefuse.data.query.NumberRangeModel 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.prefuse.data.query.NumberRangeModel in project cytoscape-impl by cytoscape.
the class PopupDaemon method stateChanged.
/**
* Upon state change, pop-up a tiny window with low-high.
*
* @param e ChangeEvent Object.
*/
public void stateChanged(ChangeEvent e) {
NumberRangeModel model = (NumberRangeModel) getModel();
Number low = (Number) model.getLowValue();
Number high = (Number) model.getHighValue();
Number min = (Number) model.getMinValue();
Number max = (Number) model.getMaxValue();
DecimalFormat format;
String lowStr = null;
String highStr = null;
if (low instanceof Integer) {
lowStr = Integer.toString((Integer) low);
highStr = Integer.toString((Integer) high);
} else {
if ((max.doubleValue() - min.doubleValue()) < .001) {
format = new DecimalFormat("0.###E0");
} else if ((max.doubleValue() - min.doubleValue()) > 100000) {
format = new DecimalFormat("0.###E0");
} else {
format = new DecimalFormat("###,###.000");
}
lowStr = format.format(low);
highStr = format.format(high);
}
if (isVisible()) {
if (popup == null) {
PopupFactory popupFactory = PopupFactory.getSharedInstance();
JPanel panel = new JPanel();
panel.setBorder(new LineBorder(Color.LIGHT_GRAY, 1));
panel.setPreferredSize(getPreferredSize());
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
popupLow = new JLabel(lowStr);
popupLow.setBorder(new EmptyBorder(6, 2, 6, 2));
popupHigh = new JLabel(highStr);
popupHigh.setBorder(new EmptyBorder(6, 2, 6, 2));
panel.add(popupLow);
panel.add(Box.createHorizontalGlue());
panel.add(popupHigh);
popup = popupFactory.getPopup(this, panel, getLocationOnScreen().x, getLocationOnScreen().y + getPreferredSize().height + 2);
popupDaemon = new PopupDaemon(this, 2000);
popup.show();
popupDaemon.restart();
} else {
popupLow.setText(lowStr);
popupHigh.setText(highStr);
popupDaemon.restart();
}
}
}
use of org.cytoscape.filter.internal.prefuse.data.query.NumberRangeModel 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.prefuse.data.query.NumberRangeModel in project cytoscape-impl by cytoscape.
the class RangeSelectionListener method stateChanged.
/**
* State Change Event.
*
* @param e ChangeEvent Object.
*/
public void stateChanged(ChangeEvent e) {
final CyNetwork cyNetwork = applicationManager.getCurrentNetwork();
GenericIndex index = quickFind.getIndex(cyNetwork);
NumberRangeModel model = (NumberRangeModel) slider.getModel();
if (slider.isVisible()) {
if (index instanceof NumberIndex) {
Number lowValue = (Number) model.getLowValue();
Number highValue = (Number) model.getHighValue();
quickFind.selectRange(cyNetwork, lowValue, highValue);
}
}
}
Aggregations