本文整理汇总了Java中javafx.beans.binding.NumberExpression.add方法的典型用法代码示例。如果您正苦于以下问题:Java NumberExpression.add方法的具体用法?Java NumberExpression.add怎么用?Java NumberExpression.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.beans.binding.NumberExpression
的用法示例。
在下文中一共展示了NumberExpression.add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generatePairingNodes
import javafx.beans.binding.NumberExpression; //导入方法依赖的package包/类
private List<Node> generatePairingNodes(List<List<Pairing>> pairings,
NumberExpression xMin, NumberExpression yMin) {
List<Node> nodes = new ArrayList<>();
List<PairingNode> prevNodes = null;
List<PairingNode> nextNodes = null;
NumberExpression maxX = xMin;
NumberExpression maxY = yMin;
int r = 0;
for (List<Pairing> round : pairings) {
if (round.size() == 0) {
continue;
}
NumberExpression currentMaxX = maxX;
nextNodes = new ArrayList<>();
PairingNode prevNode = null;
int pairingId = 1;
for (Pairing pairing : round) {
PairingNode node = new PairingNode(this.loadedTournament,
pairing, pairingId++);
if (prevNode == null) {
node.layoutYProperty().bind(yMin);
} else {
node.layoutYProperty().bind(
prevNode.layoutYProperty()
.add(prevNode.heightProperty()).add(10));
}
node.layoutXProperty().bind(currentMaxX);
nodes.add(node);
nextNodes.add(node);
maxX = Bindings.max(maxX,
node.layoutXProperty().add(node.widthProperty())
.add(50));
maxY = Bindings.max(maxY,
node.layoutYProperty().add(node.heightProperty()));
prevNode = node;
}
if (prevNodes != null && nextNodes.size() > 0) {
this.createConnections(prevNodes, nextNodes, nodes);
}
prevNodes = nextNodes;
maxX.add(50);
}
return nodes;
}
示例2: createConnections
import javafx.beans.binding.NumberExpression; //导入方法依赖的package包/类
private void createConnections(List<PairingNode> previousPairings,
List<PairingNode> nextPairings, List<Node> nodes) {
Map<PairingNode, List<PairingNode>> precedingNodes = new HashMap<>();
for (PairingNode prev : previousPairings) {
Pairing prevPairing = prev.getPairing();
for (Player prevPlayer : prevPairing.getOpponents()) {
for (PairingNode next : nextPairings) {
List<PairingNode> predecessors = precedingNodes.get(next);
if (predecessors == null) {
predecessors = new ArrayList<>();
precedingNodes.put(next, predecessors);
}
Pairing nextPairing = next.getPairing();
if (this.collectionContainsPlayer(
nextPairing.getOpponents(), prevPlayer)) {
predecessors.add(prev);
this.createConnection(prev, prevPlayer, next, nodes);
break;
}
}
}
}
for (Entry<PairingNode, List<PairingNode>> entry : precedingNodes
.entrySet()) {
NumberExpression averageY = new SimpleDoubleProperty(0);
for (PairingNode node : entry.getValue()) {
averageY = averageY.add(node.layoutYProperty().add(
node.heightProperty().divide(2d)));
}
averageY = averageY.divide((double) entry.getValue().size());
entry.getKey().layoutYProperty().unbind();
entry.getKey()
.layoutYProperty()
.bind(averageY.subtract(entry.getKey().heightProperty()
.divide(2d)));
}
}