下面列出了javafx.scene.shape.Rectangle#setLayoutY ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private Rectangle createTic(double angle, double width, double height) {
Rectangle rectangle = new Rectangle(-width / 2, -height / 2, width, height);
rectangle.setFill(Color.rgb(10, 10, 10));
rectangle.setRotate(angle);
rectangle.setLayoutX(radius * Math.cos(Math.toRadians(angle)));
rectangle.setLayoutY(radius * Math.sin(Math.toRadians(angle)));
return rectangle;
}
public NodePropertiesSample() {
super(300,100);
//X position of node = X + LayoutX + TranslateX
rectA = new Rectangle(50, 50, Color.LIGHTSALMON);
//set position of node temporary (can be changed after)
rectA.setTranslateX(10);
rectB = new Rectangle(50, 50, Color.LIGHTGREEN);
//set position of node when addinf to some layout
rectB.setLayoutX(20);
rectB.setLayoutY(10);
rectC = new Rectangle(50, 50, Color.DODGERBLUE);
//last posibility of setting X position of node
rectC.setX(30);
rectC.setY(20);
//opacity of node can be set
rectC.setOpacity(0.8);
// REMOVE ME
setControls(
new SimplePropertySheet.PropDesc("Rectangle A translate X", rectA.translateXProperty(), 0d, 50d),
new SimplePropertySheet.PropDesc("Rectangle B translate X", rectB.translateXProperty(), 0d, 50d),
new SimplePropertySheet.PropDesc("Rectangle C translate X", rectC.translateXProperty(), 0d, 50d),
new SimplePropertySheet.PropDesc("Rectangle A Opacity", rectA.opacityProperty(), 0d, 1d),
new SimplePropertySheet.PropDesc("Rectangle B Opacity", rectB.opacityProperty(), 0d, 1d),
new SimplePropertySheet.PropDesc("Rectangle C Opacity", rectC.opacityProperty(), 0d, 1d)
);
getChildren().add(createRadioButtons());
// END REMOVE ME
Group g = new Group(rectA, rectB, rectC);
g.setLayoutX(160 + 35);
getChildren().addAll(g);
}
private Rectangle createTic(double angle, double width, double height) {
Rectangle rectangle = new Rectangle(-width / 2, -height / 2, width, height);
rectangle.setFill(Color.rgb(10, 10, 10));
rectangle.setRotate(angle);
rectangle.setLayoutX(radius * Math.cos(Math.toRadians(angle)));
rectangle.setLayoutY(radius * Math.sin(Math.toRadians(angle)));
return rectangle;
}
public NodePropertiesSample() {
super(300,100);
//X position of node = X + LayoutX + TranslateX
rectA = new Rectangle(50, 50, Color.LIGHTSALMON);
//set position of node temporary (can be changed after)
rectA.setTranslateX(10);
rectB = new Rectangle(50, 50, Color.LIGHTGREEN);
//set position of node when addinf to some layout
rectB.setLayoutX(20);
rectB.setLayoutY(10);
rectC = new Rectangle(50, 50, Color.DODGERBLUE);
//last posibility of setting X position of node
rectC.setX(30);
rectC.setY(20);
//opacity of node can be set
rectC.setOpacity(0.8);
// REMOVE ME
setControls(
new SimplePropertySheet.PropDesc("Rectangle A translate X", rectA.translateXProperty(), 0d, 50d),
new SimplePropertySheet.PropDesc("Rectangle B translate X", rectB.translateXProperty(), 0d, 50d),
new SimplePropertySheet.PropDesc("Rectangle C translate X", rectC.translateXProperty(), 0d, 50d),
new SimplePropertySheet.PropDesc("Rectangle A Opacity", rectA.opacityProperty(), 0d, 1d),
new SimplePropertySheet.PropDesc("Rectangle B Opacity", rectB.opacityProperty(), 0d, 1d),
new SimplePropertySheet.PropDesc("Rectangle C Opacity", rectC.opacityProperty(), 0d, 1d)
);
getChildren().add(createRadioButtons());
// END REMOVE ME
Group g = new Group(rectA, rectB, rectC);
g.setLayoutX(160 + 35);
getChildren().addAll(g);
}
private Rectangle createTic(double angle, double width, double height) {
Rectangle rectangle = new Rectangle(-width / 2, -height / 2, width, height);
rectangle.setFill(Color.rgb(10, 10, 10));
rectangle.setRotate(angle);
rectangle.setLayoutX(radius * Math.cos(Math.toRadians(angle)));
rectangle.setLayoutY(radius * Math.sin(Math.toRadians(angle)));
return rectangle;
}
private Node generate(double w, double h) {
double rx = Math.random() * (w - 100);
double ry = Math.random() * (h - 100);
double rw = Math.random() * 90 + 10;
double rh = Math.random() * 90 + 10;
Rectangle rectangle = new Rectangle(0, 0, rw, rh);
rectangle.setLayoutX(rx);
rectangle.setLayoutY(ry);
rectangle.setFill(
new Color(Math.random(), Math.random(), Math.random(), 0.5));
rectangle.setStroke(Color.TRANSPARENT);
return rectangle;
}
protected Animation buildSubtitleRectAnim(HBox mainTitleBackground, Rectangle subTitleRect) {
// Small rectangle (prompt)
// Calculate main title width and height upfront
Rectangle2D mainTitleBounds = getBoundsUpfront(mainTitleBackground);
double mainTitleWidth = mainTitleBounds.getWidth();
double mainTitleHeight = mainTitleBounds.getHeight();
// Position of the end
Point2D endPointLL = calcEndPointOfLeaderLine();
double x = endPointLL.getX();
double y = endPointLL.getY();
int direction = getEndLeaderLineDirection();
if (direction == LEFT) {
subTitleRect.setLayoutX( x + (subTitleRect.getWidth() * direction));
} else {
subTitleRect.setLayoutX( x );
}
subTitleRect.setLayoutY( y + (mainTitleHeight/2) + 2);
return new Timeline(
new KeyFrame(Duration.millis(1),
new KeyValue(subTitleRect.visibleProperty(), true),
new KeyValue(subTitleRect.heightProperty(), 0)), // show
new KeyFrame(Duration.millis(300),
new KeyValue(subTitleRect.heightProperty(), 20)
)
);
}
private void setVisibleSelectionBorder(final double x, final double y, final double w, final double h, final boolean ongoing) {
final Rectangle rec = ongoing ? ongoingSelectionBorder : selectionBorder;
rec.setLayoutX(x);
rec.setLayoutY(y);
rec.setWidth(w);
rec.setHeight(h);
rec.setVisible(true);
}