本文整理汇总了Java中javafx.scene.shape.Rectangle.setTranslateY方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.setTranslateY方法的具体用法?Java Rectangle.setTranslateY怎么用?Java Rectangle.setTranslateY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.shape.Rectangle
的用法示例。
在下文中一共展示了Rectangle.setTranslateY方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ShearSample
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public ShearSample() {
super(125,160);
//create rectangle
Rectangle rect = new Rectangle(75, 75, Color.web("#ed4b00", 0.5));
rect.setTranslateY(50);
Shear shear = new Shear(0.7, 0);
rect.getTransforms().add(shear);
//show the rectangles
getChildren().addAll(rect);
// REMOVE ME
setControls(
new SimplePropertySheet.PropDesc("Shear X", shear.xProperty(), 0d, 1d),
new SimplePropertySheet.PropDesc("Shear Y", shear.yProperty(), 0d, 1d),
new SimplePropertySheet.PropDesc("Shear Pivot X", shear.pivotXProperty(), 0d, 50d),
new SimplePropertySheet.PropDesc("Shear Pivot Y", shear.pivotYProperty(), 0d, 50d)
);
// END REMOVE ME
}
示例2: createRectangle
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public static Group createRectangle(Color color, double tx, double ty, double sx, double sy) {
Group squareGroup = new Group();
Rectangle squareShape = new Rectangle(1.0, 1.0);
squareShape.setFill(color);
squareShape.setTranslateX(-0.5);
squareShape.setTranslateY(-0.5);
squareGroup.getChildren().add(squareShape);
squareGroup.setTranslateX(tx);
squareGroup.setTranslateY(ty);
squareGroup.setScaleX(sx);
squareGroup.setScaleY(sy);
return squareGroup;
}
示例3: PauseTransitionSample
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public PauseTransitionSample() {
super(400,150);
// create rectangle
Rectangle rect = new Rectangle(-25,-25,50, 50);
rect.setArcHeight(15);
rect.setArcWidth(15);
rect.setFill(Color.CRIMSON);
rect.setTranslateX(50);
rect.setTranslateY(75);
getChildren().add(rect);
animation = SequentialTransitionBuilder.create()
.node(rect)
.children(
TranslateTransitionBuilder.create()
.duration(Duration.seconds(2))
.fromX(50)
.toX(200)
.build(),
PauseTransitionBuilder.create()
.duration(Duration.seconds(2))
.build(),
TranslateTransitionBuilder.create()
.duration(Duration.seconds(2))
.fromX(200)
.toX(350)
.build()
)
.cycleCount(Timeline.INDEFINITE)
.autoReverse(true)
.build();
}
示例4: TranslateSample
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public TranslateSample() {
super(230, 220);
//create 2 rectangles with different color
Rectangle rect1 = new Rectangle(90, 90, Color.web("#ed4b00", 0.75));
Rectangle rect2 = new Rectangle(90, 90, Color.web("#ed4b00", 0.5));
//translate second one
rect2.setTranslateX(140);
// rectangle with adjustable translate
Rectangle rect3 = new Rectangle(40, 130, 60, 60);
rect3.setFill(Color.DODGERBLUE);
rect3.setTranslateX(20);
rect3.setTranslateY(10);
//show the rectangles
getChildren().addAll(rect2, rect1, rect3);
// REMOVE ME
setControls(
new SimplePropertySheet.PropDesc("Translate X", rect3.translateXProperty(), 0d, 50d),
new SimplePropertySheet.PropDesc("Translate Y", rect3.translateYProperty(), 0d, 50d)
);
// END REMOVE ME
//create arrow
Polygon polygon = createArrow();
polygon.setLayoutX(110);
polygon.setLayoutY(30);
polygon.setRotate(90);
getChildren().addAll(polygon);
}
示例5: doorClosed
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public void doorClosed() {
// Draw trim
Rectangle rgDT = new Rectangle(WIDTH, HEIGHT);
rgDT.setFill(Color.web("4d2626"));
this.getChildren().add(rgDT);
// Draw door
Rectangle rgDD = new Rectangle(WIDTH - (WIDTH / (WIDTH / 4)), HEIGHT - (HEIGHT / (HEIGHT / 2)));
rgDD.setTranslateX((WIDTH / (WIDTH / 2)));
rgDD.setTranslateY((HEIGHT / (HEIGHT / 2)));
rgDD.setFill(Color.web("673232"));
this.getChildren().add(rgDD);
// Draw three hinges
VBox vbHinges = new VBox(WIDTH / 3);
Rectangle rgDH1 = new Rectangle((WIDTH / (WIDTH / 2)), (HEIGHT / (HEIGHT / 8)));
rgDH1.setFill(Color.web("a5a5a5"));
Rectangle rgDH2 = new Rectangle((WIDTH / (WIDTH / 2)), (HEIGHT / (HEIGHT / 8)));
rgDH2.setFill(Color.web("a5a5a5"));
Rectangle rgDH3 = new Rectangle((WIDTH / (WIDTH / 2)), (HEIGHT / (HEIGHT / 8)));
rgDH3.setFill(Color.web("a5a5a5"));
vbHinges.getChildren().addAll(rgDH1, rgDH2, rgDH3);
vbHinges.setTranslateX(rgDH1.getWidth() / 2);
vbHinges.setTranslateY(rgDH1.getHeight());
this.getChildren().add(vbHinges);
// Draw door handle block
Rectangle rgDHM = new Rectangle((WIDTH / (WIDTH / 4)), (WIDTH / (WIDTH / 4)));
rgDHM.setTranslateX(WIDTH - rgDHM.getWidth() * 2);
rgDHM.setTranslateY(HEIGHT / 2 - rgDHM.getHeight() / 2);
rgDHM.setFill(Color.web("bfbfbf"));
this.getChildren().add(rgDHM);
// Draw door handle
Rectangle rgDHL = new Rectangle((WIDTH / (WIDTH / 8)), (WIDTH / (WIDTH / 2)));
rgDHL.setTranslateX(WIDTH - rgDHL.getWidth() * 2);
rgDHL.setTranslateY(HEIGHT / 2 - rgDHL.getHeight() / 2);
rgDHL.setFill(Color.web("a5a5a5"));
this.getChildren().add(rgDHL);
}
示例6: doorOpen
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public void doorOpen() {
// Draw trim
Rectangle rgDT = new Rectangle(WIDTH, HEIGHT);
rgDT.setFill(Color.TRANSPARENT);
rgDT.setStroke(Color.web("4d2626"));
rgDT.setStrokeWidth((WIDTH / (WIDTH / 2)));
this.getChildren().add(rgDT);
// Draw three hinges
VBox vbHinges = new VBox(WIDTH / 3);
Rectangle rgDH1 = new Rectangle((WIDTH / (WIDTH / 2)), (HEIGHT / (HEIGHT / 8)));
rgDH1.setFill(Color.web("a5a5a5"));
Rectangle rgDH2 = new Rectangle((WIDTH / (WIDTH / 2)), (HEIGHT / (HEIGHT / 8)));
rgDH2.setFill(Color.web("a5a5a5"));
Rectangle rgDH3 = new Rectangle((WIDTH / (WIDTH / 2)), (HEIGHT / (HEIGHT / 8)));
rgDH3.setFill(Color.web("a5a5a5"));
vbHinges.getChildren().addAll(rgDH1, rgDH2, rgDH3);
vbHinges.setTranslateX(rgDH1.getWidth() / 2);
vbHinges.setTranslateY(rgDH1.getHeight());
this.getChildren().add(vbHinges);
// Draw door
Rectangle rgDD = new Rectangle(WIDTH - (WIDTH / (WIDTH / 4)), HEIGHT);
rgDD.setTranslateX((WIDTH / (WIDTH / 2)) - rgDD.getWidth());
rgDD.setTranslateY((HEIGHT / (HEIGHT / 2)) / 2);
rgDD.setFill(Color.web("673232"));
this.getChildren().add(rgDD);
}
示例7: doorClosed
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public void doorClosed() {
// Draw trim
Rectangle rgDT = new Rectangle(WIDTH, HEIGHT);
rgDT.setFill(Color.web("4d2626"));
this.getChildren().add(rgDT);
// Draw door
Rectangle rgDD = new Rectangle(WIDTH - (WIDTH / (WIDTH / 4)) , HEIGHT - (HEIGHT / (HEIGHT / 2)));
rgDD.setTranslateX((WIDTH / (WIDTH / 2)));
rgDD.setTranslateY((HEIGHT / (HEIGHT / 2)));
rgDD.setFill(Color.web("673232"));
this.getChildren().add(rgDD);
// Draw three hinges
VBox vbHinges = new VBox(WIDTH / 3);
Rectangle rgDH1 = new Rectangle((WIDTH / (WIDTH / 2)), (HEIGHT / (HEIGHT / 8)));
rgDH1.setFill(Color.web("a5a5a5"));
Rectangle rgDH2 = new Rectangle((WIDTH / (WIDTH / 2)), (HEIGHT / (HEIGHT / 8)));
rgDH2.setFill(Color.web("a5a5a5"));
Rectangle rgDH3 = new Rectangle((WIDTH / (WIDTH / 2)), (HEIGHT / (HEIGHT / 8)));
rgDH3.setFill(Color.web("a5a5a5"));
vbHinges.getChildren().addAll(rgDH1, rgDH2, rgDH3);
vbHinges.setTranslateX(rgDH1.getWidth() / 2);
vbHinges.setTranslateY(rgDH1.getHeight());
this.getChildren().add(vbHinges);
// Draw door handle block
Rectangle rgDHM = new Rectangle((WIDTH / (WIDTH / 4)), (WIDTH / (WIDTH / 4)));
rgDHM.setTranslateX(WIDTH - rgDHM.getWidth() * 2);
rgDHM.setTranslateY(HEIGHT / 2 - rgDHM.getHeight() / 2);
rgDHM.setFill(Color.web("bfbfbf"));
this.getChildren().add(rgDHM);
// Draw door handle
Rectangle rgDHL = new Rectangle((WIDTH / (WIDTH / 8)), (WIDTH / (WIDTH / 2)));
rgDHL.setTranslateX(WIDTH - rgDHL.getWidth() * 2);
rgDHL.setTranslateY(HEIGHT / 2 - rgDHL.getHeight() / 2);
rgDHL.setFill(Color.web("a5a5a5"));
this.getChildren().add(rgDHL);
}
示例8: ParallelTransitionSample
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public ParallelTransitionSample() {
super(400,150);
// create rectangle
Rectangle rect = new Rectangle(-25,-25,50, 50);
rect.setArcHeight(15);
rect.setArcWidth(15);
rect.setFill(Color.CRIMSON);
rect.setTranslateX(50);
rect.setTranslateY(75);
getChildren().add(rect);
// create parallel transition to do all 4 transitions at the same time
parallelTransition = ParallelTransitionBuilder.create()
.node(rect)
.children(
FadeTransitionBuilder.create()
.duration(Duration.seconds(3))
.node(rect)
.fromValue(1)
.toValue(0.3)
.autoReverse(true)
.build(),
TranslateTransitionBuilder.create()
.duration(Duration.seconds(2))
.fromX(50)
.toX(350)
.cycleCount(2)
.autoReverse(true)
.build(),
RotateTransitionBuilder.create()
.duration(Duration.seconds(3))
.byAngle(180)
.cycleCount(4)
.autoReverse(true)
.build(),
ScaleTransitionBuilder.create()
.duration(Duration.seconds(2))
.toX(2)
.toY(2)
.cycleCount(2)
.autoReverse(true)
.build()
)
.cycleCount(Timeline.INDEFINITE)
.autoReverse(true)
.build();
}
示例9: SequentialTransitionSample
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public SequentialTransitionSample() {
super(400,100);
// create rectangle
Rectangle rect = new Rectangle(-25,-25,50, 50);
rect.setArcHeight(15);
rect.setArcWidth(15);
rect.setFill(Color.CRIMSON);
rect.setTranslateX(50);
rect.setTranslateY(50);
getChildren().add(rect);
// create 4 transitions
FadeTransition fadeTransition =
FadeTransitionBuilder.create()
.duration(Duration.seconds(1))
.fromValue(1)
.toValue(0.3)
.cycleCount(2)
.autoReverse(true)
.build();
TranslateTransition translateTransition =
TranslateTransitionBuilder.create()
.duration(Duration.seconds(2))
.fromX(50)
.toX(375)
.cycleCount(2)
.autoReverse(true)
.build();
RotateTransition rotateTransition =
RotateTransitionBuilder.create()
.duration(Duration.seconds(2))
.byAngle(180)
.cycleCount(4)
.autoReverse(true)
.build();
ScaleTransition scaleTransition =
ScaleTransitionBuilder.create()
.duration(Duration.seconds(2))
.toX(2)
.toY(2)
.cycleCount(2)
.autoReverse(true)
.build();
// create sequential transition to do 4 transitions one after another
sequentialTransition = SequentialTransitionBuilder.create()
.node(rect)
.children(fadeTransition, translateTransition, rotateTransition,
scaleTransition)
.cycleCount(Timeline.INDEFINITE)
.autoReverse(true)
.build();
}
示例10: doorHalf
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public void doorHalf() {
// Draw trim
Rectangle rgDT = new Rectangle(WIDTH, HEIGHT);
rgDT.setFill(Color.TRANSPARENT);
rgDT.setStroke(Color.web("4d2626"));
rgDT.setStrokeWidth((WIDTH / (WIDTH / 2)));
this.getChildren().add(rgDT);
// Draw three hinges
VBox vbHinges = new VBox(WIDTH / 3);
Rectangle rgDH1 = new Rectangle((WIDTH / (WIDTH / 2)), (HEIGHT / (HEIGHT / 8)));
rgDH1.setFill(Color.web("a5a5a5"));
Rectangle rgDH2 = new Rectangle((WIDTH / (WIDTH / 2)), (HEIGHT / (HEIGHT / 8)));
rgDH2.setFill(Color.web("a5a5a5"));
Rectangle rgDH3 = new Rectangle((WIDTH / (WIDTH / 2)), (HEIGHT / (HEIGHT / 8)));
rgDH3.setFill(Color.web("a5a5a5"));
vbHinges.getChildren().addAll(rgDH1, rgDH2, rgDH3);
vbHinges.setTranslateX(rgDH1.getWidth() / 2);
vbHinges.setTranslateY(rgDH1.getHeight());
this.getChildren().add(vbHinges);
// Draw door
Rectangle rgDD = new Rectangle((WIDTH / (WIDTH / 2)), HEIGHT);
rgDD.setTranslateX((WIDTH / (WIDTH / 2)) - rgDD.getWidth());
rgDD.setTranslateY((HEIGHT / (HEIGHT / 2)) / 2);
rgDD.setFill(Color.web("673232"));
this.getChildren().add(rgDD);
// Draw door handle block
Rectangle rgDHM = new Rectangle((WIDTH / (WIDTH / 2)), (WIDTH / (WIDTH / 4)));
rgDHM.setTranslateX(rgDD.getX() - rgDD.getWidth());
rgDHM.setTranslateY(rgDD.getY() + rgDD.getHeight() / 2 - rgDHM.getHeight() / 2);
rgDHM.setFill(Color.web("bfbfbf"));
this.getChildren().add(rgDHM);
// Draw door handle
Rectangle rgDHL = new Rectangle((WIDTH / (WIDTH / 2)), (WIDTH / (WIDTH / 2)));
rgDHL.setTranslateX(rgDD.getX() - rgDHL.getWidth() - rgDD.getWidth());
rgDHL.setTranslateY(rgDD.getY() + rgDD.getHeight() / 2 - rgDHL.getHeight() / 2);
rgDHL.setFill(Color.web("a5a5a5"));
this.getChildren().add(rgDHL);
}
示例11: drawRestroom
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public void drawRestroom() { // Toilet and sink
// Draw toilet
Rectangle rgTL = new Rectangle(WIDTH / 8, (HEIGHT / (HEIGHT / 4)));
rgTL.setFill(Color.web("a5a5a5"));
gToilet.getChildren().add(rgTL);
Rectangle rgTT = new Rectangle(WIDTH / 10, HEIGHT / 10);
rgTT.setX(rgTL.getWidth() / 2 - rgTT.getWidth() / 2);
rgTT.setY(rgTL.getHeight());
rgTT.setFill(Color.web("bfbfbf"));
gToilet.getChildren().add(rgTT);
Polygon rgTB = new Polygon();
rgTB.getPoints().addAll(new Double[] {
rgTL.getWidth() * 0.05, rgTT.getY() + rgTT.getHeight(),
rgTL.getWidth() * 0.95, rgTT.getY() + rgTT.getHeight(),
rgTL.getWidth() * 0.85, rgTT.getY() + rgTT.getHeight() + rgTL.getHeight() * 3,
rgTL.getWidth() * 0.15, rgTT.getY() + rgTT.getHeight() + rgTL.getHeight() * 3,
});
rgTB.setFill(Color.web("bfbfbf"));
gToilet.getChildren().add(rgTB);
Rectangle rgTS = new Rectangle(rgTL.getWidth() / 2, rgTL.getHeight() * 2);
rgTS.setX(rgTL.getWidth() / 2 - rgTS.getWidth() / 2);
rgTS.setY(rgTB.getBoundsInParent().getMaxY());
rgTS.setFill(Color.web("bfbfbf"));
gToilet.getChildren().add(rgTS);
// Position toilet
gToilet.setTranslateX(WIDTH / 4);
gToilet.setTranslateY(HEIGHT - gToilet.getBoundsInParent().getHeight());
this.getChildren().add(gToilet);
// Draw sink
HBox hbSinkHandles = new HBox(WIDTH / (WIDTH / 4));
gSink.getChildren().add(hbSinkHandles);
Rectangle rgSHL = new Rectangle(WIDTH / (WIDTH / 4), HEIGHT / (HEIGHT / 8));
rgSHL.setFill(Color.web("7f7f7f"));
rgSHL.setTranslateY(2);
hbSinkHandles.getChildren().add(rgSHL);
Rectangle rgSHM = new Rectangle(WIDTH / (WIDTH / 4), HEIGHT / (HEIGHT / 12));
rgSHM.setFill(Color.web("7f7f7f"));
hbSinkHandles.getChildren().add(rgSHM);
Rectangle rgSHR = new Rectangle(WIDTH / (WIDTH / 4), HEIGHT / (HEIGHT / 8));
rgSHR.setFill(Color.web("7f7f7f"));
rgSHR.setTranslateY(2);
hbSinkHandles.getChildren().add(rgSHR);
Rectangle rgST = new Rectangle(WIDTH / 8, (HEIGHT / (HEIGHT / 8)));
rgST.setFill(Color.web("a5a5a5"));
gSink.getChildren().add(rgST);
Rectangle rgSS = new Rectangle(rgST.getWidth() / 2, rgST.getHeight() * 4);
rgSS.setX(rgST.getWidth() / 2 - rgSS.getWidth() / 2);
rgSS.setY(rgST.getY() + rgST.getHeight());
rgSS.setFill(Color.web("bfbfbf"));
gSink.getChildren().add(rgSS);
// Position sink
hbSinkHandles.setTranslateX(gSink.getBoundsInParent().getWidth() / 2 - (hbSinkHandles.getSpacing() * 5) / 2);
hbSinkHandles.setTranslateY(-HEIGHT / (HEIGHT / 8));
gSink.setTranslateX(WIDTH / 4 + gToilet.getBoundsInParent().getWidth() + (gSink.getBoundsInParent().getWidth() / 2));
gSink.setTranslateY(HEIGHT - gSink.getBoundsInParent().getHeight() - hbSinkHandles.getTranslateY());
this.getChildren().add(gSink);
}
示例12: doorHalf
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public void doorHalf() {
// Draw trim
Rectangle rgDT = new Rectangle(WIDTH, HEIGHT);
rgDT.setFill(Color.TRANSPARENT);
rgDT.setStroke(Color.web("4d2626"));
rgDT.setStrokeWidth((WIDTH / (WIDTH / 2)));
this.getChildren().add(rgDT);
// Draw three hinges
VBox vbHinges = new VBox(WIDTH / 3);
Rectangle rgDH1 = new Rectangle((WIDTH / (WIDTH / 2)), (HEIGHT / (HEIGHT / 8)));
rgDH1.setFill(Color.web("a5a5a5"));
Rectangle rgDH2 = new Rectangle((WIDTH / (WIDTH / 2)), (HEIGHT / (HEIGHT / 8)));
rgDH2.setFill(Color.web("a5a5a5"));
Rectangle rgDH3 = new Rectangle((WIDTH / (WIDTH / 2)), (HEIGHT / (HEIGHT / 8)));
rgDH3.setFill(Color.web("a5a5a5"));
vbHinges.getChildren().addAll(rgDH1, rgDH2, rgDH3);
vbHinges.setTranslateX(rgDH1.getWidth() / 2);
vbHinges.setTranslateY(rgDH1.getHeight());
this.getChildren().add(vbHinges);
// Draw door
Rectangle rgDD = new Rectangle((WIDTH / (WIDTH / 2)) , HEIGHT);
rgDD.setTranslateX((WIDTH / (WIDTH / 2)) - rgDD.getWidth());
rgDD.setTranslateY((HEIGHT / (HEIGHT / 2)) / 2);
rgDD.setFill(Color.web("673232"));
this.getChildren().add(rgDD);
// Draw door handle block
Rectangle rgDHM = new Rectangle((WIDTH / (WIDTH / 2)), (WIDTH / (WIDTH / 4)));
rgDHM.setTranslateX(rgDD.getX() - rgDD.getWidth());
rgDHM.setTranslateY(rgDD.getY() + rgDD.getHeight() / 2 - rgDHM.getHeight() / 2);
rgDHM.setFill(Color.web("bfbfbf"));
this.getChildren().add(rgDHM);
// Draw door handle
Rectangle rgDHL = new Rectangle((WIDTH / (WIDTH / 2)), (WIDTH / (WIDTH / 2)));
rgDHL.setTranslateX(rgDD.getX() - rgDHL.getWidth() - rgDD.getWidth());
rgDHL.setTranslateY(rgDD.getY() + rgDD.getHeight() / 2 - rgDHL.getHeight() / 2);
rgDHL.setFill(Color.web("a5a5a5"));
this.getChildren().add(rgDHL);
}
示例13: Hand
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public Hand() {
recomputePosition();
hand = new Rectangle(0, 0, maxSize, maxSize);
hand.setFill(new ImagePattern(new Image("data/creampie/images/hand.png")));
hand.setTranslateX(handTranslateX);
hand.setTranslateY(handTranslateY);
this.getChildren().add(hand);
// log.info(ClassLoader.getSystemResourceAsStream("data/creampie/images/hand.png"));
// background = new ImageView(new
// Image(ClassLoader.getSystemResourceAsStream("data/creampie/images/hand.png")));
// background.setFitHeight(maxSize);
// background.setPreserveRatio(true);
// pie = new ImageView(new Image("file:data/creampie/images/gateau.png"));
// pie = new ImageView(new Image(ClassLoader.getSystemResourceAsStream("data/creampie/images/gateau.png")));
pie = new Rectangle(0, 0, size, size);
pie.setFill(new ImagePattern(new Image("data/creampie/images/gateau.png")));
pie.setTranslateX(pieTranslateX);
pie.setTranslateY(pieTranslateY);
this.getChildren().add(pie);
pie.toBack();
// pie.setFitHeight(size);
// pie.setPreserveRatio(true);
this.addEventHandler(TouchEvent.TOUCH, (TouchEvent te) -> touch(te));
}