本文整理汇总了Java中javafx.scene.shape.Rectangle.setScaleX方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.setScaleX方法的具体用法?Java Rectangle.setScaleX怎么用?Java Rectangle.setScaleX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.shape.Rectangle
的用法示例。
在下文中一共展示了Rectangle.setScaleX方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setFillImageKeepingAspectRatio
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public void setFillImageKeepingAspectRatio(Rectangle rectangle, Image image, Dimension2D gamingContextDimension2D) {
double imageWidth = image.getWidth();
double imageHeight = image.getHeight();
double imageHeightToWidthRatio = imageHeight / imageWidth;
double initialHeight = rectangle.getHeight();
double initialWidth = initialHeight / imageHeightToWidthRatio;
double positionX = (gamingContextDimension2D.getWidth() - initialWidth) / 2;
double positionY = (gamingContextDimension2D.getHeight() - initialHeight) / 2;
rectangle.setFill(new ImagePattern(image));
rectangle.setX(positionX);
rectangle.setY(positionY);
rectangle.setWidth(initialWidth);
rectangle.setHeight(initialHeight);
rectangle.setTranslateX(0);
rectangle.setScaleX(1);
rectangle.setScaleY(1);
rectangle.setScaleZ(1);
}
示例2: ScaleSample
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public ScaleSample() {
super(180,180);
// simple rectangle
Rectangle rect1 = new Rectangle(0, 25, 25, 25);
rect1.setArcHeight(15);
rect1.setArcWidth(15);
rect1.setFill(Color.WHITE);
rect1.setStroke(Color.DODGERBLUE);
rect1.setStrokeWidth(3);
Polygon arrow = createArrow();
arrow.setLayoutX(46);
arrow.setLayoutY(22);
arrow.setRotate(90);
// simple rectangle with scale 2 in X axis and 0.5 in Y
Rectangle rect2 = new Rectangle(95, 25, 25, 25);
rect2.setArcHeight(15);
rect2.setArcWidth(15);
rect2.setFill(Color.WHITE);
rect2.setStroke(Color.DODGERBLUE);
rect2.setStrokeWidth(3);
rect2.setScaleX(2);
rect2.setScaleY(0.5);
// rectangle with adjustable scale
Rectangle rect3 = new Rectangle(40, 130, 25, 25);
rect3.setArcHeight(15);
rect3.setArcWidth(15);
rect3.setFill(Color.WHITE);
rect3.setStroke(Color.DODGERBLUE);
rect3.setStrokeWidth(3);
rect3.setScaleX(6);
rect3.setScaleY(0.5);
rect3.setTranslateX(rect3.getTranslateX()+30);
//getChildren().addAll(rect1, rect2, rect3);
getChildren().addAll(rect1, arrow, rect2, rect3);
// REMOVE ME
setControls(
new SimplePropertySheet.PropDesc("Scale X", rect3.scaleXProperty(), 0.1d, 16d),
new SimplePropertySheet.PropDesc("Scale Y", rect3.scaleYProperty(), 0.1d, 4d)
);
// END REMOVE ME
}