本文整理汇总了Java中javafx.beans.binding.NumberExpression类的典型用法代码示例。如果您正苦于以下问题:Java NumberExpression类的具体用法?Java NumberExpression怎么用?Java NumberExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NumberExpression类属于javafx.beans.binding包,在下文中一共展示了NumberExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addItem
import javafx.beans.binding.NumberExpression; //导入依赖的package包/类
public RadialItem addItem(MenuItem item) {
final DoubleExpression idx = new SimpleDoubleProperty(items.size());
final NumberExpression itemRange = new When(params.directionProperty().isEqualTo(Direction.CW))
.then(idx.divide(itemsCount.subtract(1)))
.otherwise(itemsCount.subtract(idx.add(1)).divide(itemsCount.subtract(1)));
final DoubleExpression itemAngleDeg = correctedStreakAngleDeg.add(angularTotalSizeDeg.multiply(itemRange)).subtract(angularTotalSizeDeg.multiply(0.5));
final RadialItem itemButton = new RadialItem(params, item.getGraphic(), item.getText(), this, itemAngleDeg,
(parentSection != null) ? parentSection.nominalRadius : new SimpleDoubleProperty(0),
(item instanceof Menu));
items.add(itemButton);
radialPane.getChildren().add(itemButton);
return itemButton;
}
示例2: calculate
import javafx.beans.binding.NumberExpression; //导入依赖的package包/类
@Override
protected double calculate() {
double value = Double.MAX_VALUE;
for (NumberExpression expression : expressions) {
value = Math.min(value, expression.getValue().doubleValue());
}
return value;
}
示例3: RangedDoubleBinding
import javafx.beans.binding.NumberExpression; //导入依赖的package包/类
/**
* @param expressions
* the expressions we wish to perform an operation against
*/
public RangedDoubleBinding(Collection<NumberExpression> expressions) {
super();
this.expressions = FXCollections.observableArrayList(expressions);
this.bind(expressions.toArray(new NumberExpression[expressions.size()]));
}
示例4: calculate
import javafx.beans.binding.NumberExpression; //导入依赖的package包/类
@Override
protected double calculate() {
double value = 0;
for(NumberExpression expression: expressions){
value += expression.getValue().doubleValue();
}
return value;
}
示例5: calculate
import javafx.beans.binding.NumberExpression; //导入依赖的package包/类
@Override
protected double calculate() {
double value = 0;
for(NumberExpression expression: expressions){
value += expression.getValue().doubleValue();
}
return value / expressions.size();
}
示例6: calculate
import javafx.beans.binding.NumberExpression; //导入依赖的package包/类
@Override
protected double calculate() {
double value = Double.MIN_VALUE;
for(NumberExpression expression: expressions){
double expressionValue = expression.doubleValue();
value = Math.max(value, expressionValue);
}
return value;
}
示例7: FibTest
import javafx.beans.binding.NumberExpression; //导入依赖的package包/类
private FibTest(int n) {
N = n;
fib = new NumberExpression[N];
fib[0] = new SimpleLongProperty(0);
fib[1] = new SimpleLongProperty(0);
for(int i = 2; i < N; ++i) {
fib[i] = fib[i-2].add(fib[i-1]);
}
}
示例8: createSteps
import javafx.beans.binding.NumberExpression; //导入依赖的package包/类
private NumberExpression createSteps(Step<?> step, int depth, int currentStateIndex, int selectedStateIndex, int firstStateIndex, int lastStateIndex,
List<Path> accumulator, Object[] stepTargets) {
final int stepStartingIndex = traceExtractor.getStateIndex(step.getStartingState());
final boolean endedStep = step.getEndingState() != null;
final int startingIndex = stepStartingIndex - currentStateIndex;
final int endingIndex = (endedStep ? traceExtractor.getStateIndex(step.getEndingState())
: nbStates.intValue()) - currentStateIndex;
final Path path = new Path();
path.setStrokeWidth(2);
final double x1 = startingIndex * UNIT + UNIT / 2;
final double x4 = endingIndex * UNIT + UNIT / 2;
final double x2 = x1 + UNIT / 4;
final double x3 = x4 - UNIT / 4;
final double baseLineY = DIAMETER / 2 + V_MARGIN;
final MoveTo moveTo = new MoveTo(x1, baseLineY);
final LineTo lineTo = new LineTo(x2, baseLineY);
final HLineTo hLineTo = new HLineTo(x3);
path.getElements().addAll(moveTo, lineTo, hLineTo);
if (endedStep) {
final LineTo lastLineTo = new LineTo(x4, baseLineY);
path.getElements().add(lastLineTo);
}
accumulator.add(path);
final List<? extends Step<?>> subSteps = traceExtractor.getSubSteps(step);
NumberExpression yOffset = new SimpleDoubleProperty(0);
if (subSteps != null && !subSteps.isEmpty()) {
for (Step<?> subStep : subSteps) {
if (subStep.getStartingState() != subStep.getEndingState()
// && ((traceExtractor.getStateIndex(subStep.getEndingState()) < firstStateIndex) || traceExtractor.getStateIndex(subStep.getStartingState()) > lastStateIndex)
) {
yOffset = Bindings.max(yOffset, createSteps(subStep, depth + 1, currentStateIndex, selectedStateIndex, firstStateIndex, lastStateIndex, accumulator, stepTargets));
}
}
}
lineTo.yProperty().bind(yOffset.add(DIAMETER / 2 + V_MARGIN));
if (stepTargets[CURRENT_FORWARD_STEP] == step) {
path.setStroke(Color.DARKORANGE);
} else if (stepTargets[CURRENT_BACKWARD_STEP] == step) {
path.setStroke(Color.DARKGREEN);
} else if (stepTargets[CURRENT_BIGSTEP] == step) {
path.setStroke(Color.DARKRED);
} else {
path.setStroke(Color.DARKBLUE);
if (!traceExplorer.getCallStack().contains(step) && (stepStartingIndex > selectedStateIndex
|| (stepStartingIndex == selectedStateIndex && endedStep))) {
path.getStrokeDashArray().addAll(5., 5.);
path.setStrokeLineCap(StrokeLineCap.ROUND);
}
}
return lineTo.yProperty();
}
示例9: bindPercentage
import javafx.beans.binding.NumberExpression; //导入依赖的package包/类
private NumberBinding bindPercentage(final NumberExpression property, final NumberBinding total) {
return Bindings.when(property.isEqualTo(0)).then(0).otherwise(property.multiply(PERCENT).divide(total));
}
示例10: 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;
}
示例11: 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)));
}
}
示例12: createConnection
import javafx.beans.binding.NumberExpression; //导入依赖的package包/类
private void createConnection(PairingNode previousNode,
Player previousPlayer, PairingNode nextNode, List<Node> nodes) {
Line horizontal1 = new Line();
horizontal1.setFill(Color.TRANSPARENT);
horizontal1.setStroke(Color.BLACK);
horizontal1.setStrokeWidth(2);
Line vertical = new Line();
vertical.setFill(Color.TRANSPARENT);
vertical.setStroke(Color.BLACK);
vertical.setStrokeWidth(2);
Line horizontal2 = new Line();
horizontal2.setFill(Color.TRANSPARENT);
horizontal2.setStroke(Color.BLACK);
horizontal2.setStrokeWidth(2);
NumberExpression left = new DoubleBinding() {
{
super.bind(previousNode.layoutXProperty(),
previousNode.widthProperty());
}
@Override
protected double computeValue() {
return previousNode.getLayoutX() + previousNode.getWidth();
}
};
NumberExpression top = new DoubleBinding() {
{
super.bind(previousNode.layoutYProperty(),
previousNode.heightProperty());
}
@Override
protected double computeValue() {
return Math.floor(previousNode.getLayoutY()
+ previousNode.getHeight() / 2d);
}
};
NumberExpression bottom = new DoubleBinding() {
{
super.bind(nextNode.layoutYProperty(),
nextNode.heightProperty());
}
@Override
protected double computeValue() {
return Math.floor(nextNode.getLayoutY() + nextNode.getHeight()
/ 2d);
}
};
NumberExpression center = new DoubleBinding() {
{
super.bind(nextNode.layoutXProperty());
}
@Override
protected double computeValue() {
return Math.floor(nextNode.getLayoutX() - 25);
}
};
horizontal1.startXProperty().bind(left);
horizontal1.endXProperty().bind(center);
horizontal1.startYProperty().bind(top);
horizontal1.endYProperty().bind(top);
vertical.startXProperty().bind(center);
vertical.endXProperty().bind(center);
vertical.startYProperty().bind(top);
vertical.endYProperty().bind(bottom);
horizontal2.startXProperty().bind(center);
horizontal2.endXProperty().bind(nextNode.layoutXProperty());
horizontal2.startYProperty().bind(bottom);
horizontal2.endYProperty().bind(bottom);
nodes.add(horizontal1);
nodes.add(vertical);
nodes.add(horizontal2);
}
示例13: AbsoluteDoubleBinding
import javafx.beans.binding.NumberExpression; //导入依赖的package包/类
/**
* @param expression the expression we wish to get the absoloute value of
*/
public AbsoluteDoubleBinding(NumberExpression expression) {
super();
this.expression = expression;
this.bind(expression);
}
示例14: MinimumDoubleBinding
import javafx.beans.binding.NumberExpression; //导入依赖的package包/类
/**
* @param expressions the expressions we want the smallest of
*/
public MinimumDoubleBinding(Collection<NumberExpression> expressions) {
super(expressions);
}
示例15: addExpression
import javafx.beans.binding.NumberExpression; //导入依赖的package包/类
/**
* Add an expression to be considered for calculation
* @param expression
*/
public void addExpression(NumberExpression expression) {
this.bind(expression);
expressions.add(expression);
}