[EMAIL PROTECTED] wrote:

My question is:-
I have created a servlet which creates a SVG document and this SVG Stream I
show on the my jsp page as an embeded object. The SVG document which I
created is Simple block diagram which is generated at run time. My
requirement is to add a onMouseover event to each of this blocks in SVG to
show some notes about the block . ( Just like "alt" message on html image
tag ). Following is the code which i used to create the block diagram which
is downloaded from you side.

Really the only way to do this is to manage to creation of the document somewhat manually. The basic idea is to call getRoot after each object you want to annotate, the object just drawn will be the lastChild of the element returned - so you can add attributes etc. Then append this 'root' to the first root you get (or some other root SVG element you create elsewhere).

   The way the SVGGraphics2D works it clears it's contents when
you call getRoot (a bit like a stream clears a char when you call
getChar) so you can just keep drawing and get a 'clean slate'.

   BTW if the content is displayed in Batik it will display the
contents of 'desc' and 'title' in a Java tooltip automatically.


                  DOMImplementation domImpl =
SVGDOMImplementation.getDOMImplementation();
                  String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
                  Document document =     domImpl.createDocument(svgNS,
"svg", null);

                        SVGGraphics2D svgGraphicsEnvironment = new
SVGGraphics2D(document);
                  svgGraphicsEnvironment.setSVGCanvasSize( new
Dimension(width+10, height+10)      );

                  mondrian.paint( svgGraphicsEnvironment );

                  ByteArrayOutputStream baos = new ByteArrayOutputStream(
8192 );
                  Writer svgOutput = new OutputStreamWriter(baos, "UTF-8");
                        svgGraphicsEnvironment.stream(svgOutput, true);

                                                  //Adding block
                  svgGraphicsEnvironment.drawRect(0,100, 200 , 300 );

                    if (imgType.equals("svg")) {
                                  emitSVG( request, response,
baos.toString() );
                   }else{
                        if (request.getHeader("Accept").indexOf("png") >=
0){
                              emitPNG( request, response, baos.toString()
);
                        }else{
                              emitJPG( request, response, baos.toString()
);
                        }
                            }


Any code sample would be of great help. Thanks in advance.

Thanks & Regards,
Srini


This communication is for informational purposes only. It is not intended
as an offer or solicitation for the purchase or sale of any financial
instrument or as an official confirmation of any transaction. All market prices,
data and other information are not warranted as to completeness or accuracy and
are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries and affiliates



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to