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


Java Shape.setTranslateX方法代碼示例

本文整理匯總了Java中javafx.scene.shape.Shape.setTranslateX方法的典型用法代碼示例。如果您正苦於以下問題:Java Shape.setTranslateX方法的具體用法?Java Shape.setTranslateX怎麽用?Java Shape.setTranslateX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.shape.Shape的用法示例。


在下文中一共展示了Shape.setTranslateX方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: generateMecanumDriveBase

import javafx.scene.shape.Shape; //導入方法依賴的package包/類
/**
 * Generates a mecanum drive base.
 *
 * @param wheelWidth  the width (or thickness) of the wheels
 * @param wheelHeight the height (or diameter) of the wheels
 * @param frameWidth  the width of the robot frame
 * @param frameHeight the height of the robot frame
 */
private static Shape generateMecanumDriveBase(double wheelWidth,
                                              double wheelHeight,
                                              double frameWidth,
                                              double frameHeight) {
  Rectangle frame = new Rectangle(wheelWidth, 0, frameWidth, frameHeight);
  frame.setFill(null);
  frame.setStroke(Color.WHITE);

  final Shape fl = mecanumWheel(wheelWidth, wheelHeight, MecanumWheelPos.FRONT_LEFT);
  final Shape fr = mecanumWheel(wheelWidth, wheelHeight, MecanumWheelPos.FRONT_RIGHT);
  final Shape rl = mecanumWheel(wheelWidth, wheelHeight, MecanumWheelPos.REAR_LEFT);
  final Shape rr = mecanumWheel(wheelWidth, wheelHeight, MecanumWheelPos.REAR_RIGHT);
  fr.setTranslateX(frameWidth + wheelWidth);
  rl.setTranslateY(frameHeight - wheelHeight);
  rr.setTranslateX(frameWidth + wheelWidth);
  rr.setTranslateY(frameHeight - wheelHeight);

  Shape combined = union(frame, fl, fr, rl, rr);
  combined.getStyleClass().addAll("robot-drive", "mecanum-drive");
  return combined;
}
 
開發者ID:wpilibsuite,項目名稱:shuffleboard,代碼行數:30,代碼來源:MecanumDriveWidget.java

示例2: register

import javafx.scene.shape.Shape; //導入方法依賴的package包/類
private void register(final ShapeFactory content, final int slotsize) {
    final PageWithSlots page = new PageWithSlots(content.name, height, width);
    page.setSlotSize(slotsize, slotsize);
    for (final AbstractEffect effect : effects) {
                Pane slot = new Pane();//Region();
                Shape shape = content.createShape();
                shape.setTranslateX(10);
                shape.setTranslateY(10);
                effect.setEffect(shape, slot); // will add shape to scene at the appropriate moment
        page.add(new TestNodeLeaf(effect.name(), slot));
    }

    Shape customShape = content.createCustomShape();
    if (null != customShape) {
        customShape.setTranslateX(10);
        customShape.setTranslateY(10);
        page.add(new TestNodeLeaf("customShape", customShape));
    }
    rootTestNode.add(page);
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:21,代碼來源:Shapes2App.java

示例3: addDebugView

import javafx.scene.shape.Shape; //導入方法依賴的package包/類
private void addDebugView(HitBox hitBox) {
    Shape view = null;

    if (hitBox.getShape().isCircle()) {
        double radius = hitBox.getWidth() / 2;
        view = new Circle(radius, radius, radius, null);

    } else if (hitBox.getShape().isRectangle()) {
        view = new Rectangle(hitBox.getWidth(), hitBox.getHeight(), null);
    }

    if (view != null) {
        view.setStroke(showBBoxColor);

        view.setTranslateX(hitBox.getMinX());
        view.setTranslateY(hitBox.getMinY());

        debugBBox.getChildren().add(view);
    }
}
 
開發者ID:AlmasB,項目名稱:FXGL,代碼行數:21,代碼來源:ViewComponent.java

示例4: TestLoadingScene

import javafx.scene.shape.Shape; //導入方法依賴的package包/類
public TestLoadingScene() {

        getText().setFont(Font.font("Segoe UI", 24));
        getText().setTranslateY(50);

        Circle circle = new Circle(50, 50, 50);

        Shape shape = Shape.subtract(new Rectangle(100, 100), circle);
        shape.setFill(Color.BLUE);
        shape.setStroke(Color.YELLOW);

        RotateTransition rt = new RotateTransition(Duration.seconds(2), shape);
        rt.setByAngle(360);
        rt.setCycleCount(15);
        rt.play();

        shape.setTranslateX(700);
        shape.setTranslateY(500);

        getContentRoot().getChildren().set(1, shape);
    }
 
開發者ID:AlmasB,項目名稱:FXGL,代碼行數:22,代碼來源:TestLoadingScene.java

示例5: TriCircle

import javafx.scene.shape.Shape; //導入方法依賴的package包/類
public TriCircle() {
    Shape shape1 = Shape.subtract(new Circle(5), new Circle(2));
    shape1.setFill(Color.WHITE);

    Shape shape2 = Shape.subtract(new Circle(5), new Circle(2));
    shape2.setFill(Color.WHITE);
    shape2.setTranslateX(5);

    Shape shape3 = Shape.subtract(new Circle(5), new Circle(2));
    shape3.setFill(Color.WHITE);
    shape3.setTranslateX(2.5);
    shape3.setTranslateY(-5);

    getChildren().addAll(shape1, shape2, shape3);

    setEffect(new GaussianBlur(2));
}
 
開發者ID:AlmasB,項目名稱:FXTutorials,代碼行數:18,代碼來源:MKXMenuApp.java

示例6: 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

示例7: createTraceWidget

import javafx.scene.shape.Shape; //導入方法依賴的package包/類
private Pane createTraceWidget(ITraceExtractor<Step<?>, State<?,?>, TracedObject<?>, Dimension<?>, Value<?>> extractor, String label, ReadOnlyDoubleProperty width) {
	final Pane pane = new Pane();
	pane.setBackground(TRANSPARENT_BACKGROUND);
	final Rectangle rectangle = new Rectangle(0, 0, 0, 12);
	rectangle.setFill(Color.LIGHTGRAY);
	rectangle.widthProperty().bind(width.subtract(10));
	rectangle.setArcHeight(12);
	rectangle.setArcWidth(12);
	Label text = new Label(label);
	text.setTextOverrun(OverrunStyle.ELLIPSIS);
	text.setAlignment(Pos.CENTER);
	text.setMouseTransparent(true);
	text.setTextFill(Color.WHITE);
	text.setFont(FONT);
	text.setMaxWidth(0);
	text.maxWidthProperty().bind(rectangle.widthProperty());
	StackPane layout = new StackPane();
	layout.getChildren().addAll(rectangle, text);
	pane.getChildren().add(layout);
	layout.setTranslateY(13);
	layout.setTranslateX(5);
	pane.setPrefHeight(25);
	pane.setMinHeight(25);
	pane.setMaxHeight(25);

	final Shape arrow1 = createCursor();
	final Shape arrow2 = createCursor();
	arrow1.setTranslateX(5);
	arrow1.setTranslateY(4);
	arrow2.translateXProperty().bind(rectangle.widthProperty().add(5));
	arrow2.setTranslateY(4);
	pane.getChildren().add(arrow1);
	pane.getChildren().add(arrow2);
	
	return pane;
}
 
開發者ID:eclipse,項目名稱:gemoc-studio-modeldebugging,代碼行數:37,代碼來源:TraceSectionsDialog.java

示例8: moveTo

import javafx.scene.shape.Shape; //導入方法依賴的package包/類
/**
 * Moves this cell to the given x and y coordinates
 * @param x the x coordinate to move to
 * @param y the y coordinate to move to
 * @param animate whether to animate the transition from the old position
 * @param emphasize whether to have the Highlighter class emphasize this cell while it moves
 */
void moveTo(double x, double y, boolean animate, boolean emphasize){
    if(animate && numCellsBeingAnimated < MAX_NUM_CELLS_TO_ANIMATE){
        numCellsBeingAnimated++;

        Shape placeHolder = (Shape) getBaseView();
        placeHolder.setTranslateX(x+TreeLayout.H_PAD);
        placeHolder.setTranslateY(y+BOX_SHIFT);
        placeHolder.setOpacity(0.0);
        ((Pane)(this.getParent())).getChildren().add(placeHolder);

        TranslateTransition t = new TranslateTransition(Duration.millis(3000), this);
        t.setToX(x);
        t.setToY(y+BOX_SHIFT);
        t.setCycleCount(1);
        t.setOnFinished(event -> {
            numCellsBeingAnimated--;
            ((Pane)(this.getParent())).getChildren().remove(placeHolder);
        });
        t.play();

        if(emphasize){
            Highlighter.emphasizeCell(this);
        }
    }else{
        setTranslateX(x);
        setTranslateY(y+BOX_SHIFT);
    }
    this.refLabel.translate(x,y);
    this.hasUpdatedPosition.set(true);
    if (!this.refLabel.isVisible())
        this.refLabel.setVisible(true);
}
 
開發者ID:dmusican,項目名稱:Elegit,代碼行數:40,代碼來源:Cell.java

示例9: createTraceWidget

import javafx.scene.shape.Shape; //導入方法依賴的package包/類
private Pane createTraceWidget(ITraceExtractor extractor, String label, ReadOnlyDoubleProperty width) {
	final Pane pane = new Pane();
	pane.setBackground(TRANSPARENT_BACKGROUND);
	final Rectangle rectangle = new Rectangle(0, 0, 0, 12);
	rectangle.setFill(Color.LIGHTGRAY);
	rectangle.widthProperty().bind(width.subtract(10));
	rectangle.setArcHeight(12);
	rectangle.setArcWidth(12);
	Label text = new Label(label);
	text.setTextOverrun(OverrunStyle.ELLIPSIS);
	text.setAlignment(Pos.CENTER);
	text.setMouseTransparent(true);
	text.setTextFill(Color.WHITE);
	text.setFont(FONT);
	text.setMaxWidth(0);
	text.maxWidthProperty().bind(rectangle.widthProperty());
	StackPane layout = new StackPane();
	layout.getChildren().addAll(rectangle, text);
	pane.getChildren().add(layout);
	layout.setTranslateY(13);
	layout.setTranslateX(5);
	pane.setPrefHeight(25);
	pane.setMinHeight(25);
	pane.setMaxHeight(25);

	final Group group1 = new Group();
	final Label label1 = new Label();
	final Shape arrow1 = createCursor();
	final Group group2 = new Group();
	final Shape arrow2 = createCursor();
	arrow1.setTranslateX(5);
	arrow1.setTranslateY(4);
	arrow2.translateXProperty().bind(rectangle.widthProperty().add(5));
	arrow2.setTranslateY(4);
	pane.getChildren().add(arrow1);
	pane.getChildren().add(arrow2);
	
	return pane;
}
 
開發者ID:SiriusLab,項目名稱:ModelDebugging,代碼行數:40,代碼來源:TraceSectionsDialog.java


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