You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Nirmesh Desai <nd...@autonomy.com> on 2008/08/18 20:37:27 UTC

textpath clone affects text positioning?

 

Hi,

 

Thanks for all your help so far...

 

I am stuck at a text path issue.

 

I am trying to use textpath with <path> element defined.

 

I clone the <path> element and update 'd' attribute as per the data I
have with javascript functions.

 

FireFox and Renesis player seem to put the text in correct place,
however batik svg viewer seems to somehow also use the 'd' defined in
the template from where I clone the <path> element so the text keeps
changing whenever I change the 'd' value in the 'template' <path>.

 

I need to try to make the svg behave same in applet and the browsers.

 

Any pointers will be helpful..

 

Thanks again.

Nirmesh.


RE: textpath clone affects text positioning?

Posted by Nirmesh Desai <nd...@autonomy.com>.
In DOM viewer I see that after setAttribute('xlink:href',value) on the cloned node the node has two xlink:href attributes, unless I am not seeing properly.

Isn't setAttribute supposed to replace value if attribute already exists?

Is there another way to set this attribute so that the new xlink is available?

Also, if I remove the [xlink:href="#templateTextPathDef"] the display works as expected.


<textPath xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#templateTextPathDef" xlink:type="simple" xlink:actuate="onLoad" id="templateTextPath" xlink:show="other" xlink:href="#item0TextPathDef">India</textPath>

Any thoughts/pointers will be helpful..

Thanks again.
Nirmesh.


-----Original Message-----
From: Helder Magalhães [mailto:helder.magalhaes@gmail.com] 
Sent: Tuesday, August 19, 2008 7:15 AM
To: batik-users@xmlgraphics.apache.org
Subject: Re: textpath <path> clone affects text positioning?

> FireFox and Renesis player seem to put the text in correct place, however
> batik svg viewer seems to somehow also use the 'd' defined in the template
> from where I clone the <path> element so the text keeps changing whenever I
> change the 'd' value in the 'template' <path>.
>
> I need to try to make the svg behave same in applet and the browsers.

As always, creating and attaching a reduced test case [1] to the
message may help receiving more and more valuable feedback. (For this
case, apparently a single SVG file containing a script snippet and
target path elements will do the trick.)

Just a though: are you deep cloning the element (i.e.,
"cloneNode(true)" [2])?. If not, then it is Firefox and Renesis who
may be suffering from issues, as non-deep copies of DOM subtrees
should act as "use" elements, that is, when you manipulate a non-deep
cloned element, the referenced element is the one who is actually
changed.

Hope this helps,

 Helder Magalhães

[1] http://webkit.org/quality/reduction.html
[2] http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-3A0ED0A4

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


RE: textpath clone affects text positioning?

Posted by Nirmesh Desai <nd...@autonomy.com>.
Thanks Thomas,

 

That worked perfectly. I had tried NS methods, but must have been careless somewhere.

 

This is great group for a cool tech..!

 

BR,

Nirmesh

 

________________________________

From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com] 
Sent: Wednesday, August 20, 2008 3:22 AM
To: batik-users@xmlgraphics.apache.org
Cc: batik-users@xmlgraphics.apache.org
Subject: RE: textpath <path> clone affects text positioning?

 


Hi Nirmesh,

"Nirmesh Desai" <nd...@autonomy.com> wrote on 08/19/2008 02:06:47 PM:

>   //use textpath found through new id
>   itemLabelTextPath.setAttribute('xlink:href','#'+textPathDefId);

   This isn't correct.  You must use the namespace aware 
version of the DOM API's: 
    itemLabelTextPath.setAttributeNS 
        ("http://www.w3.org/1999/xlink", 
         'xlink:href','#'+textPathDefId);

>   textpathDef.setAttribute('id',textPathDefId);
>   textpathDef.setAttribute('d',new_textpath);

   Technically all your other setAttribute calls should look like 

    textpathDef.setAttributeNS(null, 'id',textPathDefId);
   textpathDef.setAttributeNS(null, 'd',new_textpath);

  I should also caution that if you try to create 
element's yourself rather than cloning them you must 
use the createElementNS methods rather than createElement. 


> -----Original Message-----
> From: Helder Magalhães [mailto:helder.magalhaes@gmail.com] 
> Sent: Tuesday, August 19, 2008 7:15 AM
> To: batik-users@xmlgraphics.apache.org
> Subject: Re: textpath <path> clone affects text positioning?
> 
> > FireFox and Renesis player seem to put the text in correct place, however
> > batik svg viewer seems to somehow also use the 'd' defined in the template
> > from where I clone the <path> element so the text keeps changing whenever I
> > change the 'd' value in the 'template' <path>.
> >
> > I need to try to make the svg behave same in applet and the browsers.
> 
> As always, creating and attaching a reduced test case [1] to the
> message may help receiving more and more valuable feedback. (For this
> case, apparently a single SVG file containing a script snippet and
> target path elements will do the trick.)
> 
> Just a though: are you deep cloning the element (i.e.,
> "cloneNode(true)" [2])?. If not, then it is Firefox and Renesis who
> may be suffering from issues, as non-deep copies of DOM subtrees
> should act as "use" elements, that is, when you manipulate a non-deep
> cloned element, the referenced element is the one who is actually
> changed.
> 
> Hope this helps,
> 
>  Helder Magalhães
> 
> [1] http://webkit.org/quality/reduction.html
> [2] http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-3A0ED0A4
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


RE: textpath clone affects text positioning?

Posted by th...@kodak.com.
Hi Nirmesh,

"Nirmesh Desai" <nd...@autonomy.com> wrote on 08/19/2008 02:06:47 PM:

>   //use textpath found through new id
>   itemLabelTextPath.setAttribute('xlink:href','#'+textPathDefId);

   This isn't correct.  You must use the namespace aware
version of the DOM API's:
    itemLabelTextPath.setAttributeNS
        ("http://www.w3.org/1999/xlink", 
         'xlink:href','#'+textPathDefId);

>   textpathDef.setAttribute('id',textPathDefId);
>   textpathDef.setAttribute('d',new_textpath);

   Technically all your other setAttribute calls should look like

    textpathDef.setAttributeNS(null, 'id',textPathDefId);
    textpathDef.setAttributeNS(null, 'd',new_textpath);

  I should also caution that if you try to create
element's yourself rather than cloning them you must
use the createElementNS methods rather than createElement.


> -----Original Message-----
> From: Helder Magalhães [mailto:helder.magalhaes@gmail.com] 
> Sent: Tuesday, August 19, 2008 7:15 AM
> To: batik-users@xmlgraphics.apache.org
> Subject: Re: textpath <path> clone affects text positioning?
> 
> > FireFox and Renesis player seem to put the text in correct place, 
however
> > batik svg viewer seems to somehow also use the 'd' defined in the 
template
> > from where I clone the <path> element so the text keeps changing 
whenever I
> > change the 'd' value in the 'template' <path>.
> >
> > I need to try to make the svg behave same in applet and the browsers.
> 
> As always, creating and attaching a reduced test case [1] to the
> message may help receiving more and more valuable feedback. (For this
> case, apparently a single SVG file containing a script snippet and
> target path elements will do the trick.)
> 
> Just a though: are you deep cloning the element (i.e.,
> "cloneNode(true)" [2])?. If not, then it is Firefox and Renesis who
> may be suffering from issues, as non-deep copies of DOM subtrees
> should act as "use" elements, that is, when you manipulate a non-deep
> cloned element, the referenced element is the one who is actually
> changed.
> 
> Hope this helps,
> 
>  Helder Magalhães
> 
> [1] http://webkit.org/quality/reduction.html
> [2] http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-3A0ED0A4
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 

RE: textpath clone affects text positioning?

Posted by Nirmesh Desai <nd...@autonomy.com>.
Here is the defs

<defs id='defs'>       
    <path id="templateTextPathDef" d=""> //any change here affects cloned    node position
</defs>

The ecmascript function does following

function updateVisualization()
{
  //some code initializations etc...
   
  var templateTextPathDef = document.getElementById('templateTextPathDef');
   
  //create id

  var textpathDef = templateTextPathDef.cloneNode(true);
  textpathDef.setAttribute('id',textPathDefId);
  textpathDef.setAttribute('d',new_textpath);
	  
  defs.appendChild(textpathDef);

  //use textpath found through new id
  itemLabelTextPath.setAttribute('xlink:href','#'+textPathDefId);
  itemLabelTextPath.appendChild(document.createTextNode(labelText));

  itemLabelTextView.appendChild(itemLabelTextPath);

  visualization.appendChild(itemLabelTextView);
 
}

I am using 'true', however making shallow copy didn't help either.


Thanks
Nirmesh.


-----Original Message-----
From: Helder Magalhães [mailto:helder.magalhaes@gmail.com] 
Sent: Tuesday, August 19, 2008 7:15 AM
To: batik-users@xmlgraphics.apache.org
Subject: Re: textpath <path> clone affects text positioning?

> FireFox and Renesis player seem to put the text in correct place, however
> batik svg viewer seems to somehow also use the 'd' defined in the template
> from where I clone the <path> element so the text keeps changing whenever I
> change the 'd' value in the 'template' <path>.
>
> I need to try to make the svg behave same in applet and the browsers.

As always, creating and attaching a reduced test case [1] to the
message may help receiving more and more valuable feedback. (For this
case, apparently a single SVG file containing a script snippet and
target path elements will do the trick.)

Just a though: are you deep cloning the element (i.e.,
"cloneNode(true)" [2])?. If not, then it is Firefox and Renesis who
may be suffering from issues, as non-deep copies of DOM subtrees
should act as "use" elements, that is, when you manipulate a non-deep
cloned element, the referenced element is the one who is actually
changed.

Hope this helps,

 Helder Magalhães

[1] http://webkit.org/quality/reduction.html
[2] http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-3A0ED0A4

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: textpath clone affects text positioning?

Posted by Helder Magalhães <he...@gmail.com>.
> FireFox and Renesis player seem to put the text in correct place, however
> batik svg viewer seems to somehow also use the 'd' defined in the template
> from where I clone the <path> element so the text keeps changing whenever I
> change the 'd' value in the 'template' <path>.
>
> I need to try to make the svg behave same in applet and the browsers.

As always, creating and attaching a reduced test case [1] to the
message may help receiving more and more valuable feedback. (For this
case, apparently a single SVG file containing a script snippet and
target path elements will do the trick.)

Just a though: are you deep cloning the element (i.e.,
"cloneNode(true)" [2])?. If not, then it is Firefox and Renesis who
may be suffering from issues, as non-deep copies of DOM subtrees
should act as "use" elements, that is, when you manipulate a non-deep
cloned element, the referenced element is the one who is actually
changed.

Hope this helps,

 Helder Magalhães

[1] http://webkit.org/quality/reduction.html
[2] http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-3A0ED0A4

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org