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


Java Rectangle类代码示例

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


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

示例1: generateMecanumDriveBase

import javafx.scene.shape.Rectangle; //导入依赖的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: testConstructor

import javafx.scene.shape.Rectangle; //导入依赖的package包/类
@Test
public void testConstructor() {
    for (javafx.scene.Node node : projectionPane.getChildren()) {
        Rectangle square = (Rectangle) node;
        assertEquals(projection.getSideSize(), square.getHeight(), MAX_ERROR);
        assertEquals(projection.getSideSize(), square.getWidth(), MAX_ERROR);

        assertEquals(getX(node), square.getX(), MAX_ERROR);
        assertEquals(getY(node), square.getY(), MAX_ERROR);

        //assertEquals(Color.BLACK, square.getFill());
    }

    assertEquals(SCN_HEIGHT, projectionPane.getHeight(), MAX_ERROR);
    assertEquals(SCN_WIDTH, projectionPane.getWidth(), MAX_ERROR);
}
 
开发者ID:slemonide,项目名称:GraphSpace,代码行数:17,代码来源:TwoDimensionalProjectionTest.java

示例3: configureDigits

import javafx.scene.shape.Rectangle; //导入依赖的package包/类
private void configureDigits() {
    for (int i : numbers) {
        digits[i] = new Text("0");
        digits[i].setFont(FONT);
        digits[i].setTextOrigin(VPos.TOP);
        digits[i].setLayoutX(2.3);
        digits[i].setLayoutY(-1);
        Rectangle background;
        if (i < 6) {
            background = createBackground(Color.web("#a39f91"), Color.web("#FFFFFF"));
            digits[i].setFill(Color.web("#000000"));
        } else {
            background = createBackground(Color.web("#bdbeb3"), Color.web("#FF0000"));
            digits[i].setFill(Color.web("#FFFFFF"));
        }
        digitsGroup[i] = new Group(background, digits[i]);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:StopWatch.java

示例4: start

import javafx.scene.shape.Rectangle; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) {
    if (primaryStage == null) {
        return;
    }

  Group group = new Group();
  Rectangle rect = new Rectangle(20,20,200,200);

  FadeTransition ft = new FadeTransition(Duration.millis(5000), rect);
  ft.setFromValue(1.0);
  ft.setToValue(0.0);
  ft.play();

  group.getChildren().add(rect);

  Scene scene = new Scene(group, 300, 200);
  primaryStage.setScene(scene);
  primaryStage.show();
}
 
开发者ID:lttng,项目名称:lttng-scope,代码行数:21,代码来源:FadeTransitionEx.java

示例5: showMasterDetailInWindow

import javafx.scene.shape.Rectangle; //导入依赖的package包/类
private void showMasterDetailInWindow(final Stage stage, final Database database, final MasterDetailViewFeatures features) throws JAXBException, IOException {
    final Parent viewRoot = ViewFactory.createMasterDetailView(database, features);

    final Rectangle clip = new Rectangle();
    clip.setArcHeight(18);
    clip.setArcWidth(18);
    clip.widthProperty().bind(stage.widthProperty());
    clip.heightProperty().bind(stage.heightProperty());

    //TODO: Only clipping or PerspectiveCamera is working... :(
    features.customWindowClipProperty().addListener((obs, oldVal, newVal) -> {
        if (newVal) {
            viewRoot.setClip(clip);
        } else {
            viewRoot.setClip(null);
        }
    });

    final Scene scene = new Scene(viewRoot);

    features.useCssProperty().addListener((obs, oldVal, newVal) -> {
        updateStylesheets(scene, newVal);
    });

    updateStylesheets(scene, features.isUseCss());

    scene.setFill(Color.TRANSPARENT);
    scene.setCamera(new PerspectiveCamera());

    if (features.isCustomWindowUI()) {
        stage.initStyle(StageStyle.TRANSPARENT);
    }

    stage.setTitle("Movie Database");
    stage.setScene(scene);
    stage.setWidth(1100);
    stage.setHeight(720);
    stage.centerOnScreen();
    stage.show();

    final FeaturesDialog featuresDialog = new FeaturesDialog(stage);
    featuresDialog.addFeature(new Feature("Layout & Style", "demo2-css", features.useCssProperty()));
    featuresDialog.addFeature(new Feature("Image Background", "demo2-image-background",features.movieBackgroundProperty()));
    featuresDialog.addFeature(new Feature("List Animation", "demo2-list-animation",features.listAnimationProperty()));
    featuresDialog.addFeature(new Feature("List Shadow", "demo2-list-shadow",features.listShadowProperty()));
    // featuresDialog.addFeature(new Feature("List Cache", "demo2-list-cache",features.listCacheProperty()));
    featuresDialog.addFeature(new Feature("Poster Transform", "demo2-poster-transform",features.posterTransformProperty()));
    featuresDialog.addFeature(new Feature("Custom Window UI", "demo2-custom-window-ui",features.customWindowUIProperty()));
    featuresDialog.addFeature(new Feature("Custom Window Clip", "demo2-custom-window-clip", features.customWindowClipProperty()));
    featuresDialog.show();
}
 
开发者ID:hendrikebbers,项目名称:ExtremeGuiMakeover,代码行数:52,代码来源:MovieApp.java

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

示例7: 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(selection1, 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(PANE_WIDTH - 1000);
    selection2.setWidth(500);

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

示例8: createRectangles

import javafx.scene.shape.Rectangle; //导入依赖的package包/类
private void createRectangles(){
    top = new Rectangle();
    body = new Rectangle();
    changeHeight(getRefNode().getHeight());
    changeWidth(getRefNode().getWidth());

    top.setX(getRefNode().getX());
    top.setY(getRefNode().getY());
    top.setFill(Color.LIGHTSKYBLUE);
    top.setStroke(Color.BLACK);

    body.setX(getRefNode().getX());
    body.setY(getRefNode().getY() + top.getHeight());
    body.setFill(Color.LIGHTSKYBLUE);
    body.setStroke(Color.BLACK);

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

示例9: setCanvasSize

import javafx.scene.shape.Rectangle; //导入依赖的package包/类
/**
 * 设置canvas大小
 */
private void setCanvasSize() {
    try {
        FXMLLoader fxmlLoader = new FXMLLoader((getClass().getResource("size_chooser.fxml")));
        Parent root1 = fxmlLoader.load();
        Stage stage = new Stage(DECORATED);
        stage.setTitle("选择画布");
        Scene scene = new Scene(root1);
        sizeChooser = fxmlLoader.getController();
        stage.setScene(scene);
        stage.showAndWait();
        if (sizeChooser.getCanvas() != null) {
            canvas.setHeight(sizeChooser.getCanvas().getHeight());
            canvas.setWidth(sizeChooser.getCanvas().getWidth());
            canvas.setLayoutX(450 - canvas.getWidth() / 2);
            canvas.setLayoutY(300 - canvas.getHeight() / 2);
            Rectangle rectangle = new Rectangle(canvas.getWidth(), canvas.getHeight());
            rectangle.setLayoutX(canvas.getLayoutX());
            rectangle.setLayoutY(canvas.getLayoutY());
            mainPane.setClip(rectangle);
            GraphicsContext gc = canvas.getGraphicsContext2D();
            gc.setFill(Color.WHITE);
            gc.fillRect(0, 0, canvas.getWidth(), canvas.getHeight());
        } else {
            //不选择就退出程序
            System.exit(0);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:xfangfang,项目名称:PhotoScript,代码行数:34,代码来源:Controller.java

示例10: processSegments

import javafx.scene.shape.Rectangle; //导入依赖的package包/类
private void processSegments() {
	for (Map.Entry<HBox, List<List<DiffKind>>> e : lineToSegments.entrySet()) {
		final HBox line = e.getKey();
		final List<String> descriptions = segmentToDescription.get(line);
		final List<Node> children = line.getChildren();
		final List<List<DiffKind>> segments = e.getValue();
		int idx = 0;
		for (List<DiffKind> segment : segments) {
			if (segment == null) {
				final Rectangle rectangle = new Rectangle(WIDTH, 8, Color.TRANSPARENT);
				HBox.setMargin(rectangle, MARGIN_INSETS);
				children.add(rectangle);
			} else {
				DiffKind[] seg = new DiffKind[segment.size()];
				for (int i = 0; i < seg.length; i++) {
					seg[i] = segment.get(i);
				}
				final String description = descriptions.get(idx);
				final ValueView view = new ValueView(description, seg);
				HBox.setMargin(view, MARGIN_INSETS);
				children.add(view);
				idx++;
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:27,代码来源:TimelineDiffViewerRenderer.java

示例11: addGroups

import javafx.scene.shape.Rectangle; //导入依赖的package包/类
private void addGroups() {
	int y = 5;
	int x = 5;
	for (int i = 0; i < 12; i++) {
		Rectangle temp = new Rectangle(146,194);
		temp.setArcHeight(15);
		temp.setArcWidth(15);
		String imageLocation = "/assets/card_assets/cards/backofHand.png";
		Image tempImage = new Image(imageLocation);
		temp.setFill(new ImagePattern(tempImage));
		temp.setStroke(Color.GRAY);
		temp.setVisible(true);
		temp.toFront();
		temp.setManaged(false);
		temp.setLayoutX(x);
		temp.setLayoutY(y);
		super.getChildren().add(temp);
		x-=1;
		y-=1;
	}
}
 
开发者ID:jarolrod,项目名称:java-solitaire,代码行数:22,代码来源:StockPile.java

示例12: testRunHard

import javafx.scene.shape.Rectangle; //导入依赖的package包/类
@Test
public void testRunHard() {
    Thread projectionRenderThread = new Thread(timeLine);
    projectionRenderThread.start();

    timeInstant.revive(new Point(0, 0));
    timeInstant.revive(new Point(1, 1));
    timeInstant.revive(new Point(-1, -1));

    int centerRow = getCenterRow(projection);
    int centerColumn = getCenterColumn(projection);

    Rectangle centerSquare = (Rectangle) getNodeByRowColumnIndex(centerRow, centerColumn, projectionPane);
    //assertEquals(Color.BLACK, centerSquare.getFill());
    Rectangle squareOne = (Rectangle) getNodeByRowColumnIndex(centerRow + 1, centerColumn + 1, projectionPane);
    //assertEquals(Color.BLACK, centerSquare.getFill());
    Rectangle squareTwo = (Rectangle) getNodeByRowColumnIndex(centerRow - 1, centerColumn - 1, projectionPane);
    //assertEquals(Color.BLACK, centerSquare.getFill());

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

示例13: start

import javafx.scene.shape.Rectangle; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
  Scene scene = new Scene(new Group(rectangle = new Rectangle(100, 100)), 300, 300);
  rectangle.setLayoutX(100);
  rectangle.setLayoutY(100);
  stage.setScene(scene);
  stage.setAlwaysOnTop(true);
  stage.show();
  config = ResizeSupport.bind(rectangle);
}
 
开发者ID:XDean,项目名称:JavaFX-EX,代码行数:11,代码来源:ResizeSupportTest.java

示例14: createIconContent

import javafx.scene.shape.Rectangle; //导入依赖的package包/类
public static Node createIconContent() {
    final Rectangle r1 = new Rectangle (50, 50, 14, 14);
    r1.setArcHeight(4);
    r1.setArcWidth(4);
    r1.setFill(Color.web("#ed4b00"));

    Polygon polygon = createArrow();
    polygon.setLayoutX(68);
    polygon.setLayoutY(25);
    polygon.setRotate(45);

    Rectangle r3 = new Rectangle (25, 25, 64, 64);
    r3.setArcHeight(15);
    r3.setArcWidth(15);
    r3.setFill(Color.web("#f49b00"));
    javafx.scene.Group g = new javafx.scene.Group(r3,r1, polygon);
    return new javafx.scene.Group(g);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:19,代码来源:ScaleSample.java

示例15: createIconContent

import javafx.scene.shape.Rectangle; //导入依赖的package包/类
public static Node createIconContent() {
    StackPane sp = new StackPane();
    VBox vbox = new VBox(3);
    vbox.setAlignment(Pos.CENTER);
    vbox.setPadding(new Insets(5, 5, 5, 5));

    Rectangle rectangle = new Rectangle(32, 62, Color.LIGHTGREY);
    rectangle.setStroke(Color.BLACK);
    vbox.setPrefSize(rectangle.getWidth(), rectangle.getHeight());
    Rectangle r1 = new Rectangle(18, 14, Color.web("#1c89f4"));
    Rectangle r2 = new Rectangle(18, 14, Color.web("#349b00"));
    Rectangle r3 = new Rectangle(18, 20, Color.web("#349b00"));

    vbox.getChildren().addAll(r1, r2, r3);
    sp.getChildren().addAll(rectangle, vbox);
    return new Group(sp);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:18,代码来源:VBoxSample.java


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