Top Description Inners Fields Constructors Methods
com.dlsc.gemsfx

public Class SVGImageView

extends Control
Class Inheritance
Imports
com.dlsc.gemsfx.skins.SVGImageViewSkin, javafx.beans.property.BooleanProperty, .DoubleProperty, .StringProperty, javafx.css.CssMetaData, .Styleable, .StyleableBooleanProperty, .StyleableDoubleProperty, .StyleableProperty, .StyleableStringProperty, javafx.css.converter.BooleanConverter, .SizeConverter, .URLConverter, javafx.scene.control.Control, .Skin, java.net.MalformedURLException, .URL, java.util.ArrayList, .Collections, .List, java.util.regex.Pattern

A control which can display SVG images.

SVGImageView can display svg icons in high definition, and they won't become blurry even when zoomed in.

Note for SvgImageView: Currently, due to the limitation that weisj can only render BufferedImage from SVG, SvgImageView does not support usage in native packaging scenarios.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final BooleanProperty
private static final boolean
private static final double
private static final double
private static final boolean
private static final boolean
private static final String
private final DoubleProperty
private final DoubleProperty
private final BooleanProperty
private final BooleanProperty
private final StringProperty
private static final Pattern

Constructor Summary

AccessConstructor and Description
public
SVGImageView()

Constructs a new SVGImageView.

public
SVGImageView(String
the url of the SVG image to be rendered
url
)

Constructs a new SVGImageView with the given SVG url.

Method Summary

Modifier and TypeMethod and Description
public final BooleanProperty
backgroundLoadingProperty()

A property that indicates whether the SVG image should be loaded in the background.

private static String
constructDetailedExceptionMessage(final String mainMessage, final Throwable cause)

protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control.

public final DoubleProperty
fitHeightProperty()

Defines the height of the box that the source svg image should fit into.

public final DoubleProperty
fitWidthProperty()

Defines the width of the box that the source svg image should fit into.

public static List<CssMetaData<? extends Styleable, ?>>

Returns:

A list of CssMetaData objects containing the CSS metadata.
getClassCssMetaData
()

Hides javafx.scene.control.Control.getClassCssMetaData.

Returns the CSS metadata associated with this class.

protected List<CssMetaData<? extends Styleable, ?>>
getControlCssMetaData()

Overrides javafx.scene.control.Control.getControlCssMetaData.

Gets the unmodifiable list of the control's CSS-styleable properties.

public final double

Returns:

The fit height value
getFitHeight
()

Gets the value of fitHeightProperty().

public final double

Returns:

The fit width value.
getFitWidth
()

Gets the value of fitWidthProperty().

public final String

Returns:

The svg url value.
getSvgUrl
()

Gets the value of the svgUrl property.

public final boolean

Returns:

The background loading value.
isBackgroundLoading
()

Gets the value of the backgroundLoading property.

public final boolean

Returns:

The preserve ratio value.
isPreserveRatio
()

Gets the value of the preserveRatioProperty() property.

public final boolean

Returns:

The smooth value.
isSmooth
()

Gets the value of the smooth property.

public final BooleanProperty
preserveRatioProperty()

A property that determines whether the image should maintain its aspect ratio or not.

public final void
setBackgroundLoading(boolean
The background loading value.
backgroundLoading
)

Sets the value of the backgroundLoading property.

public final void
setFitHeight(double
the "fit height" value
fitHeight
)

Sets the value of the fitHeightProperty() property.

public final void
setFitWidth(double
the "fit width" value.
width
)

Sets the value of the fitWidthProperty().

public final void
setPreserveRatio(boolean
the preserve ratio value.
preserveRatio
)

Sets the value of the preserveRatio property.

public final void
setSmooth(boolean
The smooth value.
smooth
)

Sets the value of the smooth property.

public final void
setSvgUrl(String
The svg url value.
svgUrl
)

Sets the value of the svgUrl property.

public final BooleanProperty
smoothProperty()

A property that determines whether the SVG image should be rendered using a smoothing algorithm.

public final StringProperty
svgUrlProperty()

A property that holds the URL of the SVG image to be rendered.

private static String
validateUrl(final String url)

Inherited from javafx.scene.control.Control:
computeMaxHeightcomputeMaxWidthcomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthcontextMenuPropertyexecuteAccessibleActiongetBaselineOffsetgetContextMenugetCssMetaDatagetInitialFocusTraversablegetSkingetTooltipisResizablelayoutChildrenqueryAccessibleAttributesetContextMenusetSkinsetTooltipskinPropertytooltipProperty

Field Detail

backgroundLoadingback to summary
private final BooleanProperty backgroundLoading
DEFAULT_BACKGROUND_LOADINGback to summary
private static final boolean DEFAULT_BACKGROUND_LOADING
DEFAULT_FIT_HEIGHTback to summary
private static final double DEFAULT_FIT_HEIGHT
DEFAULT_FIT_WIDTHback to summary
private static final double DEFAULT_FIT_WIDTH
DEFAULT_PRESERVE_RATIOback to summary
private static final boolean DEFAULT_PRESERVE_RATIO
DEFAULT_SMOOTHback to summary
private static final boolean DEFAULT_SMOOTH
DEFAULT_STYLE_CLASSback to summary
private static final String DEFAULT_STYLE_CLASS
fitHeightback to summary
private final DoubleProperty fitHeight
fitWidthback to summary
private final DoubleProperty fitWidth
preserveRatioback to summary
private final BooleanProperty preserveRatio
smoothback to summary
private final BooleanProperty smooth
svgUrlback to summary
private final StringProperty svgUrl
URL_QUICKMATCHback to summary
private static final Pattern URL_QUICKMATCH

Constructor Detail

SVGImageViewback to summary
public SVGImageView()

Constructs a new SVGImageView.

SVGImageViewback to summary
public SVGImageView(String url)

Constructs a new SVGImageView with the given SVG url.

Parameters
url:String

the url of the SVG image to be rendered

Method Detail

backgroundLoadingPropertyback to summary
public final BooleanProperty backgroundLoadingProperty()

A property that indicates whether the SVG image should be loaded in the background. When set to true, the image is loaded in a background thread, allowing for asynchronous loading of images.

defaultValue false

constructDetailedExceptionMessageback to summary
private static String constructDetailedExceptionMessage(final String mainMessage, final Throwable cause)
createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Doc from javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).

Annotations
@Override
fitHeightPropertyback to summary
public final DoubleProperty fitHeightProperty()

Defines the height of the box that the source svg image should fit into. If the value is <= 0, the svg image's intrinsic height will be used.

When preserveRatioProperty() is set to true, then the actual displayed height of the image is constrained not only by this property, but also by fitWidthProperty(), and it may not be the same as fitHeight.

The default value is 0.

fitWidthPropertyback to summary
public final DoubleProperty fitWidthProperty()

Defines the width of the box that the source svg image should fit into. If the value is <= 0, the svg image's intrinsic width will be used.

When preserveRatioProperty() is set to true, then the actual displayed width of the image is constrained not only by this property, but also by fitHeightProperty(), and it may not be the same as fitWidth.

The default value is 0.

getClassCssMetaDataback to summary
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData()

Hides javafx.scene.control.Control.getClassCssMetaData.

Returns the CSS metadata associated with this class.

Returns:List<CssMetaData<? extends Styleable, ?>>

A list of CssMetaData objects containing the CSS metadata.

getControlCssMetaDataback to summary
protected List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData()

Overrides javafx.scene.control.Control.getControlCssMetaData.

Doc from javafx.scene.control.Control.getControlCssMetaData.

Gets the unmodifiable list of the control's CSS-styleable properties.

Annotations
@Override
getFitHeightback to summary
public final double getFitHeight()

Gets the value of fitHeightProperty().

Returns:double

The fit height value

getFitWidthback to summary
public final double getFitWidth()

Gets the value of fitWidthProperty().

Returns:double

The fit width value.

getSvgUrlback to summary
public final String getSvgUrl()

Gets the value of the svgUrl property.

Returns:String

The svg url value.

isBackgroundLoadingback to summary
public final boolean isBackgroundLoading()

Gets the value of the backgroundLoading property.

Returns:boolean

The background loading value.

isPreserveRatioback to summary
public final boolean isPreserveRatio()

Gets the value of the preserveRatioProperty() property.

Returns:boolean

The preserve ratio value.

isSmoothback to summary
public final boolean isSmooth()

Gets the value of the smooth property.

Returns:boolean

The smooth value.

preserveRatioPropertyback to summary
public final BooleanProperty preserveRatioProperty()

A property that determines whether the image should maintain its aspect ratio or not. When set to true, the image will preserve its aspect ratio. When set to false, the image may be stretched or compressed to fit the specified dimensions, without preserving its aspect ratio.

The default value is false

setBackgroundLoadingback to summary
public final void setBackgroundLoading(boolean backgroundLoading)

Sets the value of the backgroundLoading property.

Parameters
backgroundLoading:boolean

The background loading value.

setFitHeightback to summary
public final void setFitHeight(double fitHeight)

Sets the value of the fitHeightProperty() property.

Parameters
fitHeight:double

the "fit height" value

setFitWidthback to summary
public final void setFitWidth(double width)

Sets the value of the fitWidthProperty().

Parameters
width:double

the "fit width" value.

setPreserveRatioback to summary
public final void setPreserveRatio(boolean preserveRatio)

Sets the value of the preserveRatio property.

Parameters
preserveRatio:boolean

the preserve ratio value.

setSmoothback to summary
public final void setSmooth(boolean smooth)

Sets the value of the smooth property.

Parameters
smooth:boolean

The smooth value.

setSvgUrlback to summary
public final void setSvgUrl(String svgUrl)

Sets the value of the svgUrl property.

Parameters
svgUrl:String

The svg url value.

smoothPropertyback to summary
public final BooleanProperty smoothProperty()

A property that determines whether the SVG image should be rendered using a smoothing algorithm. If true, the image will be rendered with smoothing applied, which can improve the visual quality but may reduce performance.

defaultValue true

svgUrlPropertyback to summary
public final StringProperty svgUrlProperty()

A property that holds the URL of the SVG image to be rendered. Changing the URL will result in loading and rendering the new SVG image.

defaultValue null

validateUrlback to summary
private static String validateUrl(final String url)
com.dlsc.gemsfx back to summary

private Class SVGImageView.StyleableProperties

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final CssMetaData<? extends Styleable, Boolean>
public static final CssMetaData<SVGImageView, Number>
public static final CssMetaData<SVGImageView, Number>
private static final CssMetaData<SVGImageView, Boolean>
private static final CssMetaData<SVGImageView, Boolean>
private static final List<CssMetaData<? extends Styleable, ?>>
private static final CssMetaData<SVGImageView, String>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BACKGROUND_LOADINGback to summary
public static final CssMetaData<? extends Styleable, Boolean> BACKGROUND_LOADING
FIT_HEIGHTback to summary
public static final CssMetaData<SVGImageView, Number> FIT_HEIGHT
FIT_WIDTHback to summary
public static final CssMetaData<SVGImageView, Number> FIT_WIDTH
PRESERVE_RATIOback to summary
private static final CssMetaData<SVGImageView, Boolean> PRESERVE_RATIO
SMOOTHback to summary
private static final CssMetaData<SVGImageView, Boolean> SMOOTH
STYLEABLESback to summary
private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES
SVG_URLback to summary
private static final CssMetaData<SVGImageView, String> SVG_URL

Constructor Detail

StyleablePropertiesback to summary
private StyleableProperties()