public class RenderOptions extends Object
SVG.renderToCanvas(Canvas,RenderOptions) and SVG.renderToPicture(int,int,RenderOptions) methods.
RenderOption renderOptions = RenderOptions.create();
renderOptions.viewPort(100f, 100f, 400f, 300f) // Set the area of the Canvas to render the SVG into
.css("rect { fill: red; }") // Add some CSS that makes all rectangles red
svg.renderToCanvas(canvas, renderOptions);
| Constructor and Description |
|---|
RenderOptions()
Create a new
RenderOptions instance. |
RenderOptions(RenderOptions other)
Creates a copy of the given
RenderOptions object. |
| Modifier and Type | Method and Description |
|---|---|
static RenderOptions |
create()
Create a new
RenderOptions instance. |
RenderOptions |
css(String css)
Specifies some additional CSS rules that will be applied during render in addition to
any specified in the file itself.
|
boolean |
hasCss()
Returns true if this RenderOptions instance has had CSS set with
css(). |
boolean |
hasPreserveAspectRatio()
Returns true if this RenderOptions instance has had a preserveAspectRatio value set with
preserveAspectRatio(). |
boolean |
hasTarget()
Returns true if this RenderOptions instance has had a target set with
target(). |
boolean |
hasView()
Returns true if this RenderOptions instance has had a view set with
view(). |
boolean |
hasViewBox()
Returns true if this RenderOptions instance has had a viewBox set with
viewBox(). |
boolean |
hasViewPort()
Returns true if this RenderOptions instance has had a viewPort set with
viewPort(). |
RenderOptions |
preserveAspectRatio(PreserveAspectRatio preserveAspectRatio)
Specifies how the renderer should handle aspect ratio when rendering the SVG.
|
RenderOptions |
target(String targetId)
Specifies the
id of an element, in the SVG, to treat as the target element when
using the :target CSS pseudo class. |
RenderOptions |
view(String viewId)
Specifies the
id of a <view> element in the SVG. |
RenderOptions |
viewBox(float minX,
float minY,
float width,
float height)
Specifies alternative values to use for the root element
viewBox. |
RenderOptions |
viewPort(float minX,
float minY,
float width,
float height)
Describes the viewport into which the SVG should be rendered.
|
public RenderOptions()
RenderOptions instance. You can choose to use either this constructor,
or new RenderOptions.create(). Both are equivalent.public RenderOptions(RenderOptions other)
RenderOptions object.other - the object to copypublic static RenderOptions create()
RenderOptions instance. This is just an alternative to new RenderOptions().public RenderOptions css(String css)
css - CSS rules to applyRenderOptions instancepublic boolean hasCss()
css().public RenderOptions preserveAspectRatio(PreserveAspectRatio preserveAspectRatio)
PreserveAspectRatio.LETTERBOX. This is
equivalent to the SVG default of xMidYMid meet.preserveAspectRatio - the new aspect ration valueRenderOptions instancepublic boolean hasPreserveAspectRatio()
preserveAspectRatio().public RenderOptions view(String viewId)
id of a <view> element in the SVG. A <view>
element is a way to specify a predetermined view of the document, that differs from the default view.
For example it can allow you to focus in on a small detail of the document.
Note: setting this option will override any viewBox(float,float,float,float) or preserveAspectRatio(PreserveAspectRatio) settings.viewId - the id attribute of the view that should be used for renderingRenderOptions instancepublic boolean hasView()
view().public RenderOptions viewBox(float minX, float minY, float width, float height)
viewBox. Any existing viewBox
attribute value will be ignored.
Note: will be overridden if a view(String) is set.minX - The left X coordinate of the viewBoxminY - The top Y coordinate of the viewBoxwidth - The width of the viewBoxheight - The height of the viewBoxRenderOptions instancepublic boolean hasViewBox()
viewBox().public RenderOptions viewPort(float minX, float minY, float width, float height)
Picture
then a default viewport width and height will be used.minX - The left X coordinate of the viewportminY - The top Y coordinate of the viewportwidth - The width of the viewportheight - The height of the viewportRenderOptions instancepublic boolean hasViewPort()
viewPort().public RenderOptions target(String targetId)
id of an element, in the SVG, to treat as the target element when
using the :target CSS pseudo class.targetId - the id attribute of an elementRenderOptions instancepublic boolean hasTarget()
target().