本文整理匯總了Java中javafx.beans.binding.DoubleBinding.get方法的典型用法代碼示例。如果您正苦於以下問題:Java DoubleBinding.get方法的具體用法?Java DoubleBinding.get怎麽用?Java DoubleBinding.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.beans.binding.DoubleBinding
的用法示例。
在下文中一共展示了DoubleBinding.get方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: StraightEdgeView
import javafx.beans.binding.DoubleBinding; //導入方法依賴的package包/類
public StraightEdgeView(DoubleProperty sX, DoubleProperty sY, DoubleProperty eX, DoubleProperty eY) {
super(sX, sY, eX, eY);
aX = new DoubleBinding() {
{
super.bind(sX, eX);
}
@Override
protected double computeValue() {
return (sX.get() + eX.get()) * .5;
}
};
aY = new DoubleBinding() {
{
super.bind(sY, eY);
}
@Override
protected double computeValue() {
return (sY.get() + eY.get()) * .5;
}
};
Line line = new Line();
line.setStrokeWidth(1.5);
line.setStroke(Color.BLUE);
line.startXProperty().bind(sX);
line.startYProperty().bind(sY);
line.endXProperty().bind(eX);
line.endYProperty().bind(eY);
Polygon arrow = new Polygon();
arrow.setFill(Color.BLUE);
final ChangeListener<Number> listener = (_0, _1, _2) -> {
final double angle = a.get() + Math.PI;
final double x = aX.get();
final double y = aY.get();
final double x0 = x + 5 * Math.cos(angle);
final double x1 = x + 5 * Math.cos(angle + 2 * Math.PI / 3);
final double x2 = x + 5 * Math.cos(angle - 2 * Math.PI / 3);
final double y0 = y + 5 * Math.sin(angle);
final double y1 = y + 5 * Math.sin(angle + 2 * Math.PI / 3);
final double y2 = y + 5 * Math.sin(angle - 2 * Math.PI / 3);
arrow.getPoints().clear();
arrow.getPoints().addAll(x0, y0, x1, y1, x2, y2);
};
aX.addListener(listener);
aY.addListener(listener);
getChildren().addAll(line, arrow);
}