Class EmbeddedImage
java.lang.Object
jfx.incubator.scene.control.richtext.model.EmbeddedImage
An attribute which allows an image to be embedded into the
RichTextModel.- Since:
- 27
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleSentinel value which can be passed to eithertargetWidthortargetHeightto indicate that the rendered image dimension should be computed according to the image intrinsic aspect ratio.static final doubleSentinel value which can be passed totargetWidthto indicate that the rendered image width should not exceed the view's wrapped text width.static final doubleSentinel value which can be passed totargetWidthto indicate that the rendered image width should always fit the view's wrapped text width. -
Method Summary
Modifier and TypeMethodDescriptioncopy(double targetWidth, double targetHeight, boolean keepAspectRatio) Creates a copy of thisEmbeddedImagewith the specified target width, height, and aspect ratio.Creates the Node to be inserted into RichTextArea.doubleReturns the original image height.doubleReturns the target image height specification: positive when specifying the final height, orAUTOto determine the value fromisKeepAspectRatio()andgetHeight().doubleReturns the target image width specification: positive when specifying the final width, orAUTOto determine the value fromisKeepAspectRatio()andgetWidth(), orFIT_WIDTHto ensure the image does not exceed the viewport width, orFIT_WIDTH_ALWAYSto always fit the viewport width.doublegetWidth()Returns the original image width.booleanIndicates whether the aspect ratio of this image is preserved when scaling to fit the image within the document.static EmbeddedImageof(byte[] bytes, double width, double height, double targetWidth, double targetHeight, boolean keepAspectRatio) Creates a new EmbeddedImage instance while making a defensive copy of thebytesarray.
-
Field Details
-
AUTO
public static final double AUTOSentinel value which can be passed to eithertargetWidthortargetHeightto indicate that the rendered image dimension should be computed according to the image intrinsic aspect ratio.- See Also:
-
FIT_WIDTH
public static final double FIT_WIDTHSentinel value which can be passed totargetWidthto indicate that the rendered image width should not exceed the view's wrapped text width.- See Also:
-
FIT_WIDTH_ALWAYS
public static final double FIT_WIDTH_ALWAYSSentinel value which can be passed totargetWidthto indicate that the rendered image width should always fit the view's wrapped text width.- See Also:
-
-
Method Details
-
of
public static EmbeddedImage of(byte[] bytes, double width, double height, double targetWidth, double targetHeight, boolean keepAspectRatio) Creates a new EmbeddedImage instance while making a defensive copy of thebytesarray.Any negative value passed to either
targetWidthortargetHeight, other than a declared sentinel value, causes the image to be rendered as ifAUTOhad been passed.- Parameters:
bytes- the image sourcewidth- the original image widthheight- the original image heighttargetWidth- the target image width, orFIT_WIDTH,FIT_WIDTH_ALWAYS, orAUTOtargetHeight- the target image height, orAUTOkeepAspectRatio- whether to preserve the image aspect ratio- Returns:
- the new instance
-
getWidth
public double getWidth()Returns the original image width.- Returns:
- the image width
-
getHeight
public double getHeight()Returns the original image height.- Returns:
- the image height
-
getTargetWidth
public double getTargetWidth()Returns the target image width specification: positive when specifying the final width, orAUTOto determine the value fromisKeepAspectRatio()andgetWidth(), orFIT_WIDTHto ensure the image does not exceed the viewport width, orFIT_WIDTH_ALWAYSto always fit the viewport width.- Returns:
- the image target width
-
getTargetHeight
public double getTargetHeight()Returns the target image height specification: positive when specifying the final height, orAUTOto determine the value fromisKeepAspectRatio()andgetHeight().- Returns:
- the image target height
-
isKeepAspectRatio
public boolean isKeepAspectRatio()Indicates whether the aspect ratio of this image is preserved when scaling to fit the image within the document.- Returns:
- true if the aspect ratio is preserved
-
copy
Creates a copy of thisEmbeddedImagewith the specified target width, height, and aspect ratio.- Parameters:
targetWidth- the new target widthtargetHeight- the new target heightkeepAspectRatio- whether to keep the aspect ratio- Returns:
- the new instance
-
createNode
Creates the Node to be inserted into RichTextArea.- Returns:
- the node instance
-