List Info

Thread: desc text add problem




desc text add problem
country flaguser name
United States
2007-11-05 09:51:42
Hello,

I'm having a bit of a problem with adding text to the desc
element.  When I
add text to the desc element, it adds the text to the next
line and not
after the <desc>.  For example in the svg it'll look
like this:

<rect>
<desc>
hello</desc>
</rect>

This cause the tool tip to show up as 2 lines, the first one
being empty and
the second line showing hello.  In java I've coded it as
follows:

Element nextPatElement = patternDoc.createElementNS(null,
"rect");
nextPatElement.setAttributeNS(null, "x",
Integer.toString(x));
nextPatElement.setAttributeNS(null, "y",
Integer.toString(y));
nextPatElement.setAttributeNS(null, "width",
Integer.toString(PATTERN_DIM));
nextPatElement.setAttributeNS(null, "height",
Integer.toString(PATTERN_DIM));
nextPatElement.setAttributeNS(null, "stroke",
"black");
nextPatElement.setAttributeNS(null, "class",
pattern.getPatternName());
nextPatElement.setAttributeNS(null, "id",
pattern.getPatternName());

Element desc = patternDoc.createElementNS(null,
"desc");
desc.setTextContent(pattern.getPatternName());

nextPatElement.appendChild(desc);
root.appendChild(nextPatElement);

I've also tried:

Element nextPatElement = patternDoc.createElementNS(null,
"rect");
nextPatElement.setAttributeNS(null, "x",
Integer.toString(x));
nextPatElement.setAttributeNS(null, "y",
Integer.toString(y));
nextPatElement.setAttributeNS(null, "width",
Integer.toString(PATTERN_DIM));
nextPatElement.setAttributeNS(null, "height",
Integer.toString(PATTERN_DIM));
nextPatElement.setAttributeNS(null, "stroke",
"black");
nextPatElement.setAttributeNS(null, "class",
pattern.getPatternName());
nextPatElement.setAttributeNS(null, "id",
pattern.getPatternName());

Element desc = patternDoc.createElementNS(null,
"desc");
Text text =
patternDoc.createTextNode(pattern.getPatternName());

desc.appendChild(text);
nextPatElement.appendChild(desc);
root.appendChild(nextPatElement);

But neither seems to work.  Any hints on how I would fix
this problem.

vyang
-- 
View this message in context: http://www.nabble.com/desc-text-add-problem-
tf4752451.html#a13589459
Sent from the Batik - Users mailing list archive at
Nabble.com.


------------------------------------------------------------
---------
To unsubscribe, e-mail: batik-users-unsubscribexmlgraphics.apache.org
For additional commands, e-mail: batik-users-helpxmlgraphics.apache.org


Re: desc text add problem
country flaguser name
United States
2007-11-06 05:46:53

Hi Vyang,

vyang <vyangapt-cafm.com> wrote on 11/05/2007 10:51:42 AM:

&gt; I'm having a bit of a problem with adding text to the desc element.  When I
> add text to the desc element, it adds the text to the next line and not
> after the <desc&gt;.  For example in the svg it'll look like this:
>
> <rect&gt;
> <desc&gt;
> hello</desc>
> </rect&gt;

   How are you serializing the SVG Document.  I suspect the
serializer is causing the problem.  Most XML serializers will
move text children to a separate line so the SVG is readable.


> Element desc = patternDoc.createElementNS(null, "desc");
> desc.setTextContent(pattern.getPatternName());

    Just to test the obvious, 'pattern.getPatternName()'
doesn't start with a newline?
Re: desc text add problem
country flaguser name
United States
2007-11-06 08:23:12
Hello Thomas,

I've already tried printing the pattern.getPatternName() as
well as inputing
a string such as 'hello' and the effect is still the same. 
As for
serializing the document, I haven't looked at that since its
been working
fine, but I'll do that.

vyang


thomas.deweese wrote:
> 
> Hi Vyang,
> 
> vyang <vyangapt-cafm.com> wrote on 11/05/2007
10:51:42 AM:
> 
>> I'm having a bit of a problem with adding text to
the desc element. When 
> I
>> add text to the desc element, it adds the text to
the next line and not
>> after the <desc>.  For example in the svg
it'll look like this:
>> 
>> <rect>
>> <desc>
>> hello</desc>
>> </rect>
> 
>    How are you serializing the SVG Document.  I suspect
the 
> serializer is causing the problem.  Most XML
serializers will
> move text children to a separate line so the SVG is
readable.
> 
> 
>> Element desc = patternDoc.createElementNS(null,
"desc");
>> desc.setTextContent(pattern.getPatternName());
> 
>     Just to test the obvious,
'pattern.getPatternName()'
> doesn't start with a newline?
> 
> 

-- 
View this message in context: http://www.nabble.com/desc-text-add-problem-
tf4752451.html#a13607616
Sent from the Batik - Users mailing list archive at
Nabble.com.


------------------------------------------------------------
---------
To unsubscribe, e-mail: batik-users-unsubscribexmlgraphics.apache.org
For additional commands, e-mail: batik-users-helpxmlgraphics.apache.org


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )