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