java.lang.Object
org.jfree.svg.SVGHints
public final class SVGHints extends Object
Defines the rendering hints that can be used with the
SVGGraphics2D
class. The supported hints are:KEY_IMAGE_HANDLING
that controls how images are handled (embedded in the SVG, or referenced externally);KEY_IMAGE_HREF
that allows the caller to specify the image href attribute for the next image;KEY_TEXT_RENDERING
that allows configuration of the preferred value of the SVGtext-rendering
attribute in text elements;KEY_ELEMENT_ID
that allows the caller to specify the element ID for the next element;KEY_BEGIN_GROUP
tells theSVGGraphics2D
instance to start a new group element with an id equal to the hint value (which must be an instance of String). Any otherGraphics2D
implementation will ignore this hint;KEY_END_GROUP
tells theSVGGraphics2D
instance to end a group element. The hint value is ignored. The caller assumes responsibility for balancing the number ofKEY_BEGIN_GROUP
andKEY_END_GROUP
hints. Any otherGraphics2D
implementation will ignore this hint.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SVGHints.Key
A key for hints used by theSVGGraphics2D
class. -
Field Summary
Fields Modifier and Type Field Description static SVGHints.Key
KEY_BEGIN_GROUP
Hint key that informs theSVGGraphics2D
that the caller would like to begin a new group element.static SVGHints.Key
KEY_DRAW_STRING_TYPE
The key for the hint that controls whether strings are rendered as characters or vector graphics (implemented usingTextLayout
).static SVGHints.Key
KEY_ELEMENT_ID
Hint key to supply an element id for the next element generated.static SVGHints.Key
KEY_ELEMENT_TITLE
Hint key that informs theSVGGraphics2D
that the caller would like to add a title element to the output (with the hint value being a string containing the title text).static SVGHints.Key
KEY_END_GROUP
Hint key that informs theSVGGraphics2D
that the caller would like to close a previously opened group element.static SVGHints.Key
KEY_IMAGE_HANDLING
The key for the hint that controls whether images are embedded in the SVG or referenced externally.static SVGHints.Key
KEY_IMAGE_HREF
Hint key to supply string to be used as the href for an image that is referenced rather than embedded.static SVGHints.Key
KEY_TEXT_RENDERING
The key for a hint that permits configuration of the text-rendering attribute in SVG text elementsstatic Object
VALUE_DRAW_STRING_TYPE_STANDARD
Hint value forKEY_DRAW_STRING_TYPE
to specify that strings should be written to the output using standard SVG text elements.static Object
VALUE_DRAW_STRING_TYPE_VECTOR
Hint value forKEY_DRAW_STRING_TYPE
to say that strings should be written to the output using vector graphics primitives.static Object
VALUE_IMAGE_HANDLING_EMBED
Hint value forKEY_IMAGE_HANDLING
to specify that images should be embedded in the SVG output using PNG dataBase64
encoded.static Object
VALUE_IMAGE_HANDLING_REFERENCE
Hint value forKEY_IMAGE_HANDLING
to say that images should be referenced externally.static String
VALUE_TEXT_RENDERING_AUTO
Hint value forKEY_TEXT_RENDERING
to set thetext-rendering
attribute in SVG text elements to 'auto'.static String
VALUE_TEXT_RENDERING_INHERIT
Hint value forKEY_TEXT_RENDERING
to set thetext-rendering
attribute in SVG text elements to 'inherit'.static String
VALUE_TEXT_RENDERING_LEGIBILITY
Hint value forKEY_TEXT_RENDERING
to set thetext-rendering
attribute in SVG text elements to 'optimizeLegibility'.static String
VALUE_TEXT_RENDERING_PRECISION
Hint value forKEY_TEXT_RENDERING
to set thetext-rendering
attribute in SVG text elements to 'geometricPrecision'.static String
VALUE_TEXT_RENDERING_SPEED
Hint value forKEY_TEXT_RENDERING
to set thetext-rendering
attribute in SVG text elements to 'optimizeSpeed'. -
Method Summary
Modifier and Type Method Description static void
addBeginGroupKey(RenderingHints.Key key)
Adds a key to the list of keys that are synonyms forKEY_BEGIN_GROUP
.static void
addElementTitleKey(RenderingHints.Key key)
Adds a key to the list of keys that are synonyms forKEY_ELEMENT_TITLE
.static void
addEndGroupKey(RenderingHints.Key key)
Adds a key to the list of keys that are synonyms forKEY_END_GROUP
.static void
clearBeginGroupKeys()
Clears the list of keys that are treated as synonyms forKEY_BEGIN_GROUP
.static void
clearElementTitleKeys()
Clears the list of keys that are treated as synonyms forKEY_ELEMENT_TITLE
.static void
clearEndGroupKeys()
Clears the list of keys that are treated as synonyms forKEY_END_GROUP
.static List<RenderingHints.Key>
getBeginGroupKeys()
Creates and returns a list of keys that are synonymous withKEY_BEGIN_GROUP
.static List<RenderingHints.Key>
getElementTitleKeys()
Creates and returns a list of keys that are synonymous withKEY_ELEMENT_TITLE
.static List<RenderingHints.Key>
getEndGroupKeys()
Creates and returns a list of keys that are synonymous withKEY_END_GROUP
.static boolean
isBeginGroupKey(RenderingHints.Key key)
static boolean
isElementTitleKey(RenderingHints.Key key)
static boolean
isEndGroupKey(RenderingHints.Key key)
static void
removeBeginGroupKey(RenderingHints.Key key)
Removes a key from the list of keys that are synonyms forKEY_BEGIN_GROUP
.static void
removeElementTitleKey(RenderingHints.Key key)
Removes a key from the list of keys that are synonyms forKEY_ELEMENT_TITLE
.static void
removeEndGroupKey(RenderingHints.Key key)
Removes a key from the list of keys that are synonyms forKEY_END_GROUP
.
-
Field Details
-
KEY_IMAGE_HANDLING
The key for the hint that controls whether images are embedded in the SVG or referenced externally. Valid hint values areVALUE_IMAGE_HANDLING_EMBED
andVALUE_IMAGE_HANDLING_REFERENCE
. -
VALUE_IMAGE_HANDLING_EMBED
Hint value forKEY_IMAGE_HANDLING
to specify that images should be embedded in the SVG output using PNG dataBase64
encoded. -
VALUE_IMAGE_HANDLING_REFERENCE
Hint value forKEY_IMAGE_HANDLING
to say that images should be referenced externally. -
KEY_TEXT_RENDERING
The key for a hint that permits configuration of the text-rendering attribute in SVG text elements -
VALUE_TEXT_RENDERING_AUTO
Hint value forKEY_TEXT_RENDERING
to set thetext-rendering
attribute in SVG text elements to 'auto'.- See Also:
- Constant Field Values
-
VALUE_TEXT_RENDERING_SPEED
Hint value forKEY_TEXT_RENDERING
to set thetext-rendering
attribute in SVG text elements to 'optimizeSpeed'.- See Also:
- Constant Field Values
-
VALUE_TEXT_RENDERING_LEGIBILITY
Hint value forKEY_TEXT_RENDERING
to set thetext-rendering
attribute in SVG text elements to 'optimizeLegibility'.- See Also:
- Constant Field Values
-
VALUE_TEXT_RENDERING_PRECISION
Hint value forKEY_TEXT_RENDERING
to set thetext-rendering
attribute in SVG text elements to 'geometricPrecision'.- See Also:
- Constant Field Values
-
VALUE_TEXT_RENDERING_INHERIT
Hint value forKEY_TEXT_RENDERING
to set thetext-rendering
attribute in SVG text elements to 'inherit'.- See Also:
- Constant Field Values
-
KEY_IMAGE_HREF
Hint key to supply string to be used as the href for an image that is referenced rather than embedded. The value associated with the key should be a string and will be used for the next image element written to the SVG output (and then the hint will be cleared).- Since:
- 1.5
-
KEY_ELEMENT_ID
Hint key to supply an element id for the next element generated.- Since:
- 1.5
-
KEY_BEGIN_GROUP
Hint key that informs theSVGGraphics2D
that the caller would like to begin a new group element. The hint value is the id for the new group. After opening the new group the hint is cleared and it is the caller's responsibility to close the group later usingKEY_END_GROUP
. Groups can be nested.- Since:
- 1.7
-
KEY_END_GROUP
Hint key that informs theSVGGraphics2D
that the caller would like to close a previously opened group element. The hint value is ignored.- Since:
- 1.7
-
KEY_ELEMENT_TITLE
Hint key that informs theSVGGraphics2D
that the caller would like to add a title element to the output (with the hint value being a string containing the title text).- Since:
- 1.9
-
KEY_DRAW_STRING_TYPE
The key for the hint that controls whether strings are rendered as characters or vector graphics (implemented usingTextLayout
). The latter will result in larger output files but avoids problems with fonts not being available for the viewer. Valid hint values areVALUE_DRAW_STRING_TYPE_STANDARD
andVALUE_DRAW_STRING_TYPE_VECTOR
.- Since:
- 2.0
-
VALUE_DRAW_STRING_TYPE_STANDARD
Hint value forKEY_DRAW_STRING_TYPE
to specify that strings should be written to the output using standard SVG text elements.- Since:
- 2.0
-
VALUE_DRAW_STRING_TYPE_VECTOR
Hint value forKEY_DRAW_STRING_TYPE
to say that strings should be written to the output using vector graphics primitives.- Since:
- 2.0
-
-
Method Details
-
getBeginGroupKeys
Creates and returns a list of keys that are synonymous withKEY_BEGIN_GROUP
.- Returns:
- A list (never
null
). - Since:
- 1.8
-
addBeginGroupKey
Adds a key to the list of keys that are synonyms forKEY_BEGIN_GROUP
.- Parameters:
key
- the key (null
not permitted).- Since:
- 1.8
-
removeBeginGroupKey
Removes a key from the list of keys that are synonyms forKEY_BEGIN_GROUP
.- Parameters:
key
- the key (null
not permitted).- Since:
- 1.8
-
clearBeginGroupKeys
Clears the list of keys that are treated as synonyms forKEY_BEGIN_GROUP
.- Since:
- 1.8
-
isBeginGroupKey
Returnstrue
if this key is equivalent toKEY_BEGIN_GROUP
, andfalse
otherwise. The purpose of this method is to allow certain keys from external packages (such as JFreeChart and Orson Charts) to use their own keys to drive the behaviour ofSVGHints.KEY_BEGIN_GROUP
. This has two benefits: (1) it avoids the necessity to make JFreeSVG a direct dependency, and (2) it makes the grouping behaviour generic from the point of view of the external package, rather than SVG-specific.- Parameters:
key
- the key (null
not permitted)- Returns:
- A boolean.
- Since:
- 1.8
-
getEndGroupKeys
Creates and returns a list of keys that are synonymous withKEY_END_GROUP
.- Returns:
- A list (never
null
). - Since:
- 1.8
-
addEndGroupKey
Adds a key to the list of keys that are synonyms forKEY_END_GROUP
.- Parameters:
key
- the key (null
not permitted).- Since:
- 1.8
-
removeEndGroupKey
Removes a key from the list of keys that are synonyms forKEY_END_GROUP
.- Parameters:
key
- the key (null
not permitted).- Since:
- 1.8
-
clearEndGroupKeys
Clears the list of keys that are treated as synonyms forKEY_END_GROUP
.- Since:
- 1.8
-
isEndGroupKey
Returnstrue
if this key is equivalent toKEY_END_GROUP
, andfalse
otherwise. The purpose of this method is to allow certain keys from external packages (such as JFreeChart and Orson Charts) to use their own keys to drive the behaviour ofSVGHints.KEY_END_GROUP
. This has two benefits: (1) it avoids the necessity to make JFreeSVG a direct dependency, and (2) it makes the grouping behaviour generic from the point of view of the external package, rather than SVG-specific.- Parameters:
key
- the key (null
not permitted).- Returns:
- A boolean.
- Since:
- 1.8
-
getElementTitleKeys
Creates and returns a list of keys that are synonymous withKEY_ELEMENT_TITLE
.- Returns:
- A list (never
null
). - Since:
- 1.9
-
addElementTitleKey
Adds a key to the list of keys that are synonyms forKEY_ELEMENT_TITLE
.- Parameters:
key
- the key (null
not permitted).- Since:
- 1.9
-
removeElementTitleKey
Removes a key from the list of keys that are synonyms forKEY_ELEMENT_TITLE
.- Parameters:
key
- the key (null
not permitted).- Since:
- 1.9
-
clearElementTitleKeys
Clears the list of keys that are treated as synonyms forKEY_ELEMENT_TITLE
.- Since:
- 1.9
-
isElementTitleKey
Returnstrue
if this key is equivalent toKEY_ELEMENT_TITLE
, andfalse
otherwise. The purpose of this method is to allow certain keys from external packages (such as JFreeChart and Orson Charts) to use their own keys to drive the behaviour ofSVGHints.KEY_ELEMENT_TITLE
. This has two benefits: (1) it avoids the necessity to make JFreeSVG a direct dependency, and (2) it makes the element title behaviour generic from the point of view of the external package, rather than SVG-specific.- Parameters:
key
- the key (null
not permitted)- Returns:
- A boolean.
- Since:
- 1.9
-