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 massimo citterio <ci...@sinapto.net> on 2008/02/06 16:10:44 UTC

use and transform

I am really unable to create a "use" element with a transform or x/y
attributes.
It's always in the cloned place, and I cannot move it.
Does it work for anybody out there?
Is it a batik bug?

sample code:

 String translate = "100,100";
 String link = "#sourceid";
 String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; 
 Element elCard = document.createElementNS(svgNS, "use");
 elCard.setAttributeNS(svgNS, "id", id + "instance");
 elCard.setAttributeNS(svgNS, "transform", "translate(" + translate +
")");
//either the previous or these:
//  elCard.setAttributeNS(svgNS, "x", "300");
//  elCard.setAttributeNS(svgNS, "y", "100");

elCard.setAttributeNS(org.apache.batik.util.XMLConstants.XLINK_NAMESPACE_URI, "href", link);

document.getElementById("mysvg").getParentNode().appendChild(elCard);


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


Re: use and transform

Posted by massimo citterio <ci...@sinapto.net>.
On Wed, 2008-02-06 at 09:27 -0600, Archie Cobbs wrote:
> You should be using elCard.setAttributeNS(null, ...) instead of
> elCard.setAttributeNS(svgNS, ...).

thanks!
you are right.

the only exception is href, I must use
org.apache.batik.util.XMLConstants.XLINK_NAMESPACE_URI for it



the working code (for refecence) is:


 String translate = "100,100";
 String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
 Element elCard = document.createElementNS(svgNS, "use");
 elCard.setAttributeNS(null, "id", id + "instance");
 elCard.setAttributeNS(null, "transform", "translate(" + translate +
")");
//either the previous or these, both work:
//  elCard.setAttributeNS(null, "x", "300");
//  elCard.setAttributeNS(null, "y", "100");

//this is mandatory
elCard.setAttributeNS(org.apache.batik.util.XMLConstants.XLINK_NAMESPACE_URI, "href", link);

document.getElementById("mysvg").getParentNode().appendChild(elCard);




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


Re: use and transform

Posted by Archie Cobbs <ar...@dellroad.org>.
You should be using elCard.setAttributeNS(null, ...) instead of
elCard.setAttributeNS(svgNS, ...).

On Feb 6, 2008 9:10 AM, massimo citterio <ci...@sinapto.net> wrote:

> I am really unable to create a "use" element with a transform or x/y
> attributes.
> It's always in the cloned place, and I cannot move it.
> Does it work for anybody out there?
> Is it a batik bug?
>
> sample code:
>
>  String translate = "100,100";
>  String link = "#sourceid";
>  String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
>  Element elCard = document.createElementNS(svgNS, "use");
>  elCard.setAttributeNS(svgNS, "id", id + "instance");
>  elCard.setAttributeNS(svgNS, "transform", "translate(" + translate +
> ")");
> //either the previous or these:
> //  elCard.setAttributeNS(svgNS, "x", "300");
> //  elCard.setAttributeNS(svgNS, "y", "100");
>
> elCard.setAttributeNS(
> org.apache.batik.util.XMLConstants.XLINK_NAMESPACE_URI, "href", link);
>
> document.getElementById("mysvg").getParentNode().appendChild(elCard);
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>


-- 
Archie L. Cobbs