id attribute to svg group object.

A discussion forum for JFreeSVG (a fast, lightweight, SVG generator for the Java platform).

id attribute to svg group object.

Postby Mala » Wed Jan 29, 2014 2:56 pm

Hi,
I have been working on jFreeSVG for some time.
We can give id attributes as a rendering hints to svg elements like <rect>< line> using SVGHints.KEY_ELEMENT_ID.
But as I see in
Code: Select all
public void drawString(String str, float x, float y)

there is no call to appendOptionalElementIDFromHint(this.sb) method of SVGGRaphics2D.
So group object element do not have any id attribute ?
Is there any way to have group attribute an id attribute ?


Thanks in advance.
Mala
 
Posts: 8
Joined: Tue Jan 28, 2014 1:06 pm

Re: id attribute to svg group object.

Postby remiohead » Wed Jan 29, 2014 5:39 pm

It's not possible in the current library. Have you tried wrapping the text inside of a rect (perhaps with 0 width stroke) that does have an id?
remiohead
 
Posts: 201
Joined: Fri Oct 02, 2009 3:53 pm

Re: id attribute to svg group object.

Postby remiohead » Wed Jan 29, 2014 5:45 pm

A general solution is to create two new hints. KEY_GROUP_START begins a new group (with optional id) and KEY_GROUP_END closes a group. This allows nested groups which has proven to be very useful.
remiohead
 
Posts: 201
Joined: Fri Oct 02, 2009 3:53 pm

Re: id attribute to svg group object.

Postby david.gilbert » Sun Feb 02, 2014 4:20 pm

Mala wrote:...there is no call to appendOptionalElementIDFromHint(this.sb) method of SVGGRaphics2D.


That's a bug, thanks for making me aware of it. I've committed the fix for inclusion in the upcoming 1.7 release.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited
david.gilbert
JFreeChart Project Leader
 
Posts: 11648
Joined: Fri Mar 14, 2003 10:29 am

Re: id attribute to svg group object.

Postby Mala » Tue Feb 04, 2014 7:43 am

david.gilbert wrote:
Mala wrote:...there is no call to appendOptionalElementIDFromHint(this.sb) method of SVGGRaphics2D.


That's a bug, thanks for making me aware of it. I've committed the fix for inclusion in the upcoming 1.7 release.


Glad that it helped.
Mala
 
Posts: 8
Joined: Tue Jan 28, 2014 1:06 pm

Re: id attribute to svg group object.

Postby Eugene_T » Thu Aug 27, 2015 3:30 pm

Can you please provide samples how to add an id in java code to have it added for <rect, <circle ... and for group <g?
Eugene_T
 
Posts: 6
Joined: Thu Aug 06, 2015 10:09 am


Return to JFreeSVG

Who is online

Users browsing this forum: No registered users and 1 guest