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 Dylan Browne <db...@mango-solutions.com> on 2006/05/19 16:41:58 UTC
Export to JPG error
Hi,
I'm getting an error when attempting to export an SVG Document to JPEG (or
other image format). I've included the top of the stack trace below.
Basically the essence of the error is that:
The attribute "xlink:href" of the element <use> is required
I am using the <use> tag, but can't see where the syntax is wrong as I am
including the attribute "xlink:href". The SVG renders fine in the browser.
Here's a snippet of the SVG source where I use the <use> tag. (The "#circle"
is one of my 'defs' which is included earlier in the SVG doc).....
<use fill-opacity="0.2" xmlns:xlink="http://www.w3.org/1999/xlink"
onmousedown="select_group(evt,true,90.6912,202.90311885986404);"
stroke="blue" xlink:href="#circle"
onmouseover="select_point(evt,true,90.6912,202.90311885986404, 'DOSE =
0.00','IRESP =
106.89','ID','1.0',0.0,106.88575287553);"
transform="translate(90.6912,202.90311885986404)scale(5.0)"
width="5.0%" xlink:show="embed" xlink:type="simple"
fill="blue"
onmouseup="deselect_group(evt,true);" height="5.0%"
onmouseout="deselect_point(evt,true);deselect_group(evt,true);"
xlink:actuate="onLoad"/>
And here's the top of the stack trace:
org.apache.batik.transcoder.TranscoderException: null
Enclosed Exception:
null:-1
The attribute "xlink:href" of the element <use> is required
at
org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown S
ource)
at
org.apache.batik.transcoder.image.ImageTranscoder.transcode(Unknown S
ource)
at
org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown S
ource)
at
org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown S
ource)
at
com.mango.svg.SVGManager.streamSVGIntoImageFormat(SVGManager.java:217
)
Any help gratefully received,
Kind regards,
Dylan
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: Export to JPG error
Posted by Cameron McCormack <ca...@mcc.id.au>.
Hi Dylan.
Dylan Browne:
> I'm getting an error when attempting to export an SVG Document to JPEG (or
> other image format). I've included the top of the stack trace below.
I cannot reproduce that, using the 1.6 release and with the SVN code.
This is what I tested with:
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<defs>
<circle id="c" cx="50" cy="50" r="50"/>
</defs>
<use xlink:href="#c" xmlns:xlink="http://www.w3.org/1999/xlink"/>
</svg>
What version are you using?
Thanks,
Cameron
--
Cameron McCormack ICQ: 26955922
cam (at) mcc.id.au MSN: cam (at) mcc.id.au
http://mcc.id.au/ JBR: heycam (at) jabber.org
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: Export to JPG error
Posted by Dylan Browne <db...@mango-solutions.com>.
Thanks for the advice, good to know I was looking in the right area at
least.
I'll sort out my namespace handling to make it consistent, and post back if
it solves my problems.
Thanks again,
Dylan
-----Original Message-----
From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com]
Sent: 26 May 2006 11:10
To: batik-users@xmlgraphics.apache.org
Cc: batik-users@xmlgraphics.apache.org
Subject: RE: Export to JPG error
Hi Dylan,
"Dylan Browne" <db...@mango-solutions.com> wrote on 05/26/2006 05:26:43
AM:
> One change I made was to attempt to assign correct namespaces to
> the document and its elements, so it may be something to do with that?
Sounds likely.
> my histogram (containing SVG defined Rects) renders fine,
> my scatter plot (containing my own definition of #circle) does not.
Sounds like you aren't using/setting up the XLink namespace properly.
> I define my circle like this:
>
> Element circle_light = doc.createElementNS
> (Config.SVG_NAMESPACE,
> SVG12Constants.SVG_PATH_TAG);
The element creation looks good.
Are all your elements created through the DOM?
> circle_light.setAttribute("id", CIRCLE_BLANK);
Do you take care to use 'setAttributeNS' for the
attributes in other namespaces (xmlns:xlink, xlink:href)?
In fact you should use setAttributeNS for all attributes
in a namespace aware application, but for all SVG attributes
you use 'null' as the namespace, in Batik this doesn't matter
but in other DOM implementations it might:
circle_light.setAttributeNS(null, "id", CIRCLE_BLANK);
> The method I use to stream is this:
I don't think the problem is with the streaming it's
with the document construction.
> "Dylan Browne" <db...@mango-solutions.com> wrote on 05/19/2006
10:41:58
> AM:
>
> > I'm getting an error when attempting to export an SVG Document to JPEG
> > (or other image format). I've included the top of the stack trace
below.
> > Basically the essence of the error is that:
> >
> > The attribute "xlink:href" of the element <use> is required
> >
> > <use fill-opacity="0.2" xmlns:xlink="http://www.w3.org/1999/xlink"
> >
> > onmousedown="select_group(evt,true,90.6912,202.90311885986404);"
> > stroke="blue" xlink:href="#circle"
> >
> > onmouseover="select_point(evt,true,90.6912,202.90311885986404,
> 'DOSE =
> > 0.00','IRESP =
> > 106.89','ID','1.0',0.0,106.88575287553);"
> > transform="translate(90.6912,202.90311885986404)scale(5.0)"
> > width="5.0%" xlink:show="embed" xlink:type="simple"
> > fill="blue"
> > onmouseup="deselect_group(evt,true);" height="5.0%"
> >
> > onmouseout="deselect_point(evt,true);deselect_group(evt,true);"
> > xlink:actuate="onLoad"/>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> [attachment "svgFailsToConvertToJPG.svg" deleted by Thomas E.
> DeWeese/449433/EKC]
> ---------------------------------------------------------------------
> 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
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: Export to JPG error
Posted by Dylan Browne <db...@mango-solutions.com>.
Excellent stuff. All working now.
This has raised another issue, potentially a bug, but I'll raise it in a
separate post.
Thanks for all the help,
Dylan
-----Original Message-----
From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com]
Sent: 30 May 2006 12:07
To: batik-users@xmlgraphics.apache.org
Cc: batik-users@xmlgraphics.apache.org
Subject: RE: Export to JPG error
Hi Dylan,
"Dylan Browne" <db...@mango-solutions.com> wrote on 05/30/2006 06:07:35
AM:
> Can I confirm what the correct namespaces to use are:
> impl.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI, "svg",
null);
> createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"rect");
These are good.
> element.setAttributeNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"stroke",
"red");
This is wrong, all SVG attributes are in the 'null' namespace:
element.setAttributeNS(null, "stroke", "red");
> This all seems to work fine.
This is surprising Batik should ignore 'stroke' in the SVG
namespace...
> With my own defined shapes I use the following:
>
> Element defs = doc.createElementNS(SVGDOMImplementation.
> SVG_NAMESPACE_URI, SVG12Constants.SVG_DEFS_TAG);
> Element path_star_filled = doc.
> createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
SVG12Constants.SVG_PATH_TAG);
The above are fine, but all the setAttributeNS calls should be null:
path_star_filled.setAttributeNS(null, "id", STAR_FILLED);
path_star_filled.setAttributeNS(null,"stroke-width", "0.3");
path_star_filled.setAttributeNS(null,"stroke", "black");
path_star_filled.setAttributeNS(null,"d", "M0,0.9 [...], z");
> defs.appendChild(path_star_filled);
> And when I make a call to use one of my defined elements I use the
following:
>
> Element plotCh = doc.createElementNS(SVGDOMImplementation.
> SVG_NAMESPACE_URI,SVG12Constants.SVG_USE_TAG);
This is fine.
> plotCh.setAttributeNS
> (SVGDOMImplementation.SVG_NAMESPACE_URI,
> "xlink:href", "#" + type);
This needs to set the 'href' attribute in the
XLINK namespace (it's an xlink attribute).
import org.apache.batik.util.XMLConstants;
plotCh.setAttributeNS
(XMLConstants.XLINK_NAMESPACE_URI,
"xlink:href", "#" + type);
> plotCh.setAttributeNS(SVGDOMImplementation.
> SVG_NAMESPACE_URI,"width", new Double(w).toString() + "%");
One again should be in 'null' namespace (SVG attribute).
> Am I using the wrong name space for my defined elements?
> Im not sure if its in the definition, or the calling of
> my definition, or both?
Your element stuff looks fine, but your attributes are
problematic.
>
---------------------------------------------------------------------
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: Accessing event coordinates when zoomed
Posted by Andreas Neumann <ne...@karto.baug.ethz.ch>.
>Excellent, have it working now. Just for the info of others who may read
>this post and wish to use your mapApp class... I was trying to transform to
>a different position in the DOM hierarchy (exactly as your tooltips do), and
>I was neglecting to pass in an appropriate node to the function to allow the
>transform to work.
>
>
ah, that explains it.
Andreas
--
----------------------------------------------
Andreas Neumann
Institute of Cartography
ETH Zurich
Wolfgang-Paulistrasse 15
CH-8093 Zurich, Switzerland
Phone: ++41-44-633 3031, Fax: ++41-44-633 1153
e-mail: neumann@karto.baug.ethz.ch
www: http://www.carto.net/neumann/
SVG.Open: http://www.svgopen.org/
Carto.net: http://www.carto.net/
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: Accessing event coordinates when zoomed
Posted by Dylan Browne <db...@mango-solutions.com>.
>if you use my "mapApp" object it should just work.....
Excellent, have it working now. Just for the info of others who may read
this post and wish to use your mapApp class... I was trying to transform to
a different position in the DOM hierarchy (exactly as your tooltips do), and
I was neglecting to pass in an appropriate node to the function to allow the
transform to work.
Many thanks for all the help,
Cheers,
Dylan
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: Accessing event coordinates when zoomed
Posted by Andreas Neumann <ne...@karto.baug.ethz.ch>.
>We only need to support Adobe Viewer, so I've tried to use some JS similar
>to that in the mapApp.js as suggested.
>
>
>
if you use my "mapApp" object it should just work.
If you launch the tooltip example
(http://www.carto.net/papers/svg/gui/tooltips/) and zoom in with the
Adobe viewer, the tooltips still properly follow the mouse. They don't
compensate for the scale (means that the tooltips scale) but they follow
the mouse properly.
>I call it like this...
>
>function getMyCoords(evt){
> // Pass in the event from the screen
> var thePoint = calcCoord(evt);
> // get the zoomed/panned values from the point
> x = thePoint.getX();
> y = thePoint.getY();
>}
>
>
calcCoord() is a method of the mapApp object, not a standalone function.
Maybe if you rewrote the function it should work as well. But the mapApp
object also takes into account the use of viewBoxes (I recommend to use
viewBoxes anyway). What calcCoord returns is an SVGPoint.
Andreas
--
----------------------------------------------
Andreas Neumann
Institute of Cartography
ETH Zurich
Wolfgang-Paulistrasse 15
CH-8093 Zurich, Switzerland
Phone: ++41-44-633 3031, Fax: ++41-44-633 1153
e-mail: neumann@karto.baug.ethz.ch
www: http://www.carto.net/neumann/
SVG.Open: http://www.svgopen.org/
Carto.net: http://www.carto.net/
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: Accessing event coordinates when zoomed
Posted by Dylan Browne <db...@mango-solutions.com>.
Thanks Andreas for the reply,
I've tried to put that into practice, but doesn't seem to be quite working.
I do need to develop these tooltips rather than use the existing supported
ones as they may become fairly intricate in the future.
We only need to support Adobe Viewer, so I've tried to use some JS similar
to that in the mapApp.js as suggested.
I call it like this...
function getMyCoords(evt){
// Pass in the event from the screen
var thePoint = calcCoord(evt);
// get the zoomed/panned values from the point
x = thePoint.getX();
y = thePoint.getY();
}
... is this the correct way to get the real values? Its doesn't seem to work
when zoomed or not. The values that are returned from this seem to very
small compared to the locations I'd expect in the document... EG values less
than 10 where I'd expect values in the hundreds. If this syntax is correct
I'll look elsewhere for where my problem lies.
Thanks again for any (more) help,
Kind regards,
Dylan.
-----Original Message-----
From: Andreas Neumann [mailto:neumann@karto.baug.ethz.ch]
Sent: 13 June 2006 15:57
To: batik-users@xmlgraphics.apache.org
Subject: Re: Accessing event coordinates when zoomed
Hi Dylan,
.getScreenCTM() is your friend here.
Here is some code:
function calcCoord(evt) {
var svgPoint = document.documentElement.createSVGPoint();
svgPoint.x = evt.clientX;
svgPoint.y = evt.clientY;
var matrix = evt.target.getScreenCTM(); //alternatively use a
different node reference here instead of evt.target, f.e. if you want to
calculate to a different node in the hierarchy
svgPoint = svgPoint.matrixTransform(matrix.inverse());
return svgPoint;
}
If you need standard tooltips, Batik already provides tooltips.
Unfortunately, the Adobe SVG viewer version 3 neither supports tooltips
nor .getScreenCTM.
For this viewer there is a workaround:
http://www.carto.net/papers/svg/gui/mapApp/
And here is a tooltip example that works in all browsers:
http://www.carto.net/papers/svg/gui/tooltips/index.svg
All the best,
Andreas
Dylan Browne wrote:
>Hi,
>
>(Not strictly a Batik Posting, although I am using Batik DOM to create my
>SVG, so I hope that almost counts...!)
>
>I am using JavaScript "evt.clientX" and "evt.clientY" (I have also tried
>"screenX") to retrieve the co-ordinates of a mouseover event, and some
extra
>code then displays a label using these coordinates. (In essence, I'm
>creating a souped-up tool-tip).
>
>This works fine in standard view, but once the SVG document has been
zoomed,
>the co-ordinates returned are no longer relative to the original
>document,(as, of course, I would expect :). I'd be grateful if someone
could
>point me towards the correct JS syntax so the coordinates I return are in
>relation to my zoomed/panned document.
>
>Thanks a lot in advance for any help,
>
>Regards,
>Dylan
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>
>
--
----------------------------------------------
Andreas Neumann
Institute of Cartography
ETH Zurich
Wolfgang-Paulistrasse 15
CH-8093 Zurich, Switzerland
Phone: ++41-44-633 3031, Fax: ++41-44-633 1153
e-mail: neumann@karto.baug.ethz.ch
www: http://www.carto.net/neumann/
SVG.Open: http://www.svgopen.org/
Carto.net: http://www.carto.net/
---------------------------------------------------------------------
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: Accessing event coordinates when zoomed
Posted by Andreas Neumann <ne...@karto.baug.ethz.ch>.
Hi Dylan,
.getScreenCTM() is your friend here.
Here is some code:
function calcCoord(evt) {
var svgPoint = document.documentElement.createSVGPoint();
svgPoint.x = evt.clientX;
svgPoint.y = evt.clientY;
var matrix = evt.target.getScreenCTM(); //alternatively use a
different node reference here instead of evt.target, f.e. if you want to
calculate to a different node in the hierarchy
svgPoint = svgPoint.matrixTransform(matrix.inverse());
return svgPoint;
}
If you need standard tooltips, Batik already provides tooltips.
Unfortunately, the Adobe SVG viewer version 3 neither supports tooltips
nor .getScreenCTM.
For this viewer there is a workaround:
http://www.carto.net/papers/svg/gui/mapApp/
And here is a tooltip example that works in all browsers:
http://www.carto.net/papers/svg/gui/tooltips/index.svg
All the best,
Andreas
Dylan Browne wrote:
>Hi,
>
>(Not strictly a Batik Posting, although I am using Batik DOM to create my
>SVG, so I hope that almost counts...!)
>
>I am using JavaScript "evt.clientX" and "evt.clientY" (I have also tried
>"screenX") to retrieve the co-ordinates of a mouseover event, and some extra
>code then displays a label using these coordinates. (In essence, I'm
>creating a souped-up tool-tip).
>
>This works fine in standard view, but once the SVG document has been zoomed,
>the co-ordinates returned are no longer relative to the original
>document,(as, of course, I would expect :). I'd be grateful if someone could
>point me towards the correct JS syntax so the coordinates I return are in
>relation to my zoomed/panned document.
>
>Thanks a lot in advance for any help,
>
>Regards,
>Dylan
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>
>
--
----------------------------------------------
Andreas Neumann
Institute of Cartography
ETH Zurich
Wolfgang-Paulistrasse 15
CH-8093 Zurich, Switzerland
Phone: ++41-44-633 3031, Fax: ++41-44-633 1153
e-mail: neumann@karto.baug.ethz.ch
www: http://www.carto.net/neumann/
SVG.Open: http://www.svgopen.org/
Carto.net: http://www.carto.net/
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Accessing event coordinates when zoomed
Posted by Dylan Browne <db...@mango-solutions.com>.
Hi,
(Not strictly a Batik Posting, although I am using Batik DOM to create my
SVG, so I hope that almost counts...!)
I am using JavaScript "evt.clientX" and "evt.clientY" (I have also tried
"screenX") to retrieve the co-ordinates of a mouseover event, and some extra
code then displays a label using these coordinates. (In essence, I'm
creating a souped-up tool-tip).
This works fine in standard view, but once the SVG document has been zoomed,
the co-ordinates returned are no longer relative to the original
document,(as, of course, I would expect :). I'd be grateful if someone could
point me towards the correct JS syntax so the coordinates I return are in
relation to my zoomed/panned document.
Thanks a lot in advance for any help,
Regards,
Dylan
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: Invalid "D" attribute in Path Element when Transcoding
Posted by Dylan Browne <db...@mango-solutions.com>.
> This usually means the 'd' attribute of the element is invalid ;)
:o) Good point
> Your arc is wrong: a0.7,0.7 0 0.7,0 0.1,0.1
> The third '0.7' is supposed to be 'large arc flag' which can only
be zero or one.
Great stuff, works now.
I'll pay more attention to the error messages next time.
Thanks again,
Dylan.
---------------------------------------------------------------------
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: Invalid "D" attribute in Path Element when Transcoding
Posted by th...@kodak.com.
Hi Dylan,
"Dylan Browne" <db...@mango-solutions.com> wrote on 05/30/2006 07:56:20
AM:
> During trancoding of an SVG DOM Document I get an error relating to my
"D"
> syntax in my Path Element, although the SVG is rendered fine in the
browser.
My first guess is that you are getting the error in the browser but
aren't
seeing it.
> The attribute "d" of the element <path> is invalid
This usually means the 'd' attribute of the element is invalid ;)
> circle_light.setAttributeNS(null,"d", "M0.4,-0.4 a0.7,0.7 0 0.7,0
0.1,0.1 z");
Your arc is wrong: a0.7,0.7 0 0.7,0 0.1,0.1
^^^
The third '0.7' is supposed to be 'large arc flag' which can only
be zero or one.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Invalid "D" attribute in Path Element when Transcoding
Posted by Dylan Browne <db...@mango-solutions.com>.
Hi,
During trancoding of an SVG DOM Document I get an error relating to my "D"
syntax in my Path Element, although the SVG is rendered fine in the browser.
----------------------------------------------------------------
The stack trace is:
The attribute "d" of the element <path> is invalid
at
org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown S
ource)
at
org.apache.batik.transcoder.image.ImageTranscoder.transcode(Unknown S
ource)
at
org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown S
ource)
at
org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown S
ource)
at
com.mango.svg.SVGManager.streamSVGIntoImageFormat(SVGManager.java:239
)
----------------------------------------------------------------
The path is defined thus:
Element circle_light =
doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
SVG12Constants.SVG_PATH_TAG);
circle_light.setAttributeNS(null,"id", CIRCLE_BLANK);
circle_light.setAttributeNS(null,"stroke-width", "0.2");
circle_light.setAttributeNS(null,"fill", "white");
circle_light.setAttributeNS(null,"d", "M0.4,-0.4 a0.7,0.7 0
0.7,0 0.1,0.1 z");
defs.appendChild(circle_light);
----------------------------------------------------------------
The following definition works fine in both browser and transcoding:
Element path_square_blank =
doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
SVG12Constants.SVG_PATH_TAG);
path_square_blank.setAttributeNS(null,"id", SQUARE_BLANK);
path_square_blank.setAttributeNS(null,"stroke-width", "0.2");
path_square_blank.setAttributeNS(null,"fill", "white");
path_square_blank.setAttributeNS(null,"d", "M-0.75 -0.75,L0.75
-0.75,L0.75 0.75,L-0.75 0.75,z");
defs.appendChild(path_square_blank);
----------------------------------------------------------------
I found the following post in the archive which is related to this matter:
http://koala.ilog.fr/batik/mlists/batik-dev/archives/msg05084.html
And so have also tried removing all commas from my "D" attribute. This
didn't change anything in that the circle was still rendered in the browser,
but couldn't be transcoded.
Is there anyway to modify the syntax of my path so that Batik will accept
it?
Thanks very much in advance,
Kind regards,
Dylan
RE: Export to JPG error
Posted by th...@kodak.com.
Hi Dylan,
"Dylan Browne" <db...@mango-solutions.com> wrote on 05/30/2006 06:07:35
AM:
> Can I confirm what the correct namespaces to use are:
> impl.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI, "svg",
null);
> createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"rect");
These are good.
> element.setAttributeNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"stroke",
"red");
This is wrong, all SVG attributes are in the 'null' namespace:
element.setAttributeNS(null, "stroke", "red");
> This all seems to work fine.
This is surprising Batik should ignore 'stroke' in the SVG
namespace...
> With my own defined shapes I use the following:
>
> Element defs = doc.createElementNS(SVGDOMImplementation.
> SVG_NAMESPACE_URI, SVG12Constants.SVG_DEFS_TAG);
> Element path_star_filled = doc.
> createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
SVG12Constants.SVG_PATH_TAG);
The above are fine, but all the setAttributeNS calls should be null:
path_star_filled.setAttributeNS(null, "id", STAR_FILLED);
path_star_filled.setAttributeNS(null,"stroke-width", "0.3");
path_star_filled.setAttributeNS(null,"stroke", "black");
path_star_filled.setAttributeNS(null,"d", "M0,0.9 [...], z");
> defs.appendChild(path_star_filled);
> And when I make a call to use one of my defined elements I use the
following:
>
> Element plotCh = doc.createElementNS(SVGDOMImplementation.
> SVG_NAMESPACE_URI,SVG12Constants.SVG_USE_TAG);
This is fine.
> plotCh.setAttributeNS
> (SVGDOMImplementation.SVG_NAMESPACE_URI,
> "xlink:href", "#" + type);
This needs to set the 'href' attribute in the
XLINK namespace (it's an xlink attribute).
import org.apache.batik.util.XMLConstants;
plotCh.setAttributeNS
(XMLConstants.XLINK_NAMESPACE_URI,
"xlink:href", "#" + type);
> plotCh.setAttributeNS(SVGDOMImplementation.
> SVG_NAMESPACE_URI,"width", new Double(w).toString() + "%");
One again should be in 'null' namespace (SVG attribute).
> Am I using the wrong name space for my defined elements?
> Im not sure if its in the definition, or the calling of
> my definition, or both?
Your element stuff looks fine, but your attributes are
problematic.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
RE: Export to JPG error
Posted by Dylan Browne <db...@mango-solutions.com>.
Hi,
I've tried playing with the namespaces I use, but still get various errors.
Can I confirm what the correct namespaces to use are:
--------------------------------------------------------------
I create my SVG document using:
SVGDocument doc = (SVGDocument)
impl.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", null);
--------------------------------------------------------------
Within the document I create SVG Elements using, for example:
createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"rect");
--------------------------------------------------------------
And I set attributes on those elements using, for example:
element.setAttributeNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"stroke",
"red");
This all seems to work fine.
--------------------------------------------------------------
With my own defined shapes I use the following:
Element defs =
doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
SVG12Constants.SVG_DEFS_TAG);
Element path_star_filled =
doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
SVG12Constants.SVG_PATH_TAG);
path_star_filled.setAttributeNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"id",
STAR_FILLED);
path_star_filled.setAttributeNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"stro
ke-width", "0.3");
path_star_filled.setAttributeNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"stro
ke", "black");
path_star_filled
.setAttributeNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"d",
"M0,0.9 -0.2205,0.27 -0.9,0.27
-0.3645,-0.144 -0.63,-0.9 0,-0.432 0.63,-0.9 0.36,-0.144 0.9,0.27
0.2205,0.27,z");
defs.appendChild(path_star_filled);
--------------------------------------------------------------
And when I make a call to use one of my defined elements I use the
following:
Element plotCh =
doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,SVG12Constants.SV
G_USE_TAG);
plotCh.setAttributeNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"xlink:href",
"#" + type);
plotCh.setAttributeNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"width", new
Double(w).toString() + "%");
--------------------------------------------------------------
Am I using the wrong name space for my defined elements? Im not sure if its
in the definition, or the calling of my definition, or both?
Thanks in advance for any help,
Gratefully,
Dylan
RE: Export to JPG error
Posted by th...@kodak.com.
Hi Dylan,
"Dylan Browne" <db...@mango-solutions.com> wrote on 05/26/2006 05:26:43
AM:
> One change I made was to attempt to assign correct namespaces to
> the document and its elements, so it may be something to do with that?
Sounds likely.
> my histogram (containing SVG defined Rects) renders fine,
> my scatter plot (containing my own definition of #circle) does not.
Sounds like you aren't using/setting up the XLink namespace properly.
> I define my circle like this:
>
> Element circle_light = doc.createElementNS
> (Config.SVG_NAMESPACE,
> SVG12Constants.SVG_PATH_TAG);
The element creation looks good.
Are all your elements created through the DOM?
> circle_light.setAttribute("id", CIRCLE_BLANK);
Do you take care to use 'setAttributeNS' for the
attributes in other namespaces (xmlns:xlink, xlink:href)?
In fact you should use setAttributeNS for all attributes
in a namespace aware application, but for all SVG attributes
you use 'null' as the namespace, in Batik this doesn't matter
but in other DOM implementations it might:
circle_light.setAttributeNS(null, "id", CIRCLE_BLANK);
> The method I use to stream is this:
I don't think the problem is with the streaming it's
with the document construction.
> "Dylan Browne" <db...@mango-solutions.com> wrote on 05/19/2006
10:41:58
> AM:
>
> > I'm getting an error when attempting to export an SVG Document to JPEG
> > (or other image format). I've included the top of the stack trace
below.
> > Basically the essence of the error is that:
> >
> > The attribute "xlink:href" of the element <use> is required
> >
> > <use fill-opacity="0.2" xmlns:xlink="http://www.w3.org/1999/xlink"
> >
> > onmousedown="select_group(evt,true,90.6912,202.90311885986404);"
> > stroke="blue" xlink:href="#circle"
> >
> > onmouseover="select_point(evt,true,90.6912,202.90311885986404,
> 'DOSE =
> > 0.00','IRESP =
> > 106.89','ID','1.0',0.0,106.88575287553);"
> > transform="translate(90.6912,202.90311885986404)scale(5.0)"
> > width="5.0%" xlink:show="embed" xlink:type="simple"
> > fill="blue"
> > onmouseup="deselect_group(evt,true);" height="5.0%"
> >
> > onmouseout="deselect_point(evt,true);deselect_group(evt,true);"
> > xlink:actuate="onLoad"/>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> [attachment "svgFailsToConvertToJPG.svg" deleted by Thomas E.
> DeWeese/449433/EKC]
> ---------------------------------------------------------------------
> 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: Export to JPG error
Posted by Dylan Browne <db...@mango-solutions.com>.
Hi Thomas,
(Apologies for this long email....)
Sorry for the delay in replying, I've been trying out some things to see if
I can understand what is happening here. I previously was able to export to
JPG, so obviously some code change I have made in the last two weeks has
broken it. One change I made was to attempt to assign correct namespaces to
the document and its elements, so it may be something to do with that?
(Although that may be a red herring..)
I've attached a complete SVG file which gives the stack trace as first
reported. (If you want to actually view the SVG, you'll need my style sheet
too, let me know if that's helpful and I can send on).
Another thing that puzzles me is that using the same code I am able to
produce another SVG document (containing different Elements) which exports
to JPEG fine. Basicallly we are creating a graphing application... my
histogram (containing SVG defined Rects) renders fine, my scatter plot
(containing my own definition of #circle) does not.
--------------------------------------------------------------------
I define my circle like this:
Element circle_light =
doc.createElementNS(Config.SVG_NAMESPACE,
SVG12Constants.SVG_PATH_TAG);
circle_light.setAttribute("id", CIRCLE_BLANK);
circle_light.setAttribute("stroke-width", "0.2");
circle_light.setAttribute("fill", "white");
circle_light.setAttribute("d", "M0.4,-0.4 a0.7,0.7 0 0.7,0
0.1,0.1 z");
defs.appendChild(circle_light);
--------------------------------------------------------------------
I specify my namespace like this, then refer to it using my variable
throughout my code:
public static final String SVG_NAMESPACE =
SVGDOMImplementation.SVG_NAMESPACE_URI;
I assign the namespace both to the document, and to the elements I create
within it. Is that correct?
---------------------------------------------------------------------
The method I use to stream is this:
public void streamSVGIntoImageFormat(SVGDocument doc, String
mimeType) {
try {
ImageTranscoder t = null;
if (mimeType.equals(Config.JPEG)) {
t = new JPEGTranscoder();
t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(.8));
} else if (mimeType.equals(Config.PNG)) {
t = new PNGTranscoder();
} else if (mimeType.equals(Config.TIFF)) {
t = new TIFFTranscoder();
} else {
logger.error("ERROR: A request to stream an
image was recieved with an unsupported mime type: "
+ mimeType);
return;
}
TranscoderInput input = new TranscoderInput(doc);
OutputStream ostream = new
FileOutputStream("c:\\out." + mimeType);
TranscoderOutput output = new
TranscoderOutput(ostream);
t.transcode(input, output);
ostream.flush();
ostream.close();
byte[] bytes = getBytesFromFile(new File("c:\\out."
+ mimeType));
context.setAttribute("jpegbytes", bytes);
context.setAttribute("mimeType", mimeType);
} catch (Exception e) {
e.printStackTrace();
logger.error("Error in streaming SVG because " +
e.getMessage(), e.getCause());
}
}
------------------------------------------------------------------------
Thanks in advance for any help, this one has got me puzzled.
Kind regards,
Dylan
-----Original Message-----
From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com]
Sent: 21 May 2006 18:51
To: batik-users@xmlgraphics.apache.org
Cc: batik-users@xmlgraphics.apache.org
Subject: Re: Export to JPG error
Hi Dylan,
The single element looks ok, can you provide a complete example that shows
the problem?
Also do you get this problem with the included svgrasterizer application
or just your
'stream' application?
"Dylan Browne" <db...@mango-solutions.com> wrote on 05/19/2006 10:41:58
AM:
> I'm getting an error when attempting to export an SVG Document to JPEG
(or
> other image format). I've included the top of the stack trace below.
> Basically the essence of the error is that:
>
> The attribute "xlink:href" of the element <use> is required
>
> <use fill-opacity="0.2" xmlns:xlink="http://www.w3.org/1999/xlink"
>
> onmousedown="select_group(evt,true,90.6912,202.90311885986404);"
> stroke="blue" xlink:href="#circle"
>
> onmouseover="select_point(evt,true,90.6912,202.90311885986404,
'DOSE =
> 0.00','IRESP =
> 106.89','ID','1.0',0.0,106.88575287553);"
> transform="translate(90.6912,202.90311885986404)scale(5.0)"
> width="5.0%" xlink:show="embed" xlink:type="simple"
> fill="blue"
> onmouseup="deselect_group(evt,true);" height="5.0%"
>
> onmouseout="deselect_point(evt,true);deselect_group(evt,true);"
> xlink:actuate="onLoad"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: Export to JPG error
Posted by th...@kodak.com.
Hi Dylan,
The single element looks ok, can you provide a complete example that shows
the problem?
Also do you get this problem with the included svgrasterizer application
or just your
'stream' application?
"Dylan Browne" <db...@mango-solutions.com> wrote on 05/19/2006 10:41:58
AM:
> I'm getting an error when attempting to export an SVG Document to JPEG
(or
> other image format). I've included the top of the stack trace below.
> Basically the essence of the error is that:
>
> The attribute "xlink:href" of the element <use> is required
>
> <use fill-opacity="0.2" xmlns:xlink="http://www.w3.org/1999/xlink"
>
> onmousedown="select_group(evt,true,90.6912,202.90311885986404);"
> stroke="blue" xlink:href="#circle"
>
> onmouseover="select_point(evt,true,90.6912,202.90311885986404,
'DOSE =
> 0.00','IRESP =
> 106.89','ID','1.0',0.0,106.88575287553);"
> transform="translate(90.6912,202.90311885986404)scale(5.0)"
> width="5.0%" xlink:show="embed" xlink:type="simple"
> fill="blue"
> onmouseup="deselect_group(evt,true);" height="5.0%"
>
> onmouseout="deselect_point(evt,true);deselect_group(evt,true);"
> xlink:actuate="onLoad"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org