public class PreserveAspectRatio extends Object
preserveAspectRatio attribute of an <svg> element.
In order for scaling to happen, the SVG document must have a viewBox attribute set. For example:
<svg version="1.1" viewBox="0 0 200 100">
This class was previous named SVGPositioning. It was renamed in version 1.3
to reduce confusion when used as part of the RenderOptions class.| Modifier and Type | Class and Description |
|---|---|
static class |
PreserveAspectRatio.Alignment
Determines how the document is to me positioned relative to the viewport (normally the canvas).
|
static class |
PreserveAspectRatio.Scale
Determine whether the scaled document fills the viewport entirely or is scaled to
fill the viewport without overflowing.
|
| Modifier and Type | Field and Description |
|---|---|
static PreserveAspectRatio |
BOTTOM
Keep the document's aspect ratio, but scale it so that it fits neatly inside the viewport.
|
static PreserveAspectRatio |
END
Keep the document's aspect ratio, but scale it so that it fits neatly inside the viewport.
|
static PreserveAspectRatio |
FULLSCREEN
Keep the document's aspect ratio, but scale it so that it fills the entire viewport.
|
static PreserveAspectRatio |
FULLSCREEN_START
Keep the document's aspect ratio, but scale it so that it fills the entire viewport.
|
static PreserveAspectRatio |
LETTERBOX
Keep the document's aspect ratio, but scale it so that it fits neatly inside the viewport.
|
static PreserveAspectRatio |
START
Keep the document's aspect ratio, but scale it so that it fits neatly inside the viewport.
|
static PreserveAspectRatio |
STRETCH
Stretch horizontally and vertically to fill the viewport.
|
static PreserveAspectRatio |
TOP
Keep the document's aspect ratio, but scale it so that it fits neatly inside the viewport.
|
static PreserveAspectRatio |
UNSCALED
Draw document at its natural position and scale.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
PreserveAspectRatio.Alignment |
getAlignment()
Returns the alignment value of this instance.
|
PreserveAspectRatio.Scale |
getScale()
Returns the scale value of this instance.
|
static PreserveAspectRatio |
of(String value)
Parse the given SVG
preserveAspectRation attribute value and return an equivalent
instance of this class. |
String |
toString() |
public static final PreserveAspectRatio UNSCALED
public static final PreserveAspectRatio STRETCH
Equivalent to preserveAspectRatio="none" in an SVG.
public static final PreserveAspectRatio LETTERBOX
The document will be centred in the viewport and may have blank strips at either the top and bottom of the viewport or at the sides.
Equivalent to preserveAspectRatio="xMidYMid meet" in an SVG.
public static final PreserveAspectRatio START
The document will be positioned at the top of tall and narrow viewports, and at the left of short and wide viewports.
Equivalent to preserveAspectRatio="xMinYMin meet" in an SVG.
public static final PreserveAspectRatio END
The document will be positioned at the bottom of tall and narrow viewports, and at the right of short and wide viewports.
Equivalent to preserveAspectRatio="xMaxYMax meet" in an SVG.
public static final PreserveAspectRatio TOP
The document will be positioned at the top of tall and narrow viewports, and at the centre of short and wide viewports.
Equivalent to preserveAspectRatio="xMidYMin meet" in an SVG.
public static final PreserveAspectRatio BOTTOM
The document will be positioned at the bottom of tall and narrow viewports, and at the centre of short and wide viewports.
Equivalent to preserveAspectRatio="xMidYMax meet" in an SVG.
public static final PreserveAspectRatio FULLSCREEN
The document will be positioned so that the centre of the document will always be visible, but the edges of the document may not.
Equivalent to preserveAspectRatio="xMidYMid slice" in an SVG.
public static final PreserveAspectRatio FULLSCREEN_START
The document will be positioned so that the top left of the document will always be visible, but the right hand or bottom edge may not.
Equivalent to preserveAspectRatio="xMinYMin slice" in an SVG.
public static PreserveAspectRatio of(String value)
preserveAspectRation attribute value and return an equivalent
instance of this class.value - a string in the same format as an SVG preserveAspectRatio attributepublic PreserveAspectRatio.Alignment getAlignment()
public PreserveAspectRatio.Scale getScale()