Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can an existing SVG be loaded to include in the newly created SVG #34

Open
FDelporte opened this issue Jan 6, 2021 · 1 comment
Open

Comments

@FDelporte
Copy link

I see multiple writeToSVG methods are included in SVGUtils, but I'm wondering if I can also load an existing SVG to add it to the SVG I'm creating?

@jfree
Copy link
Owner

jfree commented Mar 19, 2021

No, that's not supported, since the goal of the library is to provide a Graphics2D API and translate the input that hits that interface into SVG output.

One way that feature could be added, without stepping outside of the Graphics2D API, would be to enhance the basic drawImage() method so that it checks for a custom RenderingHint. Suppose the value of the rendering hint is a String containing the SVG element that should take the place of the Image that is passed - then JFreeSVG could simply insert the element instead of handling the supplied image. The nice part of this approach (assuming you have a corresponding image for your SVG) is that switching to another Graphics2D implementation (for example JFreePDF) would still work, since any other Graphics2D implementation can handle the Image (and ignore the SVG in the rendering hint).

Alternatively, if you don't need the Graphics2D compatibility, you could simply add a drawSVG() or embedSVGElement() method to the API and insert the supplied SVG element into the output. I don't know what issues might arise from conflicts between the "inner" SVG (supplied by you) and the "outer" SVG (being generated by JFreeSVG). Presumable the SVG specification has some rules about it, but I didn't study this case in any detail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants