本文整理汇总了Java中com.sun.javafx.scene.control.skin.VirtualFlow类的典型用法代码示例。如果您正苦于以下问题:Java VirtualFlow类的具体用法?Java VirtualFlow怎么用?Java VirtualFlow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VirtualFlow类属于com.sun.javafx.scene.control.skin包,在下文中一共展示了VirtualFlow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scrollToVisible
import com.sun.javafx.scene.control.skin.VirtualFlow; //导入依赖的package包/类
public void scrollToVisible(int index) {
VirtualFlow<?> flow = (VirtualFlow<?>) lookup(".virtual-flow");
IndexedCell firstCell = flow.getFirstVisibleCell();
if (firstCell == null)
return;
int first = firstCell.getIndex();
int last = flow.getLastVisibleCell().getIndex();
if (index <= first) {
while (index <= first && flow.adjustPixels((index - first) - 1) < 0) {
first = flow.getFirstVisibleCell().getIndex();
}
} else {
while (index >= last && flow.adjustPixels((index - last) + 1) > 0) {
last = flow.getLastVisibleCell().getIndex();
}
}
}
示例2: scrollUp
import com.sun.javafx.scene.control.skin.VirtualFlow; //导入依赖的package包/类
private void scrollUp(int index) {
TableViewSkin<?> ts = (TableViewSkin<?>) tableDots.getSkin();
VirtualFlow<?> vf = (VirtualFlow<?>) ts.getChildren().get(1);
int first = vf.getFirstVisibleCellWithinViewPort().getIndex();
int last = vf.getLastVisibleCellWithinViewPort().getIndex();
if (index <= (last + first) / 2) {
vf.scrollTo(index - (last - first) / 2);
ts = (TableViewSkin<?>) tableDots.getSkin();
vf = (VirtualFlow<?>) ts.getChildren().get(1);
first = vf.getFirstVisibleCellWithinViewPort().getIndex();
last = vf.getLastVisibleCellWithinViewPort().getIndex();
}
}
示例3: scrollDown
import com.sun.javafx.scene.control.skin.VirtualFlow; //导入依赖的package包/类
private void scrollDown(int index) {
TableViewSkin<?> ts = (TableViewSkin<?>) tableDots.getSkin();
VirtualFlow<?> vf = (VirtualFlow<?>) ts.getChildren().get(1);
int first = vf.getFirstVisibleCellWithinViewPort().getIndex();
int last = vf.getLastVisibleCellWithinViewPort().getIndex();
if (index >= (last + first) / 2) {
vf.scrollTo(index - ((last - first) / 2));
ts = (TableViewSkin<?>) tableDots.getSkin();
vf = (VirtualFlow<?>) ts.getChildren().get(1);
first = vf.getFirstVisibleCellWithinViewPort().getIndex();
last = vf.getLastVisibleCellWithinViewPort().getIndex();
}
}
示例4: getIndex
import com.sun.javafx.scene.control.skin.VirtualFlow; //导入依赖的package包/类
private int getIndex(){
ListViewSkin<?> ts = (ListViewSkin<?>) image_list.getSkin();
VirtualFlow<?> vf = (VirtualFlow<?>) ts.getChildren().get(0);
int first = vf.getFirstVisibleCell().getIndex();
int last = vf.getLastVisibleCell().getIndex();
int out = Math.abs(last-first);
System.out.print(out);
return out;
}
示例5: getFirstAndLast
import com.sun.javafx.scene.control.skin.VirtualFlow; //导入依赖的package包/类
@SuppressWarnings("restriction")
public void getFirstAndLast(ListView<?> t) {
try {
ListViewSkin<?> ts = (ListViewSkin<?>) t.getSkin();
VirtualFlow<?> vf = (VirtualFlow<?>) ts.getChildren().get(0);
first = vf.getFirstVisibleCell().getIndex();
last = vf.getLastVisibleCell().getIndex();
}catch (Exception ex) {}
}
示例6: initialize
import com.sun.javafx.scene.control.skin.VirtualFlow; //导入依赖的package包/类
@Override
public void initialize(URL location, ResourceBundle resources) {
table.setSelectionModel(null);
Platform.runLater(() -> {
TableViewSkin tableSkin = (TableViewSkin) table.getSkin();
virtualFlow = (VirtualFlow) tableSkin.getChildren().get(1);
});
}
示例7: getVisibleRows
import com.sun.javafx.scene.control.skin.VirtualFlow; //导入依赖的package包/类
/**
* THis is a total hack. We need it as scrollTo jumps the selected row to the top
* of the table. Jarring if the row is already visible. As a workaround, we only
* scroll if the row isn't already visible
* @return A 2 element ray with the start and end index of visible rows
*/
private int[] getVisibleRows() {
// TableView<Annotation> tableView = getTableView();
// // TODO this does not work in Java 9
// // See https://stackoverflow.com/questions/46474385/how-to-find-the-indices-of-the-visible-rows-in-a-tableview-in-javafx-9/46474693#46474693
TableViewSkin<?> skin = (TableViewSkin<?>) tableView.getSkin();
if (skin == null) return new int[] {0, 0};
VirtualFlow<?> flow = (VirtualFlow<?>) skin.getChildren().get(1);
int idxFirst;
int idxLast;
if (flow != null &&
flow.getFirstVisibleCellWithinViewPort() != null &&
flow.getLastVisibleCellWithinViewPort() != null) {
idxFirst = flow.getFirstVisibleCellWithinViewPort().getIndex();
if (idxFirst > tableView.getItems().size()) {
idxFirst = tableView.getItems().size() - 1;
}
idxLast = flow.getLastVisibleCellWithinViewPort().getIndex();
if (idxLast > tableView.getItems().size()) {
idxLast = tableView.getItems().size() - 1;
}
}
else {
idxFirst = 0;
idxLast = 0;
}
return new int[]{idxFirst, idxLast};
// This TableViewExt appears to be buggy
//return tableViewExt.getVisibleRows();
}
示例8: setFirstVisibleId
import com.sun.javafx.scene.control.skin.VirtualFlow; //导入依赖的package包/类
/**
* Shifts the list view on display to start with the indicated index.
*/
private void setFirstVisibleId() {
ListViewSkin<?> listViewSkin = (ListViewSkin<?>) getCurrentListView().getSkin();
VirtualFlow<?> virtualFlow = (VirtualFlow<?>) listViewSkin.getChildren().get(0);
IndexedCell<?> firstVisibleCell = virtualFlow.getFirstVisibleCellWithinViewPort();
if (firstVisibleCell != null) {
firstVisibleId = firstVisibleCell.getIndex();
}
}
示例9: getVirtualFlow
import com.sun.javafx.scene.control.skin.VirtualFlow; //导入依赖的package包/类
private VirtualFlow<TableRow<T>> getVirtualFlow() {
Parent p = getSkinnable();
while (p != null) {
if (p instanceof VirtualFlow) {
return (VirtualFlow<TableRow<T>>) p;
}
p = p.getParent();
}
return null;
}
示例10: invokeFlowCellLength
import com.sun.javafx.scene.control.skin.VirtualFlow; //导入依赖的package包/类
/**
* Reflectively invokes protected getCellLength(i) of flow.
* @param index the index of the cell.
* @return the cell height of the cell at index.
*/
protected double invokeFlowCellLength(int index) {
double height = 1.0;
Class<?> clazz = VirtualFlow.class;
try {
Method method = clazz.getDeclaredMethod("getCellLength", Integer.TYPE);
method.setAccessible(true);
return ((double) method.invoke(flow, index));
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException e) {
e.printStackTrace();
}
return height;
}
示例11: getFirstVisibleRowIndex
import com.sun.javafx.scene.control.skin.VirtualFlow; //导入依赖的package包/类
public static int getFirstVisibleRowIndex(TableView table) {
VirtualFlow<?> flow = getVirtualFlow(table);
if (flow == null || flow.getFirstVisibleCellWithinViewPort() == null) {
return 0;
}
int indexFirst = flow.getFirstVisibleCellWithinViewPort().getIndex();
if (indexFirst >= table.getItems().size()) {
return table.getItems().size() - 1;
} else {
return indexFirst;
}
}
示例12: getLastVisibleRowIndex
import com.sun.javafx.scene.control.skin.VirtualFlow; //导入依赖的package包/类
@SuppressWarnings("WeakerAccess")
public static int getLastVisibleRowIndex(TableView table) {
VirtualFlow<?> flow = getVirtualFlow(table);
if (flow == null || flow.getLastVisibleCellWithinViewPort() == null) {
return 0;
}
int index = flow.getLastVisibleCellWithinViewPort().getIndex();
if (index >= table.getItems().size()) {
return table.getItems().size() - 1;
} else {
return index;
}
}
示例13: getVirtualFlow
import com.sun.javafx.scene.control.skin.VirtualFlow; //导入依赖的package包/类
private static VirtualFlow<?> getVirtualFlow(TableView table) {
TableViewSkin<?> skin = (TableViewSkin) table.getSkin();
if (skin == null) {
return null;
}
return (VirtualFlow) skin.getChildren().get(1);
}
示例14: asScrollable2D
import com.sun.javafx.scene.control.skin.VirtualFlow; //导入依赖的package包/类
/**
* Returns implementation of Scrollable2D interface.
*/
@As
public Scrollable2D asScrollable2D() {
if (scrollable2D == null) {
scrollable2D = new Scrollable2DImpl(this, new ScrollsLookupCriteria() {
@Override
public boolean checkFor(ScrollBar scrollBar) {
return ((scrollBar.getParent() instanceof VirtualFlow)
&& (scrollBar.getParent().getParent() instanceof TreeTableView));
}
});
}
return scrollable2D;
}
示例15: asScrollable2D
import com.sun.javafx.scene.control.skin.VirtualFlow; //导入依赖的package包/类
@As
public Scrollable2D asScrollable2D() {
if (scrollable2D == null) {
scrollable2D = new Scrollable2DImpl(this, new ScrollsLookupCriteria() {
@Override
public boolean checkFor(ScrollBar scrollBar) {
return ((scrollBar.getParent() instanceof VirtualFlow)
&& (scrollBar.getParent().getParent() instanceof TreeView));
}
});
}
return scrollable2D;
}