本文整理了Java中javafx.scene.image.Image.getWidth()
方法的一些代码示例,展示了Image.getWidth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Image.getWidth()
方法的具体详情如下:
包路径:javafx.scene.image.Image
类名称:Image
方法名:getWidth
暂无
代码示例来源:origin: jfoenixadmin/JFoenix
private void updatePlaceholder(Node newView) {
if (view.getWidth() > 0 && view.getHeight() > 0) {
SnapshotParameters parameters = new SnapshotParameters();
parameters.setFill(Color.TRANSPARENT);
Image placeholderImage = view.snapshot(parameters,
new WritableImage((int) view.getWidth(), (int) view.getHeight()));
placeholder.setImage(placeholderImage);
placeholder.setFitWidth(placeholderImage.getWidth());
placeholder.setFitHeight(placeholderImage.getHeight());
} else {
placeholder.setImage(null);
}
placeholder.setVisible(true);
placeholder.setOpacity(1.0);
view.getChildren().setAll(placeholder, newView);
placeholder.toFront();
}
}
代码示例来源:origin: com.bitplan.radolan/com.bitplan.radolan
public double getWidth() {
if (this.image != null)
return image.getWidth();
else
return 640;
}
代码示例来源:origin: com.guigarage/imaging
public static double getMatchingHeight(double width, Image i) {
return ((i.getHeight() * width) / i.getWidth());
}
代码示例来源:origin: com.guigarage/imaging
public static double getMatchingWidth(double height, Image i) {
return ((i.getWidth() * height) / i.getHeight());
}
代码示例来源:origin: com.guigarage/imaging
private synchronized void addToCache(ImageIdentifier identifier, Image image) {
cleanCache((int) image.getHeight() * (int) image.getWidth());
cache.put(identifier, new WeakReference<Image>(image));
updateUsage(identifier);
pixelCount = pixelCount + (int) image.getHeight() * (int) image.getWidth();
}
代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay
private void resetClipXPosition(double x) {
if (x < 0) {
x = 0;
}
if (x > imgView.getImage().getWidth()) {
x = imgView.getImage().getWidth();
}
imgView.setLayoutX(-x);
shipCanvas.setLayoutX(-x);
clip.setX(x);
logger.trace("Set clip position={}, view and ship canvas layout: {}", x, -x);
}
代码示例来源:origin: com.guigarage/imaging
public static int[] getRGB(Image image) {
return getRGB(image, 0, 0, (int) image.getWidth(), (int) image.getHeight());
}
代码示例来源:origin: org.controlsfx/controlsfx
/**
* {@inheritDoc}
*/
@Override
protected Collection<Decoration> createRequiredDecorations(Control target) {
return Arrays.asList(new GraphicDecoration(new ImageView(REQUIRED_IMAGE),Pos.TOP_LEFT, REQUIRED_IMAGE.getWidth()/2, REQUIRED_IMAGE.getHeight()/2));
}
代码示例来源:origin: com.guigarage/imaging
public static Image fitInDimensionAndCutEdges(Image image, double width, double heigth) {
Dimension2D newImageDimension = UiUtilities.shouldFitIn(image.getWidth(), image.getHeight(), width, heigth);
Image resizedImage = fastResize(image, newImageDimension);
return clipImage(resizedImage, new Rectangle2D((resizedImage.getWidth() - width) / 2, (resizedImage.getHeight() - heigth) / 2, width, heigth));
}
}
代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay
private boolean scrolledAllToTheRight() {
return clip.getX() >= imgView.getImage().getWidth() - clip.getWidth();
}
代码示例来源:origin: de.roskenet/springboot-javafx-support
/**
* Override this to create your own splash pane parent node.
*
* @return A standard image
*/
public Parent getParent() {
final ImageView imageView = new ImageView(getClass().getResource(getImagePath()).toExternalForm());
final ProgressBar splashProgressBar = new ProgressBar();
splashProgressBar.setPrefWidth(imageView.getImage().getWidth());
final VBox vbox = new VBox();
vbox.getChildren().addAll(imageView, splashProgressBar);
return vbox;
}
代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay
private void focusOnPoint(Point2D focus) {
double totalwidth = imgView.getImage().getWidth();
double focusX = focus.getX();
double clipX = clip.getX();
double clipWidth = clip.getWidth();
double centerX = clipX + clipWidth/2;
if (clipX == 0.0 && focusX < centerX) {
// we are all to the left
} else if (clipX + clipWidth >= totalwidth) {
// we are all to the right
} else {
double x = Math.min(focusX - clipWidth/2, totalwidth - clipWidth);
resetClipXPosition(x);
}
}
代码示例来源:origin: com.guigarage/imaging
public static Image filter(Image image, ImageFilter filter) {
int width = (int) image.getWidth();
int height = (int) image.getHeight();
WritableImage filteredImage = new WritableImage(width, height);
int[] inPixels = getRGB(image);
int[] outPixels = filter.filter(width, height, inPixels);
setRGB(filteredImage, 0, 0, width, height, outPixels);
return filteredImage;
}
代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay
private void drawShipsInCities(Image mapImage, double scale, double x) {
for (ICity city : map.getCities()) {
if (city.getCoordinates().getX() >= x && city.getCoordinates().getX() <= x + mapImage.getWidth()) {
List<INavigableVessel> ships = viewState.getPlayer().findShips(city);
if (!ships.isEmpty()) {
drawShipPresenceInCity(city);
}
}
}
}
代码示例来源:origin: net.sf.dcutils/dcutils
public void setCenter(Point2D center) {
this.center = center;
this.sprite.translateXProperty().set(this.center.getX() - this.sprite.getImage().getWidth() / 2d);
this.sprite.translateYProperty().set(this.center.getY() - this.sprite.getImage().getHeight() / 2d);
} // END setCenter
代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay
private void setUpImageView() {
String imageName = getImageNameFromScene();
Image tmpImg = xmlLoader.getImage(imageName);
ImageData imgData = xmlLoader.getImageData(imageName);
Dimension2D targetDim = new Dimension2D(controlWidth, controlHeight);
ImageScaleState state = new ImageScaleState(new Dimension2D(tmpImg.getWidth(), tmpImg.getHeight()), targetDim, imgData.getCrop(), imgData.getMaxCrop());
logger.debug("State of the port scene before: " + state);
// // todo: andi 13/12/13: it would be simpler to bound the values instead of reinitializing them
imgView = new MainGameImageView(controlWidth, controlHeight, imageUtils.cropAndScale(imageName, state), state);
List<Polygon> polygons = polygonInitFactory.getScenePolygonInitializer().initialzePolygons(state);
imgView.resetPolygons(polygons);
viewState.setState(EViewState.CITY);
logger.debug("State of the port scene after : " + state);
}
private void setUpSeamapImageView() {
代码示例来源:origin: Tristan971/Lyrebird
@Override
public void bindViewSizeToParent() {
container.setPrefWidth(imageProp.getValue().getWidth());
container.setPrefHeight(imageProp.getValue().getHeight());
photoImageView.fitHeightProperty().bind(container.heightProperty());
photoImageView.fitWidthProperty().bind(container.widthProperty());
}
代码示例来源:origin: ch.sahits.game/OpenPatricianJavaFX
public void updateShipPosition() {
INavigableVessel vessel = control.getVessel();
final Point2D location = vessel.getLocation();
double x = location.getX() * control.scaleProperty().get();
double y = location.getY() * control.scaleProperty().get();
control.setLayoutX(x - shipIcon.getWidth() / 2);
control.setLayoutY(y - shipIcon.getHeight() / 2);
logger.trace("Update ship {} position to {},{} in view {},{}", vessel.getName(), vessel.getLocation().getX(), vessel.getLocation().getY(), control.getLayoutX(), control.getLayoutY());
}
代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay
private void drawCityInfo(Image mapImage, double scale, double x) {
for (ICity city : map.getCities()) {
if (city.getCoordinates().getX() >= x && city.getCoordinates().getX() <= x + mapImage.getWidth()) {
CityIcons cityIcons = new CityIcons(city.getCityState(), imageLoader);
// draw below city
double xPos = (city.getCoordinates().getX() - ImageUtil.CITY_RADIUS) * scale;
double yPos = (city.getCoordinates().getY() + ImageUtil.CITY_RADIUS + 5) * scale;
cityIcons.setScaleX(scale);
cityIcons.setScaleY(scale);
cityIcons.setLayoutX(xPos);
cityIcons.setLayoutY(yPos);
shipCanvas.getChildren().add(0, cityIcons);
}
}
}
代码示例来源:origin: io.datafx/flow
private void updatePlaceholder(Node newView) {
if (root.getWidth() > 0 && root.getHeight() > 0) {
Image placeholderImage = root.snapshot(null, new WritableImage((int) root.getWidth(), (int) root.getHeight()));
placeholder.setImage(placeholderImage);
placeholder.setFitWidth(placeholderImage.getWidth());
placeholder.setFitHeight(placeholderImage.getHeight());
} else {
placeholder.setImage(null);
}
placeholder.setVisible(true);
placeholder.setOpacity(1.0);
root.getChildren().setAll(placeholder);
root.getChildren().add(newView);
placeholder.toFront();
}
}
内容来源于网络,如有侵权,请联系作者删除!