當前位置: 首頁>>代碼示例>>Java>>正文


Java Shape.union方法代碼示例

本文整理匯總了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)
  );
}
 
開發者ID:wpilibsuite,項目名稱:shuffleboard,代碼行數:34,代碼來源:CurvedArrow.java

示例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();
}
 
開發者ID:bourgesl,項目名稱:marlin-fx,代碼行數:22,代碼來源:ShapeOutlineBugCirclePath.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:PuzzlePieces.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:PuzzlePieces.java

示例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;
}
 
開發者ID:to2mbn,項目名稱:LoliXL,代碼行數:8,代碼來源:TitleBarView.java

示例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);
}
 
開發者ID:MrFouss,項目名稱:The-Projects,代碼行數:15,代碼來源:Pawn.java

示例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));
}
 
開發者ID:Nasso,項目名稱:urmusic-desktop,代碼行數:77,代碼來源:ThePlayer.java

示例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);
}
 
開發者ID:wpilibsuite,項目名稱:shuffleboard,代碼行數:16,代碼來源:CurvedArrow.java


注:本文中的javafx.scene.shape.Shape.union方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。