本文整理匯總了Java中javafx.scene.control.TreeTableColumn類的典型用法代碼示例。如果您正苦於以下問題:Java TreeTableColumn類的具體用法?Java TreeTableColumn怎麽用?Java TreeTableColumn使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TreeTableColumn類屬於javafx.scene.control包,在下文中一共展示了TreeTableColumn類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setupGroupView
import javafx.scene.control.TreeTableColumn; //導入依賴的package包/類
private void setupGroupView() {
groupList = new JFXTreeTableView<>();
TreeTableColumn<GroupTreeObject, String> nameColumn = new JFXTreeTableColumn<>("Name");
nameColumn.setPrefWidth(150);
nameColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures<GroupTreeObject, String> param) -> {
Group group = fromItem(param.getValue());
if (group == null) {
return new SimpleStringProperty();
}
return new SimpleStringProperty(group.getDisplayName());
});
groupList.getColumns().add(nameColumn);
TreeItem treeItem = new TreeItem<>();
treeItem.setExpanded(true);
groupList.setRoot(treeItem);
groupList.setShowRoot(false);
groupList.setPrefHeight(Short.MAX_VALUE);
}
示例2: getTestContainer
import javafx.scene.control.TreeTableColumn; //導入依賴的package包/類
@Override
protected Node getTestContainer() {
treeOrTreeTableView = new TreeTableView<Data>();
treeOrTreeTableView.setMinSize(300, 500);
treeOrTreeTableView.setMaxSize(300, 500);
treeOrTreeTableView.setPrefSize(300, 500);
TreeTableColumn<Data, Node> column = new TreeTableColumn<Data, Node>("Items' name");
column.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<Data, Node>, ObservableValue<Node>>() {
@Override
public ObservableValue<Node> call(final TreeTableColumn.CellDataFeatures<Data, Node> p) {
SimpleObjectProperty<Node> text = new SimpleObjectProperty<Node>();
text.setValue(new Label(p.getValue().getValue().getData()));
return text;
}
});
column.setPrefWidth(150);
((TreeTableView) treeOrTreeTableView).getColumns().add(column);
reset(0);
return treeOrTreeTableView;
}
示例3: testCollapsedNodeGraphicVisible
import javafx.scene.control.TreeTableColumn; //導入依賴的package包/類
/**
* 8158784: [TEST BUG] Need test for JDK-8157398
*/
@Test
public void testCollapsedNodeGraphicVisible() throws Exception {
Color nodeColor = new Color(Math.random(), Math.random(), Math.random(), 1);
TreeTableView treeTable = (TreeTableView) testedControl.getControl();
TreeItem<String> root = new TreeItem<>("Root Node");
TreeItem<String> child = new TreeItem<>("Child", new Rectangle(10, 10, nodeColor));
TreeTableColumn<String, String> column = new TreeTableColumn<>("Column");
column.setCellValueFactory(item -> new SimpleStringProperty("Whatever"));
treeTable.getColumns().setAll(column);
root.getChildren().add(child);
root.setExpanded(true);
treeTable.setShowRoot(true);
runAndWait(() -> {
treeTable.setRoot(root);
});
Wrap nodeGraphic = parent.lookup(node -> node == child.getGraphic()).wrap();
Wrap sceneWrap = Root.ROOT.lookup().wrap();
waitForColor(nodeGraphic, 1, 1, nodeColor);
Bounds graphicBounds = child.getGraphic().localToScene(child.getGraphic().getBoundsInLocal());
root.setExpanded(false);
waitForColor(sceneWrap,
(int) (graphicBounds.getMinX() + graphicBounds.getWidth() / 2),
(int) (graphicBounds.getMinY() + graphicBounds.getHeight() / 2), Color.WHITE);
}
示例4: getTreeTableItemText
import javafx.scene.control.TreeTableColumn; //導入依賴的package包/類
@SuppressWarnings("unchecked") private String getTreeTableItemText(TreeTableView<?> treeTableView,
TreeItem<?> lastPathComponent) {
@SuppressWarnings("rawtypes")
TreeTableColumn treeTableColumn = treeTableView.getTreeColumn();
if (treeTableColumn == null) {
treeTableColumn = treeTableView.getColumns().get(0);
}
ObservableValue<?> cellObservableValue = treeTableColumn.getCellObservableValue(lastPathComponent);
String original = cellObservableValue.getValue().toString();
String itemText = original;
int suffixIndex = 0;
TreeItem<?> parent = lastPathComponent.getParent();
if (parent == null)
return itemText;
ObservableList<?> children = parent.getChildren();
for (int i = 0; i < children.indexOf(lastPathComponent); i++) {
TreeItem<?> child = (TreeItem<?>) children.get(i);
cellObservableValue = treeTableColumn.getCellObservableValue(child);
String current = cellObservableValue.getValue().toString();
if (current.equals(original)) {
itemText = String.format("%s(%d)", original, ++suffixIndex);
}
}
return itemText;
}
示例5: selectTreeTableCells
import javafx.scene.control.TreeTableColumn; //導入依賴的package包/類
@SuppressWarnings("unchecked") protected void selectTreeTableCells(TreeTableView<?> treeTableView, String value) {
@SuppressWarnings("rawtypes")
TreeTableViewSelectionModel selectionModel = treeTableView.getSelectionModel();
JSONObject cells = new JSONObject(value);
JSONArray object = (JSONArray) cells.get("cells");
for (int i = 0; i < object.length(); i++) {
JSONArray jsonArray = object.getJSONArray(i);
int rowIndex = getTreeTableNodeIndex(treeTableView, jsonArray.getString(0));
int columnIndex = getTreeTableColumnIndex(treeTableView, jsonArray.getString(1));
@SuppressWarnings("rawtypes")
TreeTableColumn column = treeTableView.getColumns().get(columnIndex);
if (getVisibleCellAt(treeTableView, rowIndex, columnIndex) == null) {
treeTableView.scrollToColumn(column);
treeTableView.scrollTo(rowIndex);
}
selectionModel.select(rowIndex, column);
}
}
示例6: selectMultipleCells
import javafx.scene.control.TreeTableColumn; //導入依賴的package包/類
@SuppressWarnings("unchecked") @Test public void selectMultipleCells() {
TreeTableView<?> treeTableView = (TreeTableView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-table-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(() -> {
TreeTableViewSelectionModel<?> selectionModel = treeTableView.getSelectionModel();
selectionModel.setCellSelectionEnabled(true);
selectionModel.setSelectionMode(SelectionMode.MULTIPLE);
Point2D point = getPoint(treeTableView, 1, 0);
RFXTreeTableView rfxTreeTableView = new RFXTreeTableView(treeTableView, null, point, lr);
rfxTreeTableView.focusGained(null);
@SuppressWarnings("rawtypes")
TreeTableColumn column = getTreeTableColumnAt(treeTableView, 0);
selectionModel.select(1, column);
selectionModel.select(3, getTreeTableColumnAt(treeTableView, 1));
rfxTreeTableView.focusLost(null);
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals(
"{\"cells\":[[\"/Sales Department/Ethan Williams\",\"Employee\"],[\"/Sales Department/Michael Brown\",\"Email\"]]}",
recording.getParameters()[0]);
}
示例7: selectACell
import javafx.scene.control.TreeTableColumn; //導入依賴的package包/類
@SuppressWarnings("unchecked") @Test public void selectACell() {
TreeTableView<?> treeTableView = (TreeTableView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-table-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(() -> {
TreeTableViewSelectionModel<?> selectionModel = treeTableView.getSelectionModel();
selectionModel.setCellSelectionEnabled(true);
Point2D point = getPoint(treeTableView, 1, 0);
RFXTreeTableView rfxTreeTableView = new RFXTreeTableView(treeTableView, null, point, lr);
rfxTreeTableView.focusGained(null);
@SuppressWarnings("rawtypes")
TreeTableColumn column = getTreeTableColumnAt(treeTableView, 0);
selectionModel.select(1, column);
rfxTreeTableView.focusLost(null);
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals("{\"cells\":[[\"/Sales Department/Ethan Williams\",\"Employee\"]]}", recording.getParameters()[0]);
}
示例8: call
import javafx.scene.control.TreeTableColumn; //導入依賴的package包/類
@Override
public TreeTableCell<ReferenceDescription, ReferenceDescription> call(TreeTableColumn<ReferenceDescription, ReferenceDescription> param) {
return new TreeTableCell<ReferenceDescription, ReferenceDescription>() {
@Override
protected void updateItem(ReferenceDescription item, boolean empty) {
super.updateItem(item, empty);
if (!empty && item != null) {
setText(item.getDisplayName().getText());
setGraphic(createGraphicNode(item));
} else {
setText(null);
setGraphic(null);
}
}
};
}
示例9: resizeColumn
import javafx.scene.control.TreeTableColumn; //導入依賴的package包/類
void resizeColumn(final int index, final double delta) {
final double initialWidth = getColumnWidth(index);
new GetAction<Void>() {
@Override
public void run(Object... os) throws Exception {
if (isTableTests) {
TableView table = (TableView) testedControl.getControl();
table.resizeColumn((TableColumn) table.getColumns().get(index), delta);
} else {
TreeTableView treeTable = (TreeTableView) testedControl.getControl();
treeTable.resizeColumn((TreeTableColumn) treeTable.getColumns().get(index), delta);
}
}
}.dispatch(testedControl.getEnvironment());
new Waiter(new Timeout("", 1000)).waitState(new State<Boolean>() {
public Boolean reached() {
return (Math.abs(getColumnWidth(index) - initialWidth - delta) <= 1e-7) ? Boolean.TRUE : null;
}
});
}
示例10: getNextColumn
import javafx.scene.control.TreeTableColumn; //導入依賴的package包/類
/**
* @param forward true gets the column to the right, false the column to the left of the current column
* @return
*/
private TreeTableColumn<S, ?> getNextColumn(boolean forward) {
List<TreeTableColumn<S, ?>> columns = new ArrayList<>();
for (TreeTableColumn<S, ?> column : getTreeTableView().getColumns()) {
columns.addAll(getLeaves(column));
}
//There is no other column that supports editing.
if (columns.size() < 2) {
return null;
}
int nextIndex = columns.indexOf(getTableColumn());
if (forward) {
nextIndex++;
if (nextIndex > columns.size() - 1) {
nextIndex = 0;
}
} else {
nextIndex--;
if (nextIndex < 0) {
nextIndex = columns.size() - 1;
}
}
return columns.get(nextIndex);
}
示例11: group
import javafx.scene.control.TreeTableColumn; //導入依賴的package包/類
/**
* this is a blocking method so it should not be called from the ui thread,
* it will regroup the tree table view
* @param treeTableColumns
*/
public void group(TreeTableColumn<S, ?>... treeTableColumns) {
try{
lock.lock();
// init groups map
if (groupOrder.size() == 0) {
groups = new HashMap<>();
}
try {
if (originalRoot == null) {
originalRoot = getRoot();
}
for (TreeTableColumn<S, ?> treeTableColumn : treeTableColumns) {
groups = group(treeTableColumn, groups, null, (RecursiveTreeItem<S>) originalRoot);
}
groupOrder.addAll(treeTableColumns);
// update table ui
buildGroupedRoot(groups, null, 0);
} catch (Exception e) {
e.printStackTrace();
}
}finally {
lock.unlock();
}
}
示例12: call
import javafx.scene.control.TreeTableColumn; //導入依賴的package包/類
@Override
public TreeTableCell<FeatureTableRow, Object> call(TreeTableColumn<FeatureTableRow, Object> p) {
return new TreeTableCell<FeatureTableRow, Object>() {
@Override
public void updateItem(Object object, boolean empty) {
super.updateItem(object, empty);
setStyle("-fx-alignment: CENTER;"
+ "-fx-border-color: transparent -fx-table-cell-border-color -fx-table-cell-border-color transparent;");
if (object == null) {
setText(null);
} else {
NumberFormat formatter = MZmineCore.getConfiguration().getMZFormat();
Double doubleValue = Double.parseDouble(object.toString());
setText(formatter.format(doubleValue));
}
}
};
}
示例13: call
import javafx.scene.control.TreeTableColumn; //導入依賴的package包/類
@Override
public TreeTableCell<FeatureTableRow, Object> call(TreeTableColumn<FeatureTableRow, Object> p) {
return new TreeTableCell<FeatureTableRow, Object>() {
@Override
public void updateItem(Object object, boolean empty) {
super.updateItem(object, empty);
setStyle("-fx-alignment: CENTER;"
+ "-fx-border-color: transparent -fx-table-cell-border-color -fx-table-cell-border-color transparent;");
if (object == null) {
setText(null);
} else {
try {
NumberFormat formatter = new DecimalFormat("#0.00");
Double doubleValue = Double.parseDouble(object.toString());
setText(formatter.format(doubleValue));
} catch (NumberFormatException e) {
setText(object.toString());
}
}
}
};
}
示例14: call
import javafx.scene.control.TreeTableColumn; //導入依賴的package包/類
@Override
public TreeTableCell<FeatureTableRow, Object> call(TreeTableColumn<FeatureTableRow, Object> p) {
return new TreeTableCell<FeatureTableRow, Object>() {
@Override
public void updateItem(Object object, boolean empty) {
super.updateItem(object, empty);
setStyle("-fx-alignment: CENTER;"
+ "-fx-border-color: transparent -fx-table-cell-border-color -fx-table-cell-border-color transparent;");
if (object == null) {
setText(null);
} else {
Integer integerValue = Integer.parseInt(object.toString());
setText(integerValue.toString());
}
}
};
}
示例15: call
import javafx.scene.control.TreeTableColumn; //導入依賴的package包/類
@Override
public TreeTableCell<FeatureTableRow, Object> call(TreeTableColumn<FeatureTableRow, Object> p) {
return new TreeTableCell<FeatureTableRow, Object>() {
@Override
public void updateItem(Object object, boolean empty) {
super.updateItem(object, empty);
setStyle("-fx-alignment: CENTER;"
+ "-fx-border-color: transparent -fx-table-cell-border-color -fx-table-cell-border-color transparent;");
if (object == null) {
setText(null);
} else {
Range rangeValue = (Range) object;
NumberFormat formatter = MZmineCore.getConfiguration().getMZFormat();
String value = formatter.format(rangeValue.lowerEndpoint()) + " - "
+ formatter.format(rangeValue.upperEndpoint());
setText(value);
}
}
};
}