本文整理汇总了Java中javafx.scene.paint.ImagePattern类的典型用法代码示例。如果您正苦于以下问题:Java ImagePattern类的具体用法?Java ImagePattern怎么用?Java ImagePattern使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImagePattern类属于javafx.scene.paint包,在下文中一共展示了ImagePattern类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawPolygonPopUp
import javafx.scene.paint.ImagePattern; //导入依赖的package包/类
private void drawPolygonPopUp(int deplacement, Tile tile) {
Hexagon hex = new Hexagon();
hex.setxPixel(0.0);
hex.setyPixel(0.0);
hex.calculHex();
double x[] = hex.getListXCoord();
double y[] = hex.getListYCoord();
int placement = (int) (Consts.SIDE_SIZE);
Piece piece = tile.getPiece();
Polygon p = new Polygon();
p.setFill(new ImagePattern(piece.getImage()));
p.getPoints().addAll(new Double[]{
x[0]+placement, y[0] + (Consts.SIDE_SIZE * deplacement),
x[1]+placement, y[1] + Consts.SIDE_SIZE * deplacement,
x[2]+placement, y[2] + Consts.SIDE_SIZE * deplacement,
x[3]+placement, y[3] + Consts.SIDE_SIZE * deplacement,
x[4]+placement, y[4] + Consts.SIDE_SIZE * deplacement,
x[5]+placement, y[5] + Consts.SIDE_SIZE * deplacement});
popup.getContent().add(p);
}
示例2: addGroups
import javafx.scene.paint.ImagePattern; //导入依赖的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;
}
}
示例3: Card
import javafx.scene.paint.ImagePattern; //导入依赖的package包/类
public Card(String suit, String rank) {
super(146,194);
this.suit = suit;
this.rank = rank;
draggable = false;
imageLocation = "/resources/card_images/" + rank + suit + ".gif";
super.setArcHeight(15);
super.setArcWidth(15);
super.setStyle("-fx-background-image: url(" + imageLocation +"); -fx-background-repeat: no-repeat;-fx-background-size: contain;");
Image test = new Image(imageLocation);
super.setFill(new ImagePattern(test));
super.setStroke(Color.BLACK);
super.setManaged(false);
id = rank + suit;
super.setId(id);
updateColor(suit);
}
示例4: resetState
import javafx.scene.paint.ImagePattern; //导入依赖的package包/类
private void resetState(Scene scene) {
Image image = new Image(pictureResourceLocation);
double imageWidth = image.getWidth();
double imageHeight = image.getHeight();
double imageHeightToWidthRatio = imageHeight / imageWidth;
double initialHeight = scene.getHeight() * pictureInitialHeightToSceneHeightRatio;
double initialWidth = initialHeight / imageHeightToWidthRatio;
double positionX = (scene.getWidth() - initialWidth) / 2;
double positionY = (scene.getHeight() - initialHeight) / 2;
setFill(new ImagePattern(image));
setX(positionX);
setY(positionY);
setWidth(initialWidth);
setHeight(initialHeight);
setTranslateX(0);
setScaleX(1);
setScaleY(1);
setScaleZ(1);
setOpacity(0);
toFront(); // bug when it is uncommented (with bloc at least).
}
示例5: setFillImageKeepingAspectRatio
import javafx.scene.paint.ImagePattern; //导入依赖的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);
}
示例6: createErrorImageRectangle
import javafx.scene.paint.ImagePattern; //导入依赖的package包/类
private Rectangle createErrorImageRectangle() {
final Image image = new Image("data/common/images/error.png");
double imageWidth = image.getWidth();
double imageHeight = image.getHeight();
double imageHeightToWidthRatio = imageHeight / imageWidth;
double rectangleWidth = imageRectangle.getFitWidth() / 3;
double rectangleHeight = imageHeightToWidthRatio * rectangleWidth;
double positionX = imageRectangle.getX() + (imageRectangle.getFitWidth() - rectangleWidth) / 2;
double positionY = imageRectangle.getY() + (imageRectangle.getFitHeight() - rectangleHeight) / 2;
Rectangle errorImageRectangle = new Rectangle(rectangleWidth, rectangleHeight);
errorImageRectangle.setFill(new ImagePattern(image));
errorImageRectangle.setX(positionX);
errorImageRectangle.setY(positionY);
errorImageRectangle.setOpacity(0);
errorImageRectangle.setVisible(false);
return errorImageRectangle;
}
示例7: buildFragments
import javafx.scene.paint.ImagePattern; //导入依赖的package包/类
private List<Circle> buildFragments(BubbleType bubbleType) {
List<Circle> fragments = new ArrayList<>(nbFragments);
for (int i = 0; i < nbFragments; i++) {
Circle fragment = new Circle();
fragment.setOpacity(1);
fragment.setRadius(20);
fragment.setVisible(true);
fragment.setCenterX(-100);
fragment.setCenterY(-100);
if (bubbleType == BubbleType.COLOR) {
fragment.setFill(new Color(Math.random(), Math.random(), Math.random(), 1));
} else {
fragment.setFill(new ImagePattern(newPhoto(), 0, 0, 1, 1, true));
}
fragments.add(fragment);
}
return fragments;
}
示例8: Picto
import javafx.scene.paint.ImagePattern; //导入依赖的package包/类
public Picto(String name) {
this.rectangle = new Rectangle();
String soundResourceName = "pictogrammes/sounds/" + name + ".m4a";
URL soundSourceResource = getClass().getClassLoader().getResource(soundResourceName);
if (soundSourceResource == null) {
throw new RuntimeException("Resource not found : " + soundResourceName);
}
this.sound = new AudioClip(soundSourceResource.toExternalForm());
String imageResourceName = "pictogrammes/images/" + name + ".jpg";
URL imageResource = getClass().getClassLoader().getResource(imageResourceName);
if (imageResource == null) {
throw new RuntimeException("Resource not found : " + imageResourceName);
}
rectangle.setFill(new ImagePattern(new Image(imageResource.toExternalForm()), 0, 0, 1, 1, true));
}
示例9: Wall
import javafx.scene.paint.ImagePattern; //导入依赖的package包/类
/**
* Creates a new instance of {@code Wall} with a given height and orientation.
* @param height height of the pipe
* @param orientation Orientation of the pipe
*/
public Wall(int height, int orientation) {
this.height = height;
this.orientation = orientation;
Image img_0 = new Image(getClass().getResourceAsStream(pipe_0_URL));
Image img_1 = new Image(getClass().getResourceAsStream(pipe_1_URL));
rect = new Rectangle(pipeWidth, height);
if (orientation == 0){
rect.setFill(new ImagePattern(img_0, 0, 0, 1, 1, true));
} else if (orientation == 1){
rect.setFill(new ImagePattern(img_1, 0, 0, 1, 1, true));
}
getChildren().add(rect);
}
示例10: DataUpdateDialog
import javafx.scene.paint.ImagePattern; //导入依赖的package包/类
public DataUpdateDialog(TatMain app, Window owner, FinancialMarket fm, TatConfig config, boolean bUpdateMode) {
super();
this.bUpdateMode = bUpdateMode;
this.fm = fm;
this.config = config;
setResizable(false);
initStyle(StageStyle.DECORATED);
initOwner(owner);
application = app;
if (bUpdateMode == true){
setTitle("View & update market data");
} else {
setTitle("Select a market data");
}
initModality(Modality.APPLICATION_MODAL);
Image appIcon = new Image("icon/UPDATE_MARKET_DATA.png");
getIcons().add(appIcon);
root = new Group();
Scene scene = new Scene(root, 700, 620, Color.WHITE);
ImagePattern pattern = new ImagePattern(new Image("icon/bk5.jpg"));
scene.setFill(pattern);
setScene(scene);
marketDataTreeView = new MarketDataTreeViewNode(application, fm, config, this.bUpdateMode);
initGui();
//Add listener to exit when press Esc key
addEventHandler(KeyEvent.KEY_PRESSED, (KeyEvent event) -> {
if (KeyCode.ESCAPE == event.getCode()) {
DataUpdateDialog.this.close();
}
});
setX(owner.getX() + Math.abs(owner.getWidth() - scene.getWidth()) / 2.0);
setY(owner.getY() + Math.abs(owner.getHeight() - scene.getHeight()) / 2.0);
}
示例11: DataImportDialog
import javafx.scene.paint.ImagePattern; //导入依赖的package包/类
public DataImportDialog(Window owner, FinancialMarket fm, TatConfig config) {
super();
this.fm = fm;
this.config = config;
setResizable(false);
initStyle(StageStyle.DECORATED);
initOwner(owner);
setTitle("Financial Market Import");
initModality(Modality.APPLICATION_MODAL);
Image appIcon = new Image("icon/IMPORT_MARKET_DATA.png");
getIcons().add(appIcon);
root = new Group();
Scene scene = new Scene(root, 500, 440, Color.WHITE);
ImagePattern pattern = new ImagePattern(new Image("icon/bk5.jpg"));
scene.setFill(pattern);
setScene(scene);
initGui();
//Add listener to exit when press Esc key
addEventHandler(KeyEvent.KEY_PRESSED, (KeyEvent event) -> {
if (KeyCode.ESCAPE == event.getCode()) {
DataImportDialog.this.close();
}
if (KeyCode.ENTER == event.getCode()) {
doImport();
}
});
setX(owner.getX() + Math.abs(owner.getWidth() - scene.getWidth()) / 2.0);
setY(owner.getY() + Math.abs(owner.getHeight() - scene.getHeight()) / 2.0);
}
示例12: makeInfoGUI
import javafx.scene.paint.ImagePattern; //导入依赖的package包/类
/**
* Make Information Dialog
* @return BorderPane
*/
public void makeInfoGUI() {
root = new Group();
Scene scene = new Scene(root, 360, 185, Color.WHITE);
ImagePattern pattern = new ImagePattern(new Image("icon/bk2.jpg"));
scene.setFill(pattern);
setTitle("Information");
setScene(scene);
Image appIcon = new Image("icon/INFO.png");
getIcons().add(appIcon);
BorderPane bp = new BorderPane();
textArea = new TextArea(message);
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setMaxWidth(320);
textArea.setMaxHeight(130);
HBox hBox = new HBox();
hBox.setSpacing(5);
hBox.setPadding(new Insets(5,0,0,0));
hBox.setAlignment(Pos.BOTTOM_RIGHT);
hBox.getChildren().addAll(okButton);
bp.setCenter(textArea);
bp.setBottom(hBox);
root.getChildren().add(bp);
sizeToScene();
setX(owner.getX() + Math.abs(owner.getWidth() - scene.getWidth()) / 2.0);
setY(owner.getY() + Math.abs(owner.getHeight() - scene.getHeight()) / 2.0);
}
示例13: makeErrorGUI
import javafx.scene.paint.ImagePattern; //导入依赖的package包/类
/**
* Make a Error Dialog
* @return BorderPane
*/
public void makeErrorGUI() {
root = new Group();
Scene scene = new Scene(root, 360, 185, Color.WHITE);
ImagePattern pattern = new ImagePattern(new Image("icon/bk2.jpg"));
scene.setFill(pattern);
setTitle("Error");
setScene(scene);
Image appIcon = new Image("icon/ERROR.png");
getIcons().add(appIcon);
BorderPane bp = new BorderPane();
textArea = new TextArea(message);
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setMaxWidth(320);
textArea.setMaxHeight(130);
HBox hBox = new HBox();
hBox.setSpacing(5);
hBox.setPadding(new Insets(5,0,0,0));
hBox.setAlignment(Pos.BOTTOM_RIGHT);
hBox.getChildren().addAll(openLogButton,okButton);
bp.setCenter(textArea);
bp.setBottom(hBox);
root.getChildren().add(bp);
sizeToScene();
setX(owner.getX() + Math.abs(owner.getWidth() - scene.getWidth()) / 2.0);
setY(owner.getY() + Math.abs(owner.getHeight() - scene.getHeight()) / 2.0);
}
示例14: initNewBoard
import javafx.scene.paint.ImagePattern; //导入依赖的package包/类
private void initNewBoard() {
root = new Group();
board = new Node[currentBoardWidth][currentBoardHeight];
Scene scene = new Scene(root, (currentBoardWidth + 1) * currentSquareSize, (currentBoardHeight + 1) * currentSquareSize);
primaryStage.setScene(scene);
primaryStage.show();
ImagePattern pattern = new ImagePattern(new Image("background_1920.jpg"));
scene.setFill(pattern);
initBoardLines();
}
示例15: visit
import javafx.scene.paint.ImagePattern; //导入依赖的package包/类
public boolean visit(Board b) {
gc.clearRect(0, 0, can.getWidth(), can.getHeight());
String name = getClass().getClassLoader().getResource("main/resources/img/misc/under_tiles.png").toString();
gc.setFill(new ImagePattern(new Image(name)));
gc.strokeRect(0, 0, can.getWidth(), can.getHeight());
gc.fillRect(0, 0, can.getWidth(), can.getHeight());
return false;
}