Ah, but I drawn the circles after the document was loaded...?


> Well, the JSVGCanvas is nothing but a visual representation of what's in
> the SVGDocument.  If your circle is shown on the screen, it's gotta be
> part of that document.  So if you want to find all the circles and
> attach mouse events to them, I'd do something like this:
>
> SVGDocument svgDocument = jsvgCanvas.getDocument();
>
> // I'm not sure what's actually on your document, but it should be
> circle or
> // ellipse.
> NodeList circleList = svgDocument.getElementsByTagName("circle");
> for (int count = 0; count < circleList.getLength(); count++) {
>     EventTarget eventTarget = (EventTarget) circleList.item(count);
>     eventTarget.addEventListener(...);
> }
>
> Of course you only want to do this once; you don't want to add a new
> EventListener more than once per element.
>
> I like Thomas's solution better; attach one event listener to the root
> of your SVG document (svgDocument.getDocumentElement()) and either turn
> off mouse events for all the other elements and on for the needed
> elements (attribute pointer-events: none/visible) or identify the
> elements that should be clicked in some fashion.
>
> Michael Bishop
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Monday, February 27, 2006 1:26 PM
> To: [email protected]
> Subject: RE: Red Spots
>
> yes, it does but how does that work?
>
>
>
>> Well you're not adding them to a document in the file system, but the
>> JSVGCanvas certainly has a reference to an SVGDocument in memory,
> right?
>>
>> Michael Bishop
>>
>> -----Original Message-----
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>> Sent: Monday, February 27, 2006 1:18 PM
>> To: [email protected]
>> Subject: RE: Red Spots
>>
>> Hi there!
>>
>> I can't make the spots part of the document, because they are drawn
>> after
>> getting the information from a database (Accident database)  ...is
> there
>> a
>> way when a mouse clicks on any of the spots to activate an event?
>>
>> ThankU
>>
>> yasmin
>>
>>
>>
>>
>>
>>> Hi Yasmin,
>>>
>>> [EMAIL PROTECTED] wrote on 02/27/2006 12:42:09 PM:
>>>
>>>> ...I've drawn the circles on the canvas, they are not part of my svg
>>>> document such that the actual file is not altered, the the circles
>> are
>>> not
>>>> individual elements - any ideas :(
>>>
>>>    Yes, make them part of your document ;)
>>>    Really this is the simplest thing.  If you want to minimize the
>>> 'impact' on the original document put all the circle in a special
>> group
>>> (probably dynamically created) so you can just delete the group to
>> 'reset'
>>> the document.  This way you can let the SVG engine do all the event
>>> tracking.
>>>
>>>    You could add an event listener (mouse move or the like) to the
>>> rootmost SVG element and you will get notified of any mouse event
>>> over any element in the document.  You could then manually check
> these
>>> points against your circles.  But this seems like a bunch of extra
>> work
>>> for nothing.
>>>
>>>>
>>>> yasmin
>>>>
>>>>
>>>> > Hello,
>>>> >      For events, I attach an event to the entire document.  For
>>>> > individual elements, this may work.  You'll need to get your
> circle
>> as
>>>> > an org.w3c.dom.Element.
>>>> >
>>>> > EventTarget eventTarget = (EventTarget) yourElement;
>>>> > eventTarget.addEventListener(SVGConstants.SVG_EVENT_MOUSEDOWN, new
>>>> > YourEventListener(), false);
>>>> >
>>>> > Michael Bishop
>>>> >
>>>> > -----Original Message-----
>>>> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>>>> > Sent: Monday, February 27, 2006 12:13 PM
>>>> > To: [email protected]
>>>> > Subject: Red Spots
>>>> >
>>>> >
>>>> > Hi Michael Bishop,
>>>> >
>>>> > I have been beavering on my project and have successfully
> converted
>> my
>>>> > screen coordinates to documents and can interact with my database
>> to
>>>> > retrieve the information for the current view and show red spots
> on
>>> the
>>>> > areas where accidents have happend on the map ...now I need to
> make
>>> the
>>>> > red spots active so when a user clicks on a red spot the relevant
>>>> > information about that particular accident is displayed ...i
> simply
>>> used
>>>> > the following code to create the red spot:
>>>> >
>>>> > Graphics spot = canvas.getGraphics();
>>>> >                       spot.setColor(Color.RED);
>>>> >                       spot.fillOval(x,y,22,22);
>>>> >                       spot.dispose();
>>>> >
>>>> > but i cant assign an ActionEvent to the spot ...Any ideas?
>>>> >
>>>> > Many thanks in advance :)
>>>> >
>>>> > Yasmin
>>>> >
>>>> >
>>>> >
>>>> >
>>>> >> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
>>>> >> <HTML>
>>>> >> <HEAD>
>>>> >> <META HTTP-EQUIV="Content-Type" CONTENT="text/html;
>>>> > charset=iso-8859-1">
>>>> >>
>>>> >>
>>>> >> <META NAME="Generator" CONTENT="MS Exchange Server version
>>>> > 6.5.7226.0">
>>>> >> <TITLE>RE: Coordinates</TITLE>
>>>> >> </HEAD>
>>>> >> <BODY>
>>>> >> <DIV id=idOWAReplyText99836 dir=ltr>
>>>> >> <DIV dir=ltr><FONT face=Arial color=#000000 size=2>Element
> element
>>>
>>>> >>
>> svgDocument.createElement(SVGConstants.SVG_CIRCLE_TAG);</FONT></DIV>
>>>> >> <DIV dir=ltr><FONT face=Arial
>>>> >> size=2>element.setAttribute(SVGConstants.SVG_CX_ATTR,
>>>> >> xPosition);</FONT></DIV>
>>>> >> <DIV dir=ltr><FONT face=Arial
>>>> >> size=2>element.setAttribute(SVGConstants.SVG_CY_ATTR,
>>>> >> yPosition);</FONT></DIV>
>>>> >> <DIV dir=ltr><FONT face=Arial
>>>> >> size=2>element.setAttribute(SVGConstants.SVG_R_ATTR,
>>>> > radius);</FONT></DIV>
>>>> >> <DIV dir=ltr><FONT face=Arial
>>>> >> size=2>element.setAttribute(SVGConstants.SVG_FILL_ATTR,
>>>> >> "red");</FONT></DIV>
>>>> >> <DIV dir=ltr><FONT face=Arial
>>>> >>
>> size=2>svgDocument.getDocumentElement.append(element);</FONT></DIV>
>>>> >> <DIV dir=ltr><FONT face=Arial size=2></FONT>&nbsp;</DIV>
>>>> >> <DIV dir=ltr><FONT face=Arial size=2>Use code completion or the
>> Batik
>>>> >> Javadoc.&nbsp; Most of those SVGConstants references are probably
>>>> >> wrong.</FONT></DIV>
>>>> >> <DIV dir=ltr><FONT face=Arial size=2></FONT>&nbsp;</DIV>
>>>> >> <DIV dir=ltr><FONT face=Arial size=2>Michael
>>> Bishop</FONT></DIV></DIV>
>>>> >> <DIV dir=ltr><BR>
>>>> >> <HR tabIndex=-1>
>>>> >> <FONT face=Tahoma size=2><B>From:</B> [EMAIL PROTECTED]
>>>> >> [mailto:[EMAIL PROTECTED]<BR><B>Sent:</B> Sun 2/19/2006
>> 3:07
>>>> >> PM<BR><B>To:</B>
>>> [email protected]<BR><B>Subject:</B>
>>>> > RE:
>>>> >> Coordinates<BR></FONT><BR></DIV>
>>>> >> <DIV>
>>>> >> <P><FONT size=2>me again!<BR><BR>...I think I don't need to
>> convert
>>>> > back
>>>> >> to
>>>> >> screen coordinates I should be<BR>able to use the document
>>>> > coordinates,
>>>> >> but how
>>>> >> can I draw a red-spot<BR>(filled circle) and a given location on
>> the
>>>> >> canvas?<BR><BR>ThankU in advance<BR><BR>yasmin<BR><BR>&gt;
>>>> > &lt;!DOCTYPE
>>>> >> HTML
>>>> >> PUBLIC "-//W3C//DTD HTML 3.2//EN"&gt;<BR>&gt;
> &lt;HTML&gt;<BR>&gt;
>>>> >> &lt;HEAD&gt;<BR>&gt; &lt;META HTTP-EQUIV="Content-Type"
>>>> >> CONTENT="text/html;
>>>> >> charset=iso-8859-1"&gt;<BR>&gt;<BR>&gt;<BR>&gt; &lt;META
>>>> > NAME="Generator"
>>>> >> CONTENT="MS Exchange Server version 6.5.7226.0"&gt;<BR>&gt;
>>>> >> &lt;TITLE&gt;Coordinates&lt;/TITLE&gt;<BR>&gt;
>> &lt;/HEAD&gt;<BR>&gt;
>>>> >> &lt;BODY&gt;<BR>&gt; &lt;DIV id=idOWAReplyText8269
>>> dir=ltr&gt;<BR>&gt;
>>>> >> &lt;DIV
>>>> >> dir=ltr&gt;&lt;FONT face=Arial color=#000000 size=2&gt;Not sure;
>>>> > haven't
>>>> >> done<BR>&gt; it in<BR>&gt; reverse.&amp;nbsp; There is a method
>> for
>>> an
>>>> >> SVGLocatable called getScreenCTM<BR>&gt; that<BR>&gt; may be of
>>>> >> use.&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt; &lt;DIV dir=ltr&gt;&lt;FONT
>>>> >> face=Arial
>>>> >> size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;<BR>&gt; &lt;DIV
>>>> >> dir=ltr&gt;&lt;FONT face=Arial size=2&gt;Michael
>>>> >> Bishop&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;<BR>&gt; &lt;DIV
>>>> >> dir=ltr&gt;&lt;BR&gt;<BR>&gt; &lt;HR tabIndex=-1&gt;<BR>&gt;
>> &lt;FONT
>>>> >> face=Tahoma size=2&gt;&lt;B&gt;From:&lt;/B&gt;
>>>> >> [EMAIL PROTECTED]<BR>&gt;
>>>> >> [<A
>>>> >>
>>>> >
>>>
>>
> href="mailto:[EMAIL PROTECTED]">mailto:[EMAIL PROTECTED]</A>
>>>> > ]&lt;BR&gt;&lt;B&gt;Sent:&lt;/B&gt;
>>>> >> Sun 2/19/2006 1:08<BR>&gt; PM&lt;BR&gt;&lt;B&gt;To:&lt;/B&gt;
>>>> >>
>>>> >
>>>
>>
> [email protected]&lt;BR&gt;&lt;B&gt;Subject:&lt;/B&gt;<
>>>> > BR>&gt;
>>>> >> Coordinates&lt;BR&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;/DIV&gt;<BR>&gt;
>>>> >> &lt;DIV&gt;<BR>&gt; &lt;P&gt;&lt;FONT size=2&gt;Hi Michael
>>>> >> Bishop,&lt;BR&gt;&lt;BR&gt;...I've converted my screen<BR>&gt;
>>>> > coordinates
>>>> >> to my
>>>> >> document coordinates - now&lt;BR&gt;I'm trying to convert<BR>&gt;
>>>> >> document<BR>&gt; coordinates to screen coordinate so that
>>>> > at&lt;BR&gt;that
>>>> >> point
>>>> >> on the map, I<BR>&gt; can draw<BR>&gt; a red_spot on the
>> canvas...any
>>>> >> ideas?&lt;BR&gt;&lt;BR&gt;ThankU in<BR>&gt;
>>>> >>
>>>> >
>>>
>>
> advance&lt;BR&gt;&lt;BR&gt;yasmin&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;---------
>>>> >
>>>
>>
> ------------------------------------------------------------&lt;BR&gt;To
>>>> > <BR>&gt;
>>>> >> unsubscribe, e-mail:
>>>> >>
>> [EMAIL PROTECTED]&lt;BR&gt;For<BR>&gt;
>>>> >> additional
>>>> >> commands, e-mail:<BR>&gt;
>>>> >>
>>>> >
>>>
>>
> [EMAIL PROTECTED]&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;
>>>> > &lt;/DIV&gt;<BR>&gt;<BR>&gt;
>>>> >> &lt;/BODY&gt;<BR>&gt;
>>>> >>
>>>> >
>>>
>>
> &lt;/HTML&gt;<BR><BR><BR><BR>-------------------------------------------
>>>> > --------------------------<BR>To
>>>> >> unsubscribe, e-mail:
>>>> > [EMAIL PROTECTED]<BR>For
>>>> >> additional commands, e-mail:
>>>> >> [EMAIL PROTECTED]<BR></FONT></P></DIV>
>>>> >>
>>>> >> </BODY>
>>>> >> </HTML>
>>>> >
>>>> >
>>>> >
>>>> >
>> ---------------------------------------------------------------------
>>>> > 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]
>>>> >
>>>> >
>>>> >
>>>>
>>>>
>>>>
>>>>
> ---------------------------------------------------------------------
>>>> 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]
>>>
>>>
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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]
>>
>>
>>
>
>
>
> ---------------------------------------------------------------------
> 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]
>
>
>



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

Reply via email to