SVGImage
is a a JavaFX Group which is the result of the SVGLoader load
static method.
SVGImage
to a JavaFX ImageSVGImage
SVGLoader
class, you can use this class in the JavaFX Platform Thread or in any other Thread. The library will make sure that the conversion will be performed in the JavaFX Platform Thread, and will return the result in the calling Thread.
SVGImage
, you can use one of the following methods:SVGImage
scaled compared to the initial imageSVGImage
rather than creating another oneSVGImage
scaled with a new width compared to the initial imageSVGImage
rather than creating another onesetScaleX
and setScaleY
on the initial image, but will create a new SVGImage with the same SVG input and a scale parameter.SVGImage img = SVGLoader.load(<my SVG file>); // a new SVGImage will be created with a scale of 2 SVGImage newImg = img.scale(2); // the initial SVGImage will be scaled with a factor of 2 img.scale(2, false); // a new SVGImage will be created with a width of 200 SVGImage newImg = img.scaleTo(200); // the initial SVGImage will have a new width of 200 img.scaleTo(200, false);
SVGImage img = SVGLoader.load(<my SVG file>); img.snapshot("png", <my PNG file>));
width
parameter as the width of the resulting imageSVGImage img = SVGLoader.load(<my SVG file>); // the resulting image will have a width of 100 pixels Image fxImg = img.toImage(100); // the resulting image will be scaled by a 0.5 factor Image fxImg2 = img.toImageScaled(0.5d); // the resulting image will have a width of 50 pixels, but the image will be scaled at the SVG level before creating the image Image fxImg2 = img.toImage(ScaleQuality.RENDER_QUALITY, 50);
SVGImage
. The most useful methods of the Viewport
are:SVGImage
(can be -1 if the width is not specified in the SVG fileSVGImage
(can be -1 if the height is not specified in the SVG fileSVGImage
is a Group
class. As a Group
has no size by itself, it can not be integrated efficiently in a Layout containers (such as a BorderPane
)[1]
Group
is not directly resizableSVGImage
in a Layout container, you can use the SVGImage.createRegion() which will create a SVGImageRegion wrapping the SVGImage
. SVGImageRegion
is a Region
, it can be resized and be fully integrated in a Layout container.Group
is not directly resizableCopyright 2021-2022 Herve Girod. All Rights Reserved. Documentation and source under the BSD-3-Clause License