A discussion forum for JFreeSVG (a fast, lightweight, SVG generator for the Java platform).
-
DavidThi808
- Posts: 106
- Joined: Fri May 27, 2005 7:44 pm
- Location: Boulder, CO
-
Contact:
Post
by DavidThi808 » Sun Aug 14, 2016 3:03 pm
The documentation says:
when an HTML page contains multiple SVG elements, the items within the DEFS element for each SVG element must have IDs that are unique across all SVG elements in the page. We auto-populate the defsKeyPrefix attribute to help ensure that unique IDs are generated.
Is the best (or ok) way to handle this to call setDefsKeyPrefix() with a different string for every SVGGraphics2D we create?
thanks - dave
-
david.gilbert
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
-
Contact:
Post
by david.gilbert » Tue Aug 16, 2016 10:39 pm
If you do nothing, the prefix will be unique because it is initialised with:
Code: Select all
this.defsKeyPrefix = String.valueOf(System.nanoTime());
However, this generates a fairly long prefix...if you can manually set shorter prefixes but still guarantee the uniqueness of the keys then you'll save some space in the generated SVG.