本文整理了Java中javafx.scene.image.ImageView.setViewport()
方法的一些代码示例,展示了ImageView.setViewport()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.setViewport()
方法的具体详情如下:
包路径:javafx.scene.image.ImageView
类名称:ImageView
方法名:setViewport
暂无
代码示例来源:origin: stackoverflow.com
Image fullImage = new Image(imageURL);
// define crop in image coordinates:
Rectangle2D croppedPortion = new Rectangle2D(x, y, width, height);
// target width and height:
double scaledWidth = ... ;
double scaledHeight = ... ;
ImageView imageView = new ImageView(fullImage);
imageView.setViewport(croppedPortion);
imageView.setFitWidth(scaledWidth);
imageView.setFitHeight(scaledHeight);
imageView.setSmooth(true);
代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay
/**
* Set up the top fringe.
* @param width total with of the scene
*/
private void setupTopFringe(double width) {
double remWidth = width-topLeftWidth;
topFringRepeated.getChildren().clear();
Image topFringe = loader.getImage("images/topDeco");
topLeftWidth = topFringe.getWidth();
double decoWidth = topFringe.getWidth();
int countComplete = (int) Math.floor(remWidth/decoWidth); // number the deco can be drawn complete
double partialWidth = remWidth-(countComplete*decoWidth);
for (int i = 0; i < countComplete; i++) {
ImageView imgView = new ImageView(topFringe);
topFringRepeated.getChildren().add(imgView);
}
Rectangle2D viewportTopRight = new Rectangle2D(0, 0, partialWidth, topFringe.getHeight());
ImageView topRight = new ImageView(topFringe);
topRight.setViewport(viewportTopRight);
topFringRepeated.getChildren().add(topRight);
topFringRepeated.layoutXProperty().set(topLeftWidth);
}
public void widthChange(double oldWidth, double newWidth) {
代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay
ImageView bottomRightMortarCornerView = new ImageView(leftbottomCornerMortar);
Rectangle2D leftBottomMortarCornerViewport = new Rectangle2D(MORTAR_CORNER_DIM/2, 0, MORTAR_CORNER_DIM/2, MORTAR_CORNER_DIM);
bottomRightMortarCornerView.setViewport(leftBottomMortarCornerViewport);
bottomBorder.getChildren().add(bottomRightMortarCornerView);
Image bottomMortar = loader.getImage("images/bottomBorderMortar");
代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay
Rectangle2D topRightMortarViewport = new Rectangle2D(0, MORTAR_CORNER_DIM/2, MORTAR_CORNER_DIM, MORTAR_CORNER_DIM/2); // bottom half of image
ImageView topRightMortartImgView = new ImageView(topRightMortar);
topRightMortartImgView.setViewport(topRightMortarViewport);
rightBorder.getChildren().add(topRightMortartImgView);
Image rightMortar = loader.getImage("images/reightBorderMortar");
代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay
public void initializeMapImage(IPlayer player) {
Image mapImage = imageUtilities.createMapWithCities(map, player);
Dimension2D dim = map.getDimension();
scale = 192 / dim.getHeight();
double widthOrigImg = 236 / scale;
double xlocation = player.getHometown().getCoordinates().getX();
double x = Math.max(0, xlocation - widthOrigImg/2);
Rectangle2D viewport = new Rectangle2D(x, 0, widthOrigImg, dim.getHeight());
final Image transferableMap = mapImage;
Platform.runLater(() -> {
imgView.setViewport(viewport);
imgView.setImage(transferableMap);
for (ICity city : map.getCities()) {
if (city.getCoordinates().getX() >= x && city.getCoordinates().getX() <= x + widthOrigImg) {
List<INavigableVessel> ships = player.findShips(city);
if (!ships.isEmpty()) {
drawShipPresenceInCity(city, x);
}
}
}
});
}
内容来源于网络,如有侵权,请联系作者删除!