public void majColorButton(){ switch(state){ case Consts.WHITE: colorPlayer1.setBackground(new Background(new BackgroundFill(new ImagePattern(new Image(getClass().getClassLoader().getResource("main/resources/img/misc/whitestart.png").toString())), CornerRadii.EMPTY, Insets.EMPTY))); colorPlayer2.setBackground(new Background(new BackgroundFill(new ImagePattern(new Image(getClass().getClassLoader().getResource("main/resources/img/misc/blackstart.png").toString())), CornerRadii.EMPTY, Insets.EMPTY))); break; case Consts.BLACK: colorPlayer2.setBackground(new Background(new BackgroundFill(new ImagePattern(new Image(getClass().getClassLoader().getResource("main/resources/img/misc/whitestart.png").toString())), CornerRadii.EMPTY, Insets.EMPTY))); colorPlayer1.setBackground(new Background(new BackgroundFill(new ImagePattern(new Image(getClass().getClassLoader().getResource("main/resources/img/misc/blackstart.png").toString())), CornerRadii.EMPTY, Insets.EMPTY))); break; case Consts.RANDOM: colorPlayer1.setBackground(new Background(new BackgroundFill(new ImagePattern(new Image(getClass().getClassLoader().getResource("main/resources/img/misc/rngstart.png").toString())), CornerRadii.EMPTY, Insets.EMPTY))); colorPlayer2.setBackground(new Background(new BackgroundFill(new ImagePattern(new Image(getClass().getClassLoader().getResource("main/resources/img/misc/rngstart.png").toString())), CornerRadii.EMPTY, Insets.EMPTY))); break; default: break; } }
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); }
public void majColorButton() { switch (state) { case Consts.WHITE: colorHost.setBackground(new Background(new BackgroundFill( new ImagePattern(new Image(getClass().getClassLoader() .getResource("main/resources/img/misc/whitestart.png").toString())), CornerRadii.EMPTY, Insets.EMPTY))); break; case Consts.BLACK: colorHost.setBackground(new Background(new BackgroundFill( new ImagePattern(new Image(getClass().getClassLoader() .getResource("main/resources/img/misc/blackstart.png").toString())), CornerRadii.EMPTY, Insets.EMPTY))); break; case Consts.RANDOM: colorHost.setBackground(new Background(new BackgroundFill( new ImagePattern(new Image(getClass().getClassLoader() .getResource("main/resources/img/misc/rngstart.png").toString())), CornerRadii.EMPTY, Insets.EMPTY))); break; default: break; } }
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; } }
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); }
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). }
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); }
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; }
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; }
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)); }
/** * 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); }
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); }
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); }
/** * 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); }
/** * 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); }
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(); }
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; }
public boolean visit(Tile t) { CoordGene<Double> coord = new CoordGene<Double>((double) t.getX(), (double) t.getY()); CoordGene<Double> coordPix = traducteur.axialToPixel(coord); hex.setxPixel(coordPix.getX() + traducteur.getMoveOrigin().getX()); hex.setyPixel(coordPix.getY() + traducteur.getMoveOrigin().getY()); hex.calculHex(); Piece piece = t.getPiece(); if (piece != null) { String name; if (t.getZ() == 0) { gc.setFill(new ImagePattern(piece.getImage())); } else { name = getClass().getClassLoader() .getResource("main/resources/img/tile/" + piece.getName() + piece.getTeam() +t.getZ() +".png") .toString(); gc.setFill(new ImagePattern(new Image(name))); } gc.setStroke(Color.BLACK); gc.setLineWidth(1); gc.strokePolygon(hex.getListXCoord(), hex.getListYCoord(), 6); gc.fillPolygon(hex.getListXCoord(), hex.getListYCoord(), 6); } else { if (OptionManager.isGridEnable()) { gc.setStroke(Color.BLACK); gc.setLineWidth(1); gc.strokePolygon(hex.getListXCoord(), hex.getListYCoord(), 6); } } return false; }
public void initPlayer1Button() { inventoryPlayer1.getChildren().remove(0, inventoryPlayer1.getChildren().size()); List<Piece> inventory = core.getPlayers()[0].getInventory(); int line = 0; int col = 0; for (int i = 0; i < inventory.size(); i++) { Piece piece = inventory.get(i); ToggleButton b = new ToggleButton(); b.setMinSize(65, 65); b.setBackground(new Background(new BackgroundFill(new ImagePattern(piece.getImage()), CornerRadii.EMPTY, Insets.EMPTY))); if (core.getCurrentPlayer() == Consts.PLAYER1 && core.getState() == Consts.WAIT_FOR_INPUT) { b.setOnMouseClicked(new ControllerButtonPiece(this,inventory.get(i).getId(), i)); //eventDragAndDropPiece(b,inventory.get(i).getId()); b.getStyleClass().add("buttonInventory"); b.setCursor(Cursor.HAND); b.setTooltip(new Tooltip(inventory.get(i).getDescription())); inventoryGroup.getToggles().add(b); } b.disableProperty().bind(animationPlaying); if (i != 0 && i % 4 == 0) { col = 0; line++; } GridPane.setConstraints(b, col, line); GridPane.setHalignment(b, HPos.CENTER); GridPane.setValignment(b, VPos.TOP); inventoryPlayer1.getChildren().add(b); col++; } }
public void initPlayer2Button() { inventoryPlayer2.getChildren().remove(0, inventoryPlayer2.getChildren().size()); List<Piece> inventory = core.getPlayers()[1].getInventory(); int line = 0; int col = 0; for (int i = 0; i < inventory.size(); i++) { Piece piece = inventory.get(i); ToggleButton b = new ToggleButton(); b.setMinSize(65, 65); b.setBackground(new Background(new BackgroundFill(new ImagePattern(piece.getImage()), CornerRadii.EMPTY, Insets.EMPTY))); if (core.getCurrentPlayer() == Consts.PLAYER2 && core.getState() == Consts.WAIT_FOR_INPUT) { b.setOnMouseClicked(new ControllerButtonPiece(this,inventory.get(i).getId(), i)); b.getStyleClass().add("buttonInventory"); b.setCursor(Cursor.HAND); b.setTooltip(new Tooltip(inventory.get(i).getDescription())); inventoryGroup.getToggles().add(b); } b.disableProperty().bind(animationPlaying); if (i != 0 && i % 4 == 0) { col = 0; line++; } GridPane.setConstraints(b, col, line); GridPane.setHalignment(b, HPos.CENTER); GridPane.setValignment(b, VPos.TOP); inventoryPlayer2.getChildren().add(b); col++; } }
public Portrait(int initialRadius, RandomPositionGenerator randomPositionGenerator, Image[] availableImages) { super(initialRadius); this.initialRadius = initialRadius; this.setPosition(randomPositionGenerator.newRandomPosition(initialRadius)); setFill(new ImagePattern(pickRandomImage(availableImages), 0, 0, 1, 1, true)); }
private EventHandler<Event> buildEvent() { return new EventHandler<Event>() { @Override public void handle(Event e) { if (turned) return; if (e.getEventType() == MouseEvent.MOUSE_ENTERED || e.getEventType() == GazeEvent.GAZE_ENTERED) { progressIndicator.setOpacity(1); progressIndicator.setProgress(0); Timeline timelineCard = new Timeline(); timelineCard.getKeyFrames().add(new KeyFrame(new Duration(1), new KeyValue(card.xProperty(), card.getX() - (initWidth * zoom_factor - initWidth) / 2))); timelineCard.getKeyFrames().add(new KeyFrame(new Duration(1), new KeyValue(card.yProperty(), card.getY() - (initHeight * zoom_factor - initHeight) / 2))); timelineCard.getKeyFrames().add( new KeyFrame(new Duration(1), new KeyValue(card.widthProperty(), initWidth * zoom_factor))); timelineCard.getKeyFrames().add(new KeyFrame(new Duration(1), new KeyValue(card.heightProperty(), initHeight * zoom_factor))); timelineProgressBar = new Timeline(); timelineProgressBar.getKeyFrames().add(new KeyFrame(new Duration(fixationlength), new KeyValue(progressIndicator.progressProperty(), 1))); timelineCard.play(); timelineProgressBar.play(); timelineProgressBar.setOnFinished(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { turned = true; card.setFill(new ImagePattern(image, 0, 0, 1, 1, true)); card.removeEventFilter(MouseEvent.ANY, enterEvent); card.removeEventFilter(GazeEvent.ANY, enterEvent); if (winner) { onCorrectCardSelected(); } else {// bad card onWrongCardSelected(); } } }); } else if (e.getEventType() == MouseEvent.MOUSE_EXITED || e.getEventType() == GazeEvent.GAZE_EXITED) { Timeline timeline = new Timeline(); timeline.getKeyFrames().add(new KeyFrame(new Duration(1), new KeyValue(card.xProperty(), card.getX() + (initWidth * zoom_factor - initWidth) / 2))); timeline.getKeyFrames().add(new KeyFrame(new Duration(1), new KeyValue(card.yProperty(), card.getY() + (initHeight * zoom_factor - initHeight) / 2))); timeline.getKeyFrames() .add(new KeyFrame(new Duration(1), new KeyValue(card.widthProperty(), initWidth))); timeline.getKeyFrames() .add(new KeyFrame(new Duration(1), new KeyValue(card.heightProperty(), initHeight))); timeline.play(); timelineProgressBar.stop(); progressIndicator.setOpacity(0); progressIndicator.setProgress(0); } } }; }
private void enter() { this.removeEventHandler(MouseEvent.MOUSE_ENTERED, enterEvent); hand.fireEvent(new net.gazeplay.games.creampie.event.TouchEvent(getCenterX(), getCenterY())); Timeline timeline = new Timeline(); Timeline timeline2 = new Timeline(); timeline.getKeyFrames() .add(new KeyFrame(new Duration(2000), new KeyValue(radiusProperty(), getInitialRadius() * 1.6))); timeline.getKeyFrames() .add(new KeyFrame(new Duration(2000), new KeyValue(rotateProperty(), getRotate() + (360 * 3)))); timeline.getKeyFrames().add(new KeyFrame(new Duration(2000), new KeyValue(visibleProperty(), false))); timeline2.getKeyFrames().add(new KeyFrame(new Duration(1), new KeyValue(radiusProperty(), radius))); Position newPosition = randomPositionGenerator.newRandomPosition(getInitialRadius()); timeline2.getKeyFrames() .add(new KeyFrame(new Duration(1), new KeyValue(centerXProperty(), newPosition.getX()))); timeline2.getKeyFrames() .add(new KeyFrame(new Duration(1), new KeyValue(centerYProperty(), newPosition.getY()))); timeline2.getKeyFrames().add(new KeyFrame(new Duration(1), new KeyValue(fillProperty(), new ImagePattern(pickRandomImage(availableImages), 0, 0, 1, 1, true)))); timeline2.getKeyFrames().add(new KeyFrame(new Duration(1), new KeyValue(rotateProperty(), 0))); timeline2.getKeyFrames().add(new KeyFrame(new Duration(1000), new KeyValue(visibleProperty(), true))); SequentialTransition sequence = new SequentialTransition(timeline, timeline2); sequence.play(); sequence.setOnFinished(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { anniOff = true; stats.start(); } }); }
public Bubble(GameContext gameContext, BubbleType type, Stats stats, boolean useBackgroundImage) { this.gameContext = gameContext; this.type = type; this.stats = stats; this.image = useBackgroundImage; photos = Utils.images(Utils.getImagesFolder() + "portraits" + Utils.FILESEPARATOR); if (useBackgroundImage) { gameContext.getScene().setFill(new ImagePattern(new Image("data/bubble/images/underwater-treasures.jpg"))); } gameContext.getChildren().add(this); this.fragments = buildFragments(type); this.getChildren().addAll(fragments); enterEvent = new EventHandler<Event>() { @Override public void handle(Event e) { if (e.getEventType() == MouseEvent.MOUSE_ENTERED || e.getEventType() == GazeEvent.GAZE_ENTERED) { // log.info(e.getEventType()); enter((Circle) e.getTarget()); stats.incNbGoals(); stats.start(); } } }; }
private void setHiddenPicture(GameContext gameContext) { final int randomPictureIndex = (int) Math.floor(Math.random() * images.length); final Image randomPicture = images[randomPictureIndex]; Dimension2D dimension2D = gameContext.getGamePanelDimensionProvider().getDimension2D(); Rectangle imageRectangle = new Rectangle(0, 0, dimension2D.getWidth(), dimension2D.getHeight()); imageRectangle.setFill(new ImagePattern(randomPicture, 0, 0, 1, 1, true)); AspectRatioImageRectangleUtil aspectRatioImageRectangleUtil = new AspectRatioImageRectangleUtil(); aspectRatioImageRectangleUtil.setFillImageKeepingAspectRatio(imageRectangle, randomPicture, dimension2D); gameContext.getChildren().add(imageRectangle); }
private Node createLogo() { double width = scene.getWidth() * 0.5; double height = scene.getHeight() * 0.2; double posY = scene.getHeight() * 0.1; double posX = (scene.getWidth() - width) / 2; Rectangle logo = new Rectangle(posX, posY, width, height); logo.setFill(new ImagePattern(new Image("data/common/images/gazeplay.jpg"), 0, 0, 1, 1, true)); return logo; }
public ImagePattern createGridPattern() { Collections.shuffle(array_sizes); index = array_sizes.get(0); size = arraypts[ index ].length; //size = 10; indicator = new ProgressIndicator(0); double w = gridSize; double h = gridSize; circle = new Circle(); circle.setRadius(45.0f); circle.setOpacity(1); circle.setFill(Color.LIGHTBLUE); circle.setVisible(true); canvas.setGridLinesVisible(true); GazeUtils.addEventFilter(circle); enterEvent = buildEvent(); circle.addEventFilter(MouseEvent.ANY, enterEvent); circle.addEventFilter(GazeEvent.ANY, enterEvent); indicator.setOpacity(0.0); canvas.add(indicator, arraypts[index][count], arraypts[index][count+1]); canvas.add(circle,arraypts[index][count], arraypts[index][count+1]); Image image = canvas.snapshot(new SnapshotParameters(), null); ImagePattern pattern = new ImagePattern(image, 0, 0, w, h, false); return pattern; }
public ImagePattern createGridPattern() { Collections.shuffle(array_sizes); index = array_sizes.get(0); size = arraypts[ index ].length; //size = 10; indicator = new ProgressIndicator(0); double w = gridSize; double h = gridSize; circle = new Circle(); circle.setRadius(45.0f); circle.setOpacity(1); circle.setFill(Color.BLUE); circle.setVisible(true); canvas.setGridLinesVisible(true); GazeUtils.addEventFilter(circle); enterEvent = buildEvent(); circle.addEventFilter(MouseEvent.ANY, enterEvent); circle.addEventFilter(GazeEvent.ANY, enterEvent); indicator.setOpacity(0.0); canvas.add(indicator, arraypts[index][count], arraypts[index][count+1]); canvas.add(circle,arraypts[index][count], arraypts[index][count+1]); Image image = canvas.snapshot(new SnapshotParameters(), null); ImagePattern pattern = new ImagePattern(image, 0, 0, w, h, false); return pattern; }
public Choice(String name) { this.rectangle = new Rectangle(); this.sound = new AudioClip("file:sounds/" + name + ".m4a"); rectangle.setFill(new ImagePattern(new Image("file:images/" + name + ".png"), 0, 0, 1, 1, true)); this.name = name; }
public void show(){ Group root = new Group(); Scene scene = new Scene(root, WIDTH, HEIGHT); scene.getStylesheets().setAll("/styleSheets/login.css"); Image backgroundImage = new Image(getClass().getClassLoader().getResourceAsStream(myResources.getString("loaderImagePath"))); scene.setFill(new ImagePattern(backgroundImage)); // Bind the timerLabel text property to the timeSeconds property timerLabel.textProperty().bind(timeSeconds.divide(100).asString()); timerLabel.setId("label"); ProgressBar progressBar = new ProgressBar(); progressBar.progressProperty().bind( timeSeconds.divide(START_TIME*100.0).subtract(1).multiply(-1)); timeSeconds.set((START_TIME)*100); timelineController(); Label loadingLabel =new Label("Game loading ..."); loadingLabel.setId("label"); VBox vb = new VBox(20); // center the components within VBox vb.setAlignment(Pos.CENTER); vb.setPrefWidth(scene.getWidth()); vb.setLayoutY(60); vb.getChildren().addAll( timerLabel, progressBar, loadingLabel); root.getChildren().add(vb); scene.getStylesheets().setAll(CSS_LOCATION); primaryStage.setScene(scene); primaryStage.show(); }
/** * show the Level MenuItem to the player * The player can choose a level to start a game or choose a random game */ public void show(){ //Stage primaryStage = new Stage(); primaryStage.setTitle(TITLE); Group root = new Group(); Menu level = initLevelMenu(); Menu setting = initSettingMenu(); Menu help = initHelpMenu(); menuBar = new MenuBar(level, setting, help); root.getChildren().add(menuBar); AnimationImage im = new AnimationImage(); Scene scene = new Scene(root); Image image = new Image(getClass().getClassLoader().getResourceAsStream(myResources.getString("levelChoiceImagePath"))); scene.setFill(new ImagePattern(image)); scene.getStylesheets().setAll(CSS_LOCATION); HBox hBox = new HBox(); hBox.getChildren().add(im.getImageView(SEED)); hBox.setLayoutX(300); hBox.setLayoutY(200); root.getChildren().add(hBox); Button starting = createButton(); root.getChildren().add(starting); primaryStage.setScene(scene); primaryStage.setFullScreen(true); primaryStage.setFullScreenExitHint(""); primaryStage.setFullScreenExitKeyCombination(null); primaryStage.show(); }
/** * Make Confirmation Dialog * @return BorderPane */ public void makeConfirmGUI() { root = new Group(); Scene scene = new Scene(root, 360, 185, Color.WHITE); ImagePattern pattern = new ImagePattern(new Image("icon/bk2.jpg")); scene.setFill(pattern); setScene(scene); setTitle("Confirmation"); Image appIcon = new Image("icon/CONFIRM.png"); getIcons().add(appIcon); BorderPane bp = new BorderPane(); textArea = new TextArea(message); textArea.setEditable(false); textArea.setWrapText(true); textArea.setPrefWidth(320); textArea.setPrefHeight(130); HBox hBox = new HBox(); hBox.setSpacing(5); hBox.setPadding(new Insets(5,0,0,0)); hBox.setAlignment(Pos.BOTTOM_RIGHT); hBox.getChildren().addAll(yesButton, noButton); 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); }
/** * Make a Warning Dialog * @return BorderPane */ public void makeWaningGUI() { 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("Warning"); 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(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); }
public void updateImageAsTiled(@NotNull Image img, int tileW, int tileH, boolean modifyBoth) { ImagePattern pattern = new ImagePattern(img, 0, 0, tileW, tileH, false); ColorInput colorInput = new ColorInput(0, 0, w, h, pattern); if (modifyBoth || previewMode) { imgTrans2.setInput(colorInput); } if (modifyBoth || !previewMode) { imgTrans1.setInput(colorInput); } }
@Override public void setCanvasBackgroundToImage(@Nullable String imgPath) { if (imgPath == null) { uiCanvasEditor.setCanvasBackgroundImage(null); return; } uiCanvasEditor.setCanvasBackgroundImage(new ImagePattern(new Image(imgPath))); }
private void initialize() { theRules.setEditable(false); theRules.setMaxHeight(400); theRules.setMinWidth(400); theRules.setText("But du jeu :\n" + "Réduire la vie de votre adversaire à zéro pour gagner la partie.\n" + "\nPrincipes de jeu :\n" + "•\tChaque joueur possède un deck de 40 cartes. Au début chaque joueur commence \navec 2 cartes en mains pioché dans le deck.\n" + "•\tLa ressource utilisée dans le jeu est l’énergie. Vous débutez la partie avec un point d’énergie, \n à chaque tour vous recevrez un point d’énergie supplémentaire. L’énergie est rechargée au début de chaque tour.\n" + "•\tLe coût en énergie d’une carte est représenté en haut à droite de la carte. \n" + "•\tOn peut jouer plusieurs cartes par tour tant qu’on a l’énergie nécessaire.\n" + "•\tIl y a trois types de carte, Créature, Sort et Enchantement .\n" + "\n\nCréatures :\n" + "•\tLorsqu’une créature est jouée elle est invoquée sur le plateau. A la fin du tour l’ensemble des créatures attaquent.\n" + "•\tSi aucune créature se trouve sur le plateau adverse elles attaquent l’adversaire directement, sinon une créature attaque en priorité la créature avec le plus de défense qu’elle peut tuer sinon elle tape dans une autre créature.\n" + "•\tUne créature a une force d’attaque (représenté dans un rond rouge à gauche) et une force de défense (représenté dans un bouclier bleu à droite).\n" + "•\tSi la force d’attaque de la créature est supérieur ou égale à la force de défense de l’a créature adverse alors elle la tue et inversement.\n" + "\n\nCaractéristiques créature :\n" + "•\tFlying : Attaque directement d’adversaire sans prendre en compte les créatures sur le plateau.\n" + "•\tDeathtouch : Tue toute créature qu’il attaque même si la défense est supérieure à l’attaque de cette créature.\n" + "•\tCatch : Bloque une créature qui a la capacité Flying.\n" + "\n\nSorts :\n" + "Lorsqu’un sort est joué, il attaque l'adversaire ou béni le joueur directement." + "\n\nCaractéristiques Sorts :\n" + "•\tBlessing : Béni le joueur et lui faire gagner 3 points de vie.\n" + "•\tCurse : Attaque l'adversaire et lui faire perdre 3 points de vie.\n" + "•\tEnergy Drain : Offre 2 énérgies au joueur, et en vole deux à l’adversaire.\n" + "\n\nEnchantement :\n" + "Lorsqu’un enchantement est joué, le joueur a deux possiblité:\n" + "•\tpremière : Il est 2 énergies en plus pendant son tour (65% de chance).\n" + "•\tseconde : Il n'aura le droit qu'à une seule énergie pendant son tour (35% de chance).\n" ); Image img = new Image("images/rules.jpg"); theImage.setFill(new ImagePattern(img)); }
public ImagePattern apply(final Shape SHAPE) { double x = SHAPE.getLayoutBounds().getMinX(); double y = SHAPE.getLayoutBounds().getMinY(); double width = SHAPE.getLayoutBounds().getWidth(); double height = SHAPE.getLayoutBounds().getHeight(); centerX = width * 0.5; centerY = height * 0.5; return new ImagePattern(getImage(width, height), x, y, width, height, false); }
public ImagePattern getImagePattern(final Rectangle BOUNDS) { double x = BOUNDS.getX(); double y = BOUNDS.getY(); double width = BOUNDS.getWidth(); double height = BOUNDS.getHeight(); centerX = width * 0.5; centerY = height * 0.5; return new ImagePattern(getImage(width, height), x, y, width, height, false); }