|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object yext.svg.view.SVGModel
public class SVGModel
This class encapsulates an SVG scene graph. It can be used to render the SVG representation on a graphics context. Performance of SVG rendering can be fine-tuned by configuring an internally used caching mechanism.
When reading SVG definitions from URL
s, the following
encodings are supported:
Field Summary | |
---|---|
static byte |
BROKEN_LINK_POLICY_IGNORE
Policy that results in broken links in displayed SVG documents being ignored. |
static byte |
BROKEN_LINK_POLICY_SHOW_PLACEHOLDER
Policy that results in a placeholder displayed for broken links in displayed SVG documents. |
static byte |
BROKEN_LINK_POLICY_THROW_EXCEPTION
Policy that results in an exception being thrown if there is a broken link in the displayed SVG document. |
static RenderingHints.Key |
KEY_SVG_RENDERING
Hint to request a specific rendering mode for SVG content. |
static int |
SVG_BOUNDS_POLICY_COMBINED
SVG bounds policy specifier. |
static int |
SVG_BOUNDS_POLICY_GEOMETRY
SVG bounds policy specifier. |
static int |
SVG_BOUNDS_POLICY_VISIBLE
SVG bounds policy specifier. |
static Object |
VALUE_SVG_RENDERING_DEFAULT
SVG rendering hint value -- let the implementation decide whether to use vectorization or rasterization depending on the current configuration of the caching mechanism. |
static Object |
VALUE_SVG_RENDERING_FORCE_RASTERIZATION
SVG rendering hint value -- force rasterization of vector graphics even if image caching is disabled or the resulting image size exceeds the the value returned by getMaximumImageSize() . |
static Object |
VALUE_SVG_RENDERING_FORCE_VECTORIZATION
SVG rendering hint value -- force vector graphics rendering even if image caching is enabled. |
Constructor Summary | |
---|---|
SVGModel()
Creates an empty svg model. |
|
SVGModel(Reader r)
Creates a new model that represents the SVG definition accessible via the specified Reader . |
|
SVGModel(URL svgURL)
Creates a new model that represents the given SVG resource. |
Method Summary | |
---|---|
static void |
clearImageCache()
Clears the image cache. |
Object |
clone()
|
void |
deserializeSVGContent(Reader r)
Replaces the SVG definition represented by this SVGModel to
the one accessible via the specified Reader . |
boolean |
equalsSVGContent(SVGModel other)
Determines whether or not the SVG definition represented by this SVGModel equals the SVG definition represented in the given
model. |
static byte |
getBrokenLinkPolicy()
Returns the policy for handling broken links in displayed SVG documents. |
static int |
getImageCacheSize()
Returns the maximum number of images that will be cached. |
static int |
getMaximumImageSize()
Returns the maximum size of images that will be cached. |
static double |
getMinimumRelativeImageSize()
Returns the minimum relative image size for which pre-cached image duplicates are reused. |
Rectangle2D |
getSvgBounds()
Returns the bounds of the SVG model. |
int |
getSVGBoundsPolicy()
Returns the policy on how to determine the bounds of this svg node. |
URL |
getSVGURL()
Returns the URL of the SVG graphics that was parsed to construct the model. |
static boolean |
isImageCacheEnabled()
Returns whether or not image caching is enabled. |
boolean |
isInitialized()
Returns whether or not the model has been properly initialized. |
void |
paint(Graphics2D gfx,
double x,
double y,
double width,
double height)
Renders the svg model to the given graphics context. |
void |
serializeSVGContent(Writer w)
Writes the SVG definition represented by this SVGModel to
the specified Writer . |
static void |
setBrokenLinkPolicy(byte policy)
Specifies the policy for handling broken links in displayed SVG documents. |
static void |
setImageCacheEnabled(boolean imageCacheEnabled)
Enables or disables image caching. |
static void |
setImageCacheSize(int imageCacheSize)
Sets the maximum number of images that will be cached. |
static void |
setMaximumImageSize(int maximumImageSize)
Sets the maximum size of images that will be cached. |
static void |
setMinimumRelativeImageSize(double minimumRelativeImageSize)
Sets the minimum relative image size for which pre-cached image duplicates are reused. |
void |
setSVGBoundsPolicy(int svgBoundsPolicy)
Sets the policy on how to determine the bounds of this svg entity. |
void |
setSVGURL(URL svgURL)
Sets the URL of the SVG graphics that will be parsed to construct the model. |
void |
updateSVGContent(URL svgURL)
Replaces the SVG definition represented by this SVGModel to
the one referenced by the specified URL . |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final RenderingHints.Key KEY_SVG_RENDERING
public static final Object VALUE_SVG_RENDERING_FORCE_VECTORIZATION
public static final Object VALUE_SVG_RENDERING_FORCE_RASTERIZATION
getMaximumImageSize()
.
public static final Object VALUE_SVG_RENDERING_DEFAULT
isImageCacheEnabled()
,
getImageCacheSize()
,
getMaximumImageSize()
,
getMinimumRelativeImageSize()
public static final int SVG_BOUNDS_POLICY_VISIBLE
public static final int SVG_BOUNDS_POLICY_GEOMETRY
public static final int SVG_BOUNDS_POLICY_COMBINED
SVG_BOUNDS_POLICY_VISIBLE
and
SVG_BOUNDS_POLICY_GEOMETRY
.
public static final byte BROKEN_LINK_POLICY_THROW_EXCEPTION
setBrokenLinkPolicy(byte)
,
Constant Field Valuespublic static final byte BROKEN_LINK_POLICY_IGNORE
setBrokenLinkPolicy(byte)
,
Constant Field Valuespublic static final byte BROKEN_LINK_POLICY_SHOW_PLACEHOLDER
setBrokenLinkPolicy(byte)
,
Constant Field ValuesConstructor Detail |
---|
public SVGModel()
public SVGModel(URL svgURL)
public SVGModel(Reader r)
Reader
.
Method Detail |
---|
public Rectangle2D getSvgBounds()
null
if no visual
bounds can be determined.public void paint(Graphics2D gfx, double x, double y, double width, double height)
public void updateSVGContent(URL svgURL) throws IOException
SVGModel
to
the one referenced by the specified URL
.
IOException
public void setSVGURL(URL svgURL)
public URL getSVGURL()
public void deserializeSVGContent(Reader r) throws IOException
SVGModel
to
the one accessible via the specified Reader
.
IOException
public void serializeSVGContent(Writer w) throws IOException
SVGModel
to
the specified Writer
.
IOException
public boolean equalsSVGContent(SVGModel other)
SVGModel
equals the SVG definition represented in the given
model.
The SVG definition represented by this SVGModel
is the textual
data written by method serializeSVGContent(Writer)
.
other
- the SVGModel
whose SVG definition is compared
to this model's SVG definition.
true
if the SVG definition of both models are equal.public boolean isInitialized()
public int getSVGBoundsPolicy()
SVG_BOUNDS_POLICY_VISIBLE
is set.
SVG_BOUNDS_POLICY_VISIBLE
,
SVG_BOUNDS_POLICY_GEOMETRY
, or SVG_BOUNDS_POLICY_COMBINED
.public void setSVGBoundsPolicy(int svgBoundsPolicy)
SVG_BOUNDS_POLICY_VISIBLE
is set.
svgBoundsPolicy
- one of SVG_BOUNDS_POLICY_VISIBLE
,
SVG_BOUNDS_POLICY_GEOMETRY
, or SVG_BOUNDS_POLICY_COMBINED
.public Object clone()
clone
in class Object
public static void clearImageCache()
public static boolean isImageCacheEnabled()
setImageCacheEnabled(boolean)
public static void setImageCacheEnabled(boolean imageCacheEnabled)
public static int getImageCacheSize()
setImageCacheSize(int)
public static void setImageCacheSize(int imageCacheSize)
10
.
public static int getMaximumImageSize()
setMaximumImageSize(int)
public static void setMaximumImageSize(int maximumImageSize)
W x H
the image size is W * H * 4
. The width and
height of an image is calculated by multiplying the width and height of the SVG by the
scale factor of the graphics context it is rendered on.
By default the maximum image size is set to 100.000
bytes.
public static double getMinimumRelativeImageSize()
public static void setMinimumRelativeImageSize(double minimumRelativeImageSize)
query width/cached width >= minimumRelativeImageSize
as well as
query height/cached height >= minimumRelativeImageSize
hold.
By default the minimum relative image size is set to 0.9
.
public static byte getBrokenLinkPolicy()
BROKEN_LINK_POLICY_THROW_EXCEPTION
.
BROKEN_LINK_POLICY_THROW_EXCEPTION
,
BROKEN_LINK_POLICY_IGNORE
, and
BROKEN_LINK_POLICY_SHOW_PLACEHOLDER
.public static void setBrokenLinkPolicy(byte policy)
BROKEN_LINK_POLICY_THROW_EXCEPTION
.
policy
- one of
BROKEN_LINK_POLICY_THROW_EXCEPTION
,
BROKEN_LINK_POLICY_IGNORE
, and
BROKEN_LINK_POLICY_SHOW_PLACEHOLDER
.
IllegalArgumentException
- if the specified policy does not equal
one of the aforementioned constants.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |