java.lang.Object
org.jfree.svg.SVGHints
Defines the rendering hints that can be used with the
SVGGraphics2D class. The supported hints are:KEY_IMAGE_HANDLINGthat controls how images are handled (embedded in the SVG, or referenced externally);KEY_IMAGE_HREFthat allows the caller to specify the image href attribute for the next image;KEY_TEXT_RENDERINGthat allows configuration of the preferred value of the SVGtext-renderingattribute in text elements;KEY_ELEMENT_IDthat allows the caller to specify the element ID for the next element;KEY_BEGIN_GROUPtells theSVGGraphics2Dinstance to start a new group element with an id equal to the hint value (which must be an instance of String). Any otherGraphics2Dimplementation will ignore this hint;KEY_END_GROUPtells theSVGGraphics2Dinstance to end a group element. The hint value is ignored. The caller assumes responsibility for balancing the number ofKEY_BEGIN_GROUPandKEY_END_GROUPhints. Any otherGraphics2Dimplementation will ignore this hint.
Nested Class Summary
Nested ClassesField Summary
Modifier and TypeFieldDescriptionprivate static final List<RenderingHints.Key> A list of keys that are treated as synonyms for KEY_BEGIN_GROUP (the list does not include KEY_BEGIN_GROUP itself).private static final List<RenderingHints.Key> A list of keys that are treated as synonyms for KEY_ELEMENT_TITLE (the list does not include KEY_ELEMENT_TITLE itself).private static final List<RenderingHints.Key> A list of keys that are treated as synonyms for KEY_END_GROUP (the list does not include KEY_END_GROUP itself).static final SVGHints.KeyHint key that informs theSVGGraphics2Dthat the caller would like to begin a new group element.static final SVGHints.KeyThe key for the hint that controls whether strings are rendered as characters or vector graphics (implemented usingTextLayout).static final SVGHints.KeyHint key to supply an element id for the next element generated.static final SVGHints.KeyHint key that informs theSVGGraphics2Dthat the caller would like to add a title element to the output (with the hint value being a string containing the title text).static final SVGHints.KeyHint key that informs theSVGGraphics2Dthat the caller would like to close a previously opened group element.static final SVGHints.KeyThe key for the hint that controls whether images are embedded in the SVG or referenced externally.static final SVGHints.KeyHint key to supply string to be used as the href for an image that is referenced rather than embedded.static final SVGHints.KeyThe key for a hint that permits configuration of the text-rendering attribute in SVG text elementsstatic final ObjectHint value forKEY_DRAW_STRING_TYPEto specify that strings should be written to the output using standard SVG text elements.static final ObjectHint value forKEY_DRAW_STRING_TYPEto say that strings should be written to the output using vector graphics primitives.static final ObjectHint value forKEY_IMAGE_HANDLINGto specify that images should be embedded in the SVG output using PNG dataBase64encoded.static final ObjectHint value forKEY_IMAGE_HANDLINGto say that images should be referenced externally.static final StringHint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'auto'.static final StringHint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'inherit'.static final StringHint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'optimizeLegibility'.static final StringHint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'geometricPrecision'.static final StringHint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'optimizeSpeed'.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionstatic voidAdds a key to the list of keys that are synonyms forKEY_BEGIN_GROUP.static voidAdds a key to the list of keys that are synonyms forKEY_ELEMENT_TITLE.static voidAdds a key to the list of keys that are synonyms forKEY_END_GROUP.static voidClears the list of keys that are treated as synonyms forKEY_BEGIN_GROUP.static voidClears the list of keys that are treated as synonyms forKEY_ELEMENT_TITLE.static voidClears the list of keys that are treated as synonyms forKEY_END_GROUP.private static RenderingHints.KeyLoads a hint key by naming its class and field reflectively.static List<RenderingHints.Key> Creates and returns a list of keys that are synonymous withKEY_BEGIN_GROUP.static List<RenderingHints.Key> Creates and returns a list of keys that are synonymous withKEY_ELEMENT_TITLE.static List<RenderingHints.Key> Creates and returns a list of keys that are synonymous withKEY_END_GROUP.private static RenderingHints.KeyThe key for the JFreeChart begin-element hint.private static RenderingHints.KeyThe key for the JFreeChart end-element hint.private static RenderingHints.KeyThe key for the Orson Charts begin-element hint.private static RenderingHints.KeyThe key for the Orson Charts element-title hint.private static RenderingHints.KeyThe key for the Orson Charts end-element hint.static booleanstatic booleanstatic booleanprivate static booleanReturnstrueif JFreeChart (1.0.18 or later) is on the classpath, andfalseotherwise.private static booleanReturnstrueif Orson Charts (version 1.3 or later) is on the classpath, andfalseotherwise.static voidRemoves a key from the list of keys that are synonyms forKEY_BEGIN_GROUP.static voidRemoves a key from the list of keys that are synonyms forKEY_ELEMENT_TITLE.static voidRemoves 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_EMBEDandVALUE_IMAGE_HANDLING_REFERENCE.VALUE_IMAGE_HANDLING_EMBED
Hint value forKEY_IMAGE_HANDLINGto specify that images should be embedded in the SVG output using PNG dataBase64encoded.VALUE_IMAGE_HANDLING_REFERENCE
Hint value forKEY_IMAGE_HANDLINGto 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 elementsVALUE_TEXT_RENDERING_AUTO
Hint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'auto'.- See Also:
VALUE_TEXT_RENDERING_SPEED
Hint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'optimizeSpeed'.- See Also:
VALUE_TEXT_RENDERING_LEGIBILITY
Hint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'optimizeLegibility'.- See Also:
VALUE_TEXT_RENDERING_PRECISION
Hint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'geometricPrecision'.- See Also:
VALUE_TEXT_RENDERING_INHERIT
Hint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'inherit'.- See Also:
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).KEY_ELEMENT_ID
Hint key to supply an element id for the next element generated.KEY_BEGIN_GROUP
Hint key that informs theSVGGraphics2Dthat 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.KEY_END_GROUP
Hint key that informs theSVGGraphics2Dthat the caller would like to close a previously opened group element. The hint value is ignored.KEY_ELEMENT_TITLE
Hint key that informs theSVGGraphics2Dthat the caller would like to add a title element to the output (with the hint value being a string containing the title text).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_STANDARDandVALUE_DRAW_STRING_TYPE_VECTOR.VALUE_DRAW_STRING_TYPE_STANDARD
Hint value forKEY_DRAW_STRING_TYPEto specify that strings should be written to the output using standard SVG text elements.VALUE_DRAW_STRING_TYPE_VECTOR
Hint value forKEY_DRAW_STRING_TYPEto say that strings should be written to the output using vector graphics primitives.beginGroupKeys
A list of keys that are treated as synonyms for KEY_BEGIN_GROUP (the list does not include KEY_BEGIN_GROUP itself).endGroupKeys
A list of keys that are treated as synonyms for KEY_END_GROUP (the list does not include KEY_END_GROUP itself).elementTitleKeys
A list of keys that are treated as synonyms for KEY_ELEMENT_TITLE (the list does not include KEY_ELEMENT_TITLE itself).
Constructor Details
SVGHints
private SVGHints()Utility class, not intended for instantiation.
Method Details
getBeginGroupKeys
Creates and returns a list of keys that are synonymous withKEY_BEGIN_GROUP.- Returns:
- A list (never
null).
addBeginGroupKey
Adds a key to the list of keys that are synonyms forKEY_BEGIN_GROUP.- Parameters:
key- the hint key to add to the begin-group list
removeBeginGroupKey
Removes a key from the list of keys that are synonyms forKEY_BEGIN_GROUP.- Parameters:
key- the hint key to remove from the begin-group list
clearBeginGroupKeys
public static void clearBeginGroupKeys()Clears the list of keys that are treated as synonyms forKEY_BEGIN_GROUP.isBeginGroupKey
Returnstrueif this key is equivalent toKEY_BEGIN_GROUP, andfalseotherwise. 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 hint key to test- Returns:
trueif the key begins a grouping element in the SVG output.
getEndGroupKeys
Creates and returns a list of keys that are synonymous withKEY_END_GROUP.- Returns:
- A list (never
null).
addEndGroupKey
Adds a key to the list of keys that are synonyms forKEY_END_GROUP.- Parameters:
key- the hint key to add to the end-group list
removeEndGroupKey
Removes a key from the list of keys that are synonyms forKEY_END_GROUP.- Parameters:
key- the hint key to remove from the end-group list
clearEndGroupKeys
public static void clearEndGroupKeys()Clears the list of keys that are treated as synonyms forKEY_END_GROUP.isEndGroupKey
Returnstrueif this key is equivalent toKEY_END_GROUP, andfalseotherwise. 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 hint key to test- Returns:
trueif the key ends a grouping element in the SVG output.
getElementTitleKeys
Creates and returns a list of keys that are synonymous withKEY_ELEMENT_TITLE.- Returns:
- A list (never
null).
addElementTitleKey
Adds a key to the list of keys that are synonyms forKEY_ELEMENT_TITLE.- Parameters:
key- the hint key to add to the element-title list
removeElementTitleKey
Removes a key from the list of keys that are synonyms forKEY_ELEMENT_TITLE.- Parameters:
key- the hint key to remove from the element-title list
clearElementTitleKeys
public static void clearElementTitleKeys()Clears the list of keys that are treated as synonyms forKEY_ELEMENT_TITLE.isElementTitleKey
Returnstrueif this key is equivalent toKEY_ELEMENT_TITLE, andfalseotherwise. 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 hint key to test- Returns:
trueif the key requests an element title in the SVG output.
isOrsonChartsOnClasspath
private static boolean isOrsonChartsOnClasspath()Returnstrueif Orson Charts (version 1.3 or later) is on the classpath, andfalseotherwise. This method is used to auto-register keys from Orson Charts that should translate to the behaviour ofKEY_BEGIN_GROUPandKEY_END_GROUP.- Returns:
trueifcom.orsoncharts.Chart3DHints.KEY_BEGIN_ELEMENTcould be read.
isJFreeChartOnClasspath
private static boolean isJFreeChartOnClasspath()Returnstrueif JFreeChart (1.0.18 or later) is on the classpath, andfalseotherwise. This method is used to auto-register keys from JFreeChart that should translate to the behaviour ofKEY_BEGIN_GROUPandKEY_END_GROUP.The JFreeChart library can be found at http://www.jfree.org/jfreechart/.
- Returns:
trueiforg.jfree.chart.ChartHints.KEY_BEGIN_ELEMENTcould be read.
fetchKey
Loads a hint key by naming its class and field reflectively.- Parameters:
className- the class holding the keyfieldName- the key's field name- Returns:
- the key, null if it cannot be loaded
getOrsonChartsBeginElementKey
The key for the Orson Charts begin-element hint.- Returns:
- the hint key
getOrsonChartsEndElementKey
The key for the Orson Charts end-element hint.- Returns:
- the hint key
getOrsonChartsElementTitleKey
The key for the Orson Charts element-title hint.- Returns:
- the hint key
getJFreeChartBeginElementKey
The key for the JFreeChart begin-element hint.- Returns:
- the hint key
getJFreeChartEndElementKey
The key for the JFreeChart end-element hint.- Returns:
- the hint key