本文整理匯總了Java中javafx.scene.image.ImageView.setOnMouseClicked方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageView.setOnMouseClicked方法的具體用法?Java ImageView.setOnMouseClicked怎麽用?Java ImageView.setOnMouseClicked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.image.ImageView
的用法示例。
在下文中一共展示了ImageView.setOnMouseClicked方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initData
import javafx.scene.image.ImageView; //導入方法依賴的package包/類
@Override
public void initData(Parent node, Map<String, String> bundle) {
progressbar = (ProgressIndicator) node.lookup("#progressbar");
iv_sync = (ImageView) node.lookup("#iv_sync");
iv_down = (ImageView) node.lookup("#iv_down");
iv_sync.setOnMouseEntered(e-> {
iv_sync.setImage(sync_enter);
});
iv_sync.setOnMouseExited(e-> {
iv_sync.setImage(sync_defalt);
});
iv_down.setOnMouseEntered(e-> {
iv_down.setImage(down_enter);
});
iv_down.setOnMouseExited(e-> {
iv_down.setImage(down_default);
});
iv_down.setOnMouseClicked(e->{
download();
});
iv_sync.setOnMouseClicked(e->{
sync();
});
}
示例2: setImages
import javafx.scene.image.ImageView; //導入方法依賴的package包/類
public void setImages(List<Image> images, ImageClickHandler handler) throws IOException {
grid.clear();
for (Image image : images) {
ImageView imageView = grid.addImage(image.getThumbnailPath());
if(imageView == null)
continue;
// toolTipProvider.setToolTip(imageView, image);
toolTipProvider.setPopOver(imageView, image);
imageView.setOnMouseClicked(eventHandlerFactory.createFrom(image, handler));
imageView.setOnMouseEntered(event -> getScene().setCursor(Cursor.HAND));
imageView.setOnMouseExited(event -> getScene().setCursor(Cursor.DEFAULT));
}
}
示例3: showQRCode
import javafx.scene.image.ImageView; //導入方法依賴的package包/類
@FXML
protected void showQRCode(MouseEvent event) {
// Serialize to PNG and back into an image. Pretty lame but it's the shortest code to write and I'm feeling
// lazy tonight.
final byte[] imageBytes = QRCode
.from(uri())
.withSize(320, 240)
.to(ImageType.PNG)
.stream()
.toByteArray();
Image qrImage = new Image(new ByteArrayInputStream(imageBytes));
ImageView view = new ImageView(qrImage);
view.setEffect(new DropShadow());
// Embed the image in a pane to ensure the drop-shadow interacts with the fade nicely, otherwise it looks weird.
// Then fix the width/height to stop it expanding to fill the parent, which would result in the image being
// non-centered on the screen. Finally fade/blur it in.
Pane pane = new Pane(view);
pane.setMaxSize(qrImage.getWidth(), qrImage.getHeight());
final Main.OverlayUI<ClickableBitcoinAddress> overlay = Main.instance.overlayUI(pane, this);
view.setOnMouseClicked(event1 -> overlay.done());
}
示例4: start
import javafx.scene.image.ImageView; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception {
ImageView demo1Button = new ImageView();
ImageView demo2Button = new ImageView();
demo1Button.setFitWidth(200);
demo2Button.setFitWidth(200);
demo1Button.setPreserveRatio(true);
demo2Button.setPreserveRatio(true);
HBox.setHgrow(demo1Button, Priority.ALWAYS);
HBox.setHgrow(demo2Button, Priority.ALWAYS);
demo1Button.getStyleClass().add("demo1");
demo2Button.getStyleClass().add("demo2");
demo1Button.setOnMouseClicked(evt -> showDemo1());
demo2Button.setOnMouseClicked(evt -> showDemo2());
HBox container = new HBox(demo1Button, demo2Button);
Scene scene = new Scene(container);
scene.getStylesheets().add(MovieApp.class.getResource("/chooser.css").toExternalForm());
scene.getStylesheets().add(MovieApp.class.getResource("/fonts.css").toExternalForm());
primaryStage.setResizable(false);
primaryStage.setTitle("Extreme GUI Makeover");
primaryStage.setScene(scene);
primaryStage.sizeToScene();
primaryStage.setX(50);
primaryStage.setY(100);
primaryStage.show();
}
示例5: getMonstersOnScreen
import javafx.scene.image.ImageView; //導入方法依賴的package包/類
public void getMonstersOnScreen() {
List<SpriteMakerModel> allSprites = new ArrayList<SpriteMakerModel>(myData.getSprites());
List<SpriteMakerModel> onlyMonsters = new ArrayList<>();
for (SpriteMakerModel possibleMonster : allSprites) {
if (isMonster(possibleMonster)) {
onlyMonsters.add(possibleMonster);
}
}
for (SpriteMakerModel monster : onlyMonsters) {
Images imageComp = (Images) monster.getComponentByType(Images.TYPE);
ImageView iv = new ImageView(imageComp.image().getFXImage());
iv.setFitWidth(100);
iv.setFitHeight(100);
iv.setOnMouseClicked(click -> {
setCurrentMonster(monster, new ImageView(imageComp.image().getFXImage()));
mySpawnerInfo.setCurrentMonsterToSpawn(monster);
});
monsterImages.getChildren().add(iv);
}
}
示例6: render
import javafx.scene.image.ImageView; //導入方法依賴的package包/類
public void render(List<Skill> newSkills) {
if (sameSkills(oldSkills, newSkills)) {return;}
oldSkills = newSkills;
box.getChildren().clear();
for (Skill skill: newSkills) {
if (skill.getIcon().isPresent()) {
ImageView skillImageView = new ImageView(skill.getIcon().get().getFXImage());
skillImageView.setFitWidth(skill.getIcon().get().width());
skillImageView.setFitHeight(skill.getIcon().get().height());
skillImageView.setOnMouseClicked(e -> {
bus.emit(new SelectSkillEvent(SelectSkillEvent.SELECT, skill));
});
box.getChildren().add(skillImageView);
}
}
}
示例7: newDir2
import javafx.scene.image.ImageView; //導入方法依賴的package包/類
public void newDir2() {
int j = 0; // Used to properly insert to grid when there are files other than an image
for (int i=0; i<fileList.length; i++) {
String path = "" + fileList[i];
if (fileList[i].getName().contains(".png") || fileList[i].getName().contains(".jpg")||
fileList[i].getName().contains(".gif") || fileList[i].getName().contains(".jpeg")) {
String title = "" + fileList[i];
pth = new Image("file://" + fileList[i]);
ImageView view = (ImageView) (tilePane.getChildren().get(j));
view.setImage(pth);
view.setCache(true);
final ImageView imgViewPoped = new ImageView("file://" + fileList[i]);
// image click actions
view.setOnMouseClicked(mouse -> {
MouseButton button = mouse.getButton();
if (mouse.getClickCount() == 2 && button == MouseButton.PRIMARY && !mouse.isConsumed()) {
mouse.consume();
txtDirPath.setText(path);
settings.setBackgroundInfo(path);
} else if (button == MouseButton.SECONDARY) {
displayImg(imgViewPoped, title);
}
});
j++;
} else {
System.out.println("Not an image file.");
}
}
}
示例8: 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);
});
}
}
示例9: loadFromFile
import javafx.scene.image.ImageView; //導入方法依賴的package包/類
public void loadFromFile(SpriteMakerModel monster) {
if (isMonster(monster)) {
Images imageComp = (Images) monster.getComponentByType(Images.TYPE);
ImageView iv = new ImageView(imageComp.image().getFXImage());
iv.setFitWidth(IMAGE_SIZE);
iv.setFitHeight(IMAGE_SIZE);
iv.setOnMouseClicked(click -> {
setCurrentMonster(monster, new ImageView(imageComp.image().getFXImage()));
mySpawnerInfo.setCurrentMonsterToSpawn(monster);
});
monsterImages.getChildren().add(iv);
}
}
示例10: startCameraEdges
import javafx.scene.image.ImageView; //導入方法依賴的package包/類
private void startCameraEdges(final ImageView imageViewForOpenCV) {
// preserve image ratio
imageViewForOpenCV.setPreserveRatio(true);
// mouse listener
imageViewForOpenCV.setOnMouseClicked(e -> {
LOGGER.info("[" + e.getX() + ", " + e.getY() + "]");
clickedPoint.x = e.getX();
clickedPoint.y = e.getY();
});
if (!isCameraActive) {
// disable setting checkboxes
this.canny.setDisable(true);
this.dilateErode.setDisable(true);
// start the video capture
VIDEO_CAPTURE.open(0);
// is the video stream available?
if (VIDEO_CAPTURE.isOpened()) {
isCameraActive = true;
// grab a frame every 33 ms (30 frames/sec)
Runnable frameGrabber = () -> {
// effectively grab and process a single frame
Mat frame = grabFrameEdges();
// convert and show the frame
Image imageToShow = UtilsOpenCV.mat2Image(frame);
updateImageView(imageViewForOpenCV, imageToShow);
};
timer = Executors.newSingleThreadScheduledExecutor();
timer.scheduleAtFixedRate(frameGrabber, 0, 33, TimeUnit.MILLISECONDS);
// update the button content
btnOpenCVStartCamera.setText("Stop Camera");
} else {
// log the error
LOGGER.error("Failed to open the camera connection...");
}
} else {
// the camera is not active at this point
isCameraActive = false;
// update again the button content
btnOpenCVStartCamera.setText("Start Camera");
// enable setting checkboxes
canny.setDisable(false);
dilateErode.setDisable(false);
// stop the timer
this.stopAcquisition();
}
}