当前位置: 首页>>代码示例>>Java>>正文


Java DoubleBinding类代码示例

本文整理汇总了Java中javafx.beans.binding.DoubleBinding的典型用法代码示例。如果您正苦于以下问题:Java DoubleBinding类的具体用法?Java DoubleBinding怎么用?Java DoubleBinding使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DoubleBinding类属于javafx.beans.binding包,在下文中一共展示了DoubleBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DirectedPath

import javafx.beans.binding.DoubleBinding; //导入依赖的package包/类
/**
 * Constructs and binds the appropriate properties for the line and
 * the arrow
 */
public DirectedPath(DoubleBinding startX, DoubleBinding startY,
                    DoubleBinding endX,DoubleBinding endY){

    this.path = new Path();

    MoveTo start = new MoveTo();
    start.xProperty().bind(startX);
    start.yProperty().bind(startY);

    LineTo end = new LineTo();
    end.xProperty().bind(endX);
    end.yProperty().bind(endY);

    path.getElements().add(start);
    path.getElements().add(end);

    this.arrow = getArrow();

    this.getChildren().add(path);
    this.getChildren().add(arrow);

    this.path.getStyleClass().setAll("edge");
}
 
开发者ID:dmusican,项目名称:Elegit,代码行数:28,代码来源:DirectedPath.java

示例2: initProgressBinding

import javafx.beans.binding.DoubleBinding; //导入依赖的package包/类
private void initProgressBinding() {
	DoubleExpression tmp = constantOf(0);

	for (Command command : registeredCommands) {
		final ReadOnlyDoubleProperty progressProperty = command.progressProperty();

		/**
		 * When the progress of a command is "undefined", the progress property has a value of -1.
		 * But in our use case we like to have a value of 0 in this case. 
		 * Therefore we create a custom binding here.
		 */
		final DoubleBinding normalizedProgress = Bindings
				.createDoubleBinding(() -> (progressProperty.get() == -1) ? 0.0 : progressProperty.get(),
						progressProperty);

		tmp = tmp.add(normalizedProgress);
	}
	
	int divisor = registeredCommands.isEmpty() ? 1 : registeredCommands.size();
	progress.bind(Bindings.divide(tmp, divisor));
}
 
开发者ID:cmlanche,项目名称:easyMvvmFx,代码行数:22,代码来源:CompositeCommand.java

示例3: EdgeView

import javafx.beans.binding.DoubleBinding; //导入依赖的package包/类
public EdgeView(final DoubleProperty sX, final DoubleProperty sY, final DoubleProperty eX,
		final DoubleProperty eY) {
	a = new DoubleBinding() {
		private final DoubleBinding dX = sX.subtract(eX);
		private final DoubleBinding dY = sY.subtract(eY);

		{
			super.bind(dX, dY);
		}

		@Override
		protected double computeValue() {
			return Math.atan2(dY.get(), dX.get());
		}
	};
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:17,代码来源:EdgeView.java

示例4: calculateXBinding

import javafx.beans.binding.DoubleBinding; //导入依赖的package包/类
private static <T extends Circular> ObservableDoubleValue calculateXBinding(final T source, final Point target) {
    return new DoubleBinding() {
        {
            super.bind(source.xProperty(), source.yProperty());
            super.bind(target.xProperty(), target.yProperty());
            super.bind(source.radiusProperty());
            super.bind(source.scaleProperty());
        }

        @Override
        protected double computeValue() {
            final double angle = Math.atan2(source.yProperty().get() - target.yProperty().get(), source.xProperty().get() - target.xProperty().get()) - Math.toRadians(180);
            return source.xProperty().get() + source.radiusProperty().get() * source.scaleProperty().get() * Math.cos(angle);
        }
    };
}
 
开发者ID:ulriknyman,项目名称:H-Uppaal,代码行数:17,代码来源:BindingHelper.java

示例5: calculateYBinding

import javafx.beans.binding.DoubleBinding; //导入依赖的package包/类
private static <T extends Circular> ObservableDoubleValue calculateYBinding(final T source, final Point target) {
    return new DoubleBinding() {
        {
            super.bind(source.xProperty(), source.yProperty());
            super.bind(target.xProperty(), target.yProperty());
            super.bind(source.radiusProperty());
            super.bind(source.scaleProperty());
        }

        @Override
        protected double computeValue() {
            final double angle = Math.atan2(source.yProperty().get() - target.yProperty().get(), source.xProperty().get() - target.xProperty().get()) - Math.toRadians(180);
            return source.yProperty().get() + source.radiusProperty().get() * source.scaleProperty().get() * Math.sin(angle);
        }
    };
}
 
开发者ID:ulriknyman,项目名称:H-Uppaal,代码行数:17,代码来源:BindingHelper.java

示例6: getDouble

import javafx.beans.binding.DoubleBinding; //导入依赖的package包/类
private NumberBinding getDouble(AnimatableField field, NodeModel node, KeyValueModel keyValue, KeyFrameModel keyFrame) {
    DoubleBinding currentValue = ModelFunctions.toDoubleBinding(keyValue.valueProperty());
    KeyFrameModel earlier = getEarlierKeyFrameWithNonNullValue(field, node, keyFrame);
    KeyFrameModel later = getLaterKeyFrameWithNonNullValue(field, node, keyFrame);

    if (earlier != null) {
        DoubleProperty earlierTime = earlier.absoluteTimeProperty();
        double earlierValue = (Double) earlier.getKeyValues().get(node).get(field).getValue();

        if (later != null) {
            DoubleProperty laterTime = later.absoluteTimeProperty();
            double laterValue = (Double) later.getKeyValues().get(node).get(field).getValue();

            DoubleBinding interpolated = Bindings.createDoubleBinding(() -> {
                double timeFraction = (keyFrame.getAbsoluteTime() - earlierTime.get()) / (laterTime.get() - earlierTime.get());
                double interpolatorFactor = later.getKeyValues().get(node).get(field).getInterpolator().curve(timeFraction);
                return (double) Math.round(earlierValue + (laterValue - earlierValue) * interpolatorFactor);
            }, earlierTime, laterTime, keyFrame.absoluteTimeProperty());

            return Bindings.when(keyValue.valueProperty().isNotNull()).then(currentValue).otherwise(interpolated);
        } else {
            return Bindings.when(keyValue.valueProperty().isNotNull()).then(currentValue).otherwise(earlierValue);
        }
    } else {
        return currentValue;
    }
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:28,代码来源:TimelineSceneSynchronizer.java

示例7: Board

import javafx.beans.binding.DoubleBinding; //导入依赖的package包/类
public Board() {

        super(GAP, GAP);
        getStyleClass().add("board");

        build();

        sceneProperty().addListener((o, os, ns) -> {
            DoubleBinding tileSize = getScene().widthProperty().subtract(GAP * 4).divide(SIZE);
            prefTileHeightProperty().bind(tileSize);
            prefTileWidthProperty().bind(tileSize);
        });

        setTileAlignment(Pos.CENTER);
        setPrefColumns(Board.SIZE);
        setAlignment(Pos.CENTER);
    }
 
开发者ID:gluonhq,项目名称:gluon-samples,代码行数:18,代码来源:Board.java

示例8: createSymbol

import javafx.beans.binding.DoubleBinding; //导入依赖的package包/类
@Override
public Collection<Shape> createSymbol(BoardCell cell) {
    final DoubleBinding padding = cell.widthProperty().multiply(.15);

    Line l1 = new Line(20, 20, cell.getWidth() - 20, cell.getHeight() - 20);
    l1.setMouseTransparent(true);
    l1.getStyleClass().add("board-symbol");
    l1.endXProperty().bind(cell.widthProperty().subtract(padding));
    l1.endYProperty().bind(cell.heightProperty().subtract(padding));

    Line l2 = new Line(20, cell.getHeight() - 20, cell.getWidth() - 20, 20);
    l2.setMouseTransparent(true);
    l2.getStyleClass().add("board-symbol");
    l2.endXProperty().bind(cell.widthProperty().subtract(padding));
    l2.startYProperty().bind(cell.heightProperty().subtract(padding));

    return Arrays.asList(l1,l2);
}
 
开发者ID:gluonhq,项目名称:gluon-samples,代码行数:19,代码来源:BoardCell.java

示例9: InternalNode

import javafx.beans.binding.DoubleBinding; //导入依赖的package包/类
/**
 * Constructs a new {@link InternalNode}.
 * @param children The children nodes of this InternalNode.
 */
public InternalNode(List<AbstractNode> children) {
	this.children = children;
	List<Edge> outgoingEdges = new ArrayList<>();
	bindMargins();
	bindLeafCount();

	// Position the children.
	DoubleBinding rangeBegin = marginProperty().divide(2).negate();
	for (AbstractNode child : children) {
		child.translateYProperty().bind(rangeBegin.add(child.marginProperty().divide(2)));
		child.translateXProperty().set(LEVELWIDTH);
		rangeBegin = rangeBegin.add(child.marginProperty());
		Edge e = new Edge(child);
		outgoingEdges.add(e);
	}
	this.getChildren().addAll(0, outgoingEdges);
	// Add the nodes after the edges, so that they're on top.
	this.getChildren().addAll(children);
}
 
开发者ID:ProgrammingLife2015,项目名称:dnainator,代码行数:24,代码来源:InternalNode.java

示例10: PointingHeroIcon

import javafx.beans.binding.DoubleBinding; //导入依赖的package包/类
public PointingHeroIcon(ObservableEntity oe) {
    super(oe);

    shape = new Polygon(
        0, -200, -120, 200, 120, 200
    );

    shape.fillProperty().bind(getPlayerColor());

    ObjectBinding<Vector> angRotVector = oe.getPropertyBinding(Vector.class, "CBodyComponent.m_angRotation", null);
    DoubleBinding angRot = Bindings.createDoubleBinding(() -> (double) angRotVector.get().getElement(1), angRotVector);

    IntegerBinding angDiff = Bindings.selectInteger(oe.getPropertyBinding(Integer.class, "m_anglediff", 0));

    shape.translateXProperty().bind(getMapX());
    shape.translateYProperty().bind(getMapY());
    shape.rotateProperty().bind(getBaseAngle().add(angRot).add(angDiff));
}
 
开发者ID:spheenik,项目名称:clarity-analyzer,代码行数:19,代码来源:PointingHeroIcon.java

示例11: checkAndAddMidPoints

import javafx.beans.binding.DoubleBinding; //导入依赖的package包/类
/**
 * Checks the start and endpoints to see if any midpoints are necessary for drawing the line
 * between them correctly. If the endpoints are more than 1 column apart and, the midpoints
 * are added at the calculated x value
 * @param startY the starting y coordinate of this edge
 * @param endY the ending y coordinate of this edge
 */
private void checkAndAddMidPoints(DoubleBinding startY, DoubleBinding endY){
    if(target.rowLocationProperty.get() - source.rowLocationProperty.get() > 1
            || target.rowLocationProperty.get() - source.rowLocationProperty.get() < 0){
        if(!addedMidPoints){
            path.addPoint(midLineX.add(0), startY.subtract(TreeLayout.V_SPACING/3.), 1);
            path.addPoint(midLineX.add(0), endY.add(TreeLayout.V_SPACING/2.), 2);
            this.addedMidPoints = true;
        }
    }else{
        if(addedMidPoints){
            path.removePoint(2);
            path.removePoint(1);
            this.addedMidPoints = false;
        }
    }
}
 
开发者ID:dmusican,项目名称:Elegit,代码行数:24,代码来源:Edge.java

示例12: bindNode

import javafx.beans.binding.DoubleBinding; //导入依赖的package包/类
private void bindNode() {
    final View v = View.getInstance();
    
    node.translateXProperty().bind(new DoubleBinding() {

        {
            super.bind(v.xProperty());
        }
        
        @Override
        protected double computeValue() {
            double offset = v.getX() % View.WIDTH.get();
            if (offset < 0) {
                offset += View.WIDTH.get();
            }
            return -offset;
        }
    });
    
    node.translateYProperty().bind(new SimpleDoubleProperty(32).add(v.yProperty()));
}
 
开发者ID:svanimpe,项目名称:fx-jumpman,代码行数:22,代码来源:ScrollingBackground.java

示例13: bindLogBoundsToDefaultBounds

import javafx.beans.binding.DoubleBinding; //导入依赖的package包/类
/**
 * Bind our logarithmic bounds with the super class bounds, consider the base 10 logarithmic scale.
 */
private void bindLogBoundsToDefaultBounds() {
	logLowerBound.bind(new DoubleBinding() {

		{
			super.bind(lowerBoundProperty());
		}

		@Override
		protected double computeValue() {
			return Math.log10(lowerBoundProperty().get());
		}
	});
	logUpperBound.bind(new DoubleBinding() {

		{
			super.bind(upperBoundProperty());
		}

		@Override
		protected double computeValue() {
			return Math.log10(upperBoundProperty().get());
		}
	});
}
 
开发者ID:BrainTech,项目名称:svarog,代码行数:28,代码来源:LogarithmicAxis.java

示例14: getRightPane

import javafx.beans.binding.DoubleBinding; //导入依赖的package包/类
private Node getRightPane() {
	StackPane rightPane = new StackPane();
	rightPane.setStyle("-fx-background-color:#F0F0F0;");
	rightPane.setPadding(new Insets(0,10,10,10));
	rightPane.setPrefWidth(300);
	rightPane.getChildren().add( getBox() );
	
	final double translateVal = 55.0D;
	rightPane.setTranslateY(-1 * translateVal);
	rightPane.minHeightProperty().bind(new DoubleBinding() {
		{
			bind(leftPane.heightProperty());
		}
		@Override
		protected double computeValue() {
			return (leftPane.getHeight()+translateVal);
		}
	});
	return rightPane;
}
 
开发者ID:SaiPradeepDandem,项目名称:javafx-demos,代码行数:21,代码来源:CustomBorderPane.java

示例15: constantOf

import javafx.beans.binding.DoubleBinding; //导入依赖的package包/类
private DoubleBinding constantOf(double defaultValue) {
	return new DoubleBinding() {
		@Override
		protected double computeValue() {
			return defaultValue;
		}
	};
}
 
开发者ID:cmlanche,项目名称:easyMvvmFx,代码行数:9,代码来源:CompositeCommand.java


注:本文中的javafx.beans.binding.DoubleBinding类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。