本文整理汇总了Java中javafx.scene.shape.Shape.union方法的典型用法代码示例。如果您正苦于以下问题:Java Shape.union方法的具体用法?Java Shape.union怎么用?Java Shape.union使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.shape.Shape
的用法示例。
在下文中一共展示了Shape.union方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import javafx.scene.shape.Shape; //导入方法依赖的package包/类
/**
* Creates a new curved arrow.
*
* @param startAngle the starting angle of the arc, in radians
* @param radius the radius of the arrow. Must be non-negative.
* @param length the length of the arrow, in the same units as {@code radius}
* @param xOffset how much to offset the arc along the X-axis
* @param headSize the length of the head of the arrow
*
* @return a curved arrow shape
*
* @throws IllegalArgumentException if {@code radius} or {@code headSize} are negative
*/
public static Shape create(double startAngle,
double radius,
double length,
double xOffset,
double headSize) {
if (radius < 0) {
throw new IllegalArgumentException("Radius cannot be negative. Given: " + radius);
}
if (headSize < 0) {
throw new IllegalArgumentException("The size of the arrowhead cannot be negative. Given: " + headSize);
}
if (radius == Double.POSITIVE_INFINITY) {
// infinite radius = straight
return createStraight(length, startAngle, xOffset, headSize);
}
return Shape.union(
makeBody(startAngle, radius, length, xOffset),
curvedHead(startAngle, headSize, radius, xOffset, length)
);
}
示例2: start
import javafx.scene.shape.Shape; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
double r = SMALL ? 100 : 1843200.0;
double c = D - r / sqrt2;
Circle circle = new Circle(c, c, r, Color.GREY);
Circle littlecircle = new Circle(c, c, 10, Color.GREY);
Shape shape = Shape.union(circle, littlecircle);
printShape(shape);
shape.setFill(Color.BLUE);
shape.setStroke(Color.RED);
shape.setStrokeWidth(2.0);
shape.getStrokeDashArray().addAll(10.0, 5.0);
Pane root = new Pane();
root.getChildren().add(shape);
stage.setScene(new Scene(root, SIZE, SIZE));
stage.show();
}
示例3: createPiece
import javafx.scene.shape.Shape; //导入方法依赖的package包/类
private Shape createPiece() {
Shape shape = createPieceRectangle();
if (hasRightTab) {
shape = Shape.union(shape,
createPieceTab(69.5f, 0f, 10f, 17.5f, 50f, -12.5f, 11.5f,
25f, 56.25f, -14f, 6.25f, 56.25f, 14f, 6.25f));
}
if (hasBottomTab) {
shape = Shape.union(shape,
createPieceTab(0f, 69.5f, 17.5f, 10f, -12.5f, 50f, 25f,
11f, -14f, 56.25f, 6.25f, 14f, 56.25f, 6.25f));
}
if (hasLeftTab) {
shape = Shape.subtract(shape,
createPieceTab(-31f, 0f, 10f, 17.5f, -50f, -12.5f, 11f,
25f, -43.75f, -14f, 6.25f, -43.75f, 14f, 6.25f));
}
if (hasTopTab) {
shape = Shape.subtract(shape,
createPieceTab(0f, -31f, 17.5f, 10f, -12.5f, -50f, 25f,
12.5f, -14f, -43.75f, 6.25f, 14f, -43.75f, 6.25f));
}
shape.setTranslateX(correctX);
shape.setTranslateY(correctY);
shape.setLayoutX(50f);
shape.setLayoutY(50f);
return shape;
}
示例4: createPieceTab
import javafx.scene.shape.Shape; //导入方法依赖的package包/类
private Shape createPieceTab(double eclipseCenterX, double eclipseCenterY, double eclipseRadiusX, double eclipseRadiusY,
double rectangleX, double rectangleY, double rectangleWidth, double rectangleHeight,
double circle1CenterX, double circle1CenterY, double circle1Radius,
double circle2CenterX, double circle2CenterY, double circle2Radius) {
Ellipse e = new Ellipse(eclipseCenterX, eclipseCenterY, eclipseRadiusX, eclipseRadiusY);
Rectangle r = new Rectangle(rectangleX, rectangleY, rectangleWidth, rectangleHeight);
Shape tab = Shape.union(e, r);
Circle c1 = new Circle(circle1CenterX, circle1CenterY, circle1Radius);
tab = Shape.subtract(tab, c1);
Circle c2 = new Circle(circle2CenterX, circle2CenterY, circle2Radius);
tab = Shape.subtract(tab, c2);
return tab;
}
示例5: createXShape
import javafx.scene.shape.Shape; //导入方法依赖的package包/类
private Shape createXShape() {
Line l1 = new Line(0, 0, w, h);
Line l2 = new Line(w, 0, 0, h);
Shape shapeX = Shape.union(l1, l2);
shapeX.setId("xl-title-bar-close-button-shape");
return shapeX;
}
示例6: Pawn
import javafx.scene.shape.Shape; //导入方法依赖的package包/类
/**
* The main constructor
* @param player the player associated the pawn
*/
public Pawn(Player player) {
this.player = player;
color = player.getRole().roleToColor();
Circle circle = new Circle(10,10,5, color);
Polygon triangle= new Polygon(circle.getCenterX(), circle.getCenterY() - circle.getRadius(), circle.getCenterX() + circle.getRadius(), circle.getCenterY() + circle.getRadius()*3, circle.getCenterX() - circle.getRadius(), circle.getCenterY() + circle.getRadius()*3);
shape = Shape.union(circle, triangle);
shape.setFill(player.getRole().roleToColor());
shape.setStroke(color.deriveColor(0, 1, .5, 1));
shape.setStrokeWidth(2);
}
示例7: ThePlayer
import javafx.scene.shape.Shape; //导入方法依赖的package包/类
public ThePlayer() {
this.setBackground(Urmusic.PANES_BACKGROUND_FLAT);
this.setBorder(new Border(new BorderStroke(Color.web("#222"), null, null, null, BorderStrokeStyle.SOLID, null, null, null, null, new BorderWidths(1, 0, 0, 0), null)));
this.setPrefHeight(PLAYER_HEIGHT);
Pane playPauseBtnPane = new Pane();
this.playBtnShape = new Polygon(0.0, 7.5, 15.0, 0.0, 0.0, -7.5);
this.playBtnShape.setFill(Color.WHITE);
this.pauseBtnShape = Shape.union(new Rectangle(0.0, -7.5, 6.5, 15.0), new Rectangle(8.0, -7.5, 6.5, 15.0));
this.pauseBtnShape.setFill(Color.WHITE);
this.pauseBtnShape.visibleProperty().bind(this.playBtnShape.visibleProperty().not());
playPauseBtnPane.setLayoutX(10);
playPauseBtnPane.layoutYProperty().bind(this.heightProperty().subtract(20));
playPauseBtnPane.getChildren().addAll(this.playBtnShape, this.pauseBtnShape);
playPauseBtnPane.setOnMouseClicked((e) -> this.setPlaying(!this.playing));
this.timeSliderBar = new UrSliderBar();
this.timeSliderBar.setLayoutX(40);
this.timeSliderBar.layoutYProperty().bind(playPauseBtnPane.layoutYProperty());
this.timeSliderBar.prefWidthProperty().bind(this.widthProperty().subtract(VOLUME_CONTROL_WIDTH + VOLUME_ICON_SIZE + 70));
this.timeSliderBar.setOnPositionChangedByUser((pos) -> {
if(this.currentSound != null) this.currentSound.setPosition((float) (pos * this.currentSound.getDuration()));
});
this.volumeSliderBar = new UrSliderBar();
this.volumeSliderBar.layoutXProperty().bind(this.widthProperty().subtract(VOLUME_CONTROL_WIDTH + 10));
this.volumeSliderBar.layoutYProperty().bind(this.timeSliderBar.layoutYProperty());
this.volumeSliderBar.setPrefWidth(VOLUME_CONTROL_WIDTH);
this.volumeSliderBar.setSliderPosition(ApplicationPreferences.audioVolume);
this.volumeSliderBar.setOnPositionChangedByUser((pos) -> {
if(this.currentSound != null) this.currentSound.setVolume(pos.floatValue());
ApplicationPreferences.audioVolume = pos;
});
ImageView volumeImg = new ImageView(new Image("/res/img/volume.png"));
volumeImg.layoutXProperty().bind(this.volumeSliderBar.layoutXProperty().subtract(VOLUME_ICON_SIZE + 10.0));
volumeImg.layoutYProperty().bind(playPauseBtnPane.layoutYProperty().subtract(VOLUME_ICON_SIZE / 2));
volumeImg.setFitWidth(VOLUME_ICON_SIZE);
volumeImg.setFitHeight(VOLUME_ICON_SIZE);
Pane timeStuff = new Pane();
timeStuff.layoutXProperty().bind(this.widthProperty().divide(2));
timeStuff.setLayoutY(2);
Font laBelleFonte = Font.font(16.0);
Label currentTimeLabel = new Label();
currentTimeLabel.layoutXProperty().bind(currentTimeLabel.widthProperty().divide(-2).subtract(48));
currentTimeLabel.setLayoutY(0);
currentTimeLabel.textProperty().bind(this.prettytime);
currentTimeLabel.setTextFill(Color.WHITE);
currentTimeLabel.setFont(laBelleFonte);
Label slashLabel = new Label("/");
slashLabel.layoutXProperty().bind(slashLabel.widthProperty().divide(-2));
slashLabel.setLayoutY(0);
slashLabel.setTextFill(Color.WHITE);
slashLabel.setFont(laBelleFonte);
Label durationLabel = new Label();
durationLabel.layoutXProperty().bind(durationLabel.widthProperty().divide(-2).add(48));
durationLabel.setLayoutY(0);
durationLabel.textProperty().bind(this.prettyduration);
durationLabel.setTextFill(Color.WHITE);
durationLabel.setFont(laBelleFonte);
timeStuff.getChildren().addAll(currentTimeLabel, durationLabel, slashLabel);
this.getChildren().addAll(playPauseBtnPane, this.timeSliderBar, volumeImg, this.volumeSliderBar, timeStuff);
this.prettytime.set(Utils.prettyTime(0));
this.prettyduration.set(Utils.prettyTime(0));
}
示例8: createStraight
import javafx.scene.shape.Shape; //导入方法依赖的package包/类
/**
* Creates a straight arrow, which is just a curved arrow with an infinite radius.
*
* @param length the length of the arrow
* @param angle the angle of the arrow, in radians
* @param xOffset how much to offset the arrow along the X-axis
* @param headSize the length of the head of the arrow
*/
public static Shape createStraight(double length, double angle, double xOffset, double headSize) {
double x = Math.cos(angle) * length;
double y = Math.sin(angle) * length;
Line body = new Line(xOffset, 0, x + xOffset, y);
Shape head = straightHead(angle, headSize, xOffset, length);
return Shape.union(body, head);
}