Spec-Zone .ru
спецификации, руководства, описания, API

JavaFX: Обеспечение Богатого Опыта На Все Экраны Вашей Жизни

разверните все

Профиль: рабочий стол, распространенный

Краткий обзор

Image class представляет графические изображения и используется для того, чтобы загрузить изображения из указанного URL.

Изображения могут быть изменены, поскольку они загружаются (например, чтобы уменьшить объем памяти, использованный изображением). Приложение может определить качество фильтрации используемого, масштабируясь, и сохранить ли формат изображения исходного изображения.

Используйте ImageView для того, чтобы вывести на экран изображения, загруженные этим class. То же самое Image экземпляр может быть выведен на экран многократным ImageViews.

Пример кода для того, чтобы загрузить изображения.

код:

import javafx.scene.image.Image;

// load an image in background, displaying a placeholder while it's loading
// (assuming there's an ImageView node somewhere displaying this image)
var image1 = Image {
    url: "{__DIR__}flower.png"
    backgroundLoading: true
    placeholder: Image {
        url: "{__DIR__}placeholder.png"
    }
}

// load an image and resize it to 100x150 without preserving its original
// aspect ratio
var image2 = Image {
    url: "{__DIR__}flower.png"
    width: 100
    height: 150
    preserveRatio: false
}

// load an image and resize it to width of 100 while preserving its
// original aspect ratio, using faster filtering method
var image3 = Image {
    url: "{__DIR__}flower.png"
    width: 100
    smooth: false
}

// load an image and resize it only in one dimension, to the height of 100 and
// the original width, without preserving original aspect ratio
var image4 = Image {
    url: "{__DIR__}flower.png"
    height: 100
    preserveRatio: false
}

производит:

Профиль: распространенный

Переменная Сводка

доступимяввестиМожет ЧитатьМожет InitМожет ЗаписатьЗначение по умолчаниюописание
общественность-initbackgroundLoadingБулевложь

Указывает, используется ли изображение заполнителя, в то время как URL загружается в фоновом режиме.

считанный общественностьюошибкаБулевложь

Указывает, была ли ошибка обнаружена, загружая изображение.

общественность-initheightЧисло0

height ограничивающего прямоугольника, в пределах которого исходное изображение изменяется по мере необходимости, чтобы соответствовать.

height ограничивающего прямоугольника, в пределах которого исходное изображение изменяется по мере необходимости, чтобы соответствовать. Если установлено в значение <= 0, then the intrinsic height of the image will be used.

See preserveRatio for information on interaction between image's view width, height and preserveRatio attributes.

0

Profile: common

 
publicplaceholderИзображениеnull

The placeholder image which is used when backgroundLoading is set to true and the URL is loaded in the background.

public-initpreserveRatioBooleanfalse

Indicates whether to preserve the aspect ratio of the original image when scaling to fit the image within the bounding box provided by width and height.

Indicates whether to preserve the aspect ratio of the original image when scaling to fit the image within the bounding box provided by width and height.

If set to true, it affects the dimensions of this Image in the following way:

  • If only width is set, height is scaled to preserve ratio
  • If only height is set, width is scaled to preserve ratio
  • If both are set, they both may be scaled to get the best fit in a width by height rectangle while preserving the original aspect ratio
The reported width and height may be different from the initially set values if they needed to be adjusted to preserve aspect ratio. If unset or set to false, it affects the dimensions of this ImageView in the following way:
  • If only width is set, the image's width is scaled to match and height is unchanged;
  • If only height is set, the image's height is scaled to match and height is unchanged;
  • If both are set, the image is scaled to match both.

false

Profile: common

 
public-readprogressNumber0

The approximate percentage of image's loading that has been completed.

public-initsmoothBooleantrue

Indicates whether to use a better quality filtering algorithm or a faster one when scaling this image to fit within the bounding box provided by width and height.

Indicates whether to use a better quality filtering algorithm or a faster one when scaling this image to fit within the bounding box provided by width and height.

If not initialized or set to true a better quality filtering will be used, otherwise a faster but lesser quality filtering will be used.

true

Profile: common

 
public-initurlStringempty string

The string representing the URL to use in fetching the pixel data.

public-initwidthNumber0

The width of the bounding box within which the source image is resized as necessary to fit.

The width of the bounding box within which the source image is resized as necessary to fit. If set to a value <= 0, then the intrinsic width of the image will be used.

See preserveRatio for information on interaction between image's view width, height and preserveRatio attributes.

0

Profile: common

 

Inherited Variables

Script Function Summary

Function Summary

public cancel() : Void

Cancels the background loading of this image.

Cancels the background loading of this image.

Has no effect if this image isn't loaded in background or if loading has already completed.

Profile: common

 

Inherited Functions