本文整理匯總了Java中javafx.scene.control.TreeTableColumn.setCellFactory方法的典型用法代碼示例。如果您正苦於以下問題:Java TreeTableColumn.setCellFactory方法的具體用法?Java TreeTableColumn.setCellFactory怎麽用?Java TreeTableColumn.setCellFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.TreeTableColumn
的用法示例。
在下文中一共展示了TreeTableColumn.setCellFactory方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildSimpleLongValueColumn
import javafx.scene.control.TreeTableColumn; //導入方法依賴的package包/類
private static TreeTableColumn<TorrentFileEntry, Long> buildSimpleLongValueColumn(
final String columnName, final String propertyName, final String style, final Insets padding,
final Function<TorrentFileEntry, String> valueGetter) {
final TreeTableColumn<TorrentFileEntry, Long> longValueColumn = new TreeTableColumn<TorrentFileEntry, Long>(columnName);
longValueColumn.setId(columnName);
longValueColumn.setGraphic(TableUtils.buildColumnHeader(longValueColumn, style));
longValueColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>(propertyName));
longValueColumn.setCellFactory(column -> new TreeTableCell<TorrentFileEntry, Long>() {
final Label valueLabel = new Label();
@Override
protected final void updateItem(final Long value, final boolean empty) {
super.updateItem(value, empty);
if(empty) {
setText(null);
setGraphic(null);
}
else {
final TorrentFileEntry fileContent = this.getTreeTableRow().getItem();
if(fileContent == null) {
return;
}
final String formattedValue = valueGetter.apply(fileContent);
valueLabel.setText(formattedValue);
this.setGraphic(valueLabel);
this.setAlignment(Pos.CENTER_RIGHT);
super.setPadding(padding);
}
}
});
return longValueColumn;
}
示例2: buildPriorityColumn
import javafx.scene.control.TreeTableColumn; //導入方法依賴的package包/類
private static TreeTableColumn<TorrentFileEntry, FilePriority> buildPriorityColumn() {
final TreeTableColumn<TorrentFileEntry, FilePriority> priorityColumn =
new TreeTableColumn<>(PRIORITY_COLUMN_NAME);
priorityColumn.setId(PRIORITY_COLUMN_NAME);
priorityColumn.setGraphic(TableUtils.buildColumnHeader(priorityColumn, GuiUtils.LEFT_ALIGNED_COLUMN_HEADER_TYPE_NAME));
priorityColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("priority"));
priorityColumn.setCellFactory(column -> new TreeTableCell<TorrentFileEntry, FilePriority>() {
final Label valueLabel = new Label();
@Override
protected final void updateItem(final FilePriority value, final boolean empty) {
super.updateItem(value, empty);
if(empty) {
setText(null);
setGraphic(null);
}
else {
final TorrentFileEntry fileContent = this.getTreeTableRow().getItem();
if(fileContent == null) {
return;
}
valueLabel.setText(fileContent.getPriority().toString());
this.setGraphic(valueLabel);
this.setAlignment(Pos.BASELINE_LEFT);
super.setPadding(GuiUtils.leftPadding());
}
}
});
return priorityColumn;
}
示例3: buildProgressColumn
import javafx.scene.control.TreeTableColumn; //導入方法依賴的package包/類
private static TreeTableColumn<TorrentFileEntry, Double> buildProgressColumn(
final TreeTableView<TorrentFileEntry> treeTableView) {
final TreeTableColumn<TorrentFileEntry, Double> progressColumn =
new TreeTableColumn<TorrentFileEntry, Double>(PROGRESS_COLUMN_NAME);
progressColumn.setId(PROGRESS_COLUMN_NAME);
progressColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("progress"));
progressColumn.setGraphic(TableUtils.buildColumnHeader(progressColumn, GuiUtils.LEFT_ALIGNED_COLUMN_HEADER_TYPE_NAME));
progressColumn.setCellFactory(column -> new ProgressBarTreeTableCell<TorrentFileEntry>() {
@Override
public final void updateItem(final Double value, final boolean empty) {
super.updateItem(value, empty);
if(empty) {
super.setText(null);
super.setGraphic(null);
}
else {
final TorrentFileEntry fileContent = this.getTreeTableRow().getItem();
if(fileContent == null) {
return;
}
super.addEventFilter(MouseEvent.MOUSE_CLICKED, evt ->
treeTableView.getSelectionModel().select(super.getTreeTableRow().getIndex()));
super.getStyleClass().add(CssProperties.PROGRESSBAR_STOPPED);
super.setItem(fileContent.progressProperty().doubleValue());
super.setPadding(GuiUtils.noPadding());
}
}
});
return progressColumn;
}
示例4: render
import javafx.scene.control.TreeTableColumn; //導入方法依賴的package包/類
public void render() {
if (_ttv == null) {
_ttv = new TreeTableView<FormItem<?>>(
new FormTreeItem(this, null, _rootItem));
_ttv.getRoot().setExpanded(true);
_ttv.setShowRoot(false);
TreeTableColumn<FormItem<?>, String> nameColumn = new TreeTableColumn<FormItem<?>, String>(
"Name");
nameColumn.setPrefWidth(250);
nameColumn.setCellValueFactory(param -> {
String displayName = param.getValue().getValue().displayName();
return new ReadOnlyStringWrapper(displayName);
});
nameColumn.setStyle("-fx-font-weight: bold;");
TreeTableColumn<FormItem<?>, FormItem<?>> valueColumn = new TreeTableColumn<FormItem<?>, FormItem<?>>(
"Value");
valueColumn.setPrefWidth(500);
valueColumn.setCellValueFactory(param -> {
return param.getValue().valueProperty();
});
valueColumn.setCellFactory(column -> {
return new FormTreeTableCell();
});
_ttv.getColumns().add(nameColumn);
_ttv.getColumns().add(valueColumn);
_stackPane.getChildren().setAll(_ttv);
FormTreeItem rootTreeItem = (FormTreeItem) _ttv.getRoot();
ObservableList<FormItem<?>> items = _rootItem.getItems();
if (items != null) {
for (FormItem<?> item : items) {
addTreeItem(rootTreeItem, item);
}
}
}
}
示例5: buildComponentCellColumn
import javafx.scene.control.TreeTableColumn; //導入方法依賴的package包/類
private TreeTableColumn<RefexDynamicGUI, RefexDynamicGUI> buildComponentCellColumn(DynamicRefexColumnType type)
{
TreeTableColumn<RefexDynamicGUI, RefexDynamicGUI> ttCol = new TreeTableColumn<>(type.toString());
HeaderNode<String> headerNode = new HeaderNode<>(
filterCache_,
ttCol,
ColumnId.getInstance(type),
rootNode_.getScene(),
new HeaderNode.DataProvider<String>() {
@Override
public String getData(RefexDynamicGUI source) {
return source.getDisplayStrings(type, null).getKey();
}
});
ttCol.setGraphic(headerNode.getNode());
ttCol.setSortable(true);
ttCol.setResizable(true);
ttCol.setComparator(new Comparator<RefexDynamicGUI>()
{
@Override
public int compare(RefexDynamicGUI o1, RefexDynamicGUI o2)
{
return o1.compareTo(type, null, o2);
}
});
ttCol.setCellFactory((colInfo) -> {return new ComponentDataCell(type);});
ttCol.setCellValueFactory((callback) -> {return new ReadOnlyObjectWrapper<RefexDynamicGUI>(callback.getValue().getValue());});
return ttCol;
}
示例6: setCellFactory
import javafx.scene.control.TreeTableColumn; //導入方法依賴的package包/類
public void setCellFactory(FxTreeTableCellFactory<T> f)
{
TreeTableColumn c = lastColumn();
c.setCellFactory(f);
}
示例7: start
import javafx.scene.control.TreeTableColumn; //導入方法依賴的package包/類
@Override
public void start(Stage stage) throws Exception {
final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);
TreeTableColumn<Person, String> numberCol = new TreeTableColumn<>("#");
numberCol.setCellValueFactory(p -> p.getValue().getValue().hierarchyProperty());
numberCol.setPrefWidth(100);
numberCol.setCellFactory(TextFieldTreeTableCell.<Person>forTreeTableColumn());
TreeTableColumn<Person, String> firstNameCol = new TreeTableColumn<>("First Name");
firstNameCol.setPrefWidth(150);
firstNameCol.setEditable(true);
firstNameCol.setCellValueFactory(p -> p.getValue().getValue().firstNameProperty());
firstNameCol.setCellFactory(TextFieldTreeTableCell.<Person>forTreeTableColumn());
TreeTableColumn<Person, String> lastNameCol = new TreeTableColumn<>("Last Name");
lastNameCol.setPrefWidth(150);
lastNameCol.setEditable(true);
lastNameCol.setCellValueFactory(p -> p.getValue().getValue().lastNameProperty());
lastNameCol.setCellFactory(TextFieldTreeTableCell.<Person>forTreeTableColumn());
TreeTableColumn<Person, Date> birthdayCol = new TreeTableColumn<>("Birthday");
birthdayCol.setPrefWidth(250);
birthdayCol.setCellValueFactory(p -> p.getValue().getValue().birthdayProperty());
birthdayCol.setEditable(false);
birthdayCol.setCellFactory(TextFieldTreeTableCell.<Person, Date>forTreeTableColumn(new StringConverter<Date>() {
@Override
public String toString(Date t) {
return df.format(t);
}
@Override
public Date fromString(String string) {
try {
return df.parse(string);
} catch (ParseException ex) {
return null;
}
}
}));
final TreeTableView<Person> treeTableView = new TreeTableView<Person>();
treeTableView.setEditable(true);
treeTableView.setId(TREE_TABLE_VIEW_ID);
treeTableView.setRoot(new TreeItem(new Person("0", "Root", "Root", new Date(r.nextLong() % 946080000000L))));
addContent(treeTableView.getRoot(), 2, 4, "0");
treeTableView.getColumns().setAll(numberCol, firstNameCol, lastNameCol, birthdayCol);
treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
treeTableView.getSelectionModel().setCellSelectionEnabled(true);
treeTableView.getSelectionModel().select(5, numberCol);
VBox vBox = new VBox();
vBox.getChildren().setAll(treeTableView);
Scene scene = new Scene(vBox, 800, 500);
stage.setScene(scene);
stage.show();
}
示例8: cfgPctCol
import javafx.scene.control.TreeTableColumn; //導入方法依賴的package包/類
/**
* Configures a {@link TreeTableColumn} containing percentages calculated for a single profile.
* <p>
*
* @param <U> the type of the items in the {@link TableView} containing the {@link TableColumn}
* @param column the column being configured
* @param propertyName the name of the property containing the value for this column
* @param profileContext the {@link ProfileContext} for the profile whose data is shown
* @param title the column title
*/
protected <U> void cfgPctCol(TreeTableColumn<U, Number> column, String propertyName,
ProfileContext profileContext, String title)
{
column.setCellValueFactory(new TreeItemPropertyValueFactory<>(propertyName));
column.setCellFactory(col -> new PercentageTreeTableCell<>(null));
configureHeader(column, title, profileContext);
addColumnMenuItem(column, title, profileContext);
}
示例9: cfgPctDiffCol
import javafx.scene.control.TreeTableColumn; //導入方法依賴的package包/類
/**
* Configures a {@link TreeTableColumn} containing the percentage difference comparing two profiles.
* <p>
*
* @param <U> the type of the items in the {@link TableView} containing the {@link TableColumn}
* @param column the column being configured
* @param propertyName the name of the property containing the value for this column
* @param title the column title
*/
protected <U> void cfgPctDiffCol(TreeTableColumn<U, Number> column, String propertyName,
String title)
{
column.setCellValueFactory(new TreeItemPropertyValueFactory<>(propertyName));
column.setCellFactory(col -> new PercentageTreeTableCell<>(doubleDiffStyler));
configureHeader(column, title, null);
addColumnMenuItem(column, title, null);
}
示例10: cfgNrCol
import javafx.scene.control.TreeTableColumn; //導入方法依賴的package包/類
/**
* Configures a {@link TreeTableColumn} containing numbers calculated for a single profile.
* <p>
*
* @param <U> the type of the items in the {@link TableView} containing the {@link TableColumn}
* @param column the column being configured
* @param propertyName the name of the property containing the value for this column
* @param profileContext the {@link ProfileContext} for the profile whose data is shown
* @param title the column title
*/
protected <U> void cfgNrCol(TreeTableColumn<U, Number> column, String propertyName,
ProfileContext profileContext, String title)
{
column.setCellValueFactory(new TreeItemPropertyValueFactory<>(propertyName));
column.setCellFactory(col -> new CountTreeTableCell<>(null));
configureHeader(column, title, profileContext);
addColumnMenuItem(column, title, profileContext);
}
示例11: cfgNrDiffCol
import javafx.scene.control.TreeTableColumn; //導入方法依賴的package包/類
/**
* Configures a {@link TreeTableColumn} containing the number difference comparing two profiles.
* <p>
*
* @param <U> the type of the items in the {@link TableView} containing the {@link TableColumn}
* @param column the column being configured
* @param propertyName the name of the property containing the value for this column
* @param title the column title
*/
protected <U> void cfgNrDiffCol(TreeTableColumn<U, Number> column, String propertyName,
String title)
{
column.setCellValueFactory(new TreeItemPropertyValueFactory<>(propertyName));
column.setCellFactory(col -> new CountTreeTableCell<>(intDiffStyler));
configureHeader(column, title, null);
addColumnMenuItem(column, title, null);
}
示例12: cfgTimeCol
import javafx.scene.control.TreeTableColumn; //導入方法依賴的package包/類
/**
* Configures a {@link TreeTableColumn} containing durations calculated for a single profile.
* <p>
*
* @param <U> the type of the items in the {@link TableView} containing the {@link TableColumn}
* @param column the column being configured
* @param propertyName the name of the property containing the value for this column
* @param profileContext the {@link ProfileContext} for the profile whose data is shown
* @param title the column title
*/
protected <U> void cfgTimeCol(TreeTableColumn<U, Number> column, String propertyName,
ProfileContext profileContext, String title)
{
column.setCellValueFactory(new TreeItemPropertyValueFactory<>(propertyName));
column.setCellFactory(col -> new TimeTreeTableCell<>(null));
configureHeader(column, title, profileContext);
addColumnMenuItem(column, title, profileContext);
}
示例13: cfgTimeDiffCol
import javafx.scene.control.TreeTableColumn; //導入方法依賴的package包/類
/**
* Configures a {@link TableColumn} containing the duration difference comparing two profiles.
* <p>
*
* @param <U> the type of the items in the {@link TableView} containing the {@link TableColumn}
* @param column the column being configured
* @param propertyName the name of the property containing the value for this column
* @param title the column title
*/
protected <U> void cfgTimeDiffCol(TreeTableColumn<U, Number> column, String propertyName,
String title)
{
column.setCellValueFactory(new TreeItemPropertyValueFactory<>(propertyName));
column.setCellFactory(col -> new TimeTreeTableCell<>(longDiffStyler));
configureHeader(column, title, null);
addColumnMenuItem(column, title, null);
}