jfree / jfreesvg

A fast, lightweight Java library for creating Scalable Vector Graphics (SVG) output.
http://www.jfree.org/jfreesvg
GNU General Public License v3.0
319 stars 58 forks source link

Added additional settings that seem useful for SVG on the web. #4

Closed sladkoff closed 7 years ago

sladkoff commented 8 years ago

Hi.

I'm generating SVG for the web and need the SVG to be responsive. I did some research along the way and found that certain properties can be set on the root element in order to make the SVG scale nicely in browsers.

The properties in question are:

I added settings for these two in the SVGGraphics2D class accordingly.

I also found that even when the viewBox property is set, an explicit width and height on the SVG can influence responsiveness on the web as described here, for example.

For this reason I added a printDimensions flag which is true by default but can be disabled so that no dimensions are added to the SVG root element.

Hope these additions are desirable.

Things are documented and basic parameter checks are in place.

Cheers.

jfree commented 7 years ago

Hi, The changes you are proposing look very useful. There's one issue though, JFreeSVG is dual-licensed so in order to incorporate your code I would need you to agree to assign the copyright for your changes to my company Object Refinery Limited. Is that acceptable for you?

Thanks for the link to the website explaining the viewBox settings, that's very useful.

sladkoff commented 7 years ago

Sure, I'm fine with that. ^ Does this suffice as agreement or does it need to be more official :)

jfree commented 7 years ago

I've just committed some changes that should give the same results but with a slightly different approach. If you have time to look over it, let me know if the way I've done it meets your requirements. I could tweak it before the official 3.2 release.

sladkoff commented 7 years ago

Sorry for the delay. I only now got the chance to test.

I found one issue. When you set a value for meetOrSlice, exemplary SVG output looks like this: preserveAspectRatio="xMidYMid" meetorslice="slice"

meetOrSlice is actually a parameter of the preserveAspectRatio attribute and thus the output should be: preserveAspectRatio="xMidYMid slice"

Other than that it meets my requirements quite well and the enum approach is cleaner than my quick hack :)

jfree commented 7 years ago

OK, great…thanks for picking that up, I was about to start testing a week or two back then got distracted by other things. I’ll fix it asap.

Best regards, David

On 15 Sep 2016, at 01:00, sladkoff notifications@github.com wrote:

Sorry for the delay. I only now got the chance to test.

I found one issue. When you set a value for meetOrSlice, exemplary SVG output looks like this: preserveAspectRatio="xMidYMid" meetorslice="slice"

meetOrSlice is actually a parameter of the preserveAspectRatio attribute and thus the output should be: preserveAspectRatio="xMidYMid slice"

Other than that it meets my requirements quite well and the enum approach is cleaner than my quick hack :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jfree/jfreesvg/pull/4#issuecomment-247182880, or mute the thread https://github.com/notifications/unsubscribe-auth/ABwDdSapvFucTGPi2jKuqYzXrlW9m_O7ks5qqHyZgaJpZM4JHUMH.

jfree commented 7 years ago

Committed the fix.

On 15 Sep 2016, at 11:37, David Gilbert david.gilbert@object-refinery.com wrote:

OK, great…thanks for picking that up, I was about to start testing a week or two back then got distracted by other things. I’ll fix it asap.

Best regards, David

On 15 Sep 2016, at 01:00, sladkoff <notifications@github.com mailto:notifications@github.com> wrote:

Sorry for the delay. I only now got the chance to test.

I found one issue. When you set a value for meetOrSlice, exemplary SVG output looks like this: preserveAspectRatio="xMidYMid" meetorslice="slice"

meetOrSlice is actually a parameter of the preserveAspectRatio attribute and thus the output should be: preserveAspectRatio="xMidYMid slice"

Other than that it meets my requirements quite well and the enum approach is cleaner than my quick hack :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jfree/jfreesvg/pull/4#issuecomment-247182880, or mute the thread https://github.com/notifications/unsubscribe-auth/ABwDdSapvFucTGPi2jKuqYzXrlW9m_O7ks5qqHyZgaJpZM4JHUMH.

sladkoff commented 7 years ago

Looking good on my end.