Example usage for javafx.scene.control TableView scrollTo

List of usage examples for javafx.scene.control TableView scrollTo

Introduction

In this page you can find the example usage for javafx.scene.control TableView scrollTo.

Prototype

public void scrollTo(S object) 

Source Link

Document

Scrolls the TableView so that the given object is visible within the viewport.

Usage

From source file:org.simmi.GeneSetHead.java

License:asdf

public int searchTable(TableView table, String text, int i, boolean back, int... columns) {
    int v;/* w w w  .  j  av a 2  s. com*/
    if (back) {
        v = i - 1;
        if (v == -1)
            v = table.getItems().size();
    } else
        v = (i + 1) % table.getItems().size();
    if (isGeneview()) {
        while (v != i) {
            //int m = table.convertRowIndexToModel(v);
            //if( m != -1 ) {
            //Gene g = geneset.genelist.get(m);
            //String name = column == 7 || column[0] == 8 ? g.getGeneGroup().getCommonSymbol() + ", " + g.getGeneGroup().getCommonKOName( ko2name ) + ", " +  : g.getGeneGroup().getCommonName();

            ObservableList<TableColumn> cc = table.getColumns();
            String name = "";
            for (int k : columns) {
                TableColumn tc = cc.get(k);
                String val = tc.getCellObservableValue(v).toString();
                name += val;//table.getValueAt(v, k);
            }

            if (name.toLowerCase().contains(text)) {
                //int r = table.convertRowIndexToView(v);
                table.scrollTo(v);
                //Rectangle rect = table.getCellRect(v, 0, true);
                //table.scrollRectToVisible( rect );
                break;
            }
            if (back) {
                v--;
                if (v == -1)
                    v = table.getItems().size() - 1;
            } else
                v = (v + 1) % table.getItems().size();

            //} else break;
        }
    } else {
        while (v != i) {
            //int m = table.convertRowIndexToModel(v);
            //if( m != -1 ) {

            //GeneGroup gg = allgenegroups.get(m);
            //String name = gg.getCommonName();
            ObservableList<TableColumn> cc = table.getColumns();
            String name = "";
            for (int k : columns) {
                TableColumn tc = cc.get(k);
                String val = tc.getCellObservableValue(v).toString();
                name += val;
                //name += table.getValueAt(v, k);
            }

            if (name.toLowerCase().contains(text)) {
                //int r = table.convertRowIndexToView(i);
                //Rectangle rect = table.getCellRect(v, 0, true);
                //table.scrollRectToVisible( rect );
                table.scrollTo(v);
                break;
            }
            if (back) {
                v--;
                if (v == -1)
                    v = table.getItems().size() - 1;
            } else
                v = (v + 1) % table.getItems().size();

            //} else break;
        }
    }
    return v;
}