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 Rolf Jordi <ma...@exfalsio.org> on 2003/10/10 14:37:20 UTC

problem with event

Hi,
i have to do a editor for svg file.
i use the JSVGCanvas to display my svg file and i have add EventListener
to all the Elements i want to edit but the even cannt be fired on some
element because  they are very thin(the element are
paths) . It works on some element than are larger.

I am looking for a way to get all the svg elements that are draw at a
point in the SVGDocument. I dont know how to do this. If someone can
help, i thanks him already

Sorry for my bad english
And To the people than do Batik: Thank you for doing it

	Rolf Jordi


here is the EventListenr that are added to the Element svgel:

svgel.addEventListener("click",new MyEventListener(),false);

and the EventListener:
public class MyEventListener implements EventListener{

	public void handleEvent(Event arg0) {
		SVGElement el = (SVGElement) arg0.getTarget();

		up.getUpdateRunnableQueue().invokeLater(
				new AddAttributeNode(arg0.getTarget(),"opacity", "0.5"));		
				//AddAttributeNode just add a attribute using the
				//UpdateManager
	}
}

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: problem with event

Posted by Thomas DeWeese <Th...@Kodak.com>.
Rolf Jordi wrote:

> Hi,
> i have to do a editor for svg file.
> i use the JSVGCanvas to display my svg file and i have add EventListener
> to all the Elements i want to edit but the even cannt be fired on some
> element because  they are very thin(the element are
> paths) . It works on some element than are larger.

Hi Rolf,

   I take it the paths are 'stroked'?  If so the only real
way to 'fix' this is to have a hidden copy of the
path with a wider stroke.  If they are only filled (and just
happen to be very thin areas) you can just set the stroke="none"
but provide a "wide" stroke-width.

<g stroke-width="0.001" >
   <path id="foo1" d="..."/>
   <use xlink:href="#foo1" stroke-width="1"
        visibility="hidden" pointer-events="stroke"/>
</g>

    In the above it is important that the stroke-width _not_
be set on the path (otherwise it will override the stroke-width
on the use element).

> I am looking for a way to get all the svg elements that are draw at a
> point in the SVGDocument. I dont know how to do this. If someone can
> help, i thanks him already

   There are some method in the SVG DOM that allow you to get
information like this.  But they aren't yet implemented in Batik.
You can still get this information by using the GraphicsNode interface
from the batik.gvt package directly.  You can get the GVT tree for the
SVG document from the Canvas.

> 
> Sorry for my bad english
> And To the people than do Batik: Thank you for doing it

    Thanks!
> 
> 	Rolf Jordi
> 
> 
> here is the EventListenr that are added to the Element svgel:
> 
> svgel.addEventListener("click",new MyEventListener(),false);
> 
> and the EventListener:
> public class MyEventListener implements EventListener{
> 
> 	public void handleEvent(Event arg0) {
> 		SVGElement el = (SVGElement) arg0.getTarget();
> 
> 		up.getUpdateRunnableQueue().invokeLater(
> 				new AddAttributeNode(arg0.getTarget(),"opacity", "0.5"));		
> 				//AddAttributeNode just add a attribute using the
> 				//UpdateManager
> 	}
> }
> 
> ---------------------------------------------------------------------
> 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