- java.lang.Object
-
- org.jfree.svg.SVGHints
-
public final class SVGHints extends java.lang.ObjectDefines the rendering hints that can be used with theSVGGraphics2Dclass. 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 attributes controlled by the hint value (which may be aStringfor the group ID or, more generally, aMapcontaining arbitrary attribute values). 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 Classes Modifier and Type Class Description static classSVGHints.KeyA key for hints used by theSVGGraphics2Dclass.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.List<java.awt.RenderingHints.Key>beginGroupKeysA list of keys that are treated as synonyms for KEY_BEGIN_GROUP (the list does not include KEY_BEGIN_GROUP itself).private static java.util.List<java.awt.RenderingHints.Key>elementTitleKeysA list of keys that are treated as synonyms for KEY_ELEMENT_TITLE (the list does not include KEY_ELEMENT_TITLE itself).private static java.util.List<java.awt.RenderingHints.Key>endGroupKeysA list of keys that are treated as synonyms for KEY_END_GROUP (the list does not include KEY_END_GROUP itself).static SVGHints.KeyKEY_BEGIN_GROUPHint key that informs theSVGGraphics2Dthat the caller would like to begin a new group element.static SVGHints.KeyKEY_DRAW_STRING_TYPEThe key for the hint that controls whether strings are rendered as characters or vector graphics (implemented usingTextLayout).static SVGHints.KeyKEY_ELEMENT_IDHint key to supply an element id for the next element generated.static SVGHints.KeyKEY_ELEMENT_TITLEHint 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 SVGHints.KeyKEY_END_GROUPHint key that informs theSVGGraphics2Dthat the caller would like to close a previously opened group element.static SVGHints.KeyKEY_IMAGE_HANDLINGThe key for the hint that controls whether images are embedded in the SVG or referenced externally.static SVGHints.KeyKEY_IMAGE_HREFHint key to supply string to be used as the href for an image that is referenced rather than embedded.static SVGHints.KeyKEY_TEXT_RENDERINGThe key for a hint that permits configuration of the text-rendering attribute in SVG text elementsstatic java.lang.ObjectVALUE_DRAW_STRING_TYPE_STANDARDHint value forKEY_DRAW_STRING_TYPEto specify that strings should be written to the output using standard SVG text elements.static java.lang.ObjectVALUE_DRAW_STRING_TYPE_VECTORHint value forKEY_DRAW_STRING_TYPEto say that strings should be written to the output using vector graphics primitives.static java.lang.ObjectVALUE_IMAGE_HANDLING_EMBEDHint value forKEY_IMAGE_HANDLINGto specify that images should be embedded in the SVG output using PNG dataBase64encoded.static java.lang.ObjectVALUE_IMAGE_HANDLING_REFERENCEHint value forKEY_IMAGE_HANDLINGto say that images should be referenced externally.static java.lang.StringVALUE_TEXT_RENDERING_AUTOHint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'auto'.static java.lang.StringVALUE_TEXT_RENDERING_INHERITHint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'inherit'.static java.lang.StringVALUE_TEXT_RENDERING_LEGIBILITYHint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'optimizeLegibility'.static java.lang.StringVALUE_TEXT_RENDERING_PRECISIONHint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'geometricPrecision'.static java.lang.StringVALUE_TEXT_RENDERING_SPEEDHint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'optimizeSpeed'.
-
Constructor Summary
Constructors Modifier Constructor Description privateSVGHints()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddBeginGroupKey(java.awt.RenderingHints.Key key)Adds a key to the list of keys that are synonyms forKEY_BEGIN_GROUP.static voidaddElementTitleKey(java.awt.RenderingHints.Key key)Adds a key to the list of keys that are synonyms forKEY_ELEMENT_TITLE.static voidaddEndGroupKey(java.awt.RenderingHints.Key key)Adds a key to the list of keys that are synonyms forKEY_END_GROUP.static voidclearBeginGroupKeys()Clears the list of keys that are treated as synonyms forKEY_BEGIN_GROUP.static voidclearElementTitleKeys()Clears the list of keys that are treated as synonyms forKEY_ELEMENT_TITLE.static voidclearEndGroupKeys()Clears the list of keys that are treated as synonyms forKEY_END_GROUP.private static java.awt.RenderingHints.KeyfetchKey(java.lang.String className, java.lang.String fieldName)static java.util.List<java.awt.RenderingHints.Key>getBeginGroupKeys()Creates and returns a list of keys that are synonymous withKEY_BEGIN_GROUP.static java.util.List<java.awt.RenderingHints.Key>getElementTitleKeys()Creates and returns a list of keys that are synonymous withKEY_ELEMENT_TITLE.static java.util.List<java.awt.RenderingHints.Key>getEndGroupKeys()Creates and returns a list of keys that are synonymous withKEY_END_GROUP.private static java.awt.RenderingHints.KeygetJFreeChartBeginElementKey()private static java.awt.RenderingHints.KeygetJFreeChartEndElementKey()private static java.awt.RenderingHints.KeygetOrsonChartsBeginElementKey()private static java.awt.RenderingHints.KeygetOrsonChartsElementTitleKey()private static java.awt.RenderingHints.KeygetOrsonChartsEndElementKey()static booleanisBeginGroupKey(java.awt.RenderingHints.Key key)static booleanisElementTitleKey(java.awt.RenderingHints.Key key)static booleanisEndGroupKey(java.awt.RenderingHints.Key key)private static booleanisJFreeChartOnClasspath()Returnstrueif JFreeChart (1.0.18 or later) is on the classpath, andfalseotherwise.private static booleanisOrsonChartsOnClasspath()Returnstrueif Orson Charts (version 1.3 or later) is on the classpath, andfalseotherwise.static voidremoveBeginGroupKey(java.awt.RenderingHints.Key key)Removes a key from the list of keys that are synonyms forKEY_BEGIN_GROUP.static voidremoveElementTitleKey(java.awt.RenderingHints.Key key)Removes a key from the list of keys that are synonyms forKEY_ELEMENT_TITLE.static voidremoveEndGroupKey(java.awt.RenderingHints.Key key)Removes a key from the list of keys that are synonyms forKEY_END_GROUP.
-
-
-
Field Detail
-
KEY_IMAGE_HANDLING
public static final SVGHints.Key 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
public static final java.lang.Object 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
public static final java.lang.Object VALUE_IMAGE_HANDLING_REFERENCE
Hint value forKEY_IMAGE_HANDLINGto say that images should be referenced externally.
-
KEY_TEXT_RENDERING
public static final SVGHints.Key KEY_TEXT_RENDERING
The key for a hint that permits configuration of the text-rendering attribute in SVG text elements
-
VALUE_TEXT_RENDERING_AUTO
public static final java.lang.String VALUE_TEXT_RENDERING_AUTO
Hint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'auto'.- See Also:
- Constant Field Values
-
VALUE_TEXT_RENDERING_SPEED
public static final java.lang.String VALUE_TEXT_RENDERING_SPEED
Hint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'optimizeSpeed'.- See Also:
- Constant Field Values
-
VALUE_TEXT_RENDERING_LEGIBILITY
public static final java.lang.String VALUE_TEXT_RENDERING_LEGIBILITY
Hint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'optimizeLegibility'.- See Also:
- Constant Field Values
-
VALUE_TEXT_RENDERING_PRECISION
public static final java.lang.String VALUE_TEXT_RENDERING_PRECISION
Hint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'geometricPrecision'.- See Also:
- Constant Field Values
-
VALUE_TEXT_RENDERING_INHERIT
public static final java.lang.String VALUE_TEXT_RENDERING_INHERIT
Hint value forKEY_TEXT_RENDERINGto set thetext-renderingattribute in SVG text elements to 'inherit'.- See Also:
- Constant Field Values
-
KEY_IMAGE_HREF
public static final 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. 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
public static final SVGHints.Key KEY_ELEMENT_ID
Hint key to supply an element id for the next element generated.- Since:
- 1.5
-
KEY_BEGIN_GROUP
public static final SVGHints.Key KEY_BEGIN_GROUP
Hint key that informs theSVGGraphics2Dthat the caller would like to begin a new group element. The hint value is either:- a
Stringthat will be used as the value of theidattribute for the group; or - a
Mapinstance containing arbitrary attribute values for the group (usually including anid).
KEY_END_GROUP. Groups can be nested.- Since:
- 1.7
- a
-
KEY_END_GROUP
public static final SVGHints.Key KEY_END_GROUP
Hint key that informs theSVGGraphics2Dthat the caller would like to close a previously opened group element. The hint value is ignored.- Since:
- 1.7
-
KEY_ELEMENT_TITLE
public static final SVGHints.Key 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).- Since:
- 1.9
-
KEY_DRAW_STRING_TYPE
public static final SVGHints.Key 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.- Since:
- 2.0
-
VALUE_DRAW_STRING_TYPE_STANDARD
public static final java.lang.Object 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.- Since:
- 2.0
-
VALUE_DRAW_STRING_TYPE_VECTOR
public static final java.lang.Object VALUE_DRAW_STRING_TYPE_VECTOR
Hint value forKEY_DRAW_STRING_TYPEto say that strings should be written to the output using vector graphics primitives.- Since:
- 2.0
-
beginGroupKeys
private static final java.util.List<java.awt.RenderingHints.Key> beginGroupKeys
A list of keys that are treated as synonyms for KEY_BEGIN_GROUP (the list does not include KEY_BEGIN_GROUP itself).
-
endGroupKeys
private static final java.util.List<java.awt.RenderingHints.Key> endGroupKeys
A list of keys that are treated as synonyms for KEY_END_GROUP (the list does not include KEY_END_GROUP itself).
-
elementTitleKeys
private static final java.util.List<java.awt.RenderingHints.Key> elementTitleKeys
A list of keys that are treated as synonyms for KEY_ELEMENT_TITLE (the list does not include KEY_ELEMENT_TITLE itself).
-
-
Method Detail
-
getBeginGroupKeys
public static java.util.List<java.awt.RenderingHints.Key> getBeginGroupKeys()
Creates and returns a list of keys that are synonymous withKEY_BEGIN_GROUP.- Returns:
- A list (never
null). - Since:
- 1.8
-
addBeginGroupKey
public static void addBeginGroupKey(java.awt.RenderingHints.Key key)
Adds a key to the list of keys that are synonyms forKEY_BEGIN_GROUP.- Parameters:
key- the key (nullnot permitted).- Since:
- 1.8
-
removeBeginGroupKey
public static void removeBeginGroupKey(java.awt.RenderingHints.Key key)
Removes a key from the list of keys that are synonyms forKEY_BEGIN_GROUP.- Parameters:
key- the key (nullnot permitted).- Since:
- 1.8
-
clearBeginGroupKeys
public static void clearBeginGroupKeys()
Clears the list of keys that are treated as synonyms forKEY_BEGIN_GROUP.- Since:
- 1.8
-
isBeginGroupKey
public static boolean isBeginGroupKey(java.awt.RenderingHints.Key key)
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 key (nullnot permitted)- Returns:
- A boolean.
- Since:
- 1.8
-
getEndGroupKeys
public static java.util.List<java.awt.RenderingHints.Key> getEndGroupKeys()
Creates and returns a list of keys that are synonymous withKEY_END_GROUP.- Returns:
- A list (never
null). - Since:
- 1.8
-
addEndGroupKey
public static void addEndGroupKey(java.awt.RenderingHints.Key key)
Adds a key to the list of keys that are synonyms forKEY_END_GROUP.- Parameters:
key- the key (nullnot permitted).- Since:
- 1.8
-
removeEndGroupKey
public static void removeEndGroupKey(java.awt.RenderingHints.Key key)
Removes a key from the list of keys that are synonyms forKEY_END_GROUP.- Parameters:
key- the key (nullnot permitted).- Since:
- 1.8
-
clearEndGroupKeys
public static void clearEndGroupKeys()
Clears the list of keys that are treated as synonyms forKEY_END_GROUP.- Since:
- 1.8
-
isEndGroupKey
public static boolean isEndGroupKey(java.awt.RenderingHints.Key key)
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 key (nullnot permitted).- Returns:
- A boolean.
- Since:
- 1.8
-
getElementTitleKeys
public static java.util.List<java.awt.RenderingHints.Key> getElementTitleKeys()
Creates and returns a list of keys that are synonymous withKEY_ELEMENT_TITLE.- Returns:
- A list (never
null). - Since:
- 1.9
-
addElementTitleKey
public static void addElementTitleKey(java.awt.RenderingHints.Key key)
Adds a key to the list of keys that are synonyms forKEY_ELEMENT_TITLE.- Parameters:
key- the key (nullnot permitted).- Since:
- 1.9
-
removeElementTitleKey
public static void removeElementTitleKey(java.awt.RenderingHints.Key key)
Removes a key from the list of keys that are synonyms forKEY_ELEMENT_TITLE.- Parameters:
key- the key (nullnot permitted).- Since:
- 1.9
-
clearElementTitleKeys
public static void clearElementTitleKeys()
Clears the list of keys that are treated as synonyms forKEY_ELEMENT_TITLE.- Since:
- 1.9
-
isElementTitleKey
public static boolean isElementTitleKey(java.awt.RenderingHints.Key key)
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 key (nullnot permitted)- Returns:
- A boolean.
- Since:
- 1.9
-
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.
The Orson Charts library can be found at http://www.object-refinery.com/orsoncharts/- Returns:
- A boolean.
- Since:
- 1.8
-
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:
- A boolean.
- Since:
- 2.0
-
fetchKey
private static java.awt.RenderingHints.Key fetchKey(java.lang.String className, java.lang.String fieldName)
-
getOrsonChartsBeginElementKey
private static java.awt.RenderingHints.Key getOrsonChartsBeginElementKey()
-
getOrsonChartsEndElementKey
private static java.awt.RenderingHints.Key getOrsonChartsEndElementKey()
-
getOrsonChartsElementTitleKey
private static java.awt.RenderingHints.Key getOrsonChartsElementTitleKey()
-
getJFreeChartBeginElementKey
private static java.awt.RenderingHints.Key getJFreeChartBeginElementKey()
-
getJFreeChartEndElementKey
private static java.awt.RenderingHints.Key getJFreeChartEndElementKey()
-
-