Java 类javafx.beans.binding.NumberExpression 实例源码

项目:jfx.radialmenu    文件:RadialMenuSectionDynamic.java   
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;
    }
项目:Moxy-Parser    文件:MinimumDoubleBinding.java   
@Override
protected double calculate() {
    double value = Double.MAX_VALUE;
    for (NumberExpression expression : expressions) {
        value = Math.min(value, expression.getValue().doubleValue());
    }
    return value;
}
项目:Moxy-Parser    文件:RangedDoubleBinding.java   
/**
 * @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()]));
}
项目:Moxy-Parser    文件:RangedDoubleBinding.java   
/**
 * @param expressions
 *            the expressions we wish to perform an operation against
 */
public RangedDoubleBinding(NumberExpression... expressions) {
    super();
    this.expressions = FXCollections.observableArrayList(expressions);

    this.bind(expressions);
}
项目:Moxy-Parser    文件:SumDoubleBinding.java   
@Override
protected double calculate() {
    double value = 0;
    for(NumberExpression expression: expressions){
        value += expression.getValue().doubleValue();
    }
    return value;
}
项目:Moxy-Parser    文件:AverageDoubleBinding.java   
@Override
protected double calculate() {
    double value = 0;
    for(NumberExpression expression: expressions){
        value += expression.getValue().doubleValue();
    }
    return value / expressions.size();
}
项目:Moxy-Parser    文件:MaximumDoubleBinding.java   
@Override
protected double calculate() {
    double value = Double.MIN_VALUE;
    for(NumberExpression expression: expressions){
        double expressionValue = expression.doubleValue();
        value = Math.max(value, expressionValue);
    }
    return value;
}
项目:ReactFX    文件:FibTest.java   
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]);
    }
}
项目:gemoc-studio-modeldebugging    文件:MultidimensionalTimelineRenderer.java   
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();
    }
项目:VocabHunter    文件:ProgressModel.java   
private NumberBinding bindPercentage(final NumberExpression property, final NumberBinding total) {
    return Bindings.when(property.isEqualTo(0)).then(0).otherwise(property.multiply(PERCENT).divide(total));
}
项目:Tourney    文件:PairingView.java   
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;
}
项目:Tourney    文件:PairingView.java   
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)));
    }
}
项目:Tourney    文件:PairingView.java   
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);
}
项目:ModelDebugging    文件:MultidimensionalTimelineRenderer.java   
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();
    }
项目:Moxy-Parser    文件:AbsoluteDoubleBinding.java   
/**
 * @param expression the expression we wish to get the absoloute value of
 */
public AbsoluteDoubleBinding(NumberExpression expression) {
    super();
    this.expression = expression;
    this.bind(expression);
}
项目:Moxy-Parser    文件:MinimumDoubleBinding.java   
/**
 * @param expressions the expressions we want the smallest of
 */
public MinimumDoubleBinding(Collection<NumberExpression> expressions) {
    super(expressions);
}
项目:Moxy-Parser    文件:MinimumDoubleBinding.java   
/**
 * @param expressions the expressions we want to find the smallest of
 */
public MinimumDoubleBinding(NumberExpression... expressions) {
    super(expressions);
}
项目:Moxy-Parser    文件:RangedDoubleBinding.java   
/**
 * Add an expression to be considered for calculation
 * @param expression
 */
public void addExpression(NumberExpression expression) {
    this.bind(expression);
    expressions.add(expression);
}
项目:Moxy-Parser    文件:RangedDoubleBinding.java   
/**
 * Remove an expression to be considered for calculation
 * @param expression
 */
public void removeExpression(NumberExpression expression) {
    this.unbind(expression);
    expressions.remove(expression);
}
项目:Moxy-Parser    文件:PropertyMath.java   
public static AbsoluteDoubleBinding abs(NumberExpression expression) {
    return new AbsoluteDoubleBinding(expression);
}
项目:Moxy-Parser    文件:PropertyMath.java   
public static AverageDoubleBinding avg(NumberExpression... expressions) {
    return new AverageDoubleBinding(expressions);
}
项目:Moxy-Parser    文件:PropertyMath.java   
public static AverageDoubleBinding avg(
        Collection<NumberExpression> expressions) {
    return new AverageDoubleBinding(expressions);
}
项目:Moxy-Parser    文件:PropertyMath.java   
public static MaximumDoubleBinding max(NumberExpression... expressions) {
    return new MaximumDoubleBinding(expressions);
}
项目:Moxy-Parser    文件:PropertyMath.java   
public static MaximumDoubleBinding max(
        Collection<NumberExpression> expressions) {
    return new MaximumDoubleBinding(expressions);
}
项目:Moxy-Parser    文件:PropertyMath.java   
public static MinimumDoubleBinding min(NumberExpression... expressions) {
    return new MinimumDoubleBinding(expressions);
}
项目:Moxy-Parser    文件:PropertyMath.java   
public static MinimumDoubleBinding min(
        Collection<NumberExpression> expressions) {
    return new MinimumDoubleBinding(expressions);
}
项目:Moxy-Parser    文件:PropertyMath.java   
public static SumDoubleBinding sum(NumberExpression... expressions) {
    return new SumDoubleBinding(expressions);
}
项目:Moxy-Parser    文件:PropertyMath.java   
public static SumDoubleBinding sum(Collection<NumberExpression> expressions) {
    return new SumDoubleBinding(expressions);
}
项目:Moxy-Parser    文件:SumDoubleBinding.java   
/**
 * @param expressions the expressions we want the total of
 */
public SumDoubleBinding(Collection<NumberExpression> expressions) {
    super(expressions);
}
项目:Moxy-Parser    文件:SumDoubleBinding.java   
/**
 * @param expressions the expressions we want the total of
 */
public SumDoubleBinding(NumberExpression... expressions) {
    super(expressions);
}
项目:Moxy-Parser    文件:AverageDoubleBinding.java   
/**
 * @param expressions the expressions we want the average of
 */
public AverageDoubleBinding(Collection<NumberExpression> expressions) {
    super(expressions);
}
项目:Moxy-Parser    文件:AverageDoubleBinding.java   
/**
 * @param expressions the expressions we want the average of.
 */
public AverageDoubleBinding(NumberExpression... expressions) {
    super(expressions);
}
项目:Moxy-Parser    文件:MaximumDoubleBinding.java   
/**
 * @param expressions the expressions we want the largest of
 */
public MaximumDoubleBinding(Collection<NumberExpression> expressions) {
    super(expressions);
}
项目:Moxy-Parser    文件:MaximumDoubleBinding.java   
/**
 * @param expressions the expressions we want to find the largest of
 */
public MaximumDoubleBinding(NumberExpression... expressions) {
    super(expressions);
}