下面列出了怎么用javafx.scene.transform.Shear的API类实例代码及写法,或者点击链接到github查看源代码。
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
}
public static Node createIconContent() {
final Rectangle r1 = new Rectangle (22, 0, 64, 64);
r1.setArcHeight(4);
r1.setArcWidth(4);
r1.setFill(Color.web("#ed4b00",0.5));
r1.getTransforms().add(new Shear(-0.35, 0));
Polygon polygon = createArrow();
polygon.setLayoutX(-5);
polygon.setLayoutY(-2);
polygon.setRotate(90);
Rectangle r2 = new Rectangle (0, 0, 64, 64);
r2.setArcHeight(4);
r2.setArcWidth(4);
r2.setFill(Color.web("#ed4b00", 0.25));
javafx.scene.Group g = new javafx.scene.Group(r2,r1, polygon);
return new javafx.scene.Group(g);
}
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
}
public static Node createIconContent() {
final Rectangle r1 = new Rectangle (22, 0, 64, 64);
r1.setArcHeight(4);
r1.setArcWidth(4);
r1.setFill(Color.web("#ed4b00",0.5));
r1.getTransforms().add(new Shear(-0.35, 0));
Polygon polygon = createArrow();
polygon.setLayoutX(-5);
polygon.setLayoutY(-2);
polygon.setRotate(90);
Rectangle r2 = new Rectangle (0, 0, 64, 64);
r2.setArcHeight(4);
r2.setArcWidth(4);
r2.setFill(Color.web("#ed4b00", 0.25));
javafx.scene.Group g = new javafx.scene.Group(r2,r1, polygon);
return new javafx.scene.Group(g);
}
@Override
void initTimeline() {
shear = new Shear();
getNode().getTransforms().add(shear);
setTimeline(new Timeline(
new KeyFrame(Duration.millis(0),
new KeyValue(shear.xProperty(), 0),
new KeyValue(shear.yProperty(), 0),
new KeyValue(getNode().opacityProperty(), 1, Interpolator.EASE_IN)
),
new KeyFrame(Duration.millis(1000),
new KeyValue(getNode().translateXProperty(), getNode().getBoundsInParent().getWidth(), Interpolator.EASE_IN),
new KeyValue(shear.xProperty(), 0.30),
new KeyValue(shear.yProperty(), 0),
new KeyValue(getNode().opacityProperty(), 0, Interpolator.EASE_IN)
)
));
}
public Digit(Color onColor, Color offColor, Effect onEffect, Effect offEffect) {
this.onColor = onColor;
this.offColor = offColor;
this.onEffect = onEffect;
this.offEffect = offEffect;
getChildren().addAll(polygons);
getTransforms().add(new Shear(-0.1,0));
showNumber(0);
}
public Digit(Color onColor, Color offColor, Effect onEffect, Effect offEffect) {
this.onColor = onColor;
this.offColor = offColor;
this.onEffect = onEffect;
this.offEffect = offEffect;
getChildren().addAll(polygons);
getTransforms().add(new Shear(-0.1,0));
showNumber(0);
}
@Override
void initTimeline() {
Shear shear = new Shear();
getNode().getTransforms().add(shear);
setTimeline(new Timeline(
new KeyFrame(Duration.millis(0),
new KeyValue(getNode().translateXProperty(), getNode().getBoundsInParent().getWidth(), Interpolator.EASE_OUT),
new KeyValue(shear.xProperty(), -0.30),
new KeyValue(shear.yProperty(), 0),
new KeyValue(getNode().opacityProperty(), 0, Interpolator.EASE_OUT)
),
new KeyFrame(Duration.millis(600),
new KeyValue(getNode().translateXProperty(), 0, Interpolator.EASE_OUT),
new KeyValue(shear.xProperty(), 0.20),
new KeyValue(shear.yProperty(), 0),
new KeyValue(getNode().opacityProperty(), 1, Interpolator.EASE_OUT)
),
new KeyFrame(Duration.millis(800),
new KeyValue(shear.xProperty(), -0.5),
new KeyValue(shear.yProperty(), 0),
new KeyValue(getNode().opacityProperty(), 1, Interpolator.EASE_OUT)
),
new KeyFrame(Duration.millis(1000),
new KeyValue(shear.xProperty(), 0),
new KeyValue(shear.yProperty(), 0),
new KeyValue(getNode().opacityProperty(), 1, Interpolator.EASE_OUT)
)));
}
@Override
void initTimeline() {
Shear shear = new Shear();
Bounds bounds = getNode().getLayoutBounds();
shear.setPivotX(bounds.getWidth() / 2);
shear.setPivotY(bounds.getHeight() / 2);
getNode().getTransforms().add(shear);
setTimeline(new Timeline(
new KeyFrame(Duration.millis(0),
new KeyValue(shear.xProperty(), 0),
new KeyValue(shear.yProperty(), 0)),
new KeyFrame(Duration.millis(111),
new KeyValue(shear.xProperty(), 0.125),
new KeyValue(shear.yProperty(), 0.125)),
new KeyFrame(Duration.millis(222),
new KeyValue(shear.xProperty(), -0.625),
new KeyValue(shear.yProperty(), -0.625)),
new KeyFrame(Duration.millis(333),
new KeyValue(shear.xProperty(), 0.3125),
new KeyValue(shear.yProperty(), 0.3125)),
new KeyFrame(Duration.millis(444),
new KeyValue(shear.xProperty(), -0.15625),
new KeyValue(shear.yProperty(), -0.15625)),
new KeyFrame(Duration.millis(555),
new KeyValue(shear.xProperty(), 0.078125),
new KeyValue(shear.yProperty(), 0.078125)),
new KeyFrame(Duration.millis(666),
new KeyValue(shear.xProperty(), -0.0390625),
new KeyValue(shear.yProperty(), -0.0390625)),
new KeyFrame(Duration.millis(777),
new KeyValue(shear.xProperty(), 0.01953125),
new KeyValue(shear.yProperty(), 0.01953125)),
new KeyFrame(Duration.millis(888),
new KeyValue(shear.xProperty(), 0),
new KeyValue(shear.yProperty(), 0))));
}
public Digit(Color onColor, Color offColor, Effect onEffect, Effect offEffect) {
this.onColor = onColor;
this.offColor = offColor;
this.onEffect = onEffect;
this.offEffect = offEffect;
getChildren().addAll(polygons);
getTransforms().add(new Shear(-0.1,0));
showNumber(0);
}