当前位置: 首页>>代码示例>>Java>>正文


Java Rectangle.setX方法代码示例

本文整理汇总了Java中javafx.scene.shape.Rectangle.setX方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.setX方法的具体用法?Java Rectangle.setX怎么用?Java Rectangle.setX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.shape.Rectangle的用法示例。


在下文中一共展示了Rectangle.setX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: populateRenderCells

import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
private void populateRenderCells(Group squares, Stage primaryScene) {
    int SPACING = 1;

    screenCenter = new Point((int) primaryScene.getWidth() / (2 * (sideSize + SPACING)),
            (int) primaryScene.getHeight() / (2 * (sideSize + SPACING)));
    renderMap = new HashMap<>();

    for (int y = 0; y < height / (sideSize + SPACING); y++) {
        for (int x = 0; x < width / (sideSize + SPACING); x++) {
            Point position = new Point(x, y).minus(screenCenter);
            Rectangle square = new Rectangle(sideSize, sideSize, Color.BLACK);
            square.setX(x * (sideSize + SPACING));
            square.setY(y * (sideSize + SPACING));
            if (!position.isOrigin()) {
                renderMap.put(position, square);
            } else {
                square.setFill(Color.ORANGE);
            }
            squares.getChildren().add(square);
        }
    }
}
 
开发者ID:slemonide,项目名称:GraphSpace,代码行数:23,代码来源:Main.java

示例2: drawSelection

import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
private static void drawSelection(Group parent, Pane content) {
//        Rectangle selection1 = new Rectangle();
        Rectangle selection2 = new Rectangle();

        Stream.of(selection2).forEach(rect -> {
            rect.setMouseTransparent(true);

            rect.setStroke(SELECTION_STROKE_COLOR);
            rect.setStrokeWidth(SELECTION_STROKE_WIDTH);
            rect.setStrokeLineCap(StrokeLineCap.ROUND);
            rect.setFill(SELECTION_FILL_COLOR);

            rect.yProperty().bind(JfxUtils.ZERO_PROPERTY);
            rect.heightProperty().bind(content.heightProperty());
        });
//
//        selection1.setX(200);
//        selection1.setWidth(100);

        selection2.setX(500);
        selection2.setWidth(500);

        parent.getChildren().addAll(selection2);
    }
 
开发者ID:lttng,项目名称:lttng-scope,代码行数:25,代码来源:UiModelApp2.java

示例3: adjust_rectangle_properties

import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
void adjust_rectangle_properties(double starting_point_x, double starting_point_y, double ending_point_x,
        double ending_point_y, Rectangle given_rectangle) {
    given_rectangle.setX(starting_point_x);
    given_rectangle.setY(starting_point_y);
    given_rectangle.setWidth(ending_point_x - starting_point_x);
    given_rectangle.setHeight(ending_point_y - starting_point_y);

    if (given_rectangle.getWidth() < 0) {
        given_rectangle.setWidth(-given_rectangle.getWidth());
        given_rectangle.setX(given_rectangle.getX() - given_rectangle.getWidth());
    }

    if (given_rectangle.getHeight() < 0) {
        given_rectangle.setHeight(-given_rectangle.getHeight());
        given_rectangle.setY(given_rectangle.getY() - given_rectangle.getHeight());
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:18,代码来源:ImagePanel.java

示例4: onMousePressed

import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public void onMousePressed(MouseEvent event){
    mouseDragRectangle = new Rectangle();
    mouseDragRectangle.setFill(null);
    mouseDragRectangle.setStroke(Color.BLACK);
    aDrawPane.getChildren().add(mouseDragRectangle);
    mouseDragStartX = event.getX();
    mouseDragStartY = event.getY();


    if(event.getSource() instanceof AbstractNodeView){
        mouseDragRectangle.setX(((AbstractNodeView)event.getSource()).getX() + mouseDragStartX);
        mouseDragRectangle.setY(((AbstractNodeView)event.getSource()).getY() + mouseDragStartY);

    } else {
        mouseDragRectangle.setX(event.getX());
        mouseDragRectangle.setY(event.getY());
    }
}
 
开发者ID:kaanburaksener,项目名称:octoBubbles,代码行数:19,代码来源:CreateNodeController.java

示例5: 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);
}
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:24,代码来源:AspectRatioImageRectangleUtil.java

示例6: start

import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, Color.BLACK);
    primaryStage.setScene(scene);

    Group squares = new Group();
    int SPACING = 1;
    for (int y = 0; y < HEIGHT; y += SIDE_SIZE + SPACING) {
        for (int x = 0; x < WIDTH; x += SIDE_SIZE + SPACING) {
            Rectangle square = new Rectangle(SIDE_SIZE, SIDE_SIZE, Color.web("brown"));
            square.setX(x);
            square.setY(y);

            squares.getChildren().add(square);
        }
    }
    root.getChildren().add(squares);

    primaryStage.show();
}
 
开发者ID:slemonide,项目名称:GraphSpace,代码行数:22,代码来源:NiceGUI.java

示例7: onTouchDragged

import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public void onTouchDragged(TouchEvent event){
    Rectangle dragRectangle = dragRectangles.get(event.getTouchPoint().getId());
    Point2D startPoint = dragStarts.get(event.getTouchPoint().getId());

    if(event.getSource() instanceof AbstractNodeView){
        dragRectangle.setWidth(Math.abs(((AbstractNodeView)event.getSource()).getX() + event.getTouchPoint().getX() - startPoint.getX()));
        dragRectangle.setHeight(Math.abs(((AbstractNodeView)event.getSource()).getY() + event.getTouchPoint().getY() - startPoint.getY()));
        dragRectangle.setX(Math.min(startPoint.getX(), ((AbstractNodeView)event.getSource()).getX() + event.getTouchPoint().getX()));
        dragRectangle.setY(Math.min(startPoint.getY(), ((AbstractNodeView)event.getSource()).getY() + event.getTouchPoint().getY()));


    } else {
        dragRectangle.setWidth(Math.abs(startPoint.getX() - event.getTouchPoint().getX()));
        dragRectangle.setHeight(Math.abs(startPoint.getY() - event.getTouchPoint().getY()));
        dragRectangle.setX(Math.min(startPoint.getX(), event.getTouchPoint().getX()));
        dragRectangle.setY(Math.min(startPoint.getY(), event.getTouchPoint().getY()));

    }
}
 
开发者ID:kaanburaksener,项目名称:octoBubbles,代码行数:20,代码来源:CreateNodeController.java

示例8: onTouchPressed

import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public void onTouchPressed(TouchEvent event){
    Rectangle dragRectangle = new Rectangle();
    dragRectangle.setFill(null);
    dragRectangle.setStroke(Color.BLACK);

    if(event.getSource() instanceof AbstractNodeView){
        dragRectangle.setX(event.getTouchPoint().getX() + ((AbstractNodeView) event.getSource()).getX());
        dragRectangle.setY(event.getTouchPoint().getY() + ((AbstractNodeView) event.getSource()).getY());
        dragStarts.put(event.getTouchPoint().getId(), new Point2D(
                event.getTouchPoint().getX() + ((AbstractNodeView) event.getSource()).getX()
                , event.getTouchPoint().getY() + ((AbstractNodeView) event.getSource()).getY()));

    } else {
        dragRectangle.setX(event.getTouchPoint().getX());
        dragRectangle.setY(event.getTouchPoint().getY());
        dragStarts.put(event.getTouchPoint().getId(), new Point2D(event.getTouchPoint().getX(), event.getTouchPoint().getY()));
    }

    dragRectangles.put(event.getTouchPoint().getId(), dragRectangle);
    aDrawPane.getChildren().add(dragRectangle);
}
 
开发者ID:kaanburaksener,项目名称:octoBubbles,代码行数:22,代码来源:CreateNodeController.java

示例9: createPieceRectangle

import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
private Rectangle createPieceRectangle() {
    Rectangle rec = new Rectangle();
    rec.setX(-50);
    rec.setY(-50);
    rec.setWidth(SIZE);
    rec.setHeight(SIZE);
    return rec;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:PuzzlePieces.java

示例10: NodePropertiesSample

import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public NodePropertiesSample() {
    super(300,100);
    //X position of node = X + LayoutX + TranslateX
    rectA = new Rectangle(50, 50, Color.LIGHTSALMON);
    //set position of node temporary (can be changed after)
    rectA.setTranslateX(10);

    rectB = new Rectangle(50, 50, Color.LIGHTGREEN);
    //set position of node when addinf to some layout
    rectB.setLayoutX(20);
    rectB.setLayoutY(10);

    rectC = new Rectangle(50, 50, Color.DODGERBLUE);
    //last posibility of setting X position of node
    rectC.setX(30);
    rectC.setY(20);

    //opacity of node can be set
    rectC.setOpacity(0.8);

    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Rectangle A translate X", rectA.translateXProperty(), 0d, 50d),
            new SimplePropertySheet.PropDesc("Rectangle B translate X", rectB.translateXProperty(), 0d, 50d),
            new SimplePropertySheet.PropDesc("Rectangle C translate X", rectC.translateXProperty(), 0d, 50d),
            new SimplePropertySheet.PropDesc("Rectangle A Opacity", rectA.opacityProperty(), 0d, 1d),
            new SimplePropertySheet.PropDesc("Rectangle B Opacity", rectB.opacityProperty(), 0d, 1d),
            new SimplePropertySheet.PropDesc("Rectangle C Opacity", rectC.opacityProperty(), 0d, 1d)
            );

    getChildren().add(createRadioButtons());
    // END REMOVE ME

    Group g = new Group(rectA, rectB, rectC);
    g.setLayoutX(160 + 35);
    getChildren().addAll(g);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:38,代码来源:NodePropertiesSample.java

示例11: start

import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, Color.BLACK);
    primaryStage.setScene(scene);

    Group squares = new Group();
    int SPACING = 1;
    for (int y = 0; y < HEIGHT; y += SIDE_SIZE + SPACING) {
        for (int x = 0; x < WIDTH; x += SIDE_SIZE + SPACING) {
            String color;
            if (Math.random() > 0.99) {
                color = "brown";
            } else {
                color = "orange";
            }
            Rectangle square = new Rectangle(SIDE_SIZE, SIDE_SIZE, Color.web(color));
            square.setX(x);
            square.setY(y);

            squares.getChildren().add(square);
        }
    }
    root.getChildren().add(squares);

    primaryStage.show();
}
 
开发者ID:slemonide,项目名称:GraphSpace,代码行数:28,代码来源:Main.java

示例12: draw

import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public void draw() {
    // Draw elevator
    Rectangle rgB = new Rectangle(WIDTH, HEIGHT);
    rgB.setFill(Color.TRANSPARENT);
    this.getChildren().add(rgB);
    
    rgT = new Rectangle((WIDTH / 3) * 2 + (WIDTH / (WIDTH / 8)), HEIGHT / 1.5 + (HEIGHT / (HEIGHT / 4)));
    rgT.setFill(Color.web("bfbfbf"));
    rgT.setX(WIDTH / 2 - rgT.getWidth() / 2);
    rgT.setY(HEIGHT - rgT.getHeight());
    this.getChildren().add(rgT);

    //Left side elevator shaft door
    rgD1 = new Rectangle(WIDTH / 3, HEIGHT / 1.5);
    rgD1.setFill(Color.web("a5a5a5"));
    rgD1.setX(WIDTH / 2 - rgD1.getWidth());
    rgD1.setY(HEIGHT - rgD1.getHeight());
    this.getChildren().add(rgD1);

    //Right side elevator shaft door
    rgD2 = new Rectangle(WIDTH / 3, HEIGHT / 1.5);
    rgD2.setFill(Color.web("a5a5a5"));
    rgD2.setX(WIDTH / 2);
    rgD2.setY(HEIGHT - rgD2.getHeight());
    this.getChildren().add(rgD2);
    
    // Draw text
    tFloorNum = new Text(String.valueOf(FLOORNUM));
    tFloorNum.setFill(Color.web("bfbfbf"));
    tFloorNum.setFont(Font.font("Verdana", 20));
    tFloorNum.setX(WIDTH / 2 - tFloorNum.getBoundsInParent().getWidth() / 2);
    tFloorNum.setY(rgT.getY() - tFloorNum.getBoundsInParent().getHeight() / 2);
    this.getChildren().add(tFloorNum);
}
 
开发者ID:spencerhendon,项目名称:projectintern,代码行数:35,代码来源:Elevator.java

示例13: resizeBlindFoldPanel

import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
private static void resizeBlindFoldPanel(Rectangle blindFoldPanel, HBox menuHBox) {
    blindFoldPanel.setX(0);
    blindFoldPanel.setY(0);
    blindFoldPanel.setWidth(menuHBox.getWidth());
    blindFoldPanel.setHeight(menuHBox.getHeight());
}
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:7,代码来源:GameContext.java

示例14: drawStorage

import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public void drawStorage() { // Shelf and boxes
    // Draw shelf
    Rectangle rgST = new Rectangle(WIDTH / 3, HEIGHT / 2);
    rgST.setFill(Color.web("673232"));
    gShelf.getChildren().add(rgST);
    
    Rectangle rgSB = new Rectangle(rgST.getWidth() - (WIDTH / (WIDTH / 4)), rgST.getHeight() / 12);
    rgSB.setX(rgST.getWidth() / 2 - rgSB.getWidth() / 2);
    rgSB.setY(rgST.getHeight());
    rgSB.setFill(Color.web("4d2626"));
    gShelf.getChildren().add(rgSB);
    
    Rectangle rgSI = new Rectangle(rgST.getWidth() - (WIDTH / (WIDTH / 4)), rgST.getHeight() - (HEIGHT / (HEIGHT / 4)));
    rgSI.setX((WIDTH / (WIDTH / 2)));
    rgSI.setY((HEIGHT / (HEIGHT / 2)));
    rgSI.setFill(Color.web("7d3232"));
    gShelf.getChildren().add(rgSI);
    
    Rectangle rgSDT = new Rectangle(rgST.getWidth(), (HEIGHT / (HEIGHT / 2)));
    rgSDT.setY(rgST.getY() + (rgST.getHeight() / 3));
    rgSDT.setFill(Color.web("673232"));
    gShelf.getChildren().add(rgSDT);
    
    Rectangle rgSDB = new Rectangle(rgST.getWidth(), (HEIGHT / (HEIGHT / 2)));
    rgSDB.setY(rgST.getY() + (rgST.getHeight() / 3) * 2);
    rgSDB.setFill(Color.web("673232"));
    gShelf.getChildren().add(rgSDB);
    
    // Draw boxes
    Rectangle rgB1 = new Rectangle(rgST.getWidth() / 3, rgST.getHeight() / 4);
    rgB1.setX(WIDTH / (WIDTH / 2));
    rgB1.setY(rgSDB.getY() - rgB1.getHeight());
    rgB1.setFill(Color.web("d6b0a0"));
    gShelf.getChildren().add(rgB1);
    
    Rectangle rgB2 = new Rectangle(rgST.getWidth() / 3, rgST.getHeight() / 4);
    rgB2.setX(WIDTH / (WIDTH / 2) + rgB2.getWidth());
    rgB2.setY(rgSDT.getY() - rgB1.getHeight());
    rgB2.setFill(Color.web("d6b0a0"));
    gShelf.getChildren().add(rgB2);
    
    Rectangle rgB3 = new Rectangle(rgST.getWidth() / 3, rgST.getHeight() / 4);
    rgB3.setX(WIDTH / (WIDTH / 2) + rgB2.getWidth() + (rgB2.getWidth() / 2));
    rgB3.setY(rgST.getY() + rgST.getHeight() - rgB1.getHeight() - (HEIGHT / (HEIGHT / 2)));
    rgB3.setFill(Color.web("d6b0a0"));
    gShelf.getChildren().add(rgB3);
    
    // Position shelf
    gShelf.setTranslateX(WIDTH - gShelf.getBoundsInParent().getWidth() * 2.25);
    gShelf.setTranslateY(HEIGHT - gShelf.getBoundsInParent().getHeight());
    this.getChildren().add(gShelf);
}
 
开发者ID:spencerhendon,项目名称:projectintern,代码行数:53,代码来源:Room.java

示例15: drawRestroom

import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public void drawRestroom() { // Toilet and sink
    // Draw toilet
    Rectangle rgTL = new Rectangle(WIDTH / 8, (HEIGHT / (HEIGHT / 4)));
    rgTL.setFill(Color.web("a5a5a5"));
    gToilet.getChildren().add(rgTL);
    
    Rectangle rgTT = new Rectangle(WIDTH / 10, HEIGHT / 10);
    rgTT.setX(rgTL.getWidth() / 2 - rgTT.getWidth() / 2);
    rgTT.setY(rgTL.getHeight());
    rgTT.setFill(Color.web("bfbfbf"));
    gToilet.getChildren().add(rgTT);
    
    Polygon rgTB = new Polygon();
    rgTB.getPoints().addAll(new Double[] {
        rgTL.getWidth() * 0.05, rgTT.getY() + rgTT.getHeight(),
        rgTL.getWidth() * 0.95, rgTT.getY() + rgTT.getHeight(),
        rgTL.getWidth() * 0.85, rgTT.getY() + rgTT.getHeight() + rgTL.getHeight() * 3,
        rgTL.getWidth() * 0.15, rgTT.getY() + rgTT.getHeight() + rgTL.getHeight() * 3,
    });
    rgTB.setFill(Color.web("bfbfbf"));
    gToilet.getChildren().add(rgTB);
    
    Rectangle rgTS = new Rectangle(rgTL.getWidth() / 2, rgTL.getHeight() * 2);
    rgTS.setX(rgTL.getWidth() / 2 - rgTS.getWidth() / 2);
    rgTS.setY(rgTB.getBoundsInParent().getMaxY());
    rgTS.setFill(Color.web("bfbfbf"));
    gToilet.getChildren().add(rgTS);
    
    // Position toilet
    gToilet.setTranslateX(WIDTH / 4);
    gToilet.setTranslateY(HEIGHT - gToilet.getBoundsInParent().getHeight());
    this.getChildren().add(gToilet);
    
    // Draw sink
    HBox hbSinkHandles = new HBox(WIDTH / (WIDTH / 4));
    gSink.getChildren().add(hbSinkHandles);
    
    Rectangle rgSHL = new Rectangle(WIDTH / (WIDTH / 4), HEIGHT / (HEIGHT / 8));
    rgSHL.setFill(Color.web("7f7f7f"));
    rgSHL.setTranslateY(2);
    hbSinkHandles.getChildren().add(rgSHL);
    
    Rectangle rgSHM = new Rectangle(WIDTH / (WIDTH / 4), HEIGHT / (HEIGHT / 12));
    rgSHM.setFill(Color.web("7f7f7f"));
    hbSinkHandles.getChildren().add(rgSHM);
    
    Rectangle rgSHR = new Rectangle(WIDTH / (WIDTH / 4), HEIGHT / (HEIGHT / 8));
    rgSHR.setFill(Color.web("7f7f7f"));
    rgSHR.setTranslateY(2);
    hbSinkHandles.getChildren().add(rgSHR);
    
    Rectangle rgST = new Rectangle(WIDTH / 8, (HEIGHT / (HEIGHT / 8)));
    rgST.setFill(Color.web("a5a5a5"));
    gSink.getChildren().add(rgST);
    
    Rectangle rgSS = new Rectangle(rgST.getWidth() / 2, rgST.getHeight() * 4);
    rgSS.setX(rgST.getWidth() / 2 - rgSS.getWidth() / 2);
    rgSS.setY(rgST.getY() + rgST.getHeight());
    rgSS.setFill(Color.web("bfbfbf"));
    gSink.getChildren().add(rgSS);
    
    // Position sink
    hbSinkHandles.setTranslateX(gSink.getBoundsInParent().getWidth() / 2 - (hbSinkHandles.getSpacing() * 5) / 2);
    hbSinkHandles.setTranslateY(-HEIGHT / (HEIGHT / 8));
    gSink.setTranslateX(WIDTH / 4 + gToilet.getBoundsInParent().getWidth() + (gSink.getBoundsInParent().getWidth() / 2));
    gSink.setTranslateY(HEIGHT - gSink.getBoundsInParent().getHeight() - hbSinkHandles.getTranslateY());
    this.getChildren().add(gSink);
}
 
开发者ID:spencerhendon,项目名称:projectintern,代码行数:69,代码来源:Room.java


注:本文中的javafx.scene.shape.Rectangle.setX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。