本文整理汇总了Java中javafx.scene.shape.RectangleBuilder类的典型用法代码示例。如果您正苦于以下问题:Java RectangleBuilder类的具体用法?Java RectangleBuilder怎么用?Java RectangleBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RectangleBuilder类属于javafx.scene.shape包,在下文中一共展示了RectangleBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Curbstone
import javafx.scene.shape.RectangleBuilder; //导入依赖的package包/类
public Curbstone(final double size, final Color color, final double shade) {
getTransforms().addAll(rz, ry, rx);
getChildren().addAll(
RectangleBuilder.create() // back face
.width(2 * size).height(size).fill(color.deriveColor(0.0, 1.0, 1 - 0.5 * shade, 1.0))
.translateX(-0.5 * size).translateY(-0.5 * size).translateZ(0.5 * size).build(),
RectangleBuilder.create() // bottom face
.width(2 * size).height(size).fill(color.deriveColor(0.0, 1.0, 1 - 0.4 * shade, 1.0))
.translateX(-0.5 * size).translateY(0).rotationAxis(Rotate.X_AXIS).rotate(90).build(),
RectangleBuilder.create() // right face
.width(size).height(size).fill(Color.GRAY.deriveColor(0.0, 1.0, 1 - 0.3 * shade, 1.0))
.translateX(-1 * size).translateY(-0.5 * size).rotationAxis(Rotate.Y_AXIS).rotate(90)
.build(),
RectangleBuilder.create() // left face
.width(size).height(size).fill(Color.GRAY.deriveColor(0.0, 1.0, 1 - 0.2 * shade, 1.0))
.translateX(size).translateY(-0.5 * size).rotationAxis(Rotate.Y_AXIS).rotate(90).build(),
RectangleBuilder.create() // top face
.width(2 * size).height(size).fill(color.deriveColor(0.0, 1.0, 1 - 0.1 * shade, 1.0))
.translateX(-0.5 * size).translateY(-1 * size).rotationAxis(Rotate.X_AXIS).rotate(90)
.build(),
RectangleBuilder.create() // top face
.width(2 * size).height(size).fill(color).translateX(-0.5 * size).translateY(-0.5 * size)
.translateZ(-0.5 * size).build());
}
示例2: Banner
import javafx.scene.shape.RectangleBuilder; //导入依赖的package包/类
public Banner(String message) {
Rectangle rectangle = RectangleBuilder
.create()
.x(0)
.y(0)
.width(W)
.height(H)
.fill(LinearGradientBuilder
.create()
.startX(0.0)
.startY(0.0)
.endX(10.0)
.endY(0.0)
.proportional(false)
.cycleMethod(CycleMethod.REFLECT)
.stops(StopBuilder.create().offset(0.0).color(Color.BLUE).build(),
StopBuilder.create().offset(1.0).color(Color.LIGHTBLUE).build()).build()).build();
Text text = TextBuilder.create().x(25).y(H / 16).text(message).fill(Color.YELLOW).font(Font.font(null, FontWeight.BOLD, 36))
.build();
getChildren().addAll(rectangle, text);
}
示例3: getBox
import javafx.scene.shape.RectangleBuilder; //导入依赖的package包/类
private Rectangle getBox(String effectStr){
/*Text sp3 = TextBuilder.create()
.text("Inner Shadow")
.fill(Color.YELLOW)
.font(Font.font(null, FontWeight.BOLD, 40))
.style(effectStr).build();*/
Rectangle sp3 = RectangleBuilder.create()
.width(200)
.height(200)
.fill(Color.YELLOW)
.arcWidth(25)
.arcHeight(25)
.style(effectStr).build();
return sp3;
}
示例4: Help
import javafx.scene.shape.RectangleBuilder; //导入依赖的package包/类
public Help() {
Rectangle background = RectangleBuilder.create()
.width(460)
.height(300)
.arcWidth(20)
.arcHeight(20)
.fill(Color.rgb(0, 0, 0, 0.5))
.build();
Text text = TextBuilder.create()
.text("Welcome to Jumpman !\n" +
"Avoid the fireballs and make it to the goal as fast as possible.\n" +
"You can afford getting hit once, but not twice !\n\n" +
"Jumpman has the following skills:\n\n" +
" * Walk: by pressing the left or right arrow keys.\n" +
" * Run: by holding the F key while walking.\n" +
" * Brake: by pressing the opposite arrow key while moving.\n" +
" * Duck: by pressing the down arrow key.\n" +
" * Jump: by pressing the space key.\n\n" +
"Holding space longer will make Jumpman jump higher.\n" +
"Pressing more than one arrow key at the same time will not work.\n\n" +
"Press the escape key to close this window and start playing.")
.font(Font.font("Arial", FontWeight.NORMAL, 14))
.fill(Color.WHITE)
.build();
getChildren().addAll(background, text);
setOpacity(0);
AnchorPane root = View.getInstance().getRoot();
translateXProperty().bind(root.widthProperty().divide(2).subtract(widthProperty().divide(2)));
translateYProperty().bind(root.heightProperty().divide(2).subtract(heightProperty().divide(2)));
}
示例5: ClippedNode
import javafx.scene.shape.RectangleBuilder; //导入依赖的package包/类
public ClippedNode(Node content, double width, double height) {
this.width = width;
this.height = height;
this.content = content;
this.clip = RectangleBuilder.create().width(width).height(height).build();
this.content.setClip(this.clip);
this.content.translateXProperty().bind(transX.multiply(-1));
this.content.translateYProperty().bind(transY.multiply(-1));
this.clip.translateXProperty().bind(transX);
this.clip.translateYProperty().bind(transY);
getChildren().setAll(content);
}
示例6: configureBox
import javafx.scene.shape.RectangleBuilder; //导入依赖的package包/类
private void configureBox(VBox root) {
StackPane container = new StackPane();
container.setPrefHeight(250);
container.setPrefSize(boxBounds.getWidth(), boxBounds.getHeight());
container.setStyle("-fx-border-width:1px;-fx-border-style:solid;-fx-border-color:#999999;");
/* BOTTOM PANE */
Stop[] stops = new Stop[] { new Stop(0, Color.web("#F89C8C")), new Stop(1, Color.web("#BE250A"))};
LinearGradient lg = new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE, stops);
bottomPane = new StackPane();
bottomPane.getChildren().addAll(RectangleBuilder.create().width(boxBounds.getWidth()).height(boxBounds.getHeight()).fill(lg).build(),
TextBuilder.create().text("Click the above \"Slide Down\" button to see the top pane content...").wrappingWidth(200).font(Font.font("Arial", 22)).build());
/* TOP PANE */
Stop[] stops2 = new Stop[] { new Stop(0, Color.web("#FFFFFF")), new Stop(1, Color.web("#50AABC"))};
LinearGradient lg2 = new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE, stops2);
StackPane sp1 = new StackPane();
sp1.getChildren().add(TextBuilder.create().text("Click the below \"Slide Up\" button to see the bottom pane content...").wrappingWidth(200).font(Font.font("Arial", 22)).build());
topPane = new StackPane();
topPane.getChildren().addAll(RectangleBuilder.create().width(boxBounds.getWidth()).height(boxBounds.getHeight()).fill(lg2).build(), sp1);
container.getChildren().addAll(bottomPane,topPane);
setAnimation();
Group gp = new Group();
gp.getChildren().add(container);
root.getChildren().addAll(getActionPane(),gp);
}
示例7: start
import javafx.scene.shape.RectangleBuilder; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
// Create a vbox to position all nodes in a vertical stack
VBox root = new VBox();
// Create a toolbar
ToolBar toolbar = new ToolBar();
toolbar.getItems().add(new Button("Do something!"));
// position a rectangle absolutely
Rectangle r = RectangleBuilder.create()
.x(-100) // absolute position in container
.y(100) // absolute position in container
.fill(Color.AQUA)
.width(50)
.height(50)
.build();
Group canvas = new Group(r);
// put the toolbar and the canvas group in the vbox.
// Add the toolbar first so it is on top
root.getChildren().addAll(toolbar, canvas);
Scene scene = new Scene(root, 400, 400);
stage.setScene(scene);
stage.setTitle("Group Bounds Example");
stage.show();
ScenicView.show(scene);
/* Notice how the entire rectangle is on screen?
* This is because the bounds of the Group expand to fit the entire
* rectangle effectively pushing the origin of the Group over.
*/
}
示例8: start
import javafx.scene.shape.RectangleBuilder; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
// Create a vbox to position all nodes in a vertical stack
VBox root = new VBox();
// Create a toolbar
ToolBar toolbar = new ToolBar();
toolbar.getItems().add(new Button("Do something!"));
// position a rectangle absolutely
Rectangle r = RectangleBuilder.create()
.x(-100) // absolute position in container
.y(100) // absolute position in container
.fill(Color.AQUA)
.width(50)
.height(50)
.build();
Pane canvas = new Pane();
canvas.getChildren().add(r);
// put the toolbar and the canvas group in the vbox.
// Add the toolbar first so it is on top
root.getChildren().addAll(toolbar, canvas);
Scene scene = new Scene(root, 400, 400);
stage.setScene(scene);
stage.setTitle("Pane As Canvas Example");
stage.show();
ScenicView.show(scene);
/* Now the Rectangle will be completely off screen as we might expect
* A Pane does not expand to include all its children, so if there is an
* object with a negative position, the it will not be shown.
*/
}
示例9: start
import javafx.scene.shape.RectangleBuilder; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
// Create a pane as the scene root
Pane root = new Pane();
// position a rectangle absolutely
// NOTE: A rectangle is drawn from the upper left hand corner
Rectangle r = RectangleBuilder.create()
.x(100) // absolute position in container
.y(100) // absolute position in container
.fill(Color.AQUA)
.width(50)
.height(50)
.build();
// NOTE: A circle is drawn from the center
Circle c = CircleBuilder.create()
.centerX(200)
.centerY(200)
.radius(50)
.fill(Color.ORANGERED)
.build();
root.getChildren().addAll(r,c);
Scene scene = new Scene(root, 400, 400);
stage.setScene(scene);
stage.setTitle("Position Nodes Aboslutely");
stage.show();
ScenicView.show(scene);
/*
* If you inspect the rectangle and circle with SceniceView, you'll
* that they don't have a layoutX/Y. When you position nodes absolutely
* layoutX/Y is never set. This isn't a problem, just be aware that it
* happens. It can effect the way you do custom layouts.
*/
}
示例10: Cube
import javafx.scene.shape.RectangleBuilder; //导入依赖的package包/类
public Cube(double size, Color color, double shade) {
getTransforms().addAll(rz, ry, rx);
getChildren().addAll(
RectangleBuilder.create() // back face
.width(size).height(size)
.fill(color.deriveColor(0.0, 1.0, (1 - 0.5*shade), 1.0))
.translateX(-0.5*size)
.translateY(-0.5*size)
.translateZ(0.5*size)
.build(),
RectangleBuilder.create() // bottom face
.width(size).height(size)
.fill(color.deriveColor(0.0, 1.0, (1 - 0.4*shade), 1.0))
.translateX(-0.5*size)
.translateY(0)
.rotationAxis(Rotate.X_AXIS)
.rotate(90)
.build(),
RectangleBuilder.create() // right face
.width(size).height(size)
.fill(color.deriveColor(0.0, 1.0, (1 - 0.3*shade), 1.0))
.translateX(-1*size)
.translateY(-0.5*size)
.rotationAxis(Rotate.Y_AXIS)
.rotate(90)
.build(),
RectangleBuilder.create() // left face
.width(size).height(size)
.fill(color.deriveColor(0.0, 1.0, (1 - 0.2*shade), 1.0))
.translateX(0)
.translateY(-0.5*size)
.rotationAxis(Rotate.Y_AXIS)
.rotate(90)
.build(),
RectangleBuilder.create() // top face
.width(size).height(size)
.fill(color.deriveColor(0.0, 1.0, (1 - 0.1*shade), 1.0))
.translateX(-0.5*size)
.translateY(-1*size)
.rotationAxis(Rotate.X_AXIS)
.rotate(90)
.build(),
RectangleBuilder.create() // top face
.width(size).height(size)
.fill(color)
.translateX(-0.5*size)
.translateY(-0.5*size)
.translateZ(-0.5*size)
.build()
);
}
示例11: Cube
import javafx.scene.shape.RectangleBuilder; //导入依赖的package包/类
public Cube(double size, Color color, double shade) {
getTransforms().addAll(rz, ry, rx, s);
getChildren().addAll(
RectangleBuilder.create() // back face
.width(size).height(size)
.fill(color.deriveColor(0.0, 1.0, (1 - 0.5*shade), 1.0))
.translateX(-0.5*size)
.translateY(-0.5*size)
.translateZ(0.5*size)
.build(),
RectangleBuilder.create() // bottom face
.width(size).height(size)
.fill(color.deriveColor(0.0, 1.0, (1 - 0.4*shade), 1.0))
.translateX(-0.5*size)
.translateY(0)
.rotationAxis(Rotate.X_AXIS)
.rotate(90)
.build(),
RectangleBuilder.create() // right face
.width(size).height(size)
.fill(color.deriveColor(0.0, 1.0, (1 - 0.3*shade), 1.0))
.translateX(-1*size)
.translateY(-0.5*size)
.rotationAxis(Rotate.Y_AXIS)
.rotate(90)
.build(),
RectangleBuilder.create() // left face
.width(size).height(size)
.fill(color.deriveColor(0.0, 1.0, (1 - 0.2*shade), 1.0))
.translateX(0)
.translateY(-0.5*size)
.rotationAxis(Rotate.Y_AXIS)
.rotate(90)
.build(),
RectangleBuilder.create() // top face
.width(size).height(size)
.fill(color.deriveColor(0.0, 1.0, (1 - 0.1*shade), 1.0))
.translateX(-0.5*size)
.translateY(-1*size)
.rotationAxis(Rotate.X_AXIS)
.rotate(90)
.build(),
RectangleBuilder.create() // top face
.width(size).height(size)
.fill(color)
.translateX(-0.5*size)
.translateY(-0.5*size)
.translateZ(-0.5*size)
.build()
);
}
示例12: Cube
import javafx.scene.shape.RectangleBuilder; //导入依赖的package包/类
public Cube(double size, Color color, double shade) {
getTransforms().addAll(rz, ry, rx);
getChildren().addAll(
RectangleBuilder.create() // back face
.width(size).height(size)
.fill(color.deriveColor(0.0, 1.0, (1 - 0.5*shade), 1.0))
.translateX(-0.5*size)
.translateY(-0.5*size)
.translateZ(0.5*size)
.build(),
RectangleBuilder.create() // bottom face
.width(size).height(size)
.fill(color.deriveColor(0.0, 1.0, (1 - 0.4*shade), 1.0))
.translateX(-0.5*size)
.translateY(0)
.rotationAxis(Rotate.X_AXIS)
.rotate(90)
.build(),
RectangleBuilder.create() // right face
.width(size).height(size)
.fill(color.deriveColor(0.0, 1.0, (1 - 0.3*shade), 1.0))
.translateX(-1*size)
.translateY(-0.5*size)
.rotationAxis(Rotate.Y_AXIS)
.rotate(90)
.build(),
RectangleBuilder.create() // left face
.width(size).height(size)
.fill(color.deriveColor(0.0, 1.0, (1 - 0.2*shade), 1.0))
.translateX(0)
.translateY(-0.5*size)
.rotationAxis(Rotate.Y_AXIS)
.rotate(90)
.build(),
RectangleBuilder.create() // top face
.width(size).height(size)
.fill(color.deriveColor(0.0, 1.0, (1 - 0.1*shade), 1.0))
.translateX(-0.5*size)
.translateY(-1*size)
.rotationAxis(Rotate.X_AXIS)
.rotate(90)
.build(),
RectangleBuilder.create() // top face
.width(size).height(size)
.fill(color)
.translateX(-0.5*size)
.translateY(-0.5*size)
.translateZ(-0.5*size)
.build()
);
}
示例13: start
import javafx.scene.shape.RectangleBuilder; //导入依赖的package包/类
@Override public void start(Stage stage) {
final Group root;
Scene scene = SceneBuilder.create()
.width(500).height(500)
.fill(Color.WHITE)
.root(root = GroupBuilder.create()
.children(RectangleBuilder.create()
.layoutX(5).layoutY(5)
.width(490).height(490)
.fill(Color.LIGHTSKYBLUE)
.onMouseClicked(new EventHandler<MouseEvent>() {
// Eventhandler for mouse click event
@Override public void handle(MouseEvent e) {
if (clickcount > 2) { initialize(); }
for (int j = clickcount; j < 3; j++) {
org_x[j].set(e.getSceneX());
org_y[j].set(e.getSceneY());
}
clickcount++;
}
}).build(),
// line for x-axis through the Origin
LineBuilder.create()
.startX(5).startY(490)
.endX(495).endY(490)
.build(),
// Line for y-axis through the Origin
LineBuilder.create()
.startX(10).startY(5)
.endX(10).endY(495)
.build(),
// grid horizontal lines which interval is of 1cm
a_x_l[0], a_x_l[1], a_x_l[2], a_x_l[3],
a_x_l[4], a_x_l[5], a_x_l[6], a_x_l[7],
a_x_l[8], a_x_l[9], a_x_l[10], a_x_l[11],
// grid vertical lines which interval is of 1cm
a_y_l[0], a_y_l[1], a_y_l[2], a_y_l[3],
a_y_l[4], a_y_l[5], a_y_l[6], a_y_l[7],
a_y_l[8], a_y_l[9], a_y_l[10], a_y_l[11],
// Sides
l[0], l[1], l[2],
// Vertices
c[0], c[1], c[2],
// the printing space of the coordinates and
// the area of triangle
HBoxBuilder.create()
.layoutX(10)
.padding(new Insets(10, 10, 10, 10)).spacing(3)
.alignment(Pos.BOTTOM_CENTER)
.children(
LabelBuilder.create().text("A(").build(),
tx[0],
LabelBuilder.create().text(",").build(),
ty[0],
LabelBuilder.create().text("),").build(),
LabelBuilder.create().text("B(").build(),
tx[1],
LabelBuilder.create().text(",").build(),
ty[1],
LabelBuilder.create().text("),").build(),
LabelBuilder.create().text("C(").build(),
tx[2],
LabelBuilder.create().text(",").build(),
ty[2],
LabelBuilder.create().text(") ⇒ ").build(),
area_Label
).build()
).build()
).build();
stage.setTitle("Triangle Area");
stage.setScene(scene);
stage.show();
}
示例14: addGraphicControl
import javafx.scene.shape.RectangleBuilder; //导入依赖的package包/类
public void addGraphicControl(final String title,
final ObjectProperty<Node> graphicProperty) {
final Node circle = CircleBuilder.create().radius(4).fill(Color.ORANGE).build();
final Node square = RectangleBuilder.create().width(8).height(8).build();
final Node text = TextBuilder.create().text("test").build();
final ComboBox<Node> choices = new ComboBox<Node>(FXCollections.observableArrayList(circle, square, text));
choices.setCellFactory(new Callback<ListView<Node>, ListCell<Node>>() {
@Override
public ListCell<Node> call(final ListView<Node> param) {
final ListCell<Node> cell = new ListCell<Node>() {
@Override
public void updateItem(final Node item, final boolean empty) {
super.updateItem(item, empty);
if (item != null) {
setText(item.getClass().getSimpleName());
} else {
setText(null);
}
}
};
return cell;
}
});
choices.getSelectionModel().select(0);
graphicProperty.bind(choices.valueProperty());
final VBox box = new VBox();
final Text titleText = new Text(title);
titleText.textProperty().bind(new StringBinding() {
{
super.bind(choices.selectionModelProperty());
}
@Override
protected String computeValue() {
return title + " : "
+ String.valueOf(choices.selectionModelProperty().get().getSelectedItem().getClass().getSimpleName());
}
});
box.getChildren().addAll(titleText, choices);
getChildren().add(box);
}
示例15: start
import javafx.scene.shape.RectangleBuilder; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
// Create a pane as the scene root
Pane root = new Pane();
// position a rectangle absolutely
// NOTE: A rectangle is drawn from the upper left hand corner
Rectangle r = RectangleBuilder.create()
.x(0) // absolute position in container
.y(0) // absolute position in container
.fill(Color.AQUA)
.width(50)
.height(50)
.build();
r.relocate(100, 100);
// NOTE: A circle is drawn from the center
Circle c = CircleBuilder.create()
.centerX(0)
.centerY(0)
.radius(50)
.fill(Color.ORANGERED)
.build();
c.relocate(200, 200);
root.getChildren().addAll(r,c);
Scene scene = new Scene(root, 400, 400);
stage.setScene(scene);
stage.setTitle("Position Nodes With Relocate");
stage.show();
ScenicView.show(scene);
/*
* This approach treats the shape as its own coordinate system and uses
* layoutX/Y to position the nodes.
*
* Check layoutX/Y for the circle. Notice anything strange? It's position
* says it is 250, 250. What?! Remember that when you use relocate(x, y)
* it does the calculation finalX - getLayoutBounds().getMinX().
* Because a circle is drawn from the center it's layout bounds are
* [-50, -50, 100, 100]. 200 - -50 is 250. If you want to know the
* position of the circle in the parent container, use
* boundsInParent.getMinX/Y(). This also works for rectangles.
*/
}