本文整理了Java中javafx.scene.image.Image.getHeight()
方法的一些代码示例,展示了Image.getHeight()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Image.getHeight()
方法的具体详情如下:
包路径:javafx.scene.image.Image
类名称:Image
方法名:getHeight
暂无
代码示例来源: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 getHeight() {
if (this.image != null)
return image.getHeight();
else
return 480;
}
代码示例来源:origin: com.guigarage/imaging
public static double getMatchingHeight(double width, Image i) {
return ((i.getHeight() * width) / i.getWidth());
}
代码示例来源:origin: ch.sahits.game/OpenPatricianJavaFX
private DoubleBinding shieldYOffsetBinding() {
return shipIconView.layoutYProperty().add(shipIcon.getHeight() * ICON_SCALE - 0.5 * shipIcon.getHeight() * ICON_SCALE + SHIELD_Y_OFFSET);
}
代码示例来源: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: com.guigarage/imaging
public static int[] getRGB(Image image) {
return getRGB(image, 0, 0, (int) image.getWidth(), (int) image.getHeight());
}
代码示例来源:origin: com.guigarage/imaging
public static Image progressiveResize(Image image, int width, int height, InterpolationType type) {
if (width <= 0 || height <= 0) {
throw new IllegalArgumentException("Dimension must be > 0 (" + width + "/" + height + ")");
}
if (image.getWidth() == width && image.getHeight() == height) {
return new WritableImage(image.getPixelReader(), width, height);
}
if (image.getWidth() * 2 < width && image.getHeight() * 2 < height) {
Image resizedImage = fastResize(image, (int) image.getWidth() * 2, (int) image.getHeight() * 2);
return progressiveResize(resizedImage, width, height);
}
if (image.getWidth() / 2 > width && image.getHeight() / 2 > height) {
Image resizedImage = fastResize(image, (int) image.getWidth() / 2, (int) image.getHeight() / 2);
return progressiveResize(resizedImage, width, height);
}
return resizeByAwt(image, width, height, type);
}
代码示例来源: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: 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/OpenPatricianJavaFX
public OpenPatricianSmallWaxButtonSkin(final OpenPatricianSmallWaxButton button) {
super(button);
InputStream is = getClass().getResourceAsStream("sealingWaxFlattend.png");
Image img = new Image(is);
final ImageView imageView = new ImageView(img);
final Label label = new Label();
label.textProperty().bind(button.textProperty());
label.getStyleClass().add("OpenPatricianSmallWaxButtonLabeled");
label.onMouseClickedProperty().bind(button.onActionProperty());
label.textProperty().bind(button.textProperty());
imageView.onMouseReleasedProperty().bind(button.onActionProperty());
StackPane stack = new StackPane();
stack.getChildren().addAll(imageView, label);
Group group = new Group(stack);
group.setManaged(false);
button.setPrefHeight(img.getHeight());
button.setPrefWidth(img.getWidth());
button.setMaxHeight(img.getHeight());
getChildren().add(group);
}
代码示例来源: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: com.guigarage/imaging
@Override
protected Image call() throws Exception {
updateTitle("Image Cache Loader");
//Check if matching Image is in cache
Image image = getCachedImage(identifier);
if(image != null) {
if(image.getWidth() == identifier.getWidth() && image.getHeight() == identifier.getHeight()) {
updateUsage(identifier);
return image;
}
}
//Create new Image
image = new Image(identifier.getUrl(), false);
image = ImageUtilities.fitInDimensionAndCutEdges(image, identifier.getWidth(), identifier.getHeight());
addToCache(identifier, image);
return image;
}
};
代码示例来源:origin: ch.sahits.game/OpenPatricianJavaFX
public OpenPatricianLargeWaxButtonSkin(final OpenPatricianLargeWaxButton button) {
super(button);
InputStream is = getClass().getResourceAsStream("sealingWaxFlattend_long.png");
Image img = new Image(is);
final ImageView imageView = new ImageView(img);
final Label label = new Label();
label.textProperty().bind(button.textProperty());
label.idProperty().bind(button.idProperty());
label.getStyleClass().add("OpenPatricianLargeWaxButtonLabeled");
label.onMouseClickedProperty().bind(button.onActionProperty());
imageView.onMouseReleasedProperty().bind(button.onActionProperty());
StackPane stack = new StackPane();
stack.getChildren().addAll(imageView, label);
Group group = new Group(stack);
group.setManaged(false);
button.setPrefHeight(img.getHeight());
button.setPrefWidth(img.getWidth());
getChildren().add(group);
}
代码示例来源: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: 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();
}
}
代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay
private void setUpSeamapImageView() {
IHumanPlayer player = viewState.getPlayer();
Image mapImage = imageUtils.createMapWithCities(map, player);
final Font openPatrician18 = Font.font("OpenPatrician", 18);
mapImage = imageUtils.addCityNames(map, mapImage, openPatrician18);
Dimension2D origDim = new Dimension2D(mapImage.getWidth(), mapImage.getHeight());
double scale = controlHeight/origDim.getHeight();
Dimension2D targetDim = new Dimension2D(origDim.getWidth()*scale, origDim.getHeight()*scale);
mapImage = imageUtils.scale(mapImage, targetDim, scale);
Point2D coordinates = viewState.getCurrentCityProxy().get().getCity().getCoordinates();
coordinates = new Point2D(coordinates.getX() * scale, coordinates.getY() * scale);
if (seaMapView == null) {
seaMapView = (SeamapImageView) context.getBean("seamapImageView", new Object[]{mapImage, controlWidth, controlHeight, coordinates, scale});
} else {
seaMapView.resetImage(mapImage,controlWidth, controlHeight, scale);
}
imgView = seaMapView;
viewState.setState(EViewState.MAP);
}
内容来源于网络,如有侵权,请联系作者删除!