// create a final reference to the focus set, so that the following
// search listener can access it.
final TupleSet focus = m_vis.getFocusGroup(FOCUS);
// create the search query binding
SearchQueryBinding searchQ = new SearchQueryBinding(vt, "zipstr");
final SearchTupleSet search = searchQ.getSearchSet();
// create the listener that collects search results into a focus set
search.addTupleSetListener(new TupleSetListener() {
public void tupleSetChanged(TupleSet t, Tuple[] add, Tuple[] rem) {
m_vis.cancel("animate");
// invalidate changed tuples, add them all to the focus set
focus.clear();
for ( int i=0; i<add.length; ++i ) {
((VisualItem)add[i]).setValidated(false);
focus.addTuple(add[i]);
}
for ( int i=0; i<rem.length; ++i ) {
((VisualItem)rem[i]).setValidated(false);
focus.addTuple(rem[i]);
}
m_vis.run("update");
m_vis.run("animate");
}
});
m_vis.addFocusGroup(Visualization.SEARCH_ITEMS, search);
// create and parameterize a search panel for searching on zip code
final JSearchPanel searcher = searchQ.createSearchPanel();
searcher.setLabelText("zip>"); // the search box label
searcher.setShowCancel(false); // don't show the cancel query button
searcher.setShowBorder(false); // don't show the search box border
searcher.setFont(FontLib.getFont("Georgia", Font.PLAIN, 22));
searcher.setBackground(ColorLib.getGrayscale(50));