Class ImageView

java.lang.Object
javafx.scene.Node
javafx.scene.image.ImageView
All Implemented Interfaces:
LayoutMeasurable, LayoutMeasurableMixin, HasBlendModeProperty, HasClipProperty, HasEffectProperty, HasFitHeightProperty, HasFitWidthProperty, HasImageProperty, HasImageUrlProperty, HasLayoutXProperty, HasLayoutYProperty, HasManagedProperty, HasMouseTransparentProperty, HasOnMouseClickedProperty, HasOpacityProperty, HasParentProperty, HasVisibleProperty, HasXProperty, HasYProperty, Styleable, EventTarget, INode

Author:
Bruno Salmon
  • Property Details

  • Constructor Details

    • ImageView

      public ImageView()
    • ImageView

      public ImageView(String imageUrl)
    • ImageView

      public ImageView(Image image)
  • Method Details

    • imageProperty

      public Property<Image> imageProperty()
      Specified by:
      imageProperty in interface HasImageProperty
      Returns:
      the image property
      See Also:
    • imageUrlProperty

      public Property<String> imageUrlProperty()
      Specified by:
      imageUrlProperty in interface HasImageUrlProperty
      Returns:
      the imageUrl property
      See Also:
    • fitWidthProperty

      public DoubleProperty fitWidthProperty()
      Specified by:
      fitWidthProperty in interface HasFitWidthProperty
      Returns:
      the fitWidth property
      See Also:
    • fitHeightProperty

      public DoubleProperty fitHeightProperty()
      Specified by:
      fitHeightProperty in interface HasFitHeightProperty
      Returns:
      the fitHeight property
      See Also:
    • xProperty

      public DoubleProperty xProperty()
      Specified by:
      xProperty in interface HasXProperty
      Returns:
      the x property
      See Also:
    • yProperty

      public DoubleProperty yProperty()
      Specified by:
      yProperty in interface HasYProperty
      Returns:
      the y property
      See Also:
    • setPreserveRatio

      public final void setPreserveRatio(boolean value)
      Sets the value of the preserveRatio property.
      Property description:
      Indicates whether to preserve the aspect ratio of the source image when scaling to fit the image within the fitting bounding box.

      If set to true, it affects the dimensions of this ImageView in the following way *

      • If only fitWidth is set, height is scaled to preserve ratio
      • If only fitHeight 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
      If unset or set to false, it affects the dimensions of this ImageView in the following way *
      • If only fitWidth is set, image's view width is scaled to match and height is unchanged;
      • If only fitHeight is set, image's view height is scaled to match and height is unchanged;
      • If both are set, the image view is scaled to match both.

      Note that the dimensions of this node as reported by the node's bounds will be equal to the size of the scaled image and is guaranteed to be contained within fitWidth x fitHeight bonding box.
      Default value:
      false
      Parameters:
      value - the value for the preserveRatio property
      See Also:
    • isPreserveRatio

      public final boolean isPreserveRatio()
      Gets the value of the preserveRatio property.
      Property description:
      Indicates whether to preserve the aspect ratio of the source image when scaling to fit the image within the fitting bounding box.

      If set to true, it affects the dimensions of this ImageView in the following way *

      • If only fitWidth is set, height is scaled to preserve ratio
      • If only fitHeight 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
      If unset or set to false, it affects the dimensions of this ImageView in the following way *
      • If only fitWidth is set, image's view width is scaled to match and height is unchanged;
      • If only fitHeight is set, image's view height is scaled to match and height is unchanged;
      • If both are set, the image view is scaled to match both.

      Note that the dimensions of this node as reported by the node's bounds will be equal to the size of the scaled image and is guaranteed to be contained within fitWidth x fitHeight bonding box.
      Default value:
      false
      Returns:
      the value of the preserveRatio property
      See Also:
    • preserveRatioProperty

      public final BooleanProperty preserveRatioProperty()
      Indicates whether to preserve the aspect ratio of the source image when scaling to fit the image within the fitting bounding box.

      If set to true, it affects the dimensions of this ImageView in the following way *

      • If only fitWidth is set, height is scaled to preserve ratio
      • If only fitHeight 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
      If unset or set to false, it affects the dimensions of this ImageView in the following way *
      • If only fitWidth is set, image's view width is scaled to match and height is unchanged;
      • If only fitHeight is set, image's view height is scaled to match and height is unchanged;
      • If both are set, the image view is scaled to match both.

      Note that the dimensions of this node as reported by the node's bounds will be equal to the size of the scaled image and is guaranteed to be contained within fitWidth x fitHeight bonding box.
      Default value:
      false
      Returns:
      the preserveRatio property
      See Also:
    • onPeerSizeChanged

      public void onPeerSizeChanged()
      Overrides:
      onPeerSizeChanged in class Node