setting viewbox attribute

"Litterst, Edwin" <[email protected]> Thu, 7 Apr 2016 11:50:06 +0000
Newsgroups gmane.text.xml.batik.user
Message-ID <CDF587DF76AD04498073A4806BB22FB501C686C5CA@KAEX06.fiz-karlsruhe.de>
--===============1795021967951863703==
Content-Language: de-DE
Content-Type: multipart/alternative;
	boundary="_000_CDF587DF76AD04498073A4806BB22FB501C686C5CAKAEX06fizkarl_"

--_000_CDF587DF76AD04498073A4806BB22FB501C686C5CAKAEX06fizkarl_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi,

I already asked about this some time ago (http://batik.2283329.n4.nabble.co=
m/problem-setting-viewbox-td4656184.html).

I am not able to set the viewbox attribute in the svg (as attribute viewbox=
 in the XML element svg).

      DOMImplementation impl =3D SVGDOMImplementation.getDOMImplementation(=
);
      String svgNS =3D SVGDOMImplementation.SVG_NAMESPACE_URI;
      SVGDocument document =3D (SVGDocument) impl.createDocument(svgNS, "sv=
g", null);
      SVGGraphics2D svgGenerator =3D new SVGGraphics2D(document);
      Dimension dimension =3D new Dimension();
      dimension.setSize(imageWidth, imageHeight);
      svgGenerator.setSVGCanvasSize(dimension);
      final SVGSVGElement rootElement =3D document.getRootElement();
      rootElement.setAttribute("viewBox", "0 0 " + Integer.toString(imageWi=
dth) + " " + Integer.toString(imageHeight));

Debugging through the code I found out that the attribute is added to the a=
ttribute list (in the firstChild of SVGDocument) as expected. It gets lost =
when creating the image with

      Writer out =3D new OutputStreamWriter(outputStream, "UTF-8");
      ((SVGGraphics2D) graphics2D).stream(out, useCSS);

In this method the following statement:

Element svgRoot =3D getRoot();

Creates a new Element which is missing the viewBox attribute. When I add it=
 again manually (in the debugger), the expected svg is created.

Otherwise, SVGGraphics.stream creates a DocumentFragment svgDocument whose =
child contains an SVGOMAnimatedRect viewBox. But this doesn't seem to be us=
ed (at least I couldn't find it).

Do I have to do anything else except adding the viewbox attribute (e.g. con=
figuring something) or is batik not able to handle this?

Regards,
Eddie


--_000_CDF587DF76AD04498073A4806BB22FB501C686C5CAKAEX06fizkarl_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Consolas;
	panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";
	mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
span.E-MailFormatvorlage17
	{mso-style-type:personal-compose;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri","sans-serif";
	mso-fareast-language:EN-US;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"DE" link=3D"blue" vlink=3D"purple">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">Hi,<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">I already asked about this some time ago (<a href=3D=
"http://batik.2283329.n4.nabble.com/problem-setting-viewbox-td4656184.html"=
>http://batik.2283329.n4.nabble.com/problem-setting-viewbox-td4656184.html<=
/a>).<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">I am not able to set the viewbox attribute in the sv=
g (as attribute viewbox in the XML element svg).<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
DOMImplementation
</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#6A3E3E">=
impl</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:black=
"> =3D
<span style=3D"background:lime;mso-highlight:lime">SVGDOMImplementation</sp=
an>.<i>getDOMImplementation</i>();</span><span style=3D"font-size:10.0pt;fo=
nt-family:Consolas"><o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
String
</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#6A3E3E">=
svgNS</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:blac=
k"> =3D
<span style=3D"background:lime;mso-highlight:lime">SVGDOMImplementation</sp=
an>.</span><b><i><span style=3D"font-size:10.0pt;font-family:Consolas;color=
:#0000C0">SVG_NAMESPACE_URI</span></i></b><span style=3D"font-size:10.0pt;f=
ont-family:Consolas;color:black">;</span><span style=3D"font-size:10.0pt;fo=
nt-family:Consolas"><o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
SVGDocument
</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#6A3E3E">=
document</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:b=
lack"> =3D (SVGDocument)
</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#6A3E3E">=
impl</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:black=
">.createDocument(</span><span style=3D"font-size:10.0pt;font-family:Consol=
as;color:#6A3E3E">svgNS</span><span style=3D"font-size:10.0pt;font-family:C=
onsolas;color:black">,
</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#2A00FF">=
&quot;svg&quot;</span><span style=3D"font-size:10.0pt;font-family:Consolas;=
color:black">,
</span><b><span style=3D"font-size:10.0pt;font-family:Consolas;color:#7F005=
5">null</span></b><span style=3D"font-size:10.0pt;font-family:Consolas;colo=
r:black">);</span><span style=3D"font-size:10.0pt;font-family:Consolas"><o:=
p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
SVGGraphics2D
</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#6A3E3E">=
svgGenerator</span><span style=3D"font-size:10.0pt;font-family:Consolas;col=
or:black"> =3D
</span><b><span style=3D"font-size:10.0pt;font-family:Consolas;color:#7F005=
5">new</span></b><span style=3D"font-size:10.0pt;font-family:Consolas;color=
:black"> SVGGraphics2D(</span><span style=3D"font-size:10.0pt;font-family:C=
onsolas;color:#6A3E3E">document</span><span style=3D"font-size:10.0pt;font-=
family:Consolas;color:black">);</span><span style=3D"font-size:10.0pt;font-=
family:Consolas"><o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Dimension
</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#6A3E3E">=
dimension</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:=
black"> =3D
</span><b><span style=3D"font-size:10.0pt;font-family:Consolas;color:#7F005=
5">new</span></b><span style=3D"font-size:10.0pt;font-family:Consolas;color=
:black"> Dimension();</span><span style=3D"font-size:10.0pt;font-family:Con=
solas"><o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#6A3E3E">=
dimension</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:=
black">.setSize(</span><span style=3D"font-size:10.0pt;font-family:Consolas=
;color:#6A3E3E">imageWidth</span><span style=3D"font-size:10.0pt;font-famil=
y:Consolas;color:black">,
</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#6A3E3E">=
imageHeight</span><span style=3D"font-size:10.0pt;font-family:Consolas;colo=
r:black">);</span><span style=3D"font-size:10.0pt;font-family:Consolas"><o:=
p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#6A3E3E">=
svgGenerator</span><span style=3D"font-size:10.0pt;font-family:Consolas;col=
or:black">.setSVGCanvasSize(</span><span style=3D"font-size:10.0pt;font-fam=
ily:Consolas;color:#6A3E3E">dimension</span><span style=3D"font-size:10.0pt=
;font-family:Consolas;color:black">);</span><span style=3D"font-size:10.0pt=
;font-family:Consolas"><o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><b><span style=3D"font-size:10.0pt;font-family:Consolas;color:#7F005=
5">final</span></b><span style=3D"font-size:10.0pt;font-family:Consolas;col=
or:black"> SVGSVGElement
</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#6A3E3E">=
rootElement</span><span style=3D"font-size:10.0pt;font-family:Consolas;colo=
r:black"> =3D
</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#6A3E3E">=
document</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:b=
lack">.getRootElement();</span><span style=3D"font-size:10.0pt;font-family:=
Consolas"><o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#6A3E3E">=
rootElement</span><span style=3D"font-size:10.0pt;font-family:Consolas;colo=
r:black">.setAttribute(</span><span style=3D"font-size:10.0pt;font-family:C=
onsolas;color:#2A00FF">&quot;viewBox&quot;</span><span style=3D"font-size:1=
0.0pt;font-family:Consolas;color:black">,
</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#2A00FF">=
&quot;0 0 &quot;</span><span style=3D"font-size:10.0pt;font-family:Consolas=
;color:black"> &#43; Integer.<i>toString</i>(</span><span style=3D"font-siz=
e:10.0pt;font-family:Consolas;color:#6A3E3E">imageWidth</span><span style=
=3D"font-size:10.0pt;font-family:Consolas;color:black">)
 &#43; </span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#2=
A00FF">&quot; &quot;</span><span style=3D"font-size:10.0pt;font-family:Cons=
olas;color:black"> &#43; Integer.<i>toString</i>(</span><span style=3D"font=
-size:10.0pt;font-family:Consolas;color:#6A3E3E">imageHeight</span><span st=
yle=3D"font-size:10.0pt;font-family:Consolas;color:black">));</span><span s=
tyle=3D"font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Debugging through the code I found out that the attr=
ibute is added to the attribute list (in the firstChild of SVGDocument) as =
expected. It gets lost when creating the image with<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span style=3D"background:lime;mso-highlight:lime">Writer</span> </span><sp=
an style=3D"font-size:10.0pt;font-family:Consolas;color:#6A3E3E">out</span>=
<span style=3D"font-size:10.0pt;font-family:Consolas;color:black"> =3D
</span><b><span style=3D"font-size:10.0pt;font-family:Consolas;color:#7F005=
5">new</span></b><span style=3D"font-size:10.0pt;font-family:Consolas;color=
:black"> OutputStreamWriter(</span><span style=3D"font-size:10.0pt;font-fam=
ily:Consolas;color:#6A3E3E">outputStream</span><span style=3D"font-size:10.=
0pt;font-family:Consolas;color:black">,
</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#2A00FF">=
&quot;UTF-8&quot;</span><span style=3D"font-size:10.0pt;font-family:Consola=
s;color:black">);</span><span style=3D"font-size:10.0pt;font-family:Consola=
s"><o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
((SVGGraphics2D)
</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#6A3E3E">=
graphics2D</span><span style=3D"font-size:10.0pt;font-family:Consolas;color=
:black">).stream(</span><span style=3D"font-size:10.0pt;font-family:Consola=
s;color:#6A3E3E">out</span><span style=3D"font-size:10.0pt;font-family:Cons=
olas;color:black">,
</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#6A3E3E">=
useCSS</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:bla=
ck">);</span><span style=3D"font-size:10.0pt;font-family:Consolas"><o:p></o=
:p></span></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">In this method the following statement:<o:p></o:p></=
p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:Consolas=
;color:black;background:silver;mso-highlight:silver">Element
</span><span style=3D"font-size:10.0pt;font-family:Consolas;color:#6A3E3E;b=
ackground:silver;mso-highlight:silver">svgRoot</span><span style=3D"font-si=
ze:10.0pt;font-family:Consolas;color:black;background:silver;mso-highlight:=
silver"> =3D getRoot();</span><span style=3D"font-size:10.0pt;font-family:C=
onsolas;color:black"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:Consolas=
;color:black"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:Consolas=
;color:black">Creates a new Element which is missing the viewBox attribute.=
 When I add it again manually (in the debugger), the expected svg is create=
d.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:Consolas=
;color:black"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:Consolas=
;color:black">Otherwise, SVGGraphics.stream creates a DocumentFragment svgD=
ocument whose child contains an SVGOMAnimatedRect viewBox. But this doesn&#=
8217;t seem to be used (at least I couldn&#8217;t
 find it).<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:Consolas=
;color:black"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:Consolas=
;color:black">Do I have to do anything else except adding the viewbox attri=
bute (e.g. configuring something) or is batik not able to handle this?<o:p>=
</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:Consolas=
;color:black"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:Consolas=
;color:black">Regards,<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:Consolas=
;color:black">Eddie<o:p></o:p></span></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>

--_000_CDF587DF76AD04498073A4806BB22FB501C686C5CAKAEX06fizkarl_--

--===============1795021967951863703==
Content-Type: multipart/alternative; boundary="===============4517956771076609144=="
MIME-Version: 1.0
Content-Disposition: inline

--===============4517956771076609144==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable

---------------------------------------------------------------------------=
---

FIZ Karlsruhe - Leibniz-Institut f=C3=BCr Informationsinfrastruktur GmbH.
Sitz der Gesellschaft: Eggenstein-Leopoldshafen, Amtsgericht Mannheim HRB 1=
01892.
Gesch=C3=A4ftsf=C3=BChrerin: Sabine Br=C3=BCnger-Weilandt.
Vorsitzender des Aufsichtsrats: MinDirig Dr. Thomas Greiner.
--===============4517956771076609144==
Content-Type: text/html; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable

<p></p>

<hr align=3D"left" noshade=3D"" size=3D"3" width=3D"300">

<p>FIZ Karlsruhe - Leibniz-Institut f=C3=BCr Informationsinfrastruktur GmbH=
.<br>
Sitz der Gesellschaft: Eggenstein-Leopoldshafen, Amtsgericht Mannheim HRB 1=
01892. <br>
Gesch=C3=A4ftsf=C3=BChrerin: Sabine Br=C3=BCnger-Weilandt. <br>
Vorsitzender des Aufsichtsrats: MinDirig Dr. Thomas Greiner.</p>
--===============4517956771076609144==--

--===============1795021967951863703==
Content-Type: text/plain; charset=us-ascii


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
--===============1795021967951863703==--