- All Implemented Interfaces:
AutoCloseable
- Since:
- 1.2
- See Also:
-
Constructor Summary
ConstructorDescriptionSVGSurface
(MemorySegment address) Constructor used internally to instantiate a java SVGSurface object for a nativecairo_surface_t
instance -
Method Summary
Modifier and TypeMethodDescriptionstatic SVGSurface
create
(OutputStream stream, double widthInPoints, double heightInPoints) Creates a SVG surface of the specified size in points to be written incrementally to thestream
.static SVGSurface
Creates a SVG surface of the specified size in points to be written tofilename
.Get the unit of the SVG surface.restrictToVersion
(SVGVersion version) Restricts the generated SVG file to version .setDocumentUnit
(SVGUnit unit) Use the specified unit for the width and height of the generated SVG file.Methods inherited from class org.freedesktop.cairo.Surface
close, copyPage, createForRectangle, createSimilar, createSimilarImage, destroy, finish, flush, getContent, getDevice, getDeviceOffset, getDeviceScale, getFallbackResolution, getFontOptions, getMimeData, getSurfaceType, getType, getUserData, hasShowTextGlyphs, mapToImage, markDirty, markDirtyRectangle, setDeviceOffset, setDeviceScale, setFallbackResolution, setMimeData, setUserData, showPage, status, supportsMimeType, unmapImage
-
Constructor Details
-
SVGSurface
Constructor used internally to instantiate a java SVGSurface object for a nativecairo_surface_t
instance- Parameters:
address
- the memory address of the nativecairo_surface_t
instance
-
-
Method Details
-
create
Creates a SVG surface of the specified size in points to be written tofilename
.The SVG surface backend recognizes the following MIME types for the data attached to a surface (see
Surface.setMimeData(MimeType, byte[])
) when it is used as a source pattern for drawing on this surface:MimeType.JPEG
,MimeType.PNG
,MimeType.URI
. If any of them is specified, the SVG backend emits a href with the content of MIME data instead of a surface snapshot (PNG, Base64-encoded) in the corresponding image tag.The unofficial MIME type
MimeType.URI
is examined first. If present, the URI is emitted as is: assuring the correctness of URI is left to the client code.If
MimeType.URI
is not present, butMimeType.JPEG
orMimeType.PNG
is specified, the corresponding data is Base64-encoded and emitted.If
MimeType.UNIQUE_ID
is present, all surfaces with the same unique identifier will only be embedded once.- Parameters:
filename
- a filename for the SVG output (must be writable), NULL may be used to specify no output. This will generate a SVG surface that may be queried and used as a source, without generating a temporary file.widthInPoints
- width of the surface, in points (1 point == 1/72.0 inch)heightInPoints
- height of the surface, in points (1 point == 1/72.0 inch)- Returns:
- the newly created surface
- Since:
- 1.2
-
create
Creates a SVG surface of the specified size in points to be written incrementally to thestream
.- Parameters:
stream
- anOutputStream
to accept the output data, may benull
to indicate a no-op stream. With a no-op stream, the surface may be queried or used as a source without generating any temporary files.widthInPoints
- width of the surface, in points (1 point == 1/72.0 inch)heightInPoints
- height of the surface, in points (1 point == 1/72.0 inch)- Returns:
- the newly created surface
- Since:
- 1.2
-
getDocumentUnit
Get the unit of the SVG surface.- Returns:
- the SVG unit of the SVG surface.
- Since:
- 1.16
-
setDocumentUnit
Use the specified unit for the width and height of the generated SVG file. SeeSVGUnit
for a list of available unit values that can be used here.This function can be called at any time before generating the SVG file.
However to minimize the risk of ambiguities it's recommended to call it before any drawing operations have been performed on the given surface, to make it clearer what the unit used in the drawing operations is.
The simplest way to do this is to call this function immediately after creating the SVG surface.
Note if this function is never called, the default unit for SVG documents generated by cairo will be user unit.
- Parameters:
unit
- SVG unit- Returns:
- the SVG surface
- Since:
- 1.16
-
restrictToVersion
Restricts the generated SVG file to version . SeeSVGVersion.getVersions()
for a list of available version values that can be used here.This function should only be called before any drawing operations have been performed on the given surface. The simplest way to do this is to call this function immediately after creating the surface.
- Parameters:
version
- SVG version- Returns:
- the SVG surface
- Since:
- 1.2
-