本文整理汇总了Java中javafx.scene.control.TableCell类的典型用法代码示例。如果您正苦于以下问题:Java TableCell类的具体用法?Java TableCell怎么用?Java TableCell使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TableCell类属于javafx.scene.control包,在下文中一共展示了TableCell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPoint
import javafx.scene.control.TableCell; //导入依赖的package包/类
public Point2D getPoint(TableView<?> tableView, int columnIndex, int rowIndex) {
Set<Node> tableRowCell = tableView.lookupAll(".table-row-cell");
TableRow<?> row = null;
for (Node tableRow : tableRowCell) {
TableRow<?> r = (TableRow<?>) tableRow;
if (r.getIndex() == rowIndex) {
row = r;
break;
}
}
Set<Node> cells = row.lookupAll(".table-cell");
for (Node node : cells) {
TableCell<?, ?> cell = (TableCell<?, ?>) node;
if (tableView.getColumns().indexOf(cell.getTableColumn()) == columnIndex) {
Bounds bounds = cell.getBoundsInParent();
Point2D localToParent = cell.localToParent(bounds.getWidth() / 2, bounds.getHeight() / 2);
Point2D rowLocal = row.localToScene(localToParent, true);
return rowLocal;
}
}
return null;
}
示例2: call
import javafx.scene.control.TableCell; //导入依赖的package包/类
@Override
public TableCell call(TableColumn p) {
return new TableCell<Object, String>() {
private final ImageView imageview;
{
imageview = new ImageView();
imageview.setFitHeight(16);
imageview.setFitWidth(16);
imageview.setCache(true);
}
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setText(null);
setGraphic(null);
} else {
imageview.setImage(new Image(item));
setGraphic(imageview);
}
}
};
}
示例3: createWrappableTableCell
import javafx.scene.control.TableCell; //导入依赖的package包/类
/**
* Creates a wrapped table cell.
*
* @param column the table column in which the cell resides
* @return a TableCell with the text wrapped inside
*/
private TableCell<Annotation, String> createWrappableTableCell(final TableColumn<Annotation, String> column) {
return new TableCell<Annotation, String>() {
@Override
protected void updateItem(final String item, final boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setGraphic(null);
return;
}
final Text text = new Text(item);
text.setWrappingWidth(column.getWidth() - TEXT_PADDING);
setPrefHeight(text.getLayoutBounds().getHeight());
setGraphic(text);
}
};
}
示例4: wrappableTableCell
import javafx.scene.control.TableCell; //导入依赖的package包/类
/**
* Create a table cell that wraps the text inside.
*
* @param param the table column
* @return a table cell that wraps the text inside
*/
TableCell<Annotation, String> wrappableTableCell(final TableColumn<Annotation, String> param) {
return new TableCell<Annotation, String>() {
@Override
protected void updateItem(final String item, final boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setGraphic(null);
return;
}
final Text text = new Text(item);
text.setWrappingWidth(param.getWidth());
setPrefHeight(text.getLayoutBounds().getHeight());
setGraphic(text);
}
};
}
示例5: getVisibleCellAt
import javafx.scene.control.TableCell; //导入依赖的package包/类
public TableCell<?, ?> getVisibleCellAt(TableView<?> tableView, int row, int column) {
Set<Node> lookupAll = getTableCells(tableView);
TableCell<?, ?> cell = null;
for (Node node : lookupAll) {
TableCell<?, ?> cell1 = (TableCell<?, ?>) node;
TableRow<?> tableRow = cell1.getTableRow();
TableColumn<?, ?> tableColumn = cell1.getTableColumn();
if (tableRow.getIndex() == row && tableColumn == tableView.getColumns().get(column)) {
cell = cell1;
break;
}
}
if (cell != null) {
return cell;
}
return null;
}
示例6: _getValue
import javafx.scene.control.TableCell; //导入依赖的package包/类
@Override public String _getValue() {
TableCell<?, ?> cell = (TableCell<?, ?>) node;
Node graphic = cell.getGraphic();
JavaFXElement component = (JavaFXElement) JavaFXElementFactory.createElement(graphic, driver, window);
if (graphic != null && component != null) {
if (graphic instanceof CheckBox) {
String cellText = cell.getText() == null ? "" : cell.getText();
return cellText + ":" + component._getValue();
}
return component._getValue();
}
return super._getValue();
}
示例7: addGroupParticipantList
import javafx.scene.control.TableCell; //导入依赖的package包/类
/** Add participant in group list */
public void addGroupParticipantList() {
Platform.runLater(() -> {
groupParticipantTable.setItems(groupParticipantList);
// Nickname column setting
groupPartiNicknameColumn.setCellValueFactory(cellData -> cellData.getValue().getNameProperty());
groupPartiNicknameColumn.setCellFactory(new Callback<TableColumn<User, String>, TableCell<User, String>>() {
@Override
public TableCell<User, String> call(TableColumn<User, String> column) {
TableCell<User, String> tc = new TableCell<User, String>() {
@Override
public void updateItem(String item, boolean empty) {
if (item != null) {
setText(item);
}
}
};
tc.setAlignment(Pos.CENTER);
return tc;
}
});
});
}
示例8: forImage
import javafx.scene.control.TableCell; //导入依赖的package包/类
public static final <S> TableCell<S, Image> forImage() {
final ImageView imageView = new ImageView();
{
imageView.setFitWidth(ItemSlot.SLOT_SIZE);
imageView.setFitHeight(ItemSlot.SLOT_SIZE);
}
return new TableCell<S, Image>() {
@Override
protected void updateItem(Image item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setText(null);
setGraphic(null);
} else {
imageView.setImage(item);
setGraphic(imageView);
}
}
};
}
示例9: integerCell
import javafx.scene.control.TableCell; //导入依赖的package包/类
private <T> Callback<TableColumn<T, Number>, TableCell<T, Number>> integerCell(
Predicate<Integer> validator, int defaultValue) {
return TextFieldTableCell.forTableColumn(new StringConverter<Number>() {
@Override
public String toString(Number object) {
if (object == null) {
return null;
}
return object.toString();
}
@Override
public Number fromString(String string) {
try {
int value = Integer.parseInt(string);
if (validator.test(value)) {
return value;
} else {
return defaultValue;
}
} catch (NumberFormatException e) {
return defaultValue;
}
}
});
}
示例10: initialize
import javafx.scene.control.TableCell; //导入依赖的package包/类
@FXML
private void initialize() {
distanceColumn.setCellValueFactory(cell -> cell.getValue().distanceProperty());
distanceColumn.setCellFactory(param -> new TableCell<StellarObjectModel, Number>() {
@Override
protected void updateItem(Number item, boolean empty) {
if (item != null) {
NumberFormat formatter = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.ENGLISH));
setText(formatter.format(item));
}
}
});
nameColumn.setCellValueFactory(cell -> cell.getValue().nameProperty());
raColumn.setCellValueFactory(cell -> cell.getValue().rightAscensionProperty());
decColumn.setCellValueFactory(cell -> cell.getValue().declinationProperty());
}
示例11: buildThreadListGraphic
import javafx.scene.control.TableCell; //导入依赖的package包/类
protected TextFlow buildThreadListGraphic(final TableCell<ThreadElement, Set<ThreadElement>> cell, final Set<ThreadElement> threads) {
final TextFlow threadsGraphic = new TextFlow();
threadsGraphic.setPrefHeight(20);
final Iterator<ThreadElement> threadIterator = threads.iterator();
while (threadIterator.hasNext()) {
final ThreadElement thread = threadIterator.next();
threadsGraphic.getChildren().add(buildThreadLink(cell, thread));
if (threadIterator.hasNext()) {
threadsGraphic.getChildren().add(buildThreadSeparator());
}
}
return threadsGraphic;
}
示例12: checkTextContainment
import javafx.scene.control.TableCell; //导入依赖的package包/类
protected void checkTextContainment(final Wrap<? extends TableCell> cellWrap, final String textExpectToFind) {
new Waiter(new Timeout("", 1000)).ensureState(new State() {
public Object reached() {
LookupCriteria<Node> lookupCriteria = new LookupCriteria<Node>() {
public boolean check(Node cntrl) {
return Text.class.isAssignableFrom(cntrl.getClass())
|| ((Text) cntrl).getText().equals(textExpectToFind);
}
};
if (cellWrap.as(Parent.class, Node.class).lookup(Text.class, new ByText(textExpectToFind)).size() == 1) {
return true;
} else if (cellWrap.as(Parent.class, Node.class).lookup(lookupCriteria).size() == 1) {
return true;
} else {
return null;
}
}
});
}
示例13: getVisibleRange
import javafx.scene.control.TableCell; //导入依赖的package包/类
protected static Range getVisibleRange(final Wrap<? extends Control> testedControl) {
int[] visibleIndices;
if (testedControl.getControl() instanceof TableView) {
visibleIndices = org.jemmy.fx.control.TableUtils.shown(
testedControl.getEnvironment(),
testedControl,
new org.jemmy.fx.control.TableUtils.TableViewIndexInfoProvider((TableViewWrap) testedControl), TableCell.class);
} else {
visibleIndices = org.jemmy.fx.control.TableUtils.shown(
testedControl.getEnvironment(),
testedControl,
new org.jemmy.fx.control.TableUtils.TreeTableViewIndexInfoProvider((TreeTableViewWrap) testedControl), TreeTableCell.class);
}
return new Range(visibleIndices[1], visibleIndices[3]);
}
示例14: cellLookup
import javafx.scene.control.TableCell; //导入依赖的package包/类
@Test
public void cellLookup() {
System.out.println("testLookup");
final String D = "D";
Wrap<? extends TableCell> tableCellWrap = tableDock.asParent().
lookup(TableCell.class, control -> {
String item = (String) control.getItem();
return item != null && item.contains(D);
}).wrap();
assertTrue("tableViewCellsParent.lookup().wrap() returns "
+ "TableCellWrap",
tableCellWrap instanceof TableCellWrap);
assertTrue(tableCellWrap.getProperty(String.class, "getItem").contains(D));
tableCellWrap.mouse().click();
tableDock.wrap().waitState(() -> tableDock.getSelection().contains(new Point(0, 4)) ? true : null);
}
示例15: generateCallback
import javafx.scene.control.TableCell; //导入依赖的package包/类
/**
* Generates the callback function to be called on button click.
* @return
*/
private Callback<?, ?> generateCallback() {
return new Callback<TableColumn<HistoricalItem, String>, TableCell<HistoricalItem, String>>() {
@SuppressWarnings("rawtypes")
@Override
public TableCell call(TableColumn<HistoricalItem, String> parameter) {
final TableCell<HistoricalItem, String> cell = new TableCell<HistoricalItem, String>() {
final Button button = new Button(CALLBACK);
@Override
public void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if(empty) {
setGraphic(null);
} else {
HistoricalItem history = getTableView().getItems().get(getIndex());
button.setId(CALLBACK + " " + history.getValue());
button.setOnAction(event);
setGraphic(button);
}
setText(null);
}
}; return cell;
}};
}