本文整理汇总了Java中org.fxmisc.easybind.EasyBind.map方法的典型用法代码示例。如果您正苦于以下问题:Java EasyBind.map方法的具体用法?Java EasyBind.map怎么用?Java EasyBind.map使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.fxmisc.easybind.EasyBind
的用法示例。
在下文中一共展示了EasyBind.map方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setConnections
import org.fxmisc.easybind.EasyBind; //导入方法依赖的package包/类
private void setConnections(ObservableList<ReadOnlyPerson> personList) {
ObservableList<PersonCard> mappedList = EasyBind.map(
personList, (person) -> new PersonCard(person, personList.indexOf(person) + 1));
personListView.setItems(mappedList);
personListView.setCellFactory(listView -> new PersonListViewCell());
setEventHandlerForSelectionChangeEvent();
}
示例2: GroupNodeViewModel
import org.fxmisc.easybind.EasyBind; //导入方法依赖的package包/类
public GroupNodeViewModel(BibDatabaseContext databaseContext, StateManager stateManager, TaskExecutor taskExecutor, GroupTreeNode groupNode) {
this.databaseContext = Objects.requireNonNull(databaseContext);
this.taskExecutor = Objects.requireNonNull(taskExecutor);
this.stateManager = Objects.requireNonNull(stateManager);
this.groupNode = Objects.requireNonNull(groupNode);
LatexToUnicodeFormatter formatter = new LatexToUnicodeFormatter();
displayName = formatter.format(groupNode.getName());
isRoot = groupNode.isRoot();
if (groupNode.getGroup() instanceof AutomaticGroup) {
AutomaticGroup automaticGroup = (AutomaticGroup) groupNode.getGroup();
children = automaticGroup.createSubgroups(databaseContext.getDatabase().getEntries()).stream()
.map(this::toViewModel)
.sorted((group1, group2) -> group1.getDisplayName().compareToIgnoreCase(group2.getDisplayName()))
.collect(Collectors.toCollection(FXCollections::observableArrayList));
} else {
children = BindingsHelper.mapBacked(groupNode.getChildren(), this::toViewModel);
}
hasChildren = new SimpleBooleanProperty();
hasChildren.bind(Bindings.isNotEmpty(children));
hits = new SimpleIntegerProperty(0);
calculateNumberOfMatches();
expandedProperty.set(groupNode.getGroup().isExpanded());
expandedProperty.addListener((observable, oldValue, newValue) -> groupNode.getGroup().setExpanded(newValue));
// Register listener
databaseContext.getDatabase().registerListener(this);
ObservableList<Boolean> selectedEntriesMatchStatus = EasyBind.map(stateManager.getSelectedEntries(), groupNode::matches);
anySelectedEntriesMatched = BindingsHelper.any(selectedEntriesMatchStatus, matched -> matched);
allSelectedEntriesMatched = BindingsHelper.all(selectedEntriesMatchStatus, matched -> matched);
}
示例3: ErrorConsoleViewModel
import org.fxmisc.easybind.EasyBind; //导入方法依赖的package包/类
public ErrorConsoleViewModel(DialogService dialogService, ClipBoardManager clipBoardManager, BuildInfo buildInfo) {
this.dialogService = Objects.requireNonNull(dialogService);
this.clipBoardManager = Objects.requireNonNull(clipBoardManager);
this.buildInfo = Objects.requireNonNull(buildInfo);
ObservableList<LogEventViewModel> eventViewModels = EasyBind.map(LogMessages.getInstance().getMessages(), LogEventViewModel::new);
allMessagesData = new ReadOnlyListWrapper<>(eventViewModels);
}
示例4: Item
import org.fxmisc.easybind.EasyBind; //导入方法依赖的package包/类
Item(String id, String initText) {
this.id = id;
this.setText(initText);
final ObservableList<ReadOnlyIntegerProperty> numbersOfAllSubItems = EasyBind.map(openSubItems, Item::recursiveNumberOfOpenSubItems);
final ObservableValue<Number> sum = EasyBind.combine(numbersOfAllSubItems, stream -> stream.reduce(
(a, b) ->
a.intValue() + b.intValue()).orElse(0));
recursiveNumberOfOpenSubItems.bind(Bindings.size(openSubItems).add(asDouble(sum)));
subItems.addListener((ListChangeListener<Item>) change -> {
while (change.next()) {
if (change.wasAdded()) {
change.getAddedSubList().forEach(item -> {
item.getParent().ifPresent(oldParent -> oldParent.removeSubItem(item));
item.setParent(Item.this);
});
}
if (change.wasRemoved()) {
change.getRemoved().forEach(item -> item.setParent(null));
}
}
});
this.title.bind(Bindings.createStringBinding(() -> {
final String text = getText() == null ? "" : getText();
final String[] lines = text.split("\\r?\\n");
if(lines.length > 0) {
return lines[0];
}
return "";
}, this.text));
}
示例5: WidgetPane
import org.fxmisc.easybind.EasyBind; //导入方法依赖的package包/类
/**
* Creates a new widget pane. This sets up everything needed for dragging widgets and sources
* around in this pane.
*/
public WidgetPane() {
getStyleClass().add("widget-pane");
gridHighlight.getStyleClass().add("grid-highlight");
// Bind the background to show a grid matching the size of the tiles (if enabled via showGrid)
backgroundProperty().bind(
Bindings.createObjectBinding(
this::createGridBackground,
tileSizeProperty(),
hgapProperty(),
vgapProperty(),
showGrid,
gridLineBorderThickness,
secondaryGridLineCount,
secondaryGridLineThickness,
gridLineColor
)
);
tiles = EasyBind.map(getChildren().filtered(n -> n instanceof Tile), n -> (Tile) n);
// Add the highlighter when we're told to highlight
highlight.addListener((__, old, highlight) -> {
if (highlight) {
getChildren().add(gridHighlight);
gridHighlight.toFront();
gridHighlight.setMouseTransparent(true);
} else {
getChildren().remove(gridHighlight);
}
});
// Move the highlighter when the location changes
highlightPoint.addListener((__, old, point) -> {
if (getHighlightSize() == null || point == null) {
return;
}
gridHighlight.toFront();
moveNode(gridHighlight, point);
gridHighlight.pseudoClassStateChanged(
PseudoClass.getPseudoClass("colliding"),
!isOpen(point, getHighlightSize(), DragUtils.isDraggedWidget.or(ResizeUtils.isResizedTile)));
});
// Resize the highlighter then when the size changes
highlightSize.addListener((__, old, size) -> {
if (getHighlightPoint() == null || size == null) {
return;
}
gridHighlight.toFront();
setSize(gridHighlight, size);
gridHighlight.pseudoClassStateChanged(
PseudoClass.getPseudoClass("colliding"),
!isOpen(getHighlightPoint(), size, DragUtils.isDraggedWidget.or(ResizeUtils.isResizedTile)));
});
tileSizeProperty().addListener((__, prev, cur) -> resizeTiles());
hgapProperty().addListener((__, prev, cur) -> resizeTiles());
vgapProperty().addListener((__, prev, cur) -> resizeTiles());
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("WidgetPane.fxml"));
fxmlLoader.setRoot(this);
try {
fxmlLoader.load();
} catch (IOException e) {
throw new IllegalStateException("Can't load FXML : " + getClass().getSimpleName(), e);
}
}
示例6: StateManager
import org.fxmisc.easybind.EasyBind; //导入方法依赖的package包/类
public StateManager() {
MonadicBinding<BibDatabaseContext> currentDatabase = EasyBind.map(activeDatabase, database -> database.orElse(null));
activeGroups.bind(Bindings.valueAt(selectedGroups, currentDatabase));
}
示例7: map
import org.fxmisc.easybind.EasyBind; //导入方法依赖的package包/类
/**
* Returns a new ObservableValue that holds a mapping of the value held
* by this ObservableValue, and is empty when this ObservableValue is empty.
* @param f function to map the value held by this ObservableValue.
*/
default <U> MonadicBinding<U> map(Function<? super T, ? extends U> f) {
return EasyBind.map(this, f);
}