use of org.cytoscape.filter.internal.widgets.autocomplete.index.GenericIndex in project cytoscape-impl by cytoscape.
the class RangeSelectionListener method onUserSelection.
/**
* Indicates that the user has selected a text item within the QuickFind
* Search Box.
*
* @param network the current CyNetwork.
* @param hit hit value chosen by the user.
*/
public void onUserSelection(final CyNetwork network, Hit hit) {
SelectUtil.unselectAllNodes(network);
SelectUtil.unselectAllEdges(network);
// Assemble Hit Objects
final Object[] graphObjects = hit.getAssociatedObjects();
final List list = new ArrayList();
for (int i = 0; i < graphObjects.length; i++) {
list.add(graphObjects[i]);
}
// Fit Selected Content
SwingUtilities.invokeLater(new Runnable() {
public void run() {
final CyNetwork cyNetwork = applicationManager.getCurrentNetwork();
CyNetworkView networkView = applicationManager.getCurrentNetworkView();
GenericIndex index = quickFind.getIndex(cyNetwork);
if (index.getIndexType() == QuickFind.INDEX_NODES) {
SelectUtil.setSelectedNodeState(network, list, true);
final CyNetworkView currentView = applicationManager.getCurrentNetworkView();
if (currentView != null)
currentView.fitSelected();
} else {
SelectUtil.setSelectedEdgeState(network, list, true);
List<CyNode> nodeList = new ArrayList<CyNode>();
for (int i = 0; i < list.size(); i++) {
CyEdge edge = (CyEdge) list.get(i);
CyNode sourceNode = edge.getSource();
CyNode targetNode = edge.getTarget();
nodeList.add(sourceNode);
nodeList.add(targetNode);
}
SelectUtil.setSelectedNodeState(network, nodeList, true);
networkView.fitSelected();
}
// so that node does not take up whole screen.
if (graphObjects.length == 1) {
if (graphObjects[0] instanceof CyNode) {
CyNode node = (CyNode) graphObjects[0];
// Obtain dimensions of current InnerCanvas
RenderingEngine<CyNetwork> engine = applicationManager.getCurrentRenderingEngine();
VisualLexicon lexicon = engine.getVisualLexicon();
Double networkWidth = VisualPropertyUtil.get(lexicon, networkView, "NETWORK_WIDTH", BasicVisualLexicon.NETWORK, Double.class);
Double networkHeight = VisualPropertyUtil.get(lexicon, networkView, "NETWORK_HEIGHT", BasicVisualLexicon.NETWORK, Double.class);
View<CyNode> nodeView = networkView.getNodeView(node);
Double nodeWidth = VisualPropertyUtil.get(lexicon, nodeView, "NODE_WIDTH", BasicVisualLexicon.NODE, Double.class);
Double nodeHeight = VisualPropertyUtil.get(lexicon, nodeView, "NODE_HEIGHT", BasicVisualLexicon.NODE, Double.class);
double width = nodeWidth * NODE_SIZE_MULTIPLER;
double height = nodeHeight * NODE_SIZE_MULTIPLER;
double scaleFactor = Math.min(networkWidth / width, (networkHeight / height));
// TODO: How do we set the zoom in the new API?
// networkView.setZoom(scaleFactor);
}
}
networkView.updateView();
}
});
}
use of org.cytoscape.filter.internal.widgets.autocomplete.index.GenericIndex 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.GenericIndex in project cytoscape-impl by cytoscape.
the class RangeSelectionListener method handleNetworkModified.
private void handleNetworkModified(final CyNetwork cyNetwork) {
if (!networkManager.networkExists(cyNetwork.getSUID()))
return;
if (cyNetwork.getNodeCount() > 0) {
// this can happen if an empty network was added
if (quickFind.getIndex(cyNetwork) == null) {
// Run Indexer in separate background daemon thread.
Thread thread = new Thread() {
public void run() {
quickFind.addNetwork(cyNetwork, new TaskMonitorBase());
}
};
thread.start();
} else // very large networks.
if (cyNetwork.getNodeCount() < QuickFindApp.REINDEX_THRESHOLD) {
// Run Indexer in separate background daemon thread.
Thread thread = new Thread() {
public void run() {
GenericIndex index = quickFind.getIndex(cyNetwork);
quickFind.reindexNetwork(cyNetwork, index.getIndexType(), index.getControllingAttribute(), new TaskMonitorBase());
}
};
thread.start();
}
}
}
use of org.cytoscape.filter.internal.widgets.autocomplete.index.GenericIndex 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.GenericIndex 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