APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jfx.incubator.scene.control.richtext.model

public final Class EmbeddedImage

extends Object
Class Inheritance
Imports
java.io.ByteArrayInputStream, java.util.Arrays, javafx.scene.Node, javafx.scene.control.Label, javafx.scene.image.Image, .ImageView, com.sun.jfx.incubator.scene.control.richtext.EmbeddedImageHelper, .RequiresComplexLayout, .VFlow

An attribute which allows an image to be embedded into the RichTextModel.
Since
27

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
EmbeddedImage.Fixed

Image Container with a fixed-size image.

private class
EmbeddedImage.Tracking

Image Container that tracks the document width.

Field Summary

Modifier and TypeField and Description
public static final double
AUTO

Sentinel value which can be passed to either targetWidth or targetHeight to indicate that the rendered image dimension should be computed according to the image intrinsic aspect ratio.

private final byte[]
public static final double
FIT_WIDTH

Sentinel value which can be passed to targetWidth to indicate that the rendered image width should not exceed the view's wrapped text width.

public static final double
FIT_WIDTH_ALWAYS

Sentinel value which can be passed to targetWidth to indicate that the rendered image width should always fit the view's wrapped text width.

private final double
private final boolean
private final double
private final double
private final double

Constructor Summary

AccessConstructor and Description
private
EmbeddedImage(byte[] bytes, double width, double height, double targetWidth, double targetHeight, boolean keepAspectRatio)

Private constructor that DOES NOT make a defensive copy of the bytes.

Method Summary

Modifier and TypeMethod and Description
public EmbeddedImage

Returns:

the new instance
copy
(double
the new target width
targetWidth
,
double
the new target height
targetHeight
,
boolean
whether to keep the aspect ratio
keepAspectRatio
)

Creates a copy of this EmbeddedImage with the specified target width, height, and aspect ratio.

public Node

Returns:

the node instance
createNode
()

Creates the Node to be inserted into RichTextArea.

public boolean
equals(Object x)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public double

Returns:

the image height
getHeight
()

Returns the original image height.

public double

Returns:

the image target height
getTargetHeight
()

Returns the target image height specification: positive when specifying the final height, or AUTO to determine the value from isKeepAspectRatio() and getHeight().

public double

Returns:

the image target width
getTargetWidth
()

Returns the target image width specification: positive when specifying the final width, or AUTO to determine the value from isKeepAspectRatio() and getWidth(), or FIT_WIDTH to ensure the image does not exceed the viewport width, or FIT_WIDTH_ALWAYS to always fit the viewport width.

public double

Returns:

the image width
getWidth
()

Returns the original image width.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean

Returns:

true if the aspect ratio is preserved
isKeepAspectRatio
()

Indicates whether the aspect ratio of this image is preserved when scaling to fit the image within the document.

public static EmbeddedImage

Returns:

the new instance
of
(byte[]
the image source
bytes
,
double
the original image width
width
,
double
the original image height
height
,
double
the target image width, or FIT_WIDTH, FIT_WIDTH_ALWAYS, or AUTO
targetWidth
,
double
the target image height, or AUTO
targetHeight
,
boolean
whether to preserve the image aspect ratio
keepAspectRatio
)

Creates a new EmbeddedImage instance while making a defensive copy of the bytes array.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

AUTOback to summary
public static final double AUTO

Sentinel value which can be passed to either targetWidth or targetHeight to indicate that the rendered image dimension should be computed according to the image intrinsic aspect ratio.

bytesback to summary
private final byte[] bytes
FIT_WIDTHback to summary
public static final double FIT_WIDTH

Sentinel value which can be passed to targetWidth to indicate that the rendered image width should not exceed the view's wrapped text width.

FIT_WIDTH_ALWAYSback to summary
public static final double FIT_WIDTH_ALWAYS

Sentinel value which can be passed to targetWidth to indicate that the rendered image width should always fit the view's wrapped text width.

heightback to summary
private final double height
keepAspectRatioback to summary
private final boolean keepAspectRatio
targetHeightback to summary
private final double targetHeight
targetWidthback to summary
private final double targetWidth
widthback to summary
private final double width

Constructor Detail

EmbeddedImageback to summary
private EmbeddedImage(byte[] bytes, double width, double height, double targetWidth, double targetHeight, boolean keepAspectRatio)

Private constructor that DOES NOT make a defensive copy of the bytes. The only public method is EmbeddedImage.of() which does.

Method Detail

copyback to summary
public EmbeddedImage copy(double targetWidth, double targetHeight, boolean keepAspectRatio)

Creates a copy of this EmbeddedImage with the specified target width, height, and aspect ratio.

Parameters
targetWidth:double

the new target width

targetHeight:double

the new target height

keepAspectRatio:boolean

whether to keep the aspect ratio

Returns:EmbeddedImage

the new instance

createNodeback to summary
public Node createNode()

Creates the Node to be inserted into RichTextArea.

Returns:Node

the node instance

equalsback to summary
public boolean equals(Object x)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
getHeightback to summary
public double getHeight()

Returns the original image height.

Returns:double

the image height

getTargetHeightback to summary
public double getTargetHeight()

Returns the target image height specification: positive when specifying the final height, or AUTO to determine the value from isKeepAspectRatio() and getHeight().

Returns:double

the image target height

getTargetWidthback to summary
public double getTargetWidth()

Returns the target image width specification: positive when specifying the final width, or AUTO to determine the value from isKeepAspectRatio() and getWidth(), or FIT_WIDTH to ensure the image does not exceed the viewport width, or FIT_WIDTH_ALWAYS to always fit the viewport width.

Returns:double

the image target width

getWidthback to summary
public double getWidth()

Returns the original image width.

Returns:double

the image width

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
isKeepAspectRatioback to summary
public boolean isKeepAspectRatio()

Indicates whether the aspect ratio of this image is preserved when scaling to fit the image within the document.

Returns:boolean

true if the aspect ratio is preserved

ofback to summary
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 the bytes array.

Any negative value passed to either targetWidth or targetHeight, other than a declared sentinel value, causes the image to be rendered as if AUTO had been passed.

Parameters
bytes:byte[]

the image source

width:double

the original image width

height:double

the original image height

targetWidth:double

the target image width, or FIT_WIDTH, FIT_WIDTH_ALWAYS, or AUTO

targetHeight:double

the target image height, or AUTO

keepAspectRatio:boolean

whether to preserve the image aspect ratio

Returns:EmbeddedImage

the new instance

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
jfx.incubator.scene.control.richtext.model back to summary

private final Class EmbeddedImage.Fixed

extends Label
Class Inheritance

Image Container with a fixed-size image.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static double
normalize(double x)

Inherited from javafx.scene.control.Label:
createDefaultSkingetInitialFocusTraversablegetLabelForlabelForPropertysetLabelFor

Constructor Detail

Fixedback to summary
public Fixed(Image im)

Method Detail

normalizeback to summary
private static double normalize(double x)
jfx.incubator.scene.control.richtext.model back to summary

private final Class EmbeddedImage.Tracking

extends Label
implements RequiresComplexLayout
Class Inheritance
All Implemented Interfaces
com.sun.jfx.incubator.scene.control.richtext.RequiresComplexLayout

Image Container that tracks the document width.

Field Summary

Modifier and TypeField and Description
private final ImageView

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private double
private double
computeFitWidth(double av)

public void
Inherited from javafx.scene.control.Label:
createDefaultSkingetInitialFocusTraversablegetLabelForlabelForPropertysetLabelFor

Field Detail

viewback to summary
private final ImageView view

Constructor Detail

Trackingback to summary
public Tracking(Image im)

Method Detail

computeFitHeightback to summary
private double computeFitHeight()
computeFitWidthback to summary
private double computeFitWidth(double av)
updateVFlowContextback to summary
public void updateVFlowContext(VFlow f)

Implements com.sun.jfx.incubator.scene.control.richtext.RequiresComplexLayout.updateVFlowContext.

Doc from com.sun.jfx.incubator.scene.control.richtext.RequiresComplexLayout.updateVFlowContext.

Invoked during VFlow#layoutCells(boolean)

Annotations
@Override