Package qupath.lib.extension.svg
Class SvgTools.SvgBuilder
java.lang.Object
qupath.lib.extension.svg.SvgTools.SvgBuilder
- Enclosing class:
SvgTools
Builder class to enable the export of rendered QuPath objects as SVG images.
This can be useful to generate high-quality figures using a vector representation of objects,
which may be further customized in other applications (e.g. to change line thickness, color).
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enum defining ways in which raster images may be included in the SVG file. -
Constructor Summary
ConstructorDescriptionCreate a new builder, which will later be customized.SvgBuilder
(QuPathViewer viewer) Create a builder initialized according to the current viewer. -
Method Summary
Modifier and TypeMethodDescriptionCreate a String representation of the SVG document.downsample
(double downsample) Specify downsample factor (defined in terms of the full resolution image space).Specify whether the underlying (raster) image should be embedded in any export.fillAnnotations
(boolean doFill) Request whether annotations are drawn as 'filled' shapes.fillDetections
(boolean doFill) Request whether detections are drawn as 'filled' shapes.height
(int height) Export image height.hierarchy
(PathObjectHierarchy hierarchy) Specify thePathObjectHierarchy
.imageData
(ImageData<BufferedImage> imageData) Specify theImageData
.Specify if/how raster images should be included in the SVG.includeOverlays
(boolean doInclude) Specify whether overlays should be included.Specify whether the underlying (raster) image should be included in any export.options
(OverlayOptions options) Specify the overlay options to control display.pathObjects
(Collection<? extends PathObject> pathObjects) Specify a collection of objects to export.pathObjects
(PathObject... pathObjects) Specify an array of objects to export.region
(ImageRegion region) Specify the region (in terms of the full resolution image space) for export.showSelection
(boolean doShow) Request whether selected objects are displayed.size
(int width, int height) Export image size.width
(int width) Export image width.void
Write the SVG image to a file, including any references images if required.
-
Constructor Details
-
SvgBuilder
Create a builder initialized according to the current viewer.- Parameters:
viewer
-
-
SvgBuilder
public SvgBuilder()Create a new builder, which will later be customized.
-
-
Method Details
-
imageData
Specify theImageData
. This is required if the underlying raster image will be included in any export.- Parameters:
imageData
-- Returns:
- this builder
-
hierarchy
Specify thePathObjectHierarchy
. This may be used instead ofimageData(ImageData)
if the raster image is not required.- Parameters:
hierarchy
-- Returns:
- this builder
-
pathObjects
Specify a collection of objects to export. This may be used instead ofimageData(ImageData)
if the raster image is not required.- Parameters:
pathObjects
-- Returns:
- this builder
-
pathObjects
Specify an array of objects to export. This may be used instead ofimageData(ImageData)
if the raster image is not required.- Parameters:
pathObjects
-- Returns:
- this builder
-
includeOverlays
Specify whether overlays should be included. This only has an effect if images are also included, and a viewer is provided.- Parameters:
doInclude
-- Returns:
- this builder
-
options
Specify the overlay options to control display. This will override any previous customizations added to the builder.- Parameters:
options
-- Returns:
- this builder
-
fillAnnotations
Request whether annotations are drawn as 'filled' shapes.- Parameters:
doFill
-- Returns:
- this builder
-
fillDetections
Request whether detections are drawn as 'filled' shapes.- Parameters:
doFill
-- Returns:
- this builder
-
showSelection
Request whether selected objects are displayed.- Parameters:
doShow
-- Returns:
- this builder
-
region
Specify the region (in terms of the full resolution image space) for export. If aRegionRequest
is supplied, the downsample factor will be used if none has otherwise been set.- Parameters:
region
-- Returns:
- this builder
-
downsample
Specify downsample factor (defined in terms of the full resolution image space).- Parameters:
downsample
-- Returns:
- this builder
-
width
Export image width.- Parameters:
width
- width (in pixels) of the SVG image.- Returns:
- this builder
-
height
Export image height.- Parameters:
height
- height (in pixels) of the SVG image.- Returns:
- this builder
-
size
Export image size.- Parameters:
width
- width (in pixels) of the SVG image.height
- height (in pixels) of the SVG image.- Returns:
- this builder
-
embedImages
Specify whether the underlying (raster) image should be embedded in any export. This requires that the constructor with aQuPathViewer
is called to supply the necessary rendering settings.- Returns:
- this builder
- See Also:
-
linkImages
Specify whether the underlying (raster) image should be included in any export. This requires that the constructor with aQuPathViewer
is called to supply the necessary rendering settings.Only references are written, which means images must be written as separate files (which occurs automatically when using
writeSVG(File)
).- Returns:
- this builder
- See Also:
-
images
Specify if/how raster images should be included in the SVG.- Parameters:
include
-- Returns:
- this builder
-
writeSVG
Write the SVG image to a file, including any references images if required.- Parameters:
file
- SVG file to which the image should be written- Throws:
IOException
-
createDocument
Create a String representation of the SVG document.- Returns:
- the SVG String
-