本文整理匯總了Java中javafx.scene.image.ImageView.setTranslateY方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageView.setTranslateY方法的具體用法?Java ImageView.setTranslateY怎麽用?Java ImageView.setTranslateY使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.image.ImageView
的用法示例。
在下文中一共展示了ImageView.setTranslateY方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Metronome
import javafx.scene.image.ImageView; //導入方法依賴的package包/類
public Metronome() {
// création du fond du métronome
ImageView fond_metronome = new ImageView(
new Image(Metronome.class.getResourceAsStream("images/metronome.png")));
fond_metronome.setFitHeight(40);
fond_metronome.setPreserveRatio(true);
// création de l'aiguille du métronome
ImageView aiguille = new ImageView(new Image(Metronome.class.getResourceAsStream("images/aiguille.png")));
aiguille.setFitHeight(32);
aiguille.setPreserveRatio(true);
aiguille.setTranslateX(16);
aiguille.setTranslateY(2);
// on applique une transformation à l'aiguille
Rotate rotation = new Rotate(0, 3, 29);
aiguille.getTransforms().add(rotation);
// création de l'animation de l'aiguille
Timeline timeline = new Timeline();
timeline.getKeyFrames().addAll(new KeyFrame(Duration.ZERO, new KeyValue(rotation.angleProperty(), 45)),
new KeyFrame(new Duration(1000), new KeyValue(rotation.angleProperty(), -45)));
timeline.setAutoReverse(true);
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.play();
this.getChildren().add(fond_metronome);
this.getChildren().add(aiguille);
this.setTranslateX(400);
this.setTranslateY(200);
}
示例2: getPlus
import javafx.scene.image.ImageView; //導入方法依賴的package包/類
private Node getPlus () {
Image image = new Image(myBundle.getString("ImageURL"));
ImageView view = new ImageView(image);
view.setTranslateX(half(getTopWidth()) -
half(view.getBoundsInLocal().getWidth()));
view.setTranslateY(half(getTopHeight()) -
half(view.getBoundsInLocal().getHeight()));
return view;
}
示例3: MapCreatorView
import javafx.scene.image.ImageView; //導入方法依賴的package包/類
/**
* Build the CreatorView from existing Map in the DB
*/
public MapCreatorView(MapController controller, fr.iut.persistence.entities.Map mapInBdd) {
this(controller);
this.mapInBdd = mapInBdd;
//We create the image from bytes in DB
Image image = new Image(new ByteArrayInputStream(mapInBdd.getImage()));
buttonReset.setVisible(true);
adaptMapPaneToImage(image);
//We create the spots on the map from the DB
for(Spot spot : controller.getAllSpots()) {
ItemMap correspondingItem = null;
for(ItemMap itemMap : availableItems)
if(itemMap.getType().equals(spot.getSpotType())) {
correspondingItem = itemMap;
break;
}
if(correspondingItem == null) {
System.out.println("This cannot be possible !!!");
System.exit(1);
}
ImageView imageOnMap = new ImageView(correspondingItem.getSmallImage());
mapPane.getChildren().add(imageOnMap);
imageOnMap.setTranslateX(spot.getPointX());
imageOnMap.setTranslateY(spot.getPointY());
ItemMap finalCorrespondingItem = correspondingItem;
imageOnMap.setOnMouseClicked(mouseEvent1 -> {
editItem(new ImageView(finalCorrespondingItem.getBigImage()), imageOnMap, spot);
});
}
}
示例4: Splash
import javafx.scene.image.ImageView; //導入方法依賴的package包/類
Splash() {
state = STATE_SHOW_TITLE;
stateArg = 0;
initTimeline();
background = new ImageView();
background.setFocusTraversable(true);
background.setImage(Config.getImages().get(Config.IMAGE_BACKGROUND));
background.setFitWidth(Config.SCREEN_WIDTH);
background.setFitHeight(Config.SCREEN_HEIGHT);
background.setOnMousePressed(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
Main.getMainFrame().startGame();
}
});
background.setOnKeyPressed(new EventHandler<KeyEvent>() {
public void handle(KeyEvent ke) {
Main.getMainFrame().startGame();
}
});
brick = new ImageView();
brick.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BRICK));
brick.setTranslateX(-1000);
brick.setTranslateY(brick.getImage().getHeight());
brickShadow = new ImageView();
brickShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BRICKSHADOW));
brickShadow.setTranslateX(-1000);
breaker = new ImageView();
breaker.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BREAKER));
breaker.setTranslateX(-1000);
breaker.setTranslateY(brick.getTranslateY() + brick.getImage().getHeight() * 5 / 4);
breakerShadow = new ImageView();
breakerShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BREAKERSHADOW));
breakerShadow.setTranslateX(-1000);
strike = new ImageView();
strike.setImage(Config.getImages().get(Config.IMAGE_SPLASH_STRIKE));
strike.setTranslateY(brick.getTranslateY() -
(strike.getImage().getHeight() - brick.getImage().getHeight()) / 2);
strike.setVisible(false);
pressanykey = new ImageView();
pressanykey.setImage(Config.getImages().get(Config.IMAGE_SPLASH_PRESSANYKEY));
pressanykey.setTranslateX((Config.SCREEN_WIDTH - pressanykey.getImage().getWidth()) / 2);
double y = breaker.getTranslateY() + breaker.getImage().getHeight();
pressanykey.setTranslateY(y + (Config.SCREEN_HEIGHT - y) / 2);
pressanykey.setOpacity(0);
strikeShadow = new ImageView();
strikeShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_STRIKESHADOW));
strikeShadow.setTranslateX(-1000);
pressanykeyShadow = new ImageView();
pressanykeyShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_PRESSANYKEYSHADOW));
pressanykeyShadow.setTranslateX(-1000);
sun = new ImageView();
sun.setImage(Config.getImages().get(Config.IMAGE_SPLASH_SUN));
sun.setTranslateX(-1000);
NODES = new ImageView[] {brick, breaker, strike, pressanykey};
NODES_SHADOWS = new ImageView[] {brickShadow, breakerShadow, strikeShadow, pressanykeyShadow};
Group group = new Group();
group.getChildren().add(background);
group.getChildren().addAll(NODES_SHADOWS);
group.getChildren().addAll(NODES);
group.getChildren().add(sun);
getChildren().add(group);
}
示例5: initInfoPanel
import javafx.scene.image.ImageView; //導入方法依賴的package包/類
private void initInfoPanel() {
infoPanel = new Group();
roundCaption = new Text();
roundCaption.setText("ROUND");
roundCaption.setTextOrigin(VPos.TOP);
roundCaption.setFill(Color.rgb(51, 102, 51));
Font f = new Font("Impact", 18);
roundCaption.setFont(f);
roundCaption.setTranslateX(30);
roundCaption.setTranslateY(128);
round = new Text();
round.setTranslateX(roundCaption.getTranslateX() +
roundCaption.getBoundsInLocal().getWidth() + Config.INFO_TEXT_SPACE);
round.setTranslateY(roundCaption.getTranslateY());
round.setText(levelNumber + "");
round.setTextOrigin(VPos.TOP);
round.setFont(f);
round.setFill(Color.rgb(0, 204, 102));
scoreCaption = new Text();
scoreCaption.setText("SCORE");
scoreCaption.setFill(Color.rgb(51, 102, 51));
scoreCaption.setTranslateX(30);
scoreCaption.setTranslateY(164);
scoreCaption.setTextOrigin(VPos.TOP);
scoreCaption.setFont(f);
score = new Text();
score.setTranslateX(scoreCaption.getTranslateX() +
scoreCaption.getBoundsInLocal().getWidth() + Config.INFO_TEXT_SPACE);
score.setTranslateY(scoreCaption.getTranslateY());
score.setFill(Color.rgb(0, 204, 102));
score.setTextOrigin(VPos.TOP);
score.setFont(f);
score.setText("");
livesCaption = new Text();
livesCaption.setText("LIFE");
livesCaption.setTranslateX(30);
livesCaption.setTranslateY(200);
livesCaption.setFill(Color.rgb(51, 102, 51));
livesCaption.setTextOrigin(VPos.TOP);
livesCaption.setFont(f);
Color INFO_LEGEND_COLOR = Color.rgb(0, 114, 188);
int infoWidth = Config.SCREEN_WIDTH - Config.FIELD_WIDTH;
Rectangle black = new Rectangle();
black.setWidth(infoWidth);
black.setHeight(Config.SCREEN_HEIGHT);
black.setFill(Color.BLACK);
ImageView verLine = new ImageView();
verLine.setImage(new Image(Level.class.getResourceAsStream(Config.IMAGE_DIR+"vline.png")));
verLine.setTranslateX(3);
ImageView logo = new ImageView();
logo.setImage(Config.getImages().get(Config.IMAGE_LOGO));
logo.setTranslateX(30);
logo.setTranslateY(30);
Text legend = new Text();
legend.setTranslateX(30);
legend.setTranslateY(310);
legend.setText("LEGEND");
legend.setFill(INFO_LEGEND_COLOR);
legend.setTextOrigin(VPos.TOP);
legend.setFont(new Font("Impact", 18));
infoPanel.getChildren().addAll(black, verLine, logo, roundCaption,
round, scoreCaption, score, livesCaption, legend);
for (int i = 0; i < Bonus.COUNT; i++) {
Bonus bonus = new Bonus(i);
Text text = new Text();
text.setTranslateX(100);
text.setTranslateY(350 + i * 40);
text.setText(Bonus.NAMES[i]);
text.setFill(INFO_LEGEND_COLOR);
text.setTextOrigin(VPos.TOP);
text.setFont(new Font("Arial", 12));
bonus.setTranslateX(30 + (820 - 750 - bonus.getWidth()) / 2);
bonus.setTranslateY(text.getTranslateY() -
(bonus.getHeight() - text.getBoundsInLocal().getHeight()) / 2);
// Workaround JFXC-2379
infoPanel.getChildren().addAll(bonus, text);
}
infoPanel.setTranslateX(Config.FIELD_WIDTH);
}