下面列出了javafx.scene.shape.Rectangle#setEffect ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private Rectangle createBackground(Color stroke, Color fill) {
Rectangle background = new Rectangle(14, 17, fill);
background.setStroke(stroke);
background.setStrokeWidth(2);
background.setEffect(new Lighting());
background.setCache(true);
return background;
}
/**
* Prepare Stage for dock feedback display
*/
void buildDockFeedbackStage() {
dockFeedbackPopup = new Stage(StageStyle.TRANSPARENT);
dockFeedback = new Rectangle(0, 0, 100, 100);
dockFeedback.setArcHeight(10);
dockFeedback.setArcWidth(10);
dockFeedback.setFill(Color.TRANSPARENT);
dockFeedback.setStroke(Color.BLACK);
dockFeedback.setStrokeWidth(2);
dockFeedback.setCache(true);
dockFeedback.setCacheHint(CacheHint.SPEED);
dockFeedback.setEffect(new DropShadow(BlurType.TWO_PASS_BOX, Color.BLACK, 10, 0.2, 3, 3));
dockFeedback.setMouseTransparent(true);
BorderPane borderpane = new BorderPane();
borderpane.setStyle("-fx-background-color:transparent"); //J8
borderpane.setCenter(dockFeedback);
Scene scene = new Scene(borderpane);
scene.setFill(Color.TRANSPARENT);
dockFeedbackPopup.setScene(scene);
dockFeedbackPopup.sizeToScene();
}
public static Node createIconContent() {
Rectangle rectangle = new Rectangle(40,40);
rectangle.setStroke(Color.web("#b9c0c5"));
rectangle.setStrokeWidth(5);
rectangle.getStrokeDashArray().addAll(15d,15d);
rectangle.setFill(null);
javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow();
effect.setOffsetX(1);
effect.setOffsetY(1);
effect.setRadius(3);
effect.setColor(Color.rgb(0,0,0,0.6));
rectangle.setEffect(effect);
return rectangle;
}
public static Node createIconContent() {
Rectangle rectangle = new Rectangle(40,40);
rectangle.setStroke(Color.web("#b9c0c5"));
rectangle.setStrokeWidth(5);
rectangle.getStrokeDashArray().addAll(15d,15d);
rectangle.setFill(null);
javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow();
effect.setOffsetX(1);
effect.setOffsetY(1);
effect.setRadius(3);
effect.setColor(Color.rgb(0,0,0,0.6));
rectangle.setEffect(effect);
return rectangle;
}
private Rectangle createBackground(Color stroke, Color fill) {
Rectangle background = new Rectangle(14, 17, fill);
background.setStroke(stroke);
background.setStrokeWidth(2);
background.setEffect(new Lighting());
background.setCache(true);
return background;
}
private Rectangle createBackground(Color stroke, Color fill) {
Rectangle background = new Rectangle(14, 17, fill);
background.setStroke(stroke);
background.setStrokeWidth(2);
background.setEffect(new Lighting());
background.setCache(true);
return background;
}
public CoinHighlightViewComponent() {
super(5, 5);
Rectangle rect = new Rectangle(30, 30, Color.color(0.8, 0, 0, 0.9));
rect.setArcWidth(15);
rect.setArcHeight(15);
rect.setEffect(new Bloom(0.9));
getViewRoot().getChildren().add(rect);
}
public CoinHighlightViewComponent() {
super(5, 5);
Rectangle rect = new Rectangle(30, 30, Color.color(0.8, 0, 0, 0.9));
rect.setArcWidth(15);
rect.setArcHeight(15);
rect.setEffect(new Bloom(0.9));
getViewRoot().getChildren().add(rect);
}
public MenuButton(String name) {
text = new Text(name);
text.setFont(text.getFont().font(20));
text.setFill(Color.WHITE);
Rectangle bg = new Rectangle(250, 30);
bg.setOpacity(0.6);
bg.setFill(Color.BLACK);
bg.setEffect(new GaussianBlur(3.5));
setAlignment(Pos.CENTER_LEFT);
setRotate(-0.5);
getChildren().addAll(bg, text);
setOnMouseEntered(event -> {
bg.setTranslateX(10);
text.setTranslateX(10);
bg.setFill(Color.WHITE);
text.setFill(Color.BLACK);
});
setOnMouseExited(event -> {
bg.setTranslateX(0);
text.setTranslateX(0);
bg.setFill(Color.BLACK);
text.setFill(Color.WHITE);
});
DropShadow drop = new DropShadow(50, Color.WHITE);
drop.setInput(new Glow());
setOnMousePressed(event -> setEffect(drop));
setOnMouseReleased(event -> setEffect(null));
}
public MenuItem(String name, int width) {
setAlignment(Pos.CENTER_LEFT);
text = new Text(name);
text.setTranslateX(5);
text.setFont(font);
text.setFill(Colors.MENU_TEXT);
text.setStroke(Color.BLACK);
shadow = new DropShadow(5, Color.BLACK);
text.setEffect(shadow);
selection = new Rectangle(width - 45, 30);
selection.setFill(Colors.MENU_ITEM_SELECTION);
selection.setStroke(Color.BLACK);
selection.setVisible(false);
GaussianBlur blur = new GaussianBlur(8);
selection.setEffect(blur);
getChildren().addAll(selection, text);
setOnMouseEntered(e -> {
onSelect();
});
setOnMouseExited(e -> {
onDeselect();
});
setOnMousePressed(e -> {
text.setFill(Color.YELLOW);
});
}