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 maria teresa <ma...@isti.cnr.it> on 2003/10/09 11:28:21 UTC
Adding raster images
Hi,
I am developing a Java application that has to meet the following requirements:
1) load and display an SVG image on a JSVGCanvas;
2) when mouse is double clicked, a small jpg image should appear on the
canvas at
the coordinates where double click occurs;
3) the SVG file should be modified in order to embed that image in the same
position.
Actually, I have no idea about how to achieve requirement 3).
I am quite new to Batik, and I don't know its API very well,
especially the classes/interfaces that deal with the DOM.
Any suggestion would be really appreciated!!
Thank you,
mt
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: Adding raster images
Posted by Tonny Kohar <to...@kiyut.com>.
hi,
you could do something like this:
- since JSVGCanvas is a JComponent, you can add mouse listener
- on the mouse click event
SVDocument doc = canvas.getSVGDocument();
// create the image
SVGImageElement imgElt = (SVGImageElement)doc.createElement("img");
// set the image attribute
imgElt.setAttributeNS(xlinkNs,etc,etc);
imgElement.setAttributeNS(null,xAttr,xCoord);
imgElement.setAttributeNS(null,yAttr,yCoord);
...
// put the image element into svg doc
SVGSVGElement svgElt = doc.getSVGElement();
svgElt.append(imgElt);
// refresh the canvas. sorry forget the syntax :)
The difficult part is matching the screen coordinate with the transform
& viewbox of the svgDoc, including the current zoom stage
Regards
Tonny Kohar
http://www.kiyut.com
On Thu, 2003-10-09 at 16:28, maria teresa wrote:
> Hi,
> I am developing a Java application that has to meet the following requirements:
> 1) load and display an SVG image on a JSVGCanvas;
> 2) when mouse is double clicked, a small jpg image should appear on the
> canvas at
> the coordinates where double click occurs;
> 3) the SVG file should be modified in order to embed that image in the same
> position.
>
> Actually, I have no idea about how to achieve requirement 3).
>
> I am quite new to Batik, and I don't know its API very well,
> especially the classes/interfaces that deal with the DOM.
> Any suggestion would be really appreciated!!
>
> Thank you,
> mt
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org