本文整理汇总了Java中javafx.scene.shape.Rectangle.setFill方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.setFill方法的具体用法?Java Rectangle.setFill怎么用?Java Rectangle.setFill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.shape.Rectangle
的用法示例。
在下文中一共展示了Rectangle.setFill方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateItem
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
@Override
public void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
Rectangle rect = new Rectangle(100, 20);
if (item != null) {
rect.setFill(Color.web(item));
setGraphic(rect);
} else {
setGraphic(null);
}
}
示例2: createIconContent
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public static Node createIconContent() {
final Rectangle r1 = new Rectangle (0, 0, 64, 64);
r1.setArcHeight(4);
r1.setArcWidth(4);
r1.setFill(Color.web("#ed4b00"));
Polygon polygon = createArrow();
polygon.setLayoutX(65);
polygon.setLayoutY(5);
polygon.setRotate(165);
Rectangle r2 = new Rectangle (0, 0, 64, 64);
r2.setArcHeight(15);
r2.setArcWidth(15);
r2.setFill(Color.web("#ed4b00"));
r2.setRotate(60);
r2.setOpacity(0.5);
javafx.scene.Group g = new javafx.scene.Group(r2,r1, polygon);
return new javafx.scene.Group(g);
}
示例3: createIconContent
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public static Node createIconContent() {
final Rectangle r1 = new Rectangle (0, 0, 20, 20);
r1.setArcHeight(4);
r1.setArcWidth(4);
r1.setFill(Color.web("#ed4b00"));
Polygon polygon = createArrow();
polygon.setLayoutX(29);
polygon.setLayoutY(21);
polygon.setRotate(135);
Rectangle r2 = new Rectangle (50, 50, 20, 20);
r2.setArcHeight(4);
r2.setArcWidth(4);
r2.setFill(Color.web("#ed4b00"));
r2.setOpacity(0.5);
javafx.scene.Group g = new javafx.scene.Group(r2,r1, polygon);
return new javafx.scene.Group(g);
}
示例4: ScaleTransitionSample
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public ScaleTransitionSample() {
super(150,150);
Rectangle rect = new Rectangle(50, 50, 50, 50);
rect.setArcHeight(15);
rect.setArcWidth(15);
rect.setFill(Color.ORANGE);
getChildren().add(rect);
scaleTransition = ScaleTransitionBuilder.create()
.node(rect)
.duration(Duration.seconds(4))
.toX(3)
.toY(3)
.cycleCount(Timeline.INDEFINITE)
.autoReverse(true)
.build();
}
示例5: FillTransitionSample
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public FillTransitionSample() {
super(100,100);
Rectangle rect = new Rectangle(0, 0, 100, 100);
rect.setArcHeight(20);
rect.setArcWidth(20);
rect.setFill(Color.DODGERBLUE);
getChildren().add(rect);
fillTransition = FillTransitionBuilder.create()
.duration(Duration.seconds(3))
.shape(rect)
.fromValue(Color.RED)
.toValue(Color.DODGERBLUE)
.cycleCount(Timeline.INDEFINITE)
.autoReverse(true)
.build();
}
示例6: 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);
}
示例7: doorClosed
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public void doorClosed() {
// Draw trim
Rectangle rgDT = new Rectangle(WIDTH, HEIGHT);
rgDT.setFill(Color.web("4d2626"));
this.getChildren().add(rgDT);
// Draw door
Rectangle rgDD = new Rectangle(WIDTH - (WIDTH / (WIDTH / 4)), HEIGHT - (HEIGHT / (HEIGHT / 2)));
rgDD.setTranslateX((WIDTH / (WIDTH / 2)));
rgDD.setTranslateY((HEIGHT / (HEIGHT / 2)));
rgDD.setFill(Color.web("673232"));
this.getChildren().add(rgDD);
// Draw three hinges
VBox vbHinges = new VBox(WIDTH / 3);
Rectangle rgDH1 = new Rectangle((WIDTH / (WIDTH / 2)), (HEIGHT / (HEIGHT / 8)));
rgDH1.setFill(Color.web("a5a5a5"));
Rectangle rgDH2 = new Rectangle((WIDTH / (WIDTH / 2)), (HEIGHT / (HEIGHT / 8)));
rgDH2.setFill(Color.web("a5a5a5"));
Rectangle rgDH3 = new Rectangle((WIDTH / (WIDTH / 2)), (HEIGHT / (HEIGHT / 8)));
rgDH3.setFill(Color.web("a5a5a5"));
vbHinges.getChildren().addAll(rgDH1, rgDH2, rgDH3);
vbHinges.setTranslateX(rgDH1.getWidth() / 2);
vbHinges.setTranslateY(rgDH1.getHeight());
this.getChildren().add(vbHinges);
// Draw door handle block
Rectangle rgDHM = new Rectangle((WIDTH / (WIDTH / 4)), (WIDTH / (WIDTH / 4)));
rgDHM.setTranslateX(WIDTH - rgDHM.getWidth() * 2);
rgDHM.setTranslateY(HEIGHT / 2 - rgDHM.getHeight() / 2);
rgDHM.setFill(Color.web("bfbfbf"));
this.getChildren().add(rgDHM);
// Draw door handle
Rectangle rgDHL = new Rectangle((WIDTH / (WIDTH / 8)), (WIDTH / (WIDTH / 2)));
rgDHL.setTranslateX(WIDTH - rgDHL.getWidth() * 2);
rgDHL.setTranslateY(HEIGHT / 2 - rgDHL.getHeight() / 2);
rgDHL.setFill(Color.web("a5a5a5"));
this.getChildren().add(rgDHL);
}
示例8: createTic
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
private Rectangle createTic(double angle, double width, double height) {
Rectangle rectangle = new Rectangle(-width / 2, -height / 2, width, height);
rectangle.setFill(Color.rgb(10, 10, 10));
rectangle.setRotate(angle);
rectangle.setLayoutX(radius * Math.cos(Math.toRadians(angle)));
rectangle.setLayoutY(radius * Math.sin(Math.toRadians(angle)));
return rectangle;
}
示例9: ArrowHead
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public ArrowHead() {
// Calculate the rotation body (a fix to move the point of rotation)
Rectangle rotationBody = new Rectangle();
rotationBody.xProperty().bind(xProperty().subtract(getHeadWidth() / 2));
rotationBody.yProperty().bind(yProperty().subtract(getHeadHeight()));
rotationBody.widthProperty().set(getHeadWidth());
rotationBody.heightProperty().set(getHeadHeight() * 2);
rotationBody.setMouseTransparent(true);
rotationBody.setFill(Color.TRANSPARENT);
// Add the body to the head
getChildren().add(rotationBody);
}
示例10: RotateSample
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public RotateSample() {
super(220, 270);
//create 2 rectangles
Rectangle rect1 = new Rectangle(90, 90, Color.web("#ed4b00", 0.75));
Rectangle rect2 = new Rectangle(90, 90, Color.web("#ed4b00", 0.5));
//rotate the second one
rect2.getTransforms().add(new Rotate(135, 90, 90)); // parameters are angle, pivotX and pivotY
// rectangle with adjustable rotate
Rectangle rect3 = new Rectangle(40, 180, 60, 60);
rect3.setFill(Color.DODGERBLUE);
rect3.setArcWidth(10);
rect3.setArcHeight(10);
rect3.setRotate(45);
//show the rectangles
getChildren().addAll(rect2, rect1, rect3);
// REMOVE ME
setControls(
new SimplePropertySheet.PropDesc("Rotate", rect3.rotateProperty(), 0d, 360d)
);
// END REMOVE ME
//create arrow
Polygon polygon = createArrow();
polygon.setLayoutX(110);
polygon.setLayoutY(15);
polygon.setRotate(135);
getChildren().addAll(polygon);
}
示例11: RectangleSample
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public RectangleSample() {
super(180,90);
// Simple red filled rectangle
Rectangle rect1 = new Rectangle(25,25,40,40);
rect1.setFill(Color.RED);
// Blue stroked rectangle
Rectangle rect2 = new Rectangle(135,25,40,40);
rect2.setStroke(Color.DODGERBLUE);
rect2.setFill(null);
// Create a group to show all the rectangles);
getChildren().add(new Group(rect1,rect2));
// REMOVE ME
setControls(
new SimplePropertySheet.PropDesc("Rectangle 1 Fill", rect1.fillProperty()),
new SimplePropertySheet.PropDesc("Rectangle 1 Width", rect1.widthProperty(), 10d, 50d),
new SimplePropertySheet.PropDesc("Rectangle 1 Height", rect1.heightProperty(), 10d, 50d),
new SimplePropertySheet.PropDesc("Rectangle 1 Arc Width", rect1.arcWidthProperty(), 0d, 50d),
new SimplePropertySheet.PropDesc("Rectangle 1 Arc Height", rect1.arcHeightProperty(), 0d, 50d),
new SimplePropertySheet.PropDesc("Rectangle 2 Stroke", rect2.strokeProperty()),
new SimplePropertySheet.PropDesc("Rectangle 2 Stroke Width", rect2.strokeWidthProperty(), 1d, 5d),
new SimplePropertySheet.PropDesc("Rectangle 2 Width", rect2.widthProperty(), 10d, 50d),
new SimplePropertySheet.PropDesc("Rectangle 2 Height", rect2.heightProperty(), 10d, 50d),
new SimplePropertySheet.PropDesc("Rectangle 2 Arc Width", rect2.arcWidthProperty(), 0d, 50d),
new SimplePropertySheet.PropDesc("Rectangle 2 Arc Height", rect2.arcHeightProperty(), 0d, 50d)
);
// END REMOVE ME
}
示例12: addBorderToCoordinate
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public void addBorderToCoordinate(GamePoint coord) {
CoordinateConversion cc = new CoordinateConversion();
Pair<Integer, Integer> gridCoord = cc.fromGamePointToPair(coord, myGrid);
Rectangle border = new Rectangle(myGrid.getWidth()/myModel.getNumCols(), myGrid.getHeight()/myModel.getNumRows());
border.setFill(Color.TRANSPARENT);
border.setStroke(Color.RED);
myGrid.add(border, gridCoord.getKey(), gridCoord.getValue());
}
示例13: makeScene
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
private Scene makeScene () {
Group root = new Group();
// create something to animate
Rectangle rect = lim.getRectangle();
root.getChildren().add(rect);
Rectangle rect1 = new Rectangle(0,0, 30,30);
rect1.setFill(Color.RED);
root.getChildren().add(rect1);
myActor = rect;
myActor1 = rect1;
Button btnQuit = new Button("Quit");
root.getChildren().add(btnQuit);
myActor2= btnQuit;
return new Scene(root, 400, 700);
}
示例14: start
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
@Override
public void start(Stage stage) {
stage.setTitle("Toggle Button Sample");
stage.setWidth(250);
stage.setHeight(180);
HBox hbox = new HBox();
VBox vbox = new VBox();
Scene scene = new Scene(new Group(vbox));
stage.setScene(scene);
scene.getStylesheets().add("togglebuttonsample/ControlStyle.css");
Rectangle rect = new Rectangle();
rect.setHeight(50);
rect.setFill(Color.WHITE);
rect.setStroke(Color.DARKGRAY);
rect.setStrokeWidth(2);
rect.setArcHeight(10);
rect.setArcWidth(10);
final ToggleGroup group = new ToggleGroup();
group.selectedToggleProperty().addListener(
(ObservableValue<? extends Toggle> ov,
Toggle toggle, Toggle new_toggle) -> {
if (new_toggle == null)
rect.setFill(Color.WHITE);
else
rect.setFill((Color) group.getSelectedToggle().getUserData());
});
ToggleButton tb1 = new ToggleButton("Minor");
tb1.setToggleGroup(group);
tb1.setUserData(Color.LIGHTGREEN);
tb1.setSelected(true);
tb1.getStyleClass().add("toggle-button1");
ToggleButton tb2 = new ToggleButton("Major");
tb2.setToggleGroup(group);
tb2.setUserData(Color.LIGHTBLUE);
tb2.getStyleClass().add("toggle-button2");
ToggleButton tb3 = new ToggleButton("Critical");
tb3.setToggleGroup(group);
tb3.setUserData(Color.SALMON);
tb3.getStyleClass().add("toggle-button3");
hbox.getChildren().addAll(tb1, tb2, tb3);
vbox.getChildren().add(new Label("Priority:"));
vbox.getChildren().add(hbox);
vbox.getChildren().add(rect);
vbox.setPadding(new Insets(20, 10, 10, 20));
stage.show();
rect.setWidth(hbox.getWidth());
}
示例15: insertRectangles
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
protected void insertRectangles(){
setLabel();
if(showArrayList.size() >= 0){
showList.getChildren().clear();
if(showArrayList.size() >= capacitySize){
capacitySize *= 1.5;
}
//根据容量添加
for (int i = 0; i < capacitySize; i++) {
Rectangle rectangle = new Rectangle(START_X + i * WIDTH, START_Y, WIDTH, HEIGHT);
rectangle.setFill(Color.WHITE);
rectangle.setStroke(Color.BLACK);
rectangle.setOpacity(0.5);
showList.getChildren().add(rectangle);
//当有元素时
if(i < showArrayList.size()) {
Text text = new Text(rectangle.getX() + rectangle.getWidth() / 2, rectangle.getY() + rectangle.getHeight() / 2, showArrayList.get(i));
showList.getChildren().add(text);
}
//当超过线性表大小
else {
Line line = new Line(rectangle.getX(), rectangle.getY() + HEIGHT, rectangle.getX() + WIDTH, rectangle.getY());
showList.getChildren().add(line);
}
}
}
}