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 ra...@blueyonder.co.uk on 2006/03/11 23:44:31 UTC

adding Elements to SVG Doc

Hi Javid,

I did initially try to add the red circles to the svg document
programatically, infact I think you emailed me a snippet of your code but
it doesn't work, the code compiles but does not display the red-circles, I
tried to repaint my canvas, that don't work... here's the code I'm using
maybe you might be able to spot where I'm making the error...


//I added this in my constructor
canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);

//The following code I added in my ActionListener triggred by a button

canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
Runnable() {

                      public void run()
                      {
                        SVGDocument doc = canvas.getSVGDocument();
                        String SVGNS = "http://www.w3.org/2000/svg";
                        Iterator i = spots.iterator();
                        Element g = doc.getElementById("circleGroup");
                       if (g == null)
                       {
                          g = doc.createElementNS(SVGNS,"g");
                          g.setAttributeNS(null, "id", "circleGroup");
                          doc.getRootElement().appendChild(g);
                       }


                        while (i.hasNext())
                        {
                          Point2D pt2d = (Point2D) i.next();
                          Element e = doc.createElementNS(SVGNS,"circle");
                          e.setAttributeNS(null,"cx",""+pt2d.getX());
                          e.setAttributeNS(null,"cy",""+pt2d.getY());
                          e.setAttributeNS(null,"r","8");
                          e.setAttributeNS(null,"fill","Red");
                          g.appendChild(e);
                        }
                      }
                      });

                      canvas.repaint();

Thx inadvance,

yasmin



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


Re: adding Elements to SVG Doc

Posted by ra...@blueyonder.co.uk.
Hi Thomas,

I just changed "spot" to "circle" but the red circles dnt appear on the
canvas ...I am not getting any errors - do I need to repaint() the canvas
- or could it be my svg file?

Tx

yasmin



> Hi Yasmin,
>
>     Your test code worked fine for me with one change, you had:
>
>                                 Element e =
> doc.createElementNS(SVGNS,"spot");
>
>     This isn't right you want:
>
>                                 Element e =
> doc.createElementNS(SVGNS,"circle");
>
>     Which is odd because an earlier e-mail had 'circle'
> I tested by opening 'samples/mapSpain.svg'.  I think two of your circles
> still didn't show because mapSpain isn't quite large enough but the ones
> that should show did.
>
> rafiqy@blueyonder.co.uk wrote on 03/12/2006 02:07:00 PM:
>
>> I've just attached the java file only!
>>
>> Tx
>> yasmin
>>
>>
>>
>>
>>
>>
>>
>> > Hi Yasmin,
>> >
>> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 10:45:17 AM:
>> >
>> >> Now when I run my code I get the following error:
>> >>
>> >> org.w3c.dom.DOMException: The current document is unable to create an
>> >> element of the requested type (namespace: http://www.w3.org/2000/svg,
>> >> name: spot).
>> >
>> >    Batik's DOM implementation prevents you from creating elements in
> the
>> > SVG Namespace that aren't part of the SVG specification.
>> >
>> >    As far as path forward, I would suggest taking the code to create
> the
>> > circles and put it in a small example that just puts of the canvas
>> > (with any old document) and a button that adds a list of preset
> circles.
>> >
>> >    Then with all the code together I can either spot the error or
>> > run it and debug why it isn't working for you.
>> >
>> >>
>> >>    at org.apache.batik.dom.AbstractNode.createDOMException(Unknown
>> > Source)
>> >>
>> >>    at
>> > org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(Unknown
>> >> Source)
>> >>
>> >>    at org.apache.batik.dom.svg.SVGOMDocument.createElementNS(Unknown
>> > Source)
>> >>
>> >>    at mypackage22.KeyAccidentClient$4.run(KeyAccidentClient.java:349)
>> >>
>> >>    at org.apache.batik.util.RunnableQueue.run(Unknown Source)
>> >>
>> >>    at java.lang.Thread.run(Thread.java:534)
>> >>
>> >> Pls advice.
>> >>
>> >> Thx
>> >>
>> >> yasmin
>> >>
>> >>
>> >>
>> >>
>> >> > Hi Yasmin,
>> >> >
>> >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36 AM:
>> >> >
>> >> >> When I tried putting a line to test if the code is running, the
> code
>> >> > does
>> >> >> run, but apparently it does not create any elements, here's what I
>> >> > tested:
>> >> >>
>> >> >> System.out.println("This is just testing :" +
>> >> > g.getAttribute("circleGroup"));
>> >> >>
>> >> >> and nothing prints for g.getAttribute ...
>> >> >
>> >> >    This is expected, I think you want to use:
>> >> >         g.getAttributeNS(null, "id");
>> >> >
>> >> >    This should result in the string 'circleGroup'.
>> >> >
>> >> >> > rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31 PM:
>> >> >> >
>> >> >> >> I did initially try to add the red circles to the svg document
>> >> >> >> programatically, infact I think you emailed me a snippet of
> your
>> > code
>> >> >> >> but it doesn't work, the code compiles but does not display the
>> >> >> >> red-circles, I tried to repaint my canvas, that don't work...
>> > here's
>> >> >> >> the code I'm using maybe you might be able to spot where I'm
>> > making
>> >> >> >> the error...
>> >> >> >
>> >> >> >    The code looks pretty good.  You aren't that far from a
>> >> >> > standalone example, this would help me help you...
>> >> >> >
>> >> >> >> //I added this in my constructor
>> >> >> >> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>> >> >> >
>> >> >> >    This must be done _before_ you set the document on the
> canvas.
>> >> >> >
>> >> >> >> //The following code I added in my ActionListener triggred by a
>> >> > button
>> >> >> >
>> >> >> >    Are you sure this code runs?  Some println's might help make
>> > sure
>> >> >> > that your spots list isn't empty for some reason, etc.  You
> don't
>> >> >> > need to 'repaint' the canvas.
>> >> >> >
>> >> >> >>
> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
>> >> >> >> Runnable() {
>> >> >> >>
>> >> >> >>                       public void run()
>> >> >> >>                       {
>> >> >> >>                         SVGDocument doc =
> canvas.getSVGDocument();
>> >> >> >>                         String SVGNS =
>> > "http://www.w3.org/2000/svg";
>> >> >> >>                         Iterator i = spots.iterator();
>> >> >> >>                         Element g =
>> >> > doc.getElementById("circleGroup");
>> >> >> >>                        if (g == null)
>> >> >> >>                        {
>> >> >> >>                           g = doc.createElementNS(SVGNS,"g");
>> >> >> >>                           g.setAttributeNS(null, "id",
>> >> > "circleGroup");
>> >> >> >>                           doc.getRootElement().appendChild(g);
>> >> >> >>                        }
>> >> >> >>
>> >> >> >>
>> >> >> >>                         while (i.hasNext())
>> >> >> >>                         {
>> >> >> >>                           Point2D pt2d = (Point2D) i.next();
>> >> >> >>                           Element e =
>> >> >> > doc.createElementNS(SVGNS,"circle");
>> >> >> >> e.setAttributeNS(null,"cx",""+pt2d.getX());
>> >> >> >> e.setAttributeNS(null,"cy",""+pt2d.getY());
>> >> >> >>                           e.setAttributeNS(null,"r","8");
>> >> >> >>                           e.setAttributeNS(null,"fill","Red");
>> >> >> >>                           g.appendChild(e);
>> >> >> >>                         }
>> >> >> >>                       }
>> >> >> >>                       });
>> >> >> >>
>> >> >> >>                       canvas.repaint();
>> >> >> >
>> >> >> >
>> >> >> >
>> > ---------------------------------------------------------------------
>> >> >> > 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
>> >> >
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> 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
>> >
>> >
>> >
>> [attachment "TestProgram.java" 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: adding Elements to SVG Doc

Posted by Urs Reupke <ur...@gmx.net>.
Hi,

sorry, I forgot about the NodeList.
Unfortunately, it doesn't use the Java Collections API,
but it's similiar in function.
The elements within are instance of Node, which is a subtype of Element.
You should be able to retrieve your SVG Circle Element by calling the 
"item" function as you would use "List.get(int index)" with a regular list.

What do you mean by "supposed to appear clickable"? If you want a 
special cursor to appear (like, for example, when hovering the mouse 
over an active hyperlink in a webpage) you have to tell Batik (which is 
what the first listener in the file I linked to does. Batik has simpler 
ways of doing it though, if you're content with standard cursors.)

HTH
-Urs

rafiqy@blueyonder.co.uk wrote:
> Hi there,
> 
> elt.getElementsByTagName returns NodeList, I tried this but nothing
> happens, btw are the red circles suppose to appear clickable?
> 
> 
> NodeList circleElement = elt.getElementsByTagName("circle");
> 
> Thx
> 
> yasmin
> 
>> Hi Yasmin,
>>
>> your code sample was:
>>> Element element = doc.getElementById("circleGroup");
>>>  EventTarget eventTarget = (EventTarget) element;
>>>  eventTarget.addEventListener("click",new CircleAction(),false);
>>>
>>>
>>>  class CircleAction implements EventListener
>>> {
>>>     public    void handleEvent(Event evt)
>>>         {
>>>                 Element elt = (Element) evt.getCurrentTarget();
>>>
>>>                 if (evt.getType() == "click")
>>>                 {
>>>                         elt.setAttributeNS("circle","fill","yellow");
>>>                 }
>>>         }
>> In here, you add a listener to a group(?) and afterwards, when the group
>> is clicked, try to set the attribute "fill" on the element "elt" in the
>> namespace "circle" to yellow.
>> Instead, what (I believe) you want to do is to set the attribute on the
>> element circle.
>> I have not tested it (and am not familiar with the W3C DOM API either,
>> using dom4j mainly), but maybe you could change the listeners code to:
>>
>>  > Element elt = (Element) evt.getCurrentTarget();
>>  > Element circleElement = elt.getElementByTagName("circle")
>>  > if (evt.getType() == "click") {
>>  >	circleElement.setAttributeNS(null,"fill","yellow");
>>  > }
>>
>> Oh, and maybe check for the eventtype before doing anything else,
>> possible saving some time at runtime.
>>
>> I've not followed your discussion in detail,
>> but maybe you can have a look at this class from my project:
>> http://cvs.sourceforge.net/viewcvs.py/anathema/CharmTree/src/net/sf/anathema/charmtree/listening/CharmTreeListening.java?view=markup
>>
>> Within, you'll find two EventListeners,"cursorTooltipInitListener" and
>> "selectionInvokingListener". The former acts on mouseover, but the
>> latter reacts on mouseclick events for the element it's over.
>> Within, the first part retrieves the target element.
>> (Ignore the special case of an TSpan-Element being clicked)
>> Then, an element ID is read from the synonymous attribute,
>> finally, an event is fired.
>>
>> Basically, you could use this (or very simliar code) for parsing the
>> document whenever a click event occurs and locating the target element
>> by hand, thus making sure you got the circle and only the circle to
>> operate upon.
>>
>> I guess they're way to complicated for what you intend to do, but maybe
>> they can help you figure out how to do it by stripping things away.
>>
>> Good luck with your task
>> -Urs
>>
>> ---------------------------------------------------------------------
>> 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: adding Elements to SVG Doc

Posted by ra...@blueyonder.co.uk.
Hi there,

elt.getElementsByTagName returns NodeList, I tried this but nothing
happens, btw are the red circles suppose to appear clickable?


NodeList circleElement = elt.getElementsByTagName("circle");

Thx

yasmin

> Hi Yasmin,
>
> your code sample was:
>> Element element = doc.getElementById("circleGroup");
>>  EventTarget eventTarget = (EventTarget) element;
>>  eventTarget.addEventListener("click",new CircleAction(),false);
>>
>>
>>  class CircleAction implements EventListener
>> {
>>     public    void handleEvent(Event evt)
>>         {
>>                 Element elt = (Element) evt.getCurrentTarget();
>>
>>                 if (evt.getType() == "click")
>>                 {
>>                         elt.setAttributeNS("circle","fill","yellow");
>>                 }
>>         }
>
> In here, you add a listener to a group(?) and afterwards, when the group
> is clicked, try to set the attribute "fill" on the element "elt" in the
> namespace "circle" to yellow.
> Instead, what (I believe) you want to do is to set the attribute on the
> element circle.
> I have not tested it (and am not familiar with the W3C DOM API either,
> using dom4j mainly), but maybe you could change the listeners code to:
>
>  > Element elt = (Element) evt.getCurrentTarget();
>  > Element circleElement = elt.getElementByTagName("circle")
>  > if (evt.getType() == "click") {
>  >	circleElement.setAttributeNS(null,"fill","yellow");
>  > }
>
> Oh, and maybe check for the eventtype before doing anything else,
> possible saving some time at runtime.
>
> I've not followed your discussion in detail,
> but maybe you can have a look at this class from my project:
> http://cvs.sourceforge.net/viewcvs.py/anathema/CharmTree/src/net/sf/anathema/charmtree/listening/CharmTreeListening.java?view=markup
>
> Within, you'll find two EventListeners,"cursorTooltipInitListener" and
> "selectionInvokingListener". The former acts on mouseover, but the
> latter reacts on mouseclick events for the element it's over.
> Within, the first part retrieves the target element.
> (Ignore the special case of an TSpan-Element being clicked)
> Then, an element ID is read from the synonymous attribute,
> finally, an event is fired.
>
> Basically, you could use this (or very simliar code) for parsing the
> document whenever a click event occurs and locating the target element
> by hand, thus making sure you got the circle and only the circle to
> operate upon.
>
> I guess they're way to complicated for what you intend to do, but maybe
> they can help you figure out how to do it by stripping things away.
>
> Good luck with your task
> -Urs
>
> ---------------------------------------------------------------------
> 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: adding Elements to SVG Doc

Posted by Urs Reupke <ur...@gmx.net>.
Hi Yasmin,

your code sample was:
> Element element = doc.getElementById("circleGroup");
>  EventTarget eventTarget = (EventTarget) element;
>  eventTarget.addEventListener("click",new CircleAction(),false);
> 
> 
>  class CircleAction implements EventListener
> {
>     public    void handleEvent(Event evt)
>         {
>                 Element elt = (Element) evt.getCurrentTarget();
> 
>                 if (evt.getType() == "click")
>                 {
>                         elt.setAttributeNS("circle","fill","yellow");
>                 }
>         }

In here, you add a listener to a group(?) and afterwards, when the group 
is clicked, try to set the attribute "fill" on the element "elt" in the 
namespace "circle" to yellow.
Instead, what (I believe) you want to do is to set the attribute on the 
element circle.
I have not tested it (and am not familiar with the W3C DOM API either, 
using dom4j mainly), but maybe you could change the listeners code to:

 > Element elt = (Element) evt.getCurrentTarget();
 > Element circleElement = elt.getElementByTagName("circle")
 > if (evt.getType() == "click") {
 >	circleElement.setAttributeNS(null,"fill","yellow");
 > }

Oh, and maybe check for the eventtype before doing anything else, 
possible saving some time at runtime.

I've not followed your discussion in detail,
but maybe you can have a look at this class from my project:
http://cvs.sourceforge.net/viewcvs.py/anathema/CharmTree/src/net/sf/anathema/charmtree/listening/CharmTreeListening.java?view=markup

Within, you'll find two EventListeners,"cursorTooltipInitListener" and 
"selectionInvokingListener". The former acts on mouseover, but the 
latter reacts on mouseclick events for the element it's over.
Within, the first part retrieves the target element.
(Ignore the special case of an TSpan-Element being clicked)
Then, an element ID is read from the synonymous attribute,
finally, an event is fired.

Basically, you could use this (or very simliar code) for parsing the 
document whenever a click event occurs and locating the target element 
by hand, thus making sure you got the circle and only the circle to 
operate upon.

I guess they're way to complicated for what you intend to do, but maybe 
they can help you figure out how to do it by stripping things away.

Good luck with your task
-Urs

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


Re: adding Elements to SVG Doc

Posted by th...@kodak.com.
Hi Yasmin,

rafiqy@blueyonder.co.uk wrote on 03/13/2006 04:44:27 AM:

> I read the DOM interface, but I still can't get the red circles to 
change
> the colour when clicked, here's my code ...I'm sorry for being a 
nuisance.
> 
> Element element = doc.getElementById("circleGroup");
>  EventTarget eventTarget = (EventTarget) element;
>  eventTarget.addEventListener("click",new CircleAction(),false);

   This looks fine.

>  class CircleAction implements EventListener
> {
>     public    void handleEvent(Event evt)
>         {
>                 Element elt = (Element) evt.getCurrentTarget();

        'getCurrentTarget()' will return the 'g' that you registered
the listener on.  'getTarget()' will return the 'circle' that was 
clicked (and caused the event).  That is why I suggested that you wanted
'getTarget()'.

>                 if (evt.getType() == "click")
>                 {
>                         elt.setAttributeNS("circle","fill","yellow");

      As Urs already pointed out, what you probably meant was:
                                elt.setAttributeNS(null, "fill", 
"yellow");

        However, I suspect the real problem is that you are setting the
fill color with the 'style' attribute when you construct the circle.
In this case you must set the fill color with the style attribute in
the click handler (or use the CSS SAC):

                                elt.setAttributeNS(null, "style", 
"fill:yellow");

        Personally for this case I would avoid using the style attribute
in either, and use the fill attribute for both in this case.

> >     Please read the DOM interfaces.  This is the third time you have
> > failed to lookup the interface that provides a method.  BTW most of 
> > the time you want to use evt.getTarget().
> >
> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 08:08:23 PM:
> >
> >> Hi Thomas,
> >>
> >> This is the code for my CircleAction,
> >>
> >>  public class CircleAction implements EventListener
> >> {
> >>         public void handleEvent(Event evt)
> >>         {
> >>                 Element elt = (Element) evt.getCurrentTarget();
> >>
> >>                 if (evt.getType() == "click")
> >>                 {
> >>                         elt.setAttributeNS(SVG_NS, "fill", "yellow");
> >>                 }
> >>         }
> >> }
> >>
> >> The evt.getCurrentTarget() is not recognised?
> >>
> >> Thx
> >>
> >> yasmin
> >>
> >>
> >>
> >>
> >> > Hi Yasmin,
> >> >
> >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:24:15 PM:
> >> >
> >> >> I've tried this, but again I have a problem with the paranthesis 
of
> > the
> >> >> addEventListener?
> >> >
> >> >    What is the error?
> >> >    Does CircleAction implement the DOM EventListener interface?
> >> >
> >> >         org.w3c.dom.events.EventListener;
> >> >
> >> >
> >> >>  NodeList circleList = doc.getElementsByTagName("circle");
> >> >
> >> >    You only need to add one event listener to the circleGroup.
> >> > Then use evt.getTarget() to know what circle it is.
> >> >
> >> >>  for (int count = 0; count < circleList.getLength(); count++) {
> >> >>  EventTarget eventTarget = (EventTarget) circleList.item(count);
> >> >>  eventTarget.addEventListener("click",new CircleAction(),false);
> >> >> }
> >> >>
> >> >> Thx
> >> >>
> >> >> yasmin
> >> >>
> >> >>
> >> >>
> >> >> > Hi Yasmin,
> >> >> >
> >> >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 05:54:00 PM:
> >> >> >
> >> >> >> Now I'm trying to make the red circles clickable, I've tried 
this
> >> > code
> >> >> > but
> >> >> >> for some reason I can't get the element.addEventListener?
> >> >> >
> >> >> >    addEventListener is on the EventTarget interface.  So you
> >> >> > will need to cast the element to add the listener.
> >> >> >
> >> >> >>
> >> >> >> Element element = doc.getElementById("circleGroup");
> >> >> >> element.addEventListener("click", new CircleAction(), false);
> >> >> >>
> >> >> >> Thx
> >> >> >>
> >> >> >> yasmin
> >> >> >>
> >> >> >> > Hi Yasmin,
> >> >> >> >
> >> >> >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 03:44:08 PM:
> >> >> >> >
> >> >> >> >> Here's the heading of my svg file, can you see anything that
> > might
> >> > be
> >> >> >> >> causing the red circles not appearing?
> >> >> >> >
> >> >> >> >>   viewBox="424000.000 -518000 2000 2000"
> >> >> >> >
> >> >> >> >    Your viewBox certainly doesn't intersect any of the coords
> >> >> >> > in your example source code.  When you add the elements to 
the
> >> >> >> > Document you need to place your circles in the 'maps' 
coordinate
> >> >> >> > system (which normally is simplier for you).
> >> >> >> >
> >> >> >> >    So the cx & cy for a circle should look something like
> >> >> >> >         cx="425100"
> >> >> >> >         cy="-519100"
> >> >> >> >
> >> >> >> >> >     One other comment on the code.  I would suggest using 
the
> >> >> >> >> > JSVGScrollPane
> >> >> >> >> > instead of the swing JScrollPane.  The JScrollPane works 
in
> > most
> >> >> > cases
> >> >> >> >> > it tends to be much less efficient than the 
JSVGScrollPane.
> >> >> >> >> >
> >> >> >> >> > thomas.deweese@kodak.com wrote on 03/12/2006 03:01:19 PM:
> >> >> >> >> >
> >> >> >> >> >> Hi Yasmin,
> >> >> >> >> >>
> >> >> >> >> >>     Your test code worked fine for me with one change, 
you
> > had:
> >> >> >> >> >>
> >> >> >> >> >>                                 Element e =
> >> >> >> >> >> doc.createElementNS(SVGNS,"spot");
> >> >> >> >> >>
> >> >> >> >> >>     This isn't right you want:
> >> >> >> >> >>
> >> >> >> >> >>                                 Element e =
> >> >> >> >> >> doc.createElementNS(SVGNS,"circle");
> >> >> >> >> >>
> >> >> >> >> >>     Which is odd because an earlier e-mail had 'circle'
> >> >> >> >> >> I tested by opening 'samples/mapSpain.svg'.  I think two 
of
> >> > your
> >> >> >> > circles
> >> >> >> >> >> still didn't show because mapSpain isn't quite large 
enough
> > but
> >> >> > the
> >> >> >> > ones
> >> >> >> >> >> that should show did.
> >> >> >> >> >>
> >> >> >> >> >> rafiqy@blueyonder.co.uk wrote on 03/12/2006 02:07:00 PM:
> >> >> >> >> >>
> >> >> >> >> >> > I've just attached the java file only!
> >> >> >> >> >> >
> >> >> >> >> >> > Tx
> >> >> >> >> >> > yasmin
> >> >> >> >> >> >
> >> >> >> >> >> >
> >> >> >> >> >> >
> >> >> >> >> >> >
> >> >> >> >> >> >
> >> >> >> >> >> >
> >> >> >> >> >> >
> >> >> >> >> >> > > Hi Yasmin,
> >> >> >> >> >> > >
> >> >> >> >> >> > > rafiqy@blueyonder.co.uk wrote on 03/12/2006 10:45:17 
AM:
> >> >> >> >> >> > >
> >> >> >> >> >> > >> Now when I run my code I get the following error:
> >> >> >> >> >> > >>
> >> >> >> >> >> > >> org.w3c.dom.DOMException: The current document is
> > unable
> >> > to
> >> >> >> > create
> >> >> >> >> > an
> >> >> >> >> >> > >> element of the requested type (namespace:
> >> >> >> >> > http://www.w3.org/2000/svg,
> >> >> >> >> >> > >> name: spot).
> >> >> >> >> >> > >
> >> >> >> >> >> > >    Batik's DOM implementation prevents you from 
creating
> >> >> > elements
> >> >> >> > in
> >> >> >> >> >
> >> >> >> >> >> the
> >> >> >> >> >> > > SVG Namespace that aren't part of the SVG 
specification.
> >> >> >> >> >> > >
> >> >> >> >> >> > >    As far as path forward, I would suggest taking the
> > code
> >> > to
> >> >> >> > create
> >> >> >> >> >
> >> >> >> >> >> the
> >> >> >> >> >> > > circles and put it in a small example that just puts 
of
> > the
> >> >> >> > canvas
> >> >> >> >> >> > > (with any old document) and a button that adds a list 
of
> >> >> > preset
> >> >> >> >> >> circles.
> >> >> >> >> >> > >
> >> >> >> >> >> > >    Then with all the code together I can either spot 
the
> >> > error
> >> >> > or
> >> >> >> >> >> > > run it and debug why it isn't working for you.
> >> >> >> >> >> > >
> >> >> >> >> >> > >>
> >> >> >> >> >> > >>    at
> >> >> >> > org.apache.batik.dom.AbstractNode.createDOMException(Unknown
> >> >> >> >> >> > > Source)
> >> >> >> >> >> > >>
> >> >> >> >> >> > >>    at
> >> >> >> >> >> > >
> >> >> >> >> >
> >> >> >
> > org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(Unknown
> >> >> >> >> >> > >> Source)
> >> >> >> >> >> > >>
> >> >> >> >> >> > >>    at
> >> >> >> >> >
> > org.apache.batik.dom.svg.SVGOMDocument.createElementNS(Unknown
> >> >> >> >> >> > > Source)
> >> >> >> >> >> > >>
> >> >> >> >> >> > >>    at
> >> >> >> >> >
> > mypackage22.KeyAccidentClient$4.run(KeyAccidentClient.java:349)
> >> >> >> >> >> > >>
> >> >> >> >> >> > >>    at 
org.apache.batik.util.RunnableQueue.run(Unknown
> >> > Source)
> >> >> >> >> >> > >>
> >> >> >> >> >> > >>    at java.lang.Thread.run(Thread.java:534)
> >> >> >> >> >> > >>
> >> >> >> >> >> > >> Pls advice.
> >> >> >> >> >> > >>
> >> >> >> >> >> > >> Thx
> >> >> >> >> >> > >>
> >> >> >> >> >> > >> yasmin
> >> >> >> >> >> > >>
> >> >> >> >> >> > >>
> >> >> >> >> >> > >>
> >> >> >> >> >> > >>
> >> >> >> >> >> > >> > Hi Yasmin,
> >> >> >> >> >> > >> >
> >> >> >> >> >> > >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 
06:04:36
> > AM:
> >> >> >> >> >> > >> >
> >> >> >> >> >> > >> >> When I tried putting a line to test if the code 
is
> >> >> > running,
> >> >> >> > the
> >> >> >> >> >> code
> >> >> >> >> >> > >> > does
> >> >> >> >> >> > >> >> run, but apparently it does not create any 
elements,
> >> >> > here's
> >> >> >> > what
> >> >> >> >> > I
> >> >> >> >> >> > >> > tested:
> >> >> >> >> >> > >> >>
> >> >> >> >> >> > >> >> System.out.println("This is just testing :" +
> >> >> >> >> >> > >> > g.getAttribute("circleGroup"));
> >> >> >> >> >> > >> >>
> >> >> >> >> >> > >> >> and nothing prints for g.getAttribute ...
> >> >> >> >> >> > >> >
> >> >> >> >> >> > >> >    This is expected, I think you want to use:
> >> >> >> >> >> > >> >         g.getAttributeNS(null, "id");
> >> >> >> >> >> > >> >
> >> >> >> >> >> > >> >    This should result in the string 'circleGroup'.
> >> >> >> >> >> > >> >
> >> >> >> >> >> > >> >> > rafiqy@blueyonder.co.uk wrote on 03/11/2006
> > 05:44:31
> >> > PM:
> >> >> >> >> >> > >> >> >
> >> >> >> >> >> > >> >> >> I did initially try to add the red circles to 
the
> >> > svg
> >> >> >> >> > document
> >> >> >> >> >> > >> >> >> programatically, infact I think you emailed me 
a
> >> >> > snippet
> >> >> >> > of
> >> >> >> >> >> your
> >> >> >> >> >> > > code
> >> >> >> >> >> > >> >> >> but it doesn't work, the code compiles but 
does
> > not
> >> >> >> > display
> >> >> >> >> > the
> >> >> >> >> >> > >> >> >> red-circles, I tried to repaint my canvas, 
that
> >> > don't
> >> >> >> > work...
> >> >> >> >> >> > > here's
> >> >> >> >> >> > >> >> >> the code I'm using maybe you might be able to
> > spot
> >> >> > where
> >> >> >> > I'm
> >> >> >> >> >> > > making
> >> >> >> >> >> > >> >> >> the error...
> >> >> >> >> >> > >> >> >
> >> >> >> >> >> > >> >> >    The code looks pretty good.  You aren't that
> > far
> >> > from
> >> >> > a
> >> >> >> >> >> > >> >> > standalone example, this would help me help 
you...
> >> >> >> >> >> > >> >> >
> >> >> >> >> >> > >> >> >> //I added this in my constructor
> >> >> >> >> >> > >> >> >>
> > canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
> >> >> >> >> >> > >> >> >
> >> >> >> >> >> > >> >> >    This must be done _before_ you set the 
document
> > on
> >> >> > the
> >> >> >> >> >> canvas.
> >> >> >> >> >> > >> >> >
> >> >> >> >> >> > >> >> >> //The following code I added in my 
ActionListener
> >> >> > triggred
> >> >> >> > by
> >> >> >> >> > a
> >> >> >> >> >> > >> > button
> >> >> >> >> >> > >> >> >
> >> >> >> >> >> > >> >> >    Are you sure this code runs?  Some println's
> > might
> >> >> > help
> >> >> >> >> > make
> >> >> >> >> >> > > sure
> >> >> >> >> >> > >> >> > that your spots list isn't empty for some 
reason,
> >> > etc.
> >> >> > You
> >> >> >> >> >> don't
> >> >> >> >> >> > >> >> > need to 'repaint' the canvas.
> >> >> >> >> >> > >> >> >
> >> >> >> >> >> > >> >> >>
> >> >> >> >> >>
> >> > canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
> >> >> >> >> >> > >> >> >> Runnable() {
> >> >> >> >> >> > >> >> >>
> >> >> >> >> >> > >> >> >>                       public void run()
> >> >> >> >> >> > >> >> >>                       {
> >> >> >> >> >> > >> >> >>                         SVGDocument doc =
> >> >> >> >> >> canvas.getSVGDocument();
> >> >> >> >> >> > >> >> >>                         String SVGNS =
> >> >> >> >> >> > > "http://www.w3.org/2000/svg";
> >> >> >> >> >> > >> >> >>                         Iterator i =
> >> > spots.iterator();
> >> >> >> >> >> > >> >> >>                         Element g =
> >> >> >> >> >> > >> > doc.getElementById("circleGroup");
> >> >> >> >> >> > >> >> >>                        if (g == null)
> >> >> >> >> >> > >> >> >>                        {
> >> >> >> >> >> > >> >> >>                           g =
> >> >> >> > doc.createElementNS(SVGNS,"g");
> >> >> >> >> >> > >> >> >> g.setAttributeNS(null,
> >> > "id",
> >> >> >> >> >> > >> > "circleGroup");
> >> >> >> >> >> > >> >> >> doc.getRootElement().appendChild(g);
> >> >> >> >> >> > >> >> >>                        }
> >> >> >> >> >> > >> >> >>
> >> >> >> >> >> > >> >> >>
> >> >> >> >> >> > >> >> >>                         while (i.hasNext())
> >> >> >> >> >> > >> >> >>                         {
> >> >> >> >> >> > >> >> >>                           Point2D pt2d =
> > (Point2D)
> >> >> >> > i.next();
> >> >> >> >> >> > >> >> >>                           Element e =
> >> >> >> >> >> > >> >> > doc.createElementNS(SVGNS,"circle");
> >> >> >> >> >> > >> >> >> e.setAttributeNS(null,"cx",""+pt2d.getX());
> >> >> >> >> >> > >> >> >> e.setAttributeNS(null,"cy",""+pt2d.getY());
> >> >> >> >> >> > >> >> >> e.setAttributeNS(null,"r","8");
> >> >> >> >> >> > >> >> >> e.setAttributeNS(null,"fill","Red");
> >> >> >> >> >> > >> >> >>                           g.appendChild(e);
> >> >> >> >> >> > >> >> >>                         }
> >> >> >> >> >> > >> >> >>                       }
> >> >> >> >> >> > >> >> >>                       });
> >> >> >> >> >> > >> >> >>
> >> >> >> >> >> > >> >> >>                       canvas.repaint();
> >> >> >> >> >> > >> >> >
> >> >> >> >> >> > >> >> >
> >> >> >> >> >> > >> >> >
> >> >> >> >> >> > >
> >> >> >> >> >
> >> >> >
> > ---------------------------------------------------------------------
> >> >> >> >> >> > >> >> > 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
> >> >> >> >> >> > >> >
> >> >> >> >> >> > >> >
> >> >> >> >> >> > >> >
> >> >> >> >> >> > >>
> >> >> >> >> >> > >>
> >> >> >> >> >> > >>
> >> >> >> >> >> > >>
> >> >> >> >> >
> >> >> >
> > ---------------------------------------------------------------------
> >> >> >> >> >> > >> 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
> >> >> >> >> >> > >
> >> >> >> >> >> > >
> >> >> >> >> >> > >
> >> >> >> >> >> > [attachment "TestProgram.java" 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
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> > 
---------------------------------------------------------------------
> >> >> >> >> 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
> >> >> >>
> >> >> >
> >> >> >
> >> >> >
> > ---------------------------------------------------------------------
> >> >> > 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
> >> >
> >> >
> >> >
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> 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
> 


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


Re: adding Elements to SVG Doc

Posted by ra...@blueyonder.co.uk.
Hi Thomas,

I read the DOM interface, but I still can't get the red circles to change
the colour when clicked, here's my code ...I'm sorry for being a nuisance.

Element element = doc.getElementById("circleGroup");
 EventTarget eventTarget = (EventTarget) element;
 eventTarget.addEventListener("click",new CircleAction(),false);


 class CircleAction implements EventListener
{
    public    void handleEvent(Event evt)
        {
                Element elt = (Element) evt.getCurrentTarget();

                if (evt.getType() == "click")
                {
                        elt.setAttributeNS("circle","fill","yellow");
                }
        }

ThankU

yasmin






> Hi Yasmin,
>
>     Please read the DOM interfaces.  This is the third time you have
> failed to lookup
> the interface that provides a method.  BTW most of the time you want to
> use
> evt.getTarget().
>
> rafiqy@blueyonder.co.uk wrote on 03/12/2006 08:08:23 PM:
>
>> Hi Thomas,
>>
>> This is the code for my CircleAction,
>>
>>  public class CircleAction implements EventListener
>> {
>>         public void handleEvent(Event evt)
>>         {
>>                 Element elt = (Element) evt.getCurrentTarget();
>>
>>                 if (evt.getType() == "click")
>>                 {
>>                         elt.setAttributeNS(SVG_NS, "fill", "yellow");
>>                 }
>>         }
>> }
>>
>> The evt.getCurrentTarget() is not recognised?
>>
>> Thx
>>
>> yasmin
>>
>>
>>
>>
>> > Hi Yasmin,
>> >
>> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:24:15 PM:
>> >
>> >> I've tried this, but again I have a problem with the paranthesis of
> the
>> >> addEventListener?
>> >
>> >    What is the error?
>> >    Does CircleAction implement the DOM EventListener interface?
>> >
>> >         org.w3c.dom.events.EventListener;
>> >
>> >
>> >>  NodeList circleList = doc.getElementsByTagName("circle");
>> >
>> >    You only need to add one event listener to the circleGroup.
>> > Then use evt.getTarget() to know what circle it is.
>> >
>> >>  for (int count = 0; count < circleList.getLength(); count++) {
>> >>  EventTarget eventTarget = (EventTarget) circleList.item(count);
>> >>  eventTarget.addEventListener("click",new CircleAction(),false);
>> >> }
>> >>
>> >> Thx
>> >>
>> >> yasmin
>> >>
>> >>
>> >>
>> >> > Hi Yasmin,
>> >> >
>> >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 05:54:00 PM:
>> >> >
>> >> >> Now I'm trying to make the red circles clickable, I've tried this
>> > code
>> >> > but
>> >> >> for some reason I can't get the element.addEventListener?
>> >> >
>> >> >    addEventListener is on the EventTarget interface.  So you
>> >> > will need to cast the element to add the listener.
>> >> >
>> >> >>
>> >> >> Element element = doc.getElementById("circleGroup");
>> >> >> element.addEventListener("click", new CircleAction(), false);
>> >> >>
>> >> >> Thx
>> >> >>
>> >> >> yasmin
>> >> >>
>> >> >> > Hi Yasmin,
>> >> >> >
>> >> >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 03:44:08 PM:
>> >> >> >
>> >> >> >> Here's the heading of my svg file, can you see anything that
> might
>> > be
>> >> >> >> causing the red circles not appearing?
>> >> >> >
>> >> >> >>   viewBox="424000.000 -518000 2000 2000"
>> >> >> >
>> >> >> >    Your viewBox certainly doesn't intersect any of the coords
>> >> >> > in your example source code.  When you add the elements to the
>> >> >> > Document you need to place your circles in the 'maps' coordinate
>> >> >> > system (which normally is simplier for you).
>> >> >> >
>> >> >> >    So the cx & cy for a circle should look something like
>> >> >> >         cx="425100"
>> >> >> >         cy="-519100"
>> >> >> >
>> >> >> >> >     One other comment on the code.  I would suggest using the
>> >> >> >> > JSVGScrollPane
>> >> >> >> > instead of the swing JScrollPane.  The JScrollPane works in
> most
>> >> > cases
>> >> >> >> > it tends to be much less efficient than the JSVGScrollPane.
>> >> >> >> >
>> >> >> >> > thomas.deweese@kodak.com wrote on 03/12/2006 03:01:19 PM:
>> >> >> >> >
>> >> >> >> >> Hi Yasmin,
>> >> >> >> >>
>> >> >> >> >>     Your test code worked fine for me with one change, you
> had:
>> >> >> >> >>
>> >> >> >> >>                                 Element e =
>> >> >> >> >> doc.createElementNS(SVGNS,"spot");
>> >> >> >> >>
>> >> >> >> >>     This isn't right you want:
>> >> >> >> >>
>> >> >> >> >>                                 Element e =
>> >> >> >> >> doc.createElementNS(SVGNS,"circle");
>> >> >> >> >>
>> >> >> >> >>     Which is odd because an earlier e-mail had 'circle'
>> >> >> >> >> I tested by opening 'samples/mapSpain.svg'.  I think two of
>> > your
>> >> >> > circles
>> >> >> >> >> still didn't show because mapSpain isn't quite large enough
> but
>> >> > the
>> >> >> > ones
>> >> >> >> >> that should show did.
>> >> >> >> >>
>> >> >> >> >> rafiqy@blueyonder.co.uk wrote on 03/12/2006 02:07:00 PM:
>> >> >> >> >>
>> >> >> >> >> > I've just attached the java file only!
>> >> >> >> >> >
>> >> >> >> >> > Tx
>> >> >> >> >> > yasmin
>> >> >> >> >> >
>> >> >> >> >> >
>> >> >> >> >> >
>> >> >> >> >> >
>> >> >> >> >> >
>> >> >> >> >> >
>> >> >> >> >> >
>> >> >> >> >> > > Hi Yasmin,
>> >> >> >> >> > >
>> >> >> >> >> > > rafiqy@blueyonder.co.uk wrote on 03/12/2006 10:45:17 AM:
>> >> >> >> >> > >
>> >> >> >> >> > >> Now when I run my code I get the following error:
>> >> >> >> >> > >>
>> >> >> >> >> > >> org.w3c.dom.DOMException: The current document is
> unable
>> > to
>> >> >> > create
>> >> >> >> > an
>> >> >> >> >> > >> element of the requested type (namespace:
>> >> >> >> > http://www.w3.org/2000/svg,
>> >> >> >> >> > >> name: spot).
>> >> >> >> >> > >
>> >> >> >> >> > >    Batik's DOM implementation prevents you from creating
>> >> > elements
>> >> >> > in
>> >> >> >> >
>> >> >> >> >> the
>> >> >> >> >> > > SVG Namespace that aren't part of the SVG specification.
>> >> >> >> >> > >
>> >> >> >> >> > >    As far as path forward, I would suggest taking the
> code
>> > to
>> >> >> > create
>> >> >> >> >
>> >> >> >> >> the
>> >> >> >> >> > > circles and put it in a small example that just puts of
> the
>> >> >> > canvas
>> >> >> >> >> > > (with any old document) and a button that adds a list of
>> >> > preset
>> >> >> >> >> circles.
>> >> >> >> >> > >
>> >> >> >> >> > >    Then with all the code together I can either spot the
>> > error
>> >> > or
>> >> >> >> >> > > run it and debug why it isn't working for you.
>> >> >> >> >> > >
>> >> >> >> >> > >>
>> >> >> >> >> > >>    at
>> >> >> > org.apache.batik.dom.AbstractNode.createDOMException(Unknown
>> >> >> >> >> > > Source)
>> >> >> >> >> > >>
>> >> >> >> >> > >>    at
>> >> >> >> >> > >
>> >> >> >> >
>> >> >
> org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(Unknown
>> >> >> >> >> > >> Source)
>> >> >> >> >> > >>
>> >> >> >> >> > >>    at
>> >> >> >> >
> org.apache.batik.dom.svg.SVGOMDocument.createElementNS(Unknown
>> >> >> >> >> > > Source)
>> >> >> >> >> > >>
>> >> >> >> >> > >>    at
>> >> >> >> >
> mypackage22.KeyAccidentClient$4.run(KeyAccidentClient.java:349)
>> >> >> >> >> > >>
>> >> >> >> >> > >>    at org.apache.batik.util.RunnableQueue.run(Unknown
>> > Source)
>> >> >> >> >> > >>
>> >> >> >> >> > >>    at java.lang.Thread.run(Thread.java:534)
>> >> >> >> >> > >>
>> >> >> >> >> > >> Pls advice.
>> >> >> >> >> > >>
>> >> >> >> >> > >> Thx
>> >> >> >> >> > >>
>> >> >> >> >> > >> yasmin
>> >> >> >> >> > >>
>> >> >> >> >> > >>
>> >> >> >> >> > >>
>> >> >> >> >> > >>
>> >> >> >> >> > >> > Hi Yasmin,
>> >> >> >> >> > >> >
>> >> >> >> >> > >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36
> AM:
>> >> >> >> >> > >> >
>> >> >> >> >> > >> >> When I tried putting a line to test if the code is
>> >> > running,
>> >> >> > the
>> >> >> >> >> code
>> >> >> >> >> > >> > does
>> >> >> >> >> > >> >> run, but apparently it does not create any elements,
>> >> > here's
>> >> >> > what
>> >> >> >> > I
>> >> >> >> >> > >> > tested:
>> >> >> >> >> > >> >>
>> >> >> >> >> > >> >> System.out.println("This is just testing :" +
>> >> >> >> >> > >> > g.getAttribute("circleGroup"));
>> >> >> >> >> > >> >>
>> >> >> >> >> > >> >> and nothing prints for g.getAttribute ...
>> >> >> >> >> > >> >
>> >> >> >> >> > >> >    This is expected, I think you want to use:
>> >> >> >> >> > >> >         g.getAttributeNS(null, "id");
>> >> >> >> >> > >> >
>> >> >> >> >> > >> >    This should result in the string 'circleGroup'.
>> >> >> >> >> > >> >
>> >> >> >> >> > >> >> > rafiqy@blueyonder.co.uk wrote on 03/11/2006
> 05:44:31
>> > PM:
>> >> >> >> >> > >> >> >
>> >> >> >> >> > >> >> >> I did initially try to add the red circles to the
>> > svg
>> >> >> >> > document
>> >> >> >> >> > >> >> >> programatically, infact I think you emailed me a
>> >> > snippet
>> >> >> > of
>> >> >> >> >> your
>> >> >> >> >> > > code
>> >> >> >> >> > >> >> >> but it doesn't work, the code compiles but does
> not
>> >> >> > display
>> >> >> >> > the
>> >> >> >> >> > >> >> >> red-circles, I tried to repaint my canvas, that
>> > don't
>> >> >> > work...
>> >> >> >> >> > > here's
>> >> >> >> >> > >> >> >> the code I'm using maybe you might be able to
> spot
>> >> > where
>> >> >> > I'm
>> >> >> >> >> > > making
>> >> >> >> >> > >> >> >> the error...
>> >> >> >> >> > >> >> >
>> >> >> >> >> > >> >> >    The code looks pretty good.  You aren't that
> far
>> > from
>> >> > a
>> >> >> >> >> > >> >> > standalone example, this would help me help you...
>> >> >> >> >> > >> >> >
>> >> >> >> >> > >> >> >> //I added this in my constructor
>> >> >> >> >> > >> >> >>
> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>> >> >> >> >> > >> >> >
>> >> >> >> >> > >> >> >    This must be done _before_ you set the document
> on
>> >> > the
>> >> >> >> >> canvas.
>> >> >> >> >> > >> >> >
>> >> >> >> >> > >> >> >> //The following code I added in my ActionListener
>> >> > triggred
>> >> >> > by
>> >> >> >> > a
>> >> >> >> >> > >> > button
>> >> >> >> >> > >> >> >
>> >> >> >> >> > >> >> >    Are you sure this code runs?  Some println's
> might
>> >> > help
>> >> >> >> > make
>> >> >> >> >> > > sure
>> >> >> >> >> > >> >> > that your spots list isn't empty for some reason,
>> > etc.
>> >> > You
>> >> >> >> >> don't
>> >> >> >> >> > >> >> > need to 'repaint' the canvas.
>> >> >> >> >> > >> >> >
>> >> >> >> >> > >> >> >>
>> >> >> >> >>
>> > canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
>> >> >> >> >> > >> >> >> Runnable() {
>> >> >> >> >> > >> >> >>
>> >> >> >> >> > >> >> >>                       public void run()
>> >> >> >> >> > >> >> >>                       {
>> >> >> >> >> > >> >> >>                         SVGDocument doc =
>> >> >> >> >> canvas.getSVGDocument();
>> >> >> >> >> > >> >> >>                         String SVGNS =
>> >> >> >> >> > > "http://www.w3.org/2000/svg";
>> >> >> >> >> > >> >> >>                         Iterator i =
>> > spots.iterator();
>> >> >> >> >> > >> >> >>                         Element g =
>> >> >> >> >> > >> > doc.getElementById("circleGroup");
>> >> >> >> >> > >> >> >>                        if (g == null)
>> >> >> >> >> > >> >> >>                        {
>> >> >> >> >> > >> >> >>                           g =
>> >> >> > doc.createElementNS(SVGNS,"g");
>> >> >> >> >> > >> >> >>                           g.setAttributeNS(null,
>> > "id",
>> >> >> >> >> > >> > "circleGroup");
>> >> >> >> >> > >> >> >> doc.getRootElement().appendChild(g);
>> >> >> >> >> > >> >> >>                        }
>> >> >> >> >> > >> >> >>
>> >> >> >> >> > >> >> >>
>> >> >> >> >> > >> >> >>                         while (i.hasNext())
>> >> >> >> >> > >> >> >>                         {
>> >> >> >> >> > >> >> >>                           Point2D pt2d =
> (Point2D)
>> >> >> > i.next();
>> >> >> >> >> > >> >> >>                           Element e =
>> >> >> >> >> > >> >> > doc.createElementNS(SVGNS,"circle");
>> >> >> >> >> > >> >> >> e.setAttributeNS(null,"cx",""+pt2d.getX());
>> >> >> >> >> > >> >> >> e.setAttributeNS(null,"cy",""+pt2d.getY());
>> >> >> >> >> > >> >> >> e.setAttributeNS(null,"r","8");
>> >> >> >> >> > >> >> >> e.setAttributeNS(null,"fill","Red");
>> >> >> >> >> > >> >> >>                           g.appendChild(e);
>> >> >> >> >> > >> >> >>                         }
>> >> >> >> >> > >> >> >>                       }
>> >> >> >> >> > >> >> >>                       });
>> >> >> >> >> > >> >> >>
>> >> >> >> >> > >> >> >>                       canvas.repaint();
>> >> >> >> >> > >> >> >
>> >> >> >> >> > >> >> >
>> >> >> >> >> > >> >> >
>> >> >> >> >> > >
>> >> >> >> >
>> >> >
> ---------------------------------------------------------------------
>> >> >> >> >> > >> >> > 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
>> >> >> >> >> > >> >
>> >> >> >> >> > >> >
>> >> >> >> >> > >> >
>> >> >> >> >> > >>
>> >> >> >> >> > >>
>> >> >> >> >> > >>
>> >> >> >> >> > >>
>> >> >> >> >
>> >> >
> ---------------------------------------------------------------------
>> >> >> >> >> > >> 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
>> >> >> >> >> > >
>> >> >> >> >> > >
>> >> >> >> >> > >
>> >> >> >> >> > [attachment "TestProgram.java" 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
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> > ---------------------------------------------------------------------
>> >> >> >> 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
>> >> >>
>> >> >
>> >> >
>> >> >
> ---------------------------------------------------------------------
>> >> > 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
>> >
>> >
>> >
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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: adding Elements to SVG Doc

Posted by th...@kodak.com.
Hi Yasmin,

    Please read the DOM interfaces.  This is the third time you have 
failed to lookup
the interface that provides a method.  BTW most of the time you want to 
use
evt.getTarget().

rafiqy@blueyonder.co.uk wrote on 03/12/2006 08:08:23 PM:

> Hi Thomas,
> 
> This is the code for my CircleAction,
> 
>  public class CircleAction implements EventListener
> {
>         public void handleEvent(Event evt)
>         {
>                 Element elt = (Element) evt.getCurrentTarget();
> 
>                 if (evt.getType() == "click")
>                 {
>                         elt.setAttributeNS(SVG_NS, "fill", "yellow");
>                 }
>         }
> }
> 
> The evt.getCurrentTarget() is not recognised?
> 
> Thx
> 
> yasmin
> 
> 
> 
> 
> > Hi Yasmin,
> >
> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:24:15 PM:
> >
> >> I've tried this, but again I have a problem with the paranthesis of 
the
> >> addEventListener?
> >
> >    What is the error?
> >    Does CircleAction implement the DOM EventListener interface?
> >
> >         org.w3c.dom.events.EventListener;
> >
> >
> >>  NodeList circleList = doc.getElementsByTagName("circle");
> >
> >    You only need to add one event listener to the circleGroup.
> > Then use evt.getTarget() to know what circle it is.
> >
> >>  for (int count = 0; count < circleList.getLength(); count++) {
> >>  EventTarget eventTarget = (EventTarget) circleList.item(count);
> >>  eventTarget.addEventListener("click",new CircleAction(),false);
> >> }
> >>
> >> Thx
> >>
> >> yasmin
> >>
> >>
> >>
> >> > Hi Yasmin,
> >> >
> >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 05:54:00 PM:
> >> >
> >> >> Now I'm trying to make the red circles clickable, I've tried this
> > code
> >> > but
> >> >> for some reason I can't get the element.addEventListener?
> >> >
> >> >    addEventListener is on the EventTarget interface.  So you
> >> > will need to cast the element to add the listener.
> >> >
> >> >>
> >> >> Element element = doc.getElementById("circleGroup");
> >> >> element.addEventListener("click", new CircleAction(), false);
> >> >>
> >> >> Thx
> >> >>
> >> >> yasmin
> >> >>
> >> >> > Hi Yasmin,
> >> >> >
> >> >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 03:44:08 PM:
> >> >> >
> >> >> >> Here's the heading of my svg file, can you see anything that 
might
> > be
> >> >> >> causing the red circles not appearing?
> >> >> >
> >> >> >>   viewBox="424000.000 -518000 2000 2000"
> >> >> >
> >> >> >    Your viewBox certainly doesn't intersect any of the coords
> >> >> > in your example source code.  When you add the elements to the
> >> >> > Document you need to place your circles in the 'maps' coordinate
> >> >> > system (which normally is simplier for you).
> >> >> >
> >> >> >    So the cx & cy for a circle should look something like
> >> >> >         cx="425100"
> >> >> >         cy="-519100"
> >> >> >
> >> >> >> >     One other comment on the code.  I would suggest using the
> >> >> >> > JSVGScrollPane
> >> >> >> > instead of the swing JScrollPane.  The JScrollPane works in 
most
> >> > cases
> >> >> >> > it tends to be much less efficient than the JSVGScrollPane.
> >> >> >> >
> >> >> >> > thomas.deweese@kodak.com wrote on 03/12/2006 03:01:19 PM:
> >> >> >> >
> >> >> >> >> Hi Yasmin,
> >> >> >> >>
> >> >> >> >>     Your test code worked fine for me with one change, you 
had:
> >> >> >> >>
> >> >> >> >>                                 Element e =
> >> >> >> >> doc.createElementNS(SVGNS,"spot");
> >> >> >> >>
> >> >> >> >>     This isn't right you want:
> >> >> >> >>
> >> >> >> >>                                 Element e =
> >> >> >> >> doc.createElementNS(SVGNS,"circle");
> >> >> >> >>
> >> >> >> >>     Which is odd because an earlier e-mail had 'circle'
> >> >> >> >> I tested by opening 'samples/mapSpain.svg'.  I think two of
> > your
> >> >> > circles
> >> >> >> >> still didn't show because mapSpain isn't quite large enough 
but
> >> > the
> >> >> > ones
> >> >> >> >> that should show did.
> >> >> >> >>
> >> >> >> >> rafiqy@blueyonder.co.uk wrote on 03/12/2006 02:07:00 PM:
> >> >> >> >>
> >> >> >> >> > I've just attached the java file only!
> >> >> >> >> >
> >> >> >> >> > Tx
> >> >> >> >> > yasmin
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> > > Hi Yasmin,
> >> >> >> >> > >
> >> >> >> >> > > rafiqy@blueyonder.co.uk wrote on 03/12/2006 10:45:17 AM:
> >> >> >> >> > >
> >> >> >> >> > >> Now when I run my code I get the following error:
> >> >> >> >> > >>
> >> >> >> >> > >> org.w3c.dom.DOMException: The current document is 
unable
> > to
> >> >> > create
> >> >> >> > an
> >> >> >> >> > >> element of the requested type (namespace:
> >> >> >> > http://www.w3.org/2000/svg,
> >> >> >> >> > >> name: spot).
> >> >> >> >> > >
> >> >> >> >> > >    Batik's DOM implementation prevents you from creating
> >> > elements
> >> >> > in
> >> >> >> >
> >> >> >> >> the
> >> >> >> >> > > SVG Namespace that aren't part of the SVG specification.
> >> >> >> >> > >
> >> >> >> >> > >    As far as path forward, I would suggest taking the 
code
> > to
> >> >> > create
> >> >> >> >
> >> >> >> >> the
> >> >> >> >> > > circles and put it in a small example that just puts of 
the
> >> >> > canvas
> >> >> >> >> > > (with any old document) and a button that adds a list of
> >> > preset
> >> >> >> >> circles.
> >> >> >> >> > >
> >> >> >> >> > >    Then with all the code together I can either spot the
> > error
> >> > or
> >> >> >> >> > > run it and debug why it isn't working for you.
> >> >> >> >> > >
> >> >> >> >> > >>
> >> >> >> >> > >>    at
> >> >> > org.apache.batik.dom.AbstractNode.createDOMException(Unknown
> >> >> >> >> > > Source)
> >> >> >> >> > >>
> >> >> >> >> > >>    at
> >> >> >> >> > >
> >> >> >> >
> >> > 
org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(Unknown
> >> >> >> >> > >> Source)
> >> >> >> >> > >>
> >> >> >> >> > >>    at
> >> >> >> > 
org.apache.batik.dom.svg.SVGOMDocument.createElementNS(Unknown
> >> >> >> >> > > Source)
> >> >> >> >> > >>
> >> >> >> >> > >>    at
> >> >> >> > 
mypackage22.KeyAccidentClient$4.run(KeyAccidentClient.java:349)
> >> >> >> >> > >>
> >> >> >> >> > >>    at org.apache.batik.util.RunnableQueue.run(Unknown
> > Source)
> >> >> >> >> > >>
> >> >> >> >> > >>    at java.lang.Thread.run(Thread.java:534)
> >> >> >> >> > >>
> >> >> >> >> > >> Pls advice.
> >> >> >> >> > >>
> >> >> >> >> > >> Thx
> >> >> >> >> > >>
> >> >> >> >> > >> yasmin
> >> >> >> >> > >>
> >> >> >> >> > >>
> >> >> >> >> > >>
> >> >> >> >> > >>
> >> >> >> >> > >> > Hi Yasmin,
> >> >> >> >> > >> >
> >> >> >> >> > >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36 
AM:
> >> >> >> >> > >> >
> >> >> >> >> > >> >> When I tried putting a line to test if the code is
> >> > running,
> >> >> > the
> >> >> >> >> code
> >> >> >> >> > >> > does
> >> >> >> >> > >> >> run, but apparently it does not create any elements,
> >> > here's
> >> >> > what
> >> >> >> > I
> >> >> >> >> > >> > tested:
> >> >> >> >> > >> >>
> >> >> >> >> > >> >> System.out.println("This is just testing :" +
> >> >> >> >> > >> > g.getAttribute("circleGroup"));
> >> >> >> >> > >> >>
> >> >> >> >> > >> >> and nothing prints for g.getAttribute ...
> >> >> >> >> > >> >
> >> >> >> >> > >> >    This is expected, I think you want to use:
> >> >> >> >> > >> >         g.getAttributeNS(null, "id");
> >> >> >> >> > >> >
> >> >> >> >> > >> >    This should result in the string 'circleGroup'.
> >> >> >> >> > >> >
> >> >> >> >> > >> >> > rafiqy@blueyonder.co.uk wrote on 03/11/2006 
05:44:31
> > PM:
> >> >> >> >> > >> >> >
> >> >> >> >> > >> >> >> I did initially try to add the red circles to the
> > svg
> >> >> >> > document
> >> >> >> >> > >> >> >> programatically, infact I think you emailed me a
> >> > snippet
> >> >> > of
> >> >> >> >> your
> >> >> >> >> > > code
> >> >> >> >> > >> >> >> but it doesn't work, the code compiles but does 
not
> >> >> > display
> >> >> >> > the
> >> >> >> >> > >> >> >> red-circles, I tried to repaint my canvas, that
> > don't
> >> >> > work...
> >> >> >> >> > > here's
> >> >> >> >> > >> >> >> the code I'm using maybe you might be able to 
spot
> >> > where
> >> >> > I'm
> >> >> >> >> > > making
> >> >> >> >> > >> >> >> the error...
> >> >> >> >> > >> >> >
> >> >> >> >> > >> >> >    The code looks pretty good.  You aren't that 
far
> > from
> >> > a
> >> >> >> >> > >> >> > standalone example, this would help me help you...
> >> >> >> >> > >> >> >
> >> >> >> >> > >> >> >> //I added this in my constructor
> >> >> >> >> > >> >> >> 
canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
> >> >> >> >> > >> >> >
> >> >> >> >> > >> >> >    This must be done _before_ you set the document 
on
> >> > the
> >> >> >> >> canvas.
> >> >> >> >> > >> >> >
> >> >> >> >> > >> >> >> //The following code I added in my ActionListener
> >> > triggred
> >> >> > by
> >> >> >> > a
> >> >> >> >> > >> > button
> >> >> >> >> > >> >> >
> >> >> >> >> > >> >> >    Are you sure this code runs?  Some println's 
might
> >> > help
> >> >> >> > make
> >> >> >> >> > > sure
> >> >> >> >> > >> >> > that your spots list isn't empty for some reason,
> > etc.
> >> > You
> >> >> >> >> don't
> >> >> >> >> > >> >> > need to 'repaint' the canvas.
> >> >> >> >> > >> >> >
> >> >> >> >> > >> >> >>
> >> >> >> >>
> > canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
> >> >> >> >> > >> >> >> Runnable() {
> >> >> >> >> > >> >> >>
> >> >> >> >> > >> >> >>                       public void run()
> >> >> >> >> > >> >> >>                       {
> >> >> >> >> > >> >> >>                         SVGDocument doc =
> >> >> >> >> canvas.getSVGDocument();
> >> >> >> >> > >> >> >>                         String SVGNS =
> >> >> >> >> > > "http://www.w3.org/2000/svg";
> >> >> >> >> > >> >> >>                         Iterator i =
> > spots.iterator();
> >> >> >> >> > >> >> >>                         Element g =
> >> >> >> >> > >> > doc.getElementById("circleGroup");
> >> >> >> >> > >> >> >>                        if (g == null)
> >> >> >> >> > >> >> >>                        {
> >> >> >> >> > >> >> >>                           g =
> >> >> > doc.createElementNS(SVGNS,"g");
> >> >> >> >> > >> >> >>                           g.setAttributeNS(null,
> > "id",
> >> >> >> >> > >> > "circleGroup");
> >> >> >> >> > >> >> >> doc.getRootElement().appendChild(g);
> >> >> >> >> > >> >> >>                        }
> >> >> >> >> > >> >> >>
> >> >> >> >> > >> >> >>
> >> >> >> >> > >> >> >>                         while (i.hasNext())
> >> >> >> >> > >> >> >>                         {
> >> >> >> >> > >> >> >>                           Point2D pt2d = 
(Point2D)
> >> >> > i.next();
> >> >> >> >> > >> >> >>                           Element e =
> >> >> >> >> > >> >> > doc.createElementNS(SVGNS,"circle");
> >> >> >> >> > >> >> >> e.setAttributeNS(null,"cx",""+pt2d.getX());
> >> >> >> >> > >> >> >> e.setAttributeNS(null,"cy",""+pt2d.getY());
> >> >> >> >> > >> >> >> e.setAttributeNS(null,"r","8");
> >> >> >> >> > >> >> >> e.setAttributeNS(null,"fill","Red");
> >> >> >> >> > >> >> >>                           g.appendChild(e);
> >> >> >> >> > >> >> >>                         }
> >> >> >> >> > >> >> >>                       }
> >> >> >> >> > >> >> >>                       });
> >> >> >> >> > >> >> >>
> >> >> >> >> > >> >> >>                       canvas.repaint();
> >> >> >> >> > >> >> >
> >> >> >> >> > >> >> >
> >> >> >> >> > >> >> >
> >> >> >> >> > >
> >> >> >> >
> >> > 
---------------------------------------------------------------------
> >> >> >> >> > >> >> > 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
> >> >> >> >> > >> >
> >> >> >> >> > >> >
> >> >> >> >> > >> >
> >> >> >> >> > >>
> >> >> >> >> > >>
> >> >> >> >> > >>
> >> >> >> >> > >>
> >> >> >> >
> >> > 
---------------------------------------------------------------------
> >> >> >> >> > >> 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
> >> >> >> >> > >
> >> >> >> >> > >
> >> >> >> >> > >
> >> >> >> >> > [attachment "TestProgram.java" 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
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> > ---------------------------------------------------------------------
> >> >> >> 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
> >> >>
> >> >
> >> >
> >> > 
---------------------------------------------------------------------
> >> > 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
> >
> >
> >
> 
> 
> 
> ---------------------------------------------------------------------
> 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: adding Elements to SVG Doc

Posted by ra...@blueyonder.co.uk.
Hi Thomas,

This is the code for my CircleAction,

 public class CircleAction implements EventListener
{
        public void handleEvent(Event evt)
        {
                Element elt = (Element) evt.getCurrentTarget();

                if (evt.getType() == "click")
                {
                        elt.setAttributeNS(SVG_NS, "fill", "yellow");
                }
        }
}

The evt.getCurrentTarget() is not recognised?

Thx

yasmin




> Hi Yasmin,
>
> rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:24:15 PM:
>
>> I've tried this, but again I have a problem with the paranthesis of the
>> addEventListener?
>
>    What is the error?
>    Does CircleAction implement the DOM EventListener interface?
>
>         org.w3c.dom.events.EventListener;
>
>
>>  NodeList circleList = doc.getElementsByTagName("circle");
>
>    You only need to add one event listener to the circleGroup.
> Then use evt.getTarget() to know what circle it is.
>
>>  for (int count = 0; count < circleList.getLength(); count++) {
>>  EventTarget eventTarget = (EventTarget) circleList.item(count);
>>  eventTarget.addEventListener("click",new CircleAction(),false);
>> }
>>
>> Thx
>>
>> yasmin
>>
>>
>>
>> > Hi Yasmin,
>> >
>> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 05:54:00 PM:
>> >
>> >> Now I'm trying to make the red circles clickable, I've tried this
> code
>> > but
>> >> for some reason I can't get the element.addEventListener?
>> >
>> >    addEventListener is on the EventTarget interface.  So you
>> > will need to cast the element to add the listener.
>> >
>> >>
>> >> Element element = doc.getElementById("circleGroup");
>> >> element.addEventListener("click", new CircleAction(), false);
>> >>
>> >> Thx
>> >>
>> >> yasmin
>> >>
>> >> > Hi Yasmin,
>> >> >
>> >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 03:44:08 PM:
>> >> >
>> >> >> Here's the heading of my svg file, can you see anything that might
> be
>> >> >> causing the red circles not appearing?
>> >> >
>> >> >>   viewBox="424000.000 -518000 2000 2000"
>> >> >
>> >> >    Your viewBox certainly doesn't intersect any of the coords
>> >> > in your example source code.  When you add the elements to the
>> >> > Document you need to place your circles in the 'maps' coordinate
>> >> > system (which normally is simplier for you).
>> >> >
>> >> >    So the cx & cy for a circle should look something like
>> >> >         cx="425100"
>> >> >         cy="-519100"
>> >> >
>> >> >> >     One other comment on the code.  I would suggest using the
>> >> >> > JSVGScrollPane
>> >> >> > instead of the swing JScrollPane.  The JScrollPane works in most
>> > cases
>> >> >> > it tends to be much less efficient than the JSVGScrollPane.
>> >> >> >
>> >> >> > thomas.deweese@kodak.com wrote on 03/12/2006 03:01:19 PM:
>> >> >> >
>> >> >> >> Hi Yasmin,
>> >> >> >>
>> >> >> >>     Your test code worked fine for me with one change, you had:
>> >> >> >>
>> >> >> >>                                 Element e =
>> >> >> >> doc.createElementNS(SVGNS,"spot");
>> >> >> >>
>> >> >> >>     This isn't right you want:
>> >> >> >>
>> >> >> >>                                 Element e =
>> >> >> >> doc.createElementNS(SVGNS,"circle");
>> >> >> >>
>> >> >> >>     Which is odd because an earlier e-mail had 'circle'
>> >> >> >> I tested by opening 'samples/mapSpain.svg'.  I think two of
> your
>> >> > circles
>> >> >> >> still didn't show because mapSpain isn't quite large enough but
>> > the
>> >> > ones
>> >> >> >> that should show did.
>> >> >> >>
>> >> >> >> rafiqy@blueyonder.co.uk wrote on 03/12/2006 02:07:00 PM:
>> >> >> >>
>> >> >> >> > I've just attached the java file only!
>> >> >> >> >
>> >> >> >> > Tx
>> >> >> >> > yasmin
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >> > > Hi Yasmin,
>> >> >> >> > >
>> >> >> >> > > rafiqy@blueyonder.co.uk wrote on 03/12/2006 10:45:17 AM:
>> >> >> >> > >
>> >> >> >> > >> Now when I run my code I get the following error:
>> >> >> >> > >>
>> >> >> >> > >> org.w3c.dom.DOMException: The current document is unable
> to
>> >> > create
>> >> >> > an
>> >> >> >> > >> element of the requested type (namespace:
>> >> >> > http://www.w3.org/2000/svg,
>> >> >> >> > >> name: spot).
>> >> >> >> > >
>> >> >> >> > >    Batik's DOM implementation prevents you from creating
>> > elements
>> >> > in
>> >> >> >
>> >> >> >> the
>> >> >> >> > > SVG Namespace that aren't part of the SVG specification.
>> >> >> >> > >
>> >> >> >> > >    As far as path forward, I would suggest taking the code
> to
>> >> > create
>> >> >> >
>> >> >> >> the
>> >> >> >> > > circles and put it in a small example that just puts of the
>> >> > canvas
>> >> >> >> > > (with any old document) and a button that adds a list of
>> > preset
>> >> >> >> circles.
>> >> >> >> > >
>> >> >> >> > >    Then with all the code together I can either spot the
> error
>> > or
>> >> >> >> > > run it and debug why it isn't working for you.
>> >> >> >> > >
>> >> >> >> > >>
>> >> >> >> > >>    at
>> >> > org.apache.batik.dom.AbstractNode.createDOMException(Unknown
>> >> >> >> > > Source)
>> >> >> >> > >>
>> >> >> >> > >>    at
>> >> >> >> > >
>> >> >> >
>> > org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(Unknown
>> >> >> >> > >> Source)
>> >> >> >> > >>
>> >> >> >> > >>    at
>> >> >> > org.apache.batik.dom.svg.SVGOMDocument.createElementNS(Unknown
>> >> >> >> > > Source)
>> >> >> >> > >>
>> >> >> >> > >>    at
>> >> >> > mypackage22.KeyAccidentClient$4.run(KeyAccidentClient.java:349)
>> >> >> >> > >>
>> >> >> >> > >>    at org.apache.batik.util.RunnableQueue.run(Unknown
> Source)
>> >> >> >> > >>
>> >> >> >> > >>    at java.lang.Thread.run(Thread.java:534)
>> >> >> >> > >>
>> >> >> >> > >> Pls advice.
>> >> >> >> > >>
>> >> >> >> > >> Thx
>> >> >> >> > >>
>> >> >> >> > >> yasmin
>> >> >> >> > >>
>> >> >> >> > >>
>> >> >> >> > >>
>> >> >> >> > >>
>> >> >> >> > >> > Hi Yasmin,
>> >> >> >> > >> >
>> >> >> >> > >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36 AM:
>> >> >> >> > >> >
>> >> >> >> > >> >> When I tried putting a line to test if the code is
>> > running,
>> >> > the
>> >> >> >> code
>> >> >> >> > >> > does
>> >> >> >> > >> >> run, but apparently it does not create any elements,
>> > here's
>> >> > what
>> >> >> > I
>> >> >> >> > >> > tested:
>> >> >> >> > >> >>
>> >> >> >> > >> >> System.out.println("This is just testing :" +
>> >> >> >> > >> > g.getAttribute("circleGroup"));
>> >> >> >> > >> >>
>> >> >> >> > >> >> and nothing prints for g.getAttribute ...
>> >> >> >> > >> >
>> >> >> >> > >> >    This is expected, I think you want to use:
>> >> >> >> > >> >         g.getAttributeNS(null, "id");
>> >> >> >> > >> >
>> >> >> >> > >> >    This should result in the string 'circleGroup'.
>> >> >> >> > >> >
>> >> >> >> > >> >> > rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31
> PM:
>> >> >> >> > >> >> >
>> >> >> >> > >> >> >> I did initially try to add the red circles to the
> svg
>> >> >> > document
>> >> >> >> > >> >> >> programatically, infact I think you emailed me a
>> > snippet
>> >> > of
>> >> >> >> your
>> >> >> >> > > code
>> >> >> >> > >> >> >> but it doesn't work, the code compiles but does not
>> >> > display
>> >> >> > the
>> >> >> >> > >> >> >> red-circles, I tried to repaint my canvas, that
> don't
>> >> > work...
>> >> >> >> > > here's
>> >> >> >> > >> >> >> the code I'm using maybe you might be able to spot
>> > where
>> >> > I'm
>> >> >> >> > > making
>> >> >> >> > >> >> >> the error...
>> >> >> >> > >> >> >
>> >> >> >> > >> >> >    The code looks pretty good.  You aren't that far
> from
>> > a
>> >> >> >> > >> >> > standalone example, this would help me help you...
>> >> >> >> > >> >> >
>> >> >> >> > >> >> >> //I added this in my constructor
>> >> >> >> > >> >> >> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>> >> >> >> > >> >> >
>> >> >> >> > >> >> >    This must be done _before_ you set the document on
>> > the
>> >> >> >> canvas.
>> >> >> >> > >> >> >
>> >> >> >> > >> >> >> //The following code I added in my ActionListener
>> > triggred
>> >> > by
>> >> >> > a
>> >> >> >> > >> > button
>> >> >> >> > >> >> >
>> >> >> >> > >> >> >    Are you sure this code runs?  Some println's might
>> > help
>> >> >> > make
>> >> >> >> > > sure
>> >> >> >> > >> >> > that your spots list isn't empty for some reason,
> etc.
>> > You
>> >> >> >> don't
>> >> >> >> > >> >> > need to 'repaint' the canvas.
>> >> >> >> > >> >> >
>> >> >> >> > >> >> >>
>> >> >> >>
> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
>> >> >> >> > >> >> >> Runnable() {
>> >> >> >> > >> >> >>
>> >> >> >> > >> >> >>                       public void run()
>> >> >> >> > >> >> >>                       {
>> >> >> >> > >> >> >>                         SVGDocument doc =
>> >> >> >> canvas.getSVGDocument();
>> >> >> >> > >> >> >>                         String SVGNS =
>> >> >> >> > > "http://www.w3.org/2000/svg";
>> >> >> >> > >> >> >>                         Iterator i =
> spots.iterator();
>> >> >> >> > >> >> >>                         Element g =
>> >> >> >> > >> > doc.getElementById("circleGroup");
>> >> >> >> > >> >> >>                        if (g == null)
>> >> >> >> > >> >> >>                        {
>> >> >> >> > >> >> >>                           g =
>> >> > doc.createElementNS(SVGNS,"g");
>> >> >> >> > >> >> >>                           g.setAttributeNS(null,
> "id",
>> >> >> >> > >> > "circleGroup");
>> >> >> >> > >> >> >> doc.getRootElement().appendChild(g);
>> >> >> >> > >> >> >>                        }
>> >> >> >> > >> >> >>
>> >> >> >> > >> >> >>
>> >> >> >> > >> >> >>                         while (i.hasNext())
>> >> >> >> > >> >> >>                         {
>> >> >> >> > >> >> >>                           Point2D pt2d = (Point2D)
>> >> > i.next();
>> >> >> >> > >> >> >>                           Element e =
>> >> >> >> > >> >> > doc.createElementNS(SVGNS,"circle");
>> >> >> >> > >> >> >> e.setAttributeNS(null,"cx",""+pt2d.getX());
>> >> >> >> > >> >> >> e.setAttributeNS(null,"cy",""+pt2d.getY());
>> >> >> >> > >> >> >> e.setAttributeNS(null,"r","8");
>> >> >> >> > >> >> >> e.setAttributeNS(null,"fill","Red");
>> >> >> >> > >> >> >>                           g.appendChild(e);
>> >> >> >> > >> >> >>                         }
>> >> >> >> > >> >> >>                       }
>> >> >> >> > >> >> >>                       });
>> >> >> >> > >> >> >>
>> >> >> >> > >> >> >>                       canvas.repaint();
>> >> >> >> > >> >> >
>> >> >> >> > >> >> >
>> >> >> >> > >> >> >
>> >> >> >> > >
>> >> >> >
>> > ---------------------------------------------------------------------
>> >> >> >> > >> >> > 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
>> >> >> >> > >> >
>> >> >> >> > >> >
>> >> >> >> > >> >
>> >> >> >> > >>
>> >> >> >> > >>
>> >> >> >> > >>
>> >> >> >> > >>
>> >> >> >
>> > ---------------------------------------------------------------------
>> >> >> >> > >> 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
>> >> >> >> > >
>> >> >> >> > >
>> >> >> >> > >
>> >> >> >> > [attachment "TestProgram.java" 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
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >>
>> >> >>
>> >> >>
>> >> >>
> ---------------------------------------------------------------------
>> >> >> 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
>> >>
>> >
>> >
>> > ---------------------------------------------------------------------
>> > 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
>
>
>



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


Re: adding Elements to SVG Doc

Posted by th...@kodak.com.
Hi Yasmin,

rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:24:15 PM:

> I've tried this, but again I have a problem with the paranthesis of the
> addEventListener?

   What is the error?
   Does CircleAction implement the DOM EventListener interface?
 
        org.w3c.dom.events.EventListener;


>  NodeList circleList = doc.getElementsByTagName("circle");

   You only need to add one event listener to the circleGroup.
Then use evt.getTarget() to know what circle it is.

>  for (int count = 0; count < circleList.getLength(); count++) {
>  EventTarget eventTarget = (EventTarget) circleList.item(count);
>  eventTarget.addEventListener("click",new CircleAction(),false);
> }
> 
> Thx
> 
> yasmin
> 
> 
> 
> > Hi Yasmin,
> >
> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 05:54:00 PM:
> >
> >> Now I'm trying to make the red circles clickable, I've tried this 
code
> > but
> >> for some reason I can't get the element.addEventListener?
> >
> >    addEventListener is on the EventTarget interface.  So you
> > will need to cast the element to add the listener.
> >
> >>
> >> Element element = doc.getElementById("circleGroup");
> >> element.addEventListener("click", new CircleAction(), false);
> >>
> >> Thx
> >>
> >> yasmin
> >>
> >> > Hi Yasmin,
> >> >
> >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 03:44:08 PM:
> >> >
> >> >> Here's the heading of my svg file, can you see anything that might 
be
> >> >> causing the red circles not appearing?
> >> >
> >> >>   viewBox="424000.000 -518000 2000 2000"
> >> >
> >> >    Your viewBox certainly doesn't intersect any of the coords
> >> > in your example source code.  When you add the elements to the
> >> > Document you need to place your circles in the 'maps' coordinate
> >> > system (which normally is simplier for you).
> >> >
> >> >    So the cx & cy for a circle should look something like
> >> >         cx="425100"
> >> >         cy="-519100"
> >> >
> >> >> >     One other comment on the code.  I would suggest using the
> >> >> > JSVGScrollPane
> >> >> > instead of the swing JScrollPane.  The JScrollPane works in most
> > cases
> >> >> > it tends to be much less efficient than the JSVGScrollPane.
> >> >> >
> >> >> > thomas.deweese@kodak.com wrote on 03/12/2006 03:01:19 PM:
> >> >> >
> >> >> >> Hi Yasmin,
> >> >> >>
> >> >> >>     Your test code worked fine for me with one change, you had:
> >> >> >>
> >> >> >>                                 Element e =
> >> >> >> doc.createElementNS(SVGNS,"spot");
> >> >> >>
> >> >> >>     This isn't right you want:
> >> >> >>
> >> >> >>                                 Element e =
> >> >> >> doc.createElementNS(SVGNS,"circle");
> >> >> >>
> >> >> >>     Which is odd because an earlier e-mail had 'circle'
> >> >> >> I tested by opening 'samples/mapSpain.svg'.  I think two of 
your
> >> > circles
> >> >> >> still didn't show because mapSpain isn't quite large enough but
> > the
> >> > ones
> >> >> >> that should show did.
> >> >> >>
> >> >> >> rafiqy@blueyonder.co.uk wrote on 03/12/2006 02:07:00 PM:
> >> >> >>
> >> >> >> > I've just attached the java file only!
> >> >> >> >
> >> >> >> > Tx
> >> >> >> > yasmin
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> > > Hi Yasmin,
> >> >> >> > >
> >> >> >> > > rafiqy@blueyonder.co.uk wrote on 03/12/2006 10:45:17 AM:
> >> >> >> > >
> >> >> >> > >> Now when I run my code I get the following error:
> >> >> >> > >>
> >> >> >> > >> org.w3c.dom.DOMException: The current document is unable 
to
> >> > create
> >> >> > an
> >> >> >> > >> element of the requested type (namespace:
> >> >> > http://www.w3.org/2000/svg,
> >> >> >> > >> name: spot).
> >> >> >> > >
> >> >> >> > >    Batik's DOM implementation prevents you from creating
> > elements
> >> > in
> >> >> >
> >> >> >> the
> >> >> >> > > SVG Namespace that aren't part of the SVG specification.
> >> >> >> > >
> >> >> >> > >    As far as path forward, I would suggest taking the code 
to
> >> > create
> >> >> >
> >> >> >> the
> >> >> >> > > circles and put it in a small example that just puts of the
> >> > canvas
> >> >> >> > > (with any old document) and a button that adds a list of
> > preset
> >> >> >> circles.
> >> >> >> > >
> >> >> >> > >    Then with all the code together I can either spot the 
error
> > or
> >> >> >> > > run it and debug why it isn't working for you.
> >> >> >> > >
> >> >> >> > >>
> >> >> >> > >>    at
> >> > org.apache.batik.dom.AbstractNode.createDOMException(Unknown
> >> >> >> > > Source)
> >> >> >> > >>
> >> >> >> > >>    at
> >> >> >> > >
> >> >> >
> > org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(Unknown
> >> >> >> > >> Source)
> >> >> >> > >>
> >> >> >> > >>    at
> >> >> > org.apache.batik.dom.svg.SVGOMDocument.createElementNS(Unknown
> >> >> >> > > Source)
> >> >> >> > >>
> >> >> >> > >>    at
> >> >> > mypackage22.KeyAccidentClient$4.run(KeyAccidentClient.java:349)
> >> >> >> > >>
> >> >> >> > >>    at org.apache.batik.util.RunnableQueue.run(Unknown 
Source)
> >> >> >> > >>
> >> >> >> > >>    at java.lang.Thread.run(Thread.java:534)
> >> >> >> > >>
> >> >> >> > >> Pls advice.
> >> >> >> > >>
> >> >> >> > >> Thx
> >> >> >> > >>
> >> >> >> > >> yasmin
> >> >> >> > >>
> >> >> >> > >>
> >> >> >> > >>
> >> >> >> > >>
> >> >> >> > >> > Hi Yasmin,
> >> >> >> > >> >
> >> >> >> > >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36 AM:
> >> >> >> > >> >
> >> >> >> > >> >> When I tried putting a line to test if the code is
> > running,
> >> > the
> >> >> >> code
> >> >> >> > >> > does
> >> >> >> > >> >> run, but apparently it does not create any elements,
> > here's
> >> > what
> >> >> > I
> >> >> >> > >> > tested:
> >> >> >> > >> >>
> >> >> >> > >> >> System.out.println("This is just testing :" +
> >> >> >> > >> > g.getAttribute("circleGroup"));
> >> >> >> > >> >>
> >> >> >> > >> >> and nothing prints for g.getAttribute ...
> >> >> >> > >> >
> >> >> >> > >> >    This is expected, I think you want to use:
> >> >> >> > >> >         g.getAttributeNS(null, "id");
> >> >> >> > >> >
> >> >> >> > >> >    This should result in the string 'circleGroup'.
> >> >> >> > >> >
> >> >> >> > >> >> > rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31 
PM:
> >> >> >> > >> >> >
> >> >> >> > >> >> >> I did initially try to add the red circles to the 
svg
> >> >> > document
> >> >> >> > >> >> >> programatically, infact I think you emailed me a
> > snippet
> >> > of
> >> >> >> your
> >> >> >> > > code
> >> >> >> > >> >> >> but it doesn't work, the code compiles but does not
> >> > display
> >> >> > the
> >> >> >> > >> >> >> red-circles, I tried to repaint my canvas, that 
don't
> >> > work...
> >> >> >> > > here's
> >> >> >> > >> >> >> the code I'm using maybe you might be able to spot
> > where
> >> > I'm
> >> >> >> > > making
> >> >> >> > >> >> >> the error...
> >> >> >> > >> >> >
> >> >> >> > >> >> >    The code looks pretty good.  You aren't that far 
from
> > a
> >> >> >> > >> >> > standalone example, this would help me help you...
> >> >> >> > >> >> >
> >> >> >> > >> >> >> //I added this in my constructor
> >> >> >> > >> >> >> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
> >> >> >> > >> >> >
> >> >> >> > >> >> >    This must be done _before_ you set the document on
> > the
> >> >> >> canvas.
> >> >> >> > >> >> >
> >> >> >> > >> >> >> //The following code I added in my ActionListener
> > triggred
> >> > by
> >> >> > a
> >> >> >> > >> > button
> >> >> >> > >> >> >
> >> >> >> > >> >> >    Are you sure this code runs?  Some println's might
> > help
> >> >> > make
> >> >> >> > > sure
> >> >> >> > >> >> > that your spots list isn't empty for some reason, 
etc.
> > You
> >> >> >> don't
> >> >> >> > >> >> > need to 'repaint' the canvas.
> >> >> >> > >> >> >
> >> >> >> > >> >> >>
> >> >> >> 
canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
> >> >> >> > >> >> >> Runnable() {
> >> >> >> > >> >> >>
> >> >> >> > >> >> >>                       public void run()
> >> >> >> > >> >> >>                       {
> >> >> >> > >> >> >>                         SVGDocument doc =
> >> >> >> canvas.getSVGDocument();
> >> >> >> > >> >> >>                         String SVGNS =
> >> >> >> > > "http://www.w3.org/2000/svg";
> >> >> >> > >> >> >>                         Iterator i = 
spots.iterator();
> >> >> >> > >> >> >>                         Element g =
> >> >> >> > >> > doc.getElementById("circleGroup");
> >> >> >> > >> >> >>                        if (g == null)
> >> >> >> > >> >> >>                        {
> >> >> >> > >> >> >>                           g =
> >> > doc.createElementNS(SVGNS,"g");
> >> >> >> > >> >> >>                           g.setAttributeNS(null, 
"id",
> >> >> >> > >> > "circleGroup");
> >> >> >> > >> >> >> doc.getRootElement().appendChild(g);
> >> >> >> > >> >> >>                        }
> >> >> >> > >> >> >>
> >> >> >> > >> >> >>
> >> >> >> > >> >> >>                         while (i.hasNext())
> >> >> >> > >> >> >>                         {
> >> >> >> > >> >> >>                           Point2D pt2d = (Point2D)
> >> > i.next();
> >> >> >> > >> >> >>                           Element e =
> >> >> >> > >> >> > doc.createElementNS(SVGNS,"circle");
> >> >> >> > >> >> >> e.setAttributeNS(null,"cx",""+pt2d.getX());
> >> >> >> > >> >> >> e.setAttributeNS(null,"cy",""+pt2d.getY());
> >> >> >> > >> >> >> e.setAttributeNS(null,"r","8");
> >> >> >> > >> >> >> e.setAttributeNS(null,"fill","Red");
> >> >> >> > >> >> >>                           g.appendChild(e);
> >> >> >> > >> >> >>                         }
> >> >> >> > >> >> >>                       }
> >> >> >> > >> >> >>                       });
> >> >> >> > >> >> >>
> >> >> >> > >> >> >>                       canvas.repaint();
> >> >> >> > >> >> >
> >> >> >> > >> >> >
> >> >> >> > >> >> >
> >> >> >> > >
> >> >> >
> > ---------------------------------------------------------------------
> >> >> >> > >> >> > 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
> >> >> >> > >> >
> >> >> >> > >> >
> >> >> >> > >> >
> >> >> >> > >>
> >> >> >> > >>
> >> >> >> > >>
> >> >> >> > >>
> >> >> >
> > ---------------------------------------------------------------------
> >> >> >> > >> 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
> >> >> >> > >
> >> >> >> > >
> >> >> >> > >
> >> >> >> > [attachment "TestProgram.java" 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
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >>
> >> >> 
---------------------------------------------------------------------
> >> >> 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
> >>
> >
> >
> > ---------------------------------------------------------------------
> > 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: adding Elements to SVG Doc

Posted by ra...@blueyonder.co.uk.
Hi Thomas,

I've tried this, but again I have a problem with the paranthesis of the
addEventListener?


 NodeList circleList = doc.getElementsByTagName("circle");
 for (int count = 0; count < circleList.getLength(); count++) {
 EventTarget eventTarget = (EventTarget) circleList.item(count);
 eventTarget.addEventListener("click",new CircleAction(),false);
}

Thx

yasmin



> Hi Yasmin,
>
> rafiqy@blueyonder.co.uk wrote on 03/12/2006 05:54:00 PM:
>
>> Now I'm trying to make the red circles clickable, I've tried this code
> but
>> for some reason I can't get the element.addEventListener?
>
>    addEventListener is on the EventTarget interface.  So you
> will need to cast the element to add the listener.
>
>>
>> Element element = doc.getElementById("circleGroup");
>> element.addEventListener("click", new CircleAction(), false);
>>
>> Thx
>>
>> yasmin
>>
>> > Hi Yasmin,
>> >
>> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 03:44:08 PM:
>> >
>> >> Here's the heading of my svg file, can you see anything that might be
>> >> causing the red circles not appearing?
>> >
>> >>   viewBox="424000.000 -518000 2000 2000"
>> >
>> >    Your viewBox certainly doesn't intersect any of the coords
>> > in your example source code.  When you add the elements to the
>> > Document you need to place your circles in the 'maps' coordinate
>> > system (which normally is simplier for you).
>> >
>> >    So the cx & cy for a circle should look something like
>> >         cx="425100"
>> >         cy="-519100"
>> >
>> >> >     One other comment on the code.  I would suggest using the
>> >> > JSVGScrollPane
>> >> > instead of the swing JScrollPane.  The JScrollPane works in most
> cases
>> >> > it tends to be much less efficient than the JSVGScrollPane.
>> >> >
>> >> > thomas.deweese@kodak.com wrote on 03/12/2006 03:01:19 PM:
>> >> >
>> >> >> Hi Yasmin,
>> >> >>
>> >> >>     Your test code worked fine for me with one change, you had:
>> >> >>
>> >> >>                                 Element e =
>> >> >> doc.createElementNS(SVGNS,"spot");
>> >> >>
>> >> >>     This isn't right you want:
>> >> >>
>> >> >>                                 Element e =
>> >> >> doc.createElementNS(SVGNS,"circle");
>> >> >>
>> >> >>     Which is odd because an earlier e-mail had 'circle'
>> >> >> I tested by opening 'samples/mapSpain.svg'.  I think two of your
>> > circles
>> >> >> still didn't show because mapSpain isn't quite large enough but
> the
>> > ones
>> >> >> that should show did.
>> >> >>
>> >> >> rafiqy@blueyonder.co.uk wrote on 03/12/2006 02:07:00 PM:
>> >> >>
>> >> >> > I've just attached the java file only!
>> >> >> >
>> >> >> > Tx
>> >> >> > yasmin
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > > Hi Yasmin,
>> >> >> > >
>> >> >> > > rafiqy@blueyonder.co.uk wrote on 03/12/2006 10:45:17 AM:
>> >> >> > >
>> >> >> > >> Now when I run my code I get the following error:
>> >> >> > >>
>> >> >> > >> org.w3c.dom.DOMException: The current document is unable to
>> > create
>> >> > an
>> >> >> > >> element of the requested type (namespace:
>> >> > http://www.w3.org/2000/svg,
>> >> >> > >> name: spot).
>> >> >> > >
>> >> >> > >    Batik's DOM implementation prevents you from creating
> elements
>> > in
>> >> >
>> >> >> the
>> >> >> > > SVG Namespace that aren't part of the SVG specification.
>> >> >> > >
>> >> >> > >    As far as path forward, I would suggest taking the code to
>> > create
>> >> >
>> >> >> the
>> >> >> > > circles and put it in a small example that just puts of the
>> > canvas
>> >> >> > > (with any old document) and a button that adds a list of
> preset
>> >> >> circles.
>> >> >> > >
>> >> >> > >    Then with all the code together I can either spot the error
> or
>> >> >> > > run it and debug why it isn't working for you.
>> >> >> > >
>> >> >> > >>
>> >> >> > >>    at
>> > org.apache.batik.dom.AbstractNode.createDOMException(Unknown
>> >> >> > > Source)
>> >> >> > >>
>> >> >> > >>    at
>> >> >> > >
>> >> >
> org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(Unknown
>> >> >> > >> Source)
>> >> >> > >>
>> >> >> > >>    at
>> >> > org.apache.batik.dom.svg.SVGOMDocument.createElementNS(Unknown
>> >> >> > > Source)
>> >> >> > >>
>> >> >> > >>    at
>> >> > mypackage22.KeyAccidentClient$4.run(KeyAccidentClient.java:349)
>> >> >> > >>
>> >> >> > >>    at org.apache.batik.util.RunnableQueue.run(Unknown Source)
>> >> >> > >>
>> >> >> > >>    at java.lang.Thread.run(Thread.java:534)
>> >> >> > >>
>> >> >> > >> Pls advice.
>> >> >> > >>
>> >> >> > >> Thx
>> >> >> > >>
>> >> >> > >> yasmin
>> >> >> > >>
>> >> >> > >>
>> >> >> > >>
>> >> >> > >>
>> >> >> > >> > Hi Yasmin,
>> >> >> > >> >
>> >> >> > >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36 AM:
>> >> >> > >> >
>> >> >> > >> >> When I tried putting a line to test if the code is
> running,
>> > the
>> >> >> code
>> >> >> > >> > does
>> >> >> > >> >> run, but apparently it does not create any elements,
> here's
>> > what
>> >> > I
>> >> >> > >> > tested:
>> >> >> > >> >>
>> >> >> > >> >> System.out.println("This is just testing :" +
>> >> >> > >> > g.getAttribute("circleGroup"));
>> >> >> > >> >>
>> >> >> > >> >> and nothing prints for g.getAttribute ...
>> >> >> > >> >
>> >> >> > >> >    This is expected, I think you want to use:
>> >> >> > >> >         g.getAttributeNS(null, "id");
>> >> >> > >> >
>> >> >> > >> >    This should result in the string 'circleGroup'.
>> >> >> > >> >
>> >> >> > >> >> > rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31 PM:
>> >> >> > >> >> >
>> >> >> > >> >> >> I did initially try to add the red circles to the svg
>> >> > document
>> >> >> > >> >> >> programatically, infact I think you emailed me a
> snippet
>> > of
>> >> >> your
>> >> >> > > code
>> >> >> > >> >> >> but it doesn't work, the code compiles but does not
>> > display
>> >> > the
>> >> >> > >> >> >> red-circles, I tried to repaint my canvas, that don't
>> > work...
>> >> >> > > here's
>> >> >> > >> >> >> the code I'm using maybe you might be able to spot
> where
>> > I'm
>> >> >> > > making
>> >> >> > >> >> >> the error...
>> >> >> > >> >> >
>> >> >> > >> >> >    The code looks pretty good.  You aren't that far from
> a
>> >> >> > >> >> > standalone example, this would help me help you...
>> >> >> > >> >> >
>> >> >> > >> >> >> //I added this in my constructor
>> >> >> > >> >> >> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>> >> >> > >> >> >
>> >> >> > >> >> >    This must be done _before_ you set the document on
> the
>> >> >> canvas.
>> >> >> > >> >> >
>> >> >> > >> >> >> //The following code I added in my ActionListener
> triggred
>> > by
>> >> > a
>> >> >> > >> > button
>> >> >> > >> >> >
>> >> >> > >> >> >    Are you sure this code runs?  Some println's might
> help
>> >> > make
>> >> >> > > sure
>> >> >> > >> >> > that your spots list isn't empty for some reason, etc.
> You
>> >> >> don't
>> >> >> > >> >> > need to 'repaint' the canvas.
>> >> >> > >> >> >
>> >> >> > >> >> >>
>> >> >> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
>> >> >> > >> >> >> Runnable() {
>> >> >> > >> >> >>
>> >> >> > >> >> >>                       public void run()
>> >> >> > >> >> >>                       {
>> >> >> > >> >> >>                         SVGDocument doc =
>> >> >> canvas.getSVGDocument();
>> >> >> > >> >> >>                         String SVGNS =
>> >> >> > > "http://www.w3.org/2000/svg";
>> >> >> > >> >> >>                         Iterator i = spots.iterator();
>> >> >> > >> >> >>                         Element g =
>> >> >> > >> > doc.getElementById("circleGroup");
>> >> >> > >> >> >>                        if (g == null)
>> >> >> > >> >> >>                        {
>> >> >> > >> >> >>                           g =
>> > doc.createElementNS(SVGNS,"g");
>> >> >> > >> >> >>                           g.setAttributeNS(null, "id",
>> >> >> > >> > "circleGroup");
>> >> >> > >> >> >> doc.getRootElement().appendChild(g);
>> >> >> > >> >> >>                        }
>> >> >> > >> >> >>
>> >> >> > >> >> >>
>> >> >> > >> >> >>                         while (i.hasNext())
>> >> >> > >> >> >>                         {
>> >> >> > >> >> >>                           Point2D pt2d = (Point2D)
>> > i.next();
>> >> >> > >> >> >>                           Element e =
>> >> >> > >> >> > doc.createElementNS(SVGNS,"circle");
>> >> >> > >> >> >> e.setAttributeNS(null,"cx",""+pt2d.getX());
>> >> >> > >> >> >> e.setAttributeNS(null,"cy",""+pt2d.getY());
>> >> >> > >> >> >> e.setAttributeNS(null,"r","8");
>> >> >> > >> >> >> e.setAttributeNS(null,"fill","Red");
>> >> >> > >> >> >>                           g.appendChild(e);
>> >> >> > >> >> >>                         }
>> >> >> > >> >> >>                       }
>> >> >> > >> >> >>                       });
>> >> >> > >> >> >>
>> >> >> > >> >> >>                       canvas.repaint();
>> >> >> > >> >> >
>> >> >> > >> >> >
>> >> >> > >> >> >
>> >> >> > >
>> >> >
> ---------------------------------------------------------------------
>> >> >> > >> >> > 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
>> >> >> > >> >
>> >> >> > >> >
>> >> >> > >> >
>> >> >> > >>
>> >> >> > >>
>> >> >> > >>
>> >> >> > >>
>> >> >
> ---------------------------------------------------------------------
>> >> >> > >> 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
>> >> >> > >
>> >> >> > >
>> >> >> > >
>> >> >> > [attachment "TestProgram.java" 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
>> >> >
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> 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
>>
>
>
> ---------------------------------------------------------------------
> 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: adding Elements to SVG Doc

Posted by th...@kodak.com.
Hi Yasmin,

rafiqy@blueyonder.co.uk wrote on 03/12/2006 05:54:00 PM:

> Now I'm trying to make the red circles clickable, I've tried this code 
but
> for some reason I can't get the element.addEventListener?

   addEventListener is on the EventTarget interface.  So you
will need to cast the element to add the listener.

> 
> Element element = doc.getElementById("circleGroup");
> element.addEventListener("click", new CircleAction(), false);
> 
> Thx
> 
> yasmin
> 
> > Hi Yasmin,
> >
> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 03:44:08 PM:
> >
> >> Here's the heading of my svg file, can you see anything that might be
> >> causing the red circles not appearing?
> >
> >>   viewBox="424000.000 -518000 2000 2000"
> >
> >    Your viewBox certainly doesn't intersect any of the coords
> > in your example source code.  When you add the elements to the
> > Document you need to place your circles in the 'maps' coordinate
> > system (which normally is simplier for you).
> >
> >    So the cx & cy for a circle should look something like
> >         cx="425100"
> >         cy="-519100"
> >
> >> >     One other comment on the code.  I would suggest using the
> >> > JSVGScrollPane
> >> > instead of the swing JScrollPane.  The JScrollPane works in most 
cases
> >> > it tends to be much less efficient than the JSVGScrollPane.
> >> >
> >> > thomas.deweese@kodak.com wrote on 03/12/2006 03:01:19 PM:
> >> >
> >> >> Hi Yasmin,
> >> >>
> >> >>     Your test code worked fine for me with one change, you had:
> >> >>
> >> >>                                 Element e =
> >> >> doc.createElementNS(SVGNS,"spot");
> >> >>
> >> >>     This isn't right you want:
> >> >>
> >> >>                                 Element e =
> >> >> doc.createElementNS(SVGNS,"circle");
> >> >>
> >> >>     Which is odd because an earlier e-mail had 'circle'
> >> >> I tested by opening 'samples/mapSpain.svg'.  I think two of your
> > circles
> >> >> still didn't show because mapSpain isn't quite large enough but 
the
> > ones
> >> >> that should show did.
> >> >>
> >> >> rafiqy@blueyonder.co.uk wrote on 03/12/2006 02:07:00 PM:
> >> >>
> >> >> > I've just attached the java file only!
> >> >> >
> >> >> > Tx
> >> >> > yasmin
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> > > Hi Yasmin,
> >> >> > >
> >> >> > > rafiqy@blueyonder.co.uk wrote on 03/12/2006 10:45:17 AM:
> >> >> > >
> >> >> > >> Now when I run my code I get the following error:
> >> >> > >>
> >> >> > >> org.w3c.dom.DOMException: The current document is unable to
> > create
> >> > an
> >> >> > >> element of the requested type (namespace:
> >> > http://www.w3.org/2000/svg,
> >> >> > >> name: spot).
> >> >> > >
> >> >> > >    Batik's DOM implementation prevents you from creating 
elements
> > in
> >> >
> >> >> the
> >> >> > > SVG Namespace that aren't part of the SVG specification.
> >> >> > >
> >> >> > >    As far as path forward, I would suggest taking the code to
> > create
> >> >
> >> >> the
> >> >> > > circles and put it in a small example that just puts of the
> > canvas
> >> >> > > (with any old document) and a button that adds a list of 
preset
> >> >> circles.
> >> >> > >
> >> >> > >    Then with all the code together I can either spot the error 
or
> >> >> > > run it and debug why it isn't working for you.
> >> >> > >
> >> >> > >>
> >> >> > >>    at
> > org.apache.batik.dom.AbstractNode.createDOMException(Unknown
> >> >> > > Source)
> >> >> > >>
> >> >> > >>    at
> >> >> > >
> >> > 
org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(Unknown
> >> >> > >> Source)
> >> >> > >>
> >> >> > >>    at
> >> > org.apache.batik.dom.svg.SVGOMDocument.createElementNS(Unknown
> >> >> > > Source)
> >> >> > >>
> >> >> > >>    at
> >> > mypackage22.KeyAccidentClient$4.run(KeyAccidentClient.java:349)
> >> >> > >>
> >> >> > >>    at org.apache.batik.util.RunnableQueue.run(Unknown Source)
> >> >> > >>
> >> >> > >>    at java.lang.Thread.run(Thread.java:534)
> >> >> > >>
> >> >> > >> Pls advice.
> >> >> > >>
> >> >> > >> Thx
> >> >> > >>
> >> >> > >> yasmin
> >> >> > >>
> >> >> > >>
> >> >> > >>
> >> >> > >>
> >> >> > >> > Hi Yasmin,
> >> >> > >> >
> >> >> > >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36 AM:
> >> >> > >> >
> >> >> > >> >> When I tried putting a line to test if the code is 
running,
> > the
> >> >> code
> >> >> > >> > does
> >> >> > >> >> run, but apparently it does not create any elements, 
here's
> > what
> >> > I
> >> >> > >> > tested:
> >> >> > >> >>
> >> >> > >> >> System.out.println("This is just testing :" +
> >> >> > >> > g.getAttribute("circleGroup"));
> >> >> > >> >>
> >> >> > >> >> and nothing prints for g.getAttribute ...
> >> >> > >> >
> >> >> > >> >    This is expected, I think you want to use:
> >> >> > >> >         g.getAttributeNS(null, "id");
> >> >> > >> >
> >> >> > >> >    This should result in the string 'circleGroup'.
> >> >> > >> >
> >> >> > >> >> > rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31 PM:
> >> >> > >> >> >
> >> >> > >> >> >> I did initially try to add the red circles to the svg
> >> > document
> >> >> > >> >> >> programatically, infact I think you emailed me a 
snippet
> > of
> >> >> your
> >> >> > > code
> >> >> > >> >> >> but it doesn't work, the code compiles but does not
> > display
> >> > the
> >> >> > >> >> >> red-circles, I tried to repaint my canvas, that don't
> > work...
> >> >> > > here's
> >> >> > >> >> >> the code I'm using maybe you might be able to spot 
where
> > I'm
> >> >> > > making
> >> >> > >> >> >> the error...
> >> >> > >> >> >
> >> >> > >> >> >    The code looks pretty good.  You aren't that far from 
a
> >> >> > >> >> > standalone example, this would help me help you...
> >> >> > >> >> >
> >> >> > >> >> >> //I added this in my constructor
> >> >> > >> >> >> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
> >> >> > >> >> >
> >> >> > >> >> >    This must be done _before_ you set the document on 
the
> >> >> canvas.
> >> >> > >> >> >
> >> >> > >> >> >> //The following code I added in my ActionListener 
triggred
> > by
> >> > a
> >> >> > >> > button
> >> >> > >> >> >
> >> >> > >> >> >    Are you sure this code runs?  Some println's might 
help
> >> > make
> >> >> > > sure
> >> >> > >> >> > that your spots list isn't empty for some reason, etc. 
You
> >> >> don't
> >> >> > >> >> > need to 'repaint' the canvas.
> >> >> > >> >> >
> >> >> > >> >> >>
> >> >> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
> >> >> > >> >> >> Runnable() {
> >> >> > >> >> >>
> >> >> > >> >> >>                       public void run()
> >> >> > >> >> >>                       {
> >> >> > >> >> >>                         SVGDocument doc =
> >> >> canvas.getSVGDocument();
> >> >> > >> >> >>                         String SVGNS =
> >> >> > > "http://www.w3.org/2000/svg";
> >> >> > >> >> >>                         Iterator i = spots.iterator();
> >> >> > >> >> >>                         Element g =
> >> >> > >> > doc.getElementById("circleGroup");
> >> >> > >> >> >>                        if (g == null)
> >> >> > >> >> >>                        {
> >> >> > >> >> >>                           g =
> > doc.createElementNS(SVGNS,"g");
> >> >> > >> >> >>                           g.setAttributeNS(null, "id",
> >> >> > >> > "circleGroup");
> >> >> > >> >> >> doc.getRootElement().appendChild(g);
> >> >> > >> >> >>                        }
> >> >> > >> >> >>
> >> >> > >> >> >>
> >> >> > >> >> >>                         while (i.hasNext())
> >> >> > >> >> >>                         {
> >> >> > >> >> >>                           Point2D pt2d = (Point2D)
> > i.next();
> >> >> > >> >> >>                           Element e =
> >> >> > >> >> > doc.createElementNS(SVGNS,"circle");
> >> >> > >> >> >> e.setAttributeNS(null,"cx",""+pt2d.getX());
> >> >> > >> >> >> e.setAttributeNS(null,"cy",""+pt2d.getY());
> >> >> > >> >> >> e.setAttributeNS(null,"r","8");
> >> >> > >> >> >> e.setAttributeNS(null,"fill","Red");
> >> >> > >> >> >>                           g.appendChild(e);
> >> >> > >> >> >>                         }
> >> >> > >> >> >>                       }
> >> >> > >> >> >>                       });
> >> >> > >> >> >>
> >> >> > >> >> >>                       canvas.repaint();
> >> >> > >> >> >
> >> >> > >> >> >
> >> >> > >> >> >
> >> >> > >
> >> > 
---------------------------------------------------------------------
> >> >> > >> >> > 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
> >> >> > >> >
> >> >> > >> >
> >> >> > >> >
> >> >> > >>
> >> >> > >>
> >> >> > >>
> >> >> > >>
> >> > 
---------------------------------------------------------------------
> >> >> > >> 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
> >> >> > >
> >> >> > >
> >> >> > >
> >> >> > [attachment "TestProgram.java" 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
> >> >
> >> >
> >> >
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> 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
> 


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


Re: adding Elements to SVG Doc

Posted by ra...@blueyonder.co.uk.
Hi Thomas,

Now I'm trying to make the red circles clickable, I've tried this code but
for some reason I can't get the element.addEventListener?

Element element = doc.getElementById("circleGroup");
element.addEventListener("click", new CircleAction(), false);

Thx

yasmin

> Hi Yasmin,
>
> rafiqy@blueyonder.co.uk wrote on 03/12/2006 03:44:08 PM:
>
>> Here's the heading of my svg file, can you see anything that might be
>> causing the red circles not appearing?
>
>>   viewBox="424000.000 -518000 2000 2000"
>
>    Your viewBox certainly doesn't intersect any of the coords
> in your example source code.  When you add the elements to the
> Document you need to place your circles in the 'maps' coordinate
> system (which normally is simplier for you).
>
>    So the cx & cy for a circle should look something like
>         cx="425100"
>         cy="-519100"
>
>> >     One other comment on the code.  I would suggest using the
>> > JSVGScrollPane
>> > instead of the swing JScrollPane.  The JScrollPane works in most cases
>> > it tends to be much less efficient than the JSVGScrollPane.
>> >
>> > thomas.deweese@kodak.com wrote on 03/12/2006 03:01:19 PM:
>> >
>> >> Hi Yasmin,
>> >>
>> >>     Your test code worked fine for me with one change, you had:
>> >>
>> >>                                 Element e =
>> >> doc.createElementNS(SVGNS,"spot");
>> >>
>> >>     This isn't right you want:
>> >>
>> >>                                 Element e =
>> >> doc.createElementNS(SVGNS,"circle");
>> >>
>> >>     Which is odd because an earlier e-mail had 'circle'
>> >> I tested by opening 'samples/mapSpain.svg'.  I think two of your
> circles
>> >> still didn't show because mapSpain isn't quite large enough but the
> ones
>> >> that should show did.
>> >>
>> >> rafiqy@blueyonder.co.uk wrote on 03/12/2006 02:07:00 PM:
>> >>
>> >> > I've just attached the java file only!
>> >> >
>> >> > Tx
>> >> > yasmin
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > > Hi Yasmin,
>> >> > >
>> >> > > rafiqy@blueyonder.co.uk wrote on 03/12/2006 10:45:17 AM:
>> >> > >
>> >> > >> Now when I run my code I get the following error:
>> >> > >>
>> >> > >> org.w3c.dom.DOMException: The current document is unable to
> create
>> > an
>> >> > >> element of the requested type (namespace:
>> > http://www.w3.org/2000/svg,
>> >> > >> name: spot).
>> >> > >
>> >> > >    Batik's DOM implementation prevents you from creating elements
> in
>> >
>> >> the
>> >> > > SVG Namespace that aren't part of the SVG specification.
>> >> > >
>> >> > >    As far as path forward, I would suggest taking the code to
> create
>> >
>> >> the
>> >> > > circles and put it in a small example that just puts of the
> canvas
>> >> > > (with any old document) and a button that adds a list of preset
>> >> circles.
>> >> > >
>> >> > >    Then with all the code together I can either spot the error or
>> >> > > run it and debug why it isn't working for you.
>> >> > >
>> >> > >>
>> >> > >>    at
> org.apache.batik.dom.AbstractNode.createDOMException(Unknown
>> >> > > Source)
>> >> > >>
>> >> > >>    at
>> >> > >
>> > org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(Unknown
>> >> > >> Source)
>> >> > >>
>> >> > >>    at
>> > org.apache.batik.dom.svg.SVGOMDocument.createElementNS(Unknown
>> >> > > Source)
>> >> > >>
>> >> > >>    at
>> > mypackage22.KeyAccidentClient$4.run(KeyAccidentClient.java:349)
>> >> > >>
>> >> > >>    at org.apache.batik.util.RunnableQueue.run(Unknown Source)
>> >> > >>
>> >> > >>    at java.lang.Thread.run(Thread.java:534)
>> >> > >>
>> >> > >> Pls advice.
>> >> > >>
>> >> > >> Thx
>> >> > >>
>> >> > >> yasmin
>> >> > >>
>> >> > >>
>> >> > >>
>> >> > >>
>> >> > >> > Hi Yasmin,
>> >> > >> >
>> >> > >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36 AM:
>> >> > >> >
>> >> > >> >> When I tried putting a line to test if the code is running,
> the
>> >> code
>> >> > >> > does
>> >> > >> >> run, but apparently it does not create any elements, here's
> what
>> > I
>> >> > >> > tested:
>> >> > >> >>
>> >> > >> >> System.out.println("This is just testing :" +
>> >> > >> > g.getAttribute("circleGroup"));
>> >> > >> >>
>> >> > >> >> and nothing prints for g.getAttribute ...
>> >> > >> >
>> >> > >> >    This is expected, I think you want to use:
>> >> > >> >         g.getAttributeNS(null, "id");
>> >> > >> >
>> >> > >> >    This should result in the string 'circleGroup'.
>> >> > >> >
>> >> > >> >> > rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31 PM:
>> >> > >> >> >
>> >> > >> >> >> I did initially try to add the red circles to the svg
>> > document
>> >> > >> >> >> programatically, infact I think you emailed me a snippet
> of
>> >> your
>> >> > > code
>> >> > >> >> >> but it doesn't work, the code compiles but does not
> display
>> > the
>> >> > >> >> >> red-circles, I tried to repaint my canvas, that don't
> work...
>> >> > > here's
>> >> > >> >> >> the code I'm using maybe you might be able to spot where
> I'm
>> >> > > making
>> >> > >> >> >> the error...
>> >> > >> >> >
>> >> > >> >> >    The code looks pretty good.  You aren't that far from a
>> >> > >> >> > standalone example, this would help me help you...
>> >> > >> >> >
>> >> > >> >> >> //I added this in my constructor
>> >> > >> >> >> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>> >> > >> >> >
>> >> > >> >> >    This must be done _before_ you set the document on the
>> >> canvas.
>> >> > >> >> >
>> >> > >> >> >> //The following code I added in my ActionListener triggred
> by
>> > a
>> >> > >> > button
>> >> > >> >> >
>> >> > >> >> >    Are you sure this code runs?  Some println's might help
>> > make
>> >> > > sure
>> >> > >> >> > that your spots list isn't empty for some reason, etc.  You
>> >> don't
>> >> > >> >> > need to 'repaint' the canvas.
>> >> > >> >> >
>> >> > >> >> >>
>> >> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
>> >> > >> >> >> Runnable() {
>> >> > >> >> >>
>> >> > >> >> >>                       public void run()
>> >> > >> >> >>                       {
>> >> > >> >> >>                         SVGDocument doc =
>> >> canvas.getSVGDocument();
>> >> > >> >> >>                         String SVGNS =
>> >> > > "http://www.w3.org/2000/svg";
>> >> > >> >> >>                         Iterator i = spots.iterator();
>> >> > >> >> >>                         Element g =
>> >> > >> > doc.getElementById("circleGroup");
>> >> > >> >> >>                        if (g == null)
>> >> > >> >> >>                        {
>> >> > >> >> >>                           g =
> doc.createElementNS(SVGNS,"g");
>> >> > >> >> >>                           g.setAttributeNS(null, "id",
>> >> > >> > "circleGroup");
>> >> > >> >> >> doc.getRootElement().appendChild(g);
>> >> > >> >> >>                        }
>> >> > >> >> >>
>> >> > >> >> >>
>> >> > >> >> >>                         while (i.hasNext())
>> >> > >> >> >>                         {
>> >> > >> >> >>                           Point2D pt2d = (Point2D)
> i.next();
>> >> > >> >> >>                           Element e =
>> >> > >> >> > doc.createElementNS(SVGNS,"circle");
>> >> > >> >> >> e.setAttributeNS(null,"cx",""+pt2d.getX());
>> >> > >> >> >> e.setAttributeNS(null,"cy",""+pt2d.getY());
>> >> > >> >> >>                           e.setAttributeNS(null,"r","8");
>> >> > >> >> >> e.setAttributeNS(null,"fill","Red");
>> >> > >> >> >>                           g.appendChild(e);
>> >> > >> >> >>                         }
>> >> > >> >> >>                       }
>> >> > >> >> >>                       });
>> >> > >> >> >>
>> >> > >> >> >>                       canvas.repaint();
>> >> > >> >> >
>> >> > >> >> >
>> >> > >> >> >
>> >> > >
>> > ---------------------------------------------------------------------
>> >> > >> >> > 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
>> >> > >> >
>> >> > >> >
>> >> > >> >
>> >> > >>
>> >> > >>
>> >> > >>
>> >> > >>
>> > ---------------------------------------------------------------------
>> >> > >> 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
>> >> > >
>> >> > >
>> >> > >
>> >> > [attachment "TestProgram.java" 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
>> >
>> >
>> >
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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: adding Elements to SVG Doc

Posted by ra...@blueyonder.co.uk.
Hi Thomas,

I forgot I converted my map coordinates to screen coordinates when I just
wantted to draw the circles on the overlay, so now I undone all that and
its working, I got the circles showing on the map!

ThankU

yasmin



> Hi Yasmin,
>
> rafiqy@blueyonder.co.uk wrote on 03/12/2006 03:44:08 PM:
>
>> Here's the heading of my svg file, can you see anything that might be
>> causing the red circles not appearing?
>
>>   viewBox="424000.000 -518000 2000 2000"
>
>    Your viewBox certainly doesn't intersect any of the coords
> in your example source code.  When you add the elements to the
> Document you need to place your circles in the 'maps' coordinate
> system (which normally is simplier for you).
>
>    So the cx & cy for a circle should look something like
>         cx="425100"
>         cy="-519100"
>
>> >     One other comment on the code.  I would suggest using the
>> > JSVGScrollPane
>> > instead of the swing JScrollPane.  The JScrollPane works in most cases
>> > it tends to be much less efficient than the JSVGScrollPane.
>> >
>> > thomas.deweese@kodak.com wrote on 03/12/2006 03:01:19 PM:
>> >
>> >> Hi Yasmin,
>> >>
>> >>     Your test code worked fine for me with one change, you had:
>> >>
>> >>                                 Element e =
>> >> doc.createElementNS(SVGNS,"spot");
>> >>
>> >>     This isn't right you want:
>> >>
>> >>                                 Element e =
>> >> doc.createElementNS(SVGNS,"circle");
>> >>
>> >>     Which is odd because an earlier e-mail had 'circle'
>> >> I tested by opening 'samples/mapSpain.svg'.  I think two of your
> circles
>> >> still didn't show because mapSpain isn't quite large enough but the
> ones
>> >> that should show did.
>> >>
>> >> rafiqy@blueyonder.co.uk wrote on 03/12/2006 02:07:00 PM:
>> >>
>> >> > I've just attached the java file only!
>> >> >
>> >> > Tx
>> >> > yasmin
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > > Hi Yasmin,
>> >> > >
>> >> > > rafiqy@blueyonder.co.uk wrote on 03/12/2006 10:45:17 AM:
>> >> > >
>> >> > >> Now when I run my code I get the following error:
>> >> > >>
>> >> > >> org.w3c.dom.DOMException: The current document is unable to
> create
>> > an
>> >> > >> element of the requested type (namespace:
>> > http://www.w3.org/2000/svg,
>> >> > >> name: spot).
>> >> > >
>> >> > >    Batik's DOM implementation prevents you from creating elements
> in
>> >
>> >> the
>> >> > > SVG Namespace that aren't part of the SVG specification.
>> >> > >
>> >> > >    As far as path forward, I would suggest taking the code to
> create
>> >
>> >> the
>> >> > > circles and put it in a small example that just puts of the
> canvas
>> >> > > (with any old document) and a button that adds a list of preset
>> >> circles.
>> >> > >
>> >> > >    Then with all the code together I can either spot the error or
>> >> > > run it and debug why it isn't working for you.
>> >> > >
>> >> > >>
>> >> > >>    at
> org.apache.batik.dom.AbstractNode.createDOMException(Unknown
>> >> > > Source)
>> >> > >>
>> >> > >>    at
>> >> > >
>> > org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(Unknown
>> >> > >> Source)
>> >> > >>
>> >> > >>    at
>> > org.apache.batik.dom.svg.SVGOMDocument.createElementNS(Unknown
>> >> > > Source)
>> >> > >>
>> >> > >>    at
>> > mypackage22.KeyAccidentClient$4.run(KeyAccidentClient.java:349)
>> >> > >>
>> >> > >>    at org.apache.batik.util.RunnableQueue.run(Unknown Source)
>> >> > >>
>> >> > >>    at java.lang.Thread.run(Thread.java:534)
>> >> > >>
>> >> > >> Pls advice.
>> >> > >>
>> >> > >> Thx
>> >> > >>
>> >> > >> yasmin
>> >> > >>
>> >> > >>
>> >> > >>
>> >> > >>
>> >> > >> > Hi Yasmin,
>> >> > >> >
>> >> > >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36 AM:
>> >> > >> >
>> >> > >> >> When I tried putting a line to test if the code is running,
> the
>> >> code
>> >> > >> > does
>> >> > >> >> run, but apparently it does not create any elements, here's
> what
>> > I
>> >> > >> > tested:
>> >> > >> >>
>> >> > >> >> System.out.println("This is just testing :" +
>> >> > >> > g.getAttribute("circleGroup"));
>> >> > >> >>
>> >> > >> >> and nothing prints for g.getAttribute ...
>> >> > >> >
>> >> > >> >    This is expected, I think you want to use:
>> >> > >> >         g.getAttributeNS(null, "id");
>> >> > >> >
>> >> > >> >    This should result in the string 'circleGroup'.
>> >> > >> >
>> >> > >> >> > rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31 PM:
>> >> > >> >> >
>> >> > >> >> >> I did initially try to add the red circles to the svg
>> > document
>> >> > >> >> >> programatically, infact I think you emailed me a snippet
> of
>> >> your
>> >> > > code
>> >> > >> >> >> but it doesn't work, the code compiles but does not
> display
>> > the
>> >> > >> >> >> red-circles, I tried to repaint my canvas, that don't
> work...
>> >> > > here's
>> >> > >> >> >> the code I'm using maybe you might be able to spot where
> I'm
>> >> > > making
>> >> > >> >> >> the error...
>> >> > >> >> >
>> >> > >> >> >    The code looks pretty good.  You aren't that far from a
>> >> > >> >> > standalone example, this would help me help you...
>> >> > >> >> >
>> >> > >> >> >> //I added this in my constructor
>> >> > >> >> >> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>> >> > >> >> >
>> >> > >> >> >    This must be done _before_ you set the document on the
>> >> canvas.
>> >> > >> >> >
>> >> > >> >> >> //The following code I added in my ActionListener triggred
> by
>> > a
>> >> > >> > button
>> >> > >> >> >
>> >> > >> >> >    Are you sure this code runs?  Some println's might help
>> > make
>> >> > > sure
>> >> > >> >> > that your spots list isn't empty for some reason, etc.  You
>> >> don't
>> >> > >> >> > need to 'repaint' the canvas.
>> >> > >> >> >
>> >> > >> >> >>
>> >> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
>> >> > >> >> >> Runnable() {
>> >> > >> >> >>
>> >> > >> >> >>                       public void run()
>> >> > >> >> >>                       {
>> >> > >> >> >>                         SVGDocument doc =
>> >> canvas.getSVGDocument();
>> >> > >> >> >>                         String SVGNS =
>> >> > > "http://www.w3.org/2000/svg";
>> >> > >> >> >>                         Iterator i = spots.iterator();
>> >> > >> >> >>                         Element g =
>> >> > >> > doc.getElementById("circleGroup");
>> >> > >> >> >>                        if (g == null)
>> >> > >> >> >>                        {
>> >> > >> >> >>                           g =
> doc.createElementNS(SVGNS,"g");
>> >> > >> >> >>                           g.setAttributeNS(null, "id",
>> >> > >> > "circleGroup");
>> >> > >> >> >> doc.getRootElement().appendChild(g);
>> >> > >> >> >>                        }
>> >> > >> >> >>
>> >> > >> >> >>
>> >> > >> >> >>                         while (i.hasNext())
>> >> > >> >> >>                         {
>> >> > >> >> >>                           Point2D pt2d = (Point2D)
> i.next();
>> >> > >> >> >>                           Element e =
>> >> > >> >> > doc.createElementNS(SVGNS,"circle");
>> >> > >> >> >> e.setAttributeNS(null,"cx",""+pt2d.getX());
>> >> > >> >> >> e.setAttributeNS(null,"cy",""+pt2d.getY());
>> >> > >> >> >>                           e.setAttributeNS(null,"r","8");
>> >> > >> >> >> e.setAttributeNS(null,"fill","Red");
>> >> > >> >> >>                           g.appendChild(e);
>> >> > >> >> >>                         }
>> >> > >> >> >>                       }
>> >> > >> >> >>                       });
>> >> > >> >> >>
>> >> > >> >> >>                       canvas.repaint();
>> >> > >> >> >
>> >> > >> >> >
>> >> > >> >> >
>> >> > >
>> > ---------------------------------------------------------------------
>> >> > >> >> > 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
>> >> > >> >
>> >> > >> >
>> >> > >> >
>> >> > >>
>> >> > >>
>> >> > >>
>> >> > >>
>> > ---------------------------------------------------------------------
>> >> > >> 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
>> >> > >
>> >> > >
>> >> > >
>> >> > [attachment "TestProgram.java" 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
>> >
>> >
>> >
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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: adding Elements to SVG Doc

Posted by th...@kodak.com.
Hi Yasmin,

rafiqy@blueyonder.co.uk wrote on 03/12/2006 03:44:08 PM:

> Here's the heading of my svg file, can you see anything that might be
> causing the red circles not appearing?

>   viewBox="424000.000 -518000 2000 2000"

   Your viewBox certainly doesn't intersect any of the coords
in your example source code.  When you add the elements to the
Document you need to place your circles in the 'maps' coordinate
system (which normally is simplier for you).

   So the cx & cy for a circle should look something like
        cx="425100"
        cy="-519100"

> >     One other comment on the code.  I would suggest using the
> > JSVGScrollPane
> > instead of the swing JScrollPane.  The JScrollPane works in most cases
> > it tends to be much less efficient than the JSVGScrollPane.
> >
> > thomas.deweese@kodak.com wrote on 03/12/2006 03:01:19 PM:
> >
> >> Hi Yasmin,
> >>
> >>     Your test code worked fine for me with one change, you had:
> >>
> >>                                 Element e =
> >> doc.createElementNS(SVGNS,"spot");
> >>
> >>     This isn't right you want:
> >>
> >>                                 Element e =
> >> doc.createElementNS(SVGNS,"circle");
> >>
> >>     Which is odd because an earlier e-mail had 'circle'
> >> I tested by opening 'samples/mapSpain.svg'.  I think two of your 
circles
> >> still didn't show because mapSpain isn't quite large enough but the 
ones
> >> that should show did.
> >>
> >> rafiqy@blueyonder.co.uk wrote on 03/12/2006 02:07:00 PM:
> >>
> >> > I've just attached the java file only!
> >> >
> >> > Tx
> >> > yasmin
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > > Hi Yasmin,
> >> > >
> >> > > rafiqy@blueyonder.co.uk wrote on 03/12/2006 10:45:17 AM:
> >> > >
> >> > >> Now when I run my code I get the following error:
> >> > >>
> >> > >> org.w3c.dom.DOMException: The current document is unable to 
create
> > an
> >> > >> element of the requested type (namespace:
> > http://www.w3.org/2000/svg,
> >> > >> name: spot).
> >> > >
> >> > >    Batik's DOM implementation prevents you from creating elements 
in
> >
> >> the
> >> > > SVG Namespace that aren't part of the SVG specification.
> >> > >
> >> > >    As far as path forward, I would suggest taking the code to 
create
> >
> >> the
> >> > > circles and put it in a small example that just puts of the 
canvas
> >> > > (with any old document) and a button that adds a list of preset
> >> circles.
> >> > >
> >> > >    Then with all the code together I can either spot the error or
> >> > > run it and debug why it isn't working for you.
> >> > >
> >> > >>
> >> > >>    at 
org.apache.batik.dom.AbstractNode.createDOMException(Unknown
> >> > > Source)
> >> > >>
> >> > >>    at
> >> > >
> > org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(Unknown
> >> > >> Source)
> >> > >>
> >> > >>    at
> > org.apache.batik.dom.svg.SVGOMDocument.createElementNS(Unknown
> >> > > Source)
> >> > >>
> >> > >>    at
> > mypackage22.KeyAccidentClient$4.run(KeyAccidentClient.java:349)
> >> > >>
> >> > >>    at org.apache.batik.util.RunnableQueue.run(Unknown Source)
> >> > >>
> >> > >>    at java.lang.Thread.run(Thread.java:534)
> >> > >>
> >> > >> Pls advice.
> >> > >>
> >> > >> Thx
> >> > >>
> >> > >> yasmin
> >> > >>
> >> > >>
> >> > >>
> >> > >>
> >> > >> > Hi Yasmin,
> >> > >> >
> >> > >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36 AM:
> >> > >> >
> >> > >> >> When I tried putting a line to test if the code is running, 
the
> >> code
> >> > >> > does
> >> > >> >> run, but apparently it does not create any elements, here's 
what
> > I
> >> > >> > tested:
> >> > >> >>
> >> > >> >> System.out.println("This is just testing :" +
> >> > >> > g.getAttribute("circleGroup"));
> >> > >> >>
> >> > >> >> and nothing prints for g.getAttribute ...
> >> > >> >
> >> > >> >    This is expected, I think you want to use:
> >> > >> >         g.getAttributeNS(null, "id");
> >> > >> >
> >> > >> >    This should result in the string 'circleGroup'.
> >> > >> >
> >> > >> >> > rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31 PM:
> >> > >> >> >
> >> > >> >> >> I did initially try to add the red circles to the svg
> > document
> >> > >> >> >> programatically, infact I think you emailed me a snippet 
of
> >> your
> >> > > code
> >> > >> >> >> but it doesn't work, the code compiles but does not 
display
> > the
> >> > >> >> >> red-circles, I tried to repaint my canvas, that don't 
work...
> >> > > here's
> >> > >> >> >> the code I'm using maybe you might be able to spot where 
I'm
> >> > > making
> >> > >> >> >> the error...
> >> > >> >> >
> >> > >> >> >    The code looks pretty good.  You aren't that far from a
> >> > >> >> > standalone example, this would help me help you...
> >> > >> >> >
> >> > >> >> >> //I added this in my constructor
> >> > >> >> >> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
> >> > >> >> >
> >> > >> >> >    This must be done _before_ you set the document on the
> >> canvas.
> >> > >> >> >
> >> > >> >> >> //The following code I added in my ActionListener triggred 
by
> > a
> >> > >> > button
> >> > >> >> >
> >> > >> >> >    Are you sure this code runs?  Some println's might help
> > make
> >> > > sure
> >> > >> >> > that your spots list isn't empty for some reason, etc.  You
> >> don't
> >> > >> >> > need to 'repaint' the canvas.
> >> > >> >> >
> >> > >> >> >>
> >> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
> >> > >> >> >> Runnable() {
> >> > >> >> >>
> >> > >> >> >>                       public void run()
> >> > >> >> >>                       {
> >> > >> >> >>                         SVGDocument doc =
> >> canvas.getSVGDocument();
> >> > >> >> >>                         String SVGNS =
> >> > > "http://www.w3.org/2000/svg";
> >> > >> >> >>                         Iterator i = spots.iterator();
> >> > >> >> >>                         Element g =
> >> > >> > doc.getElementById("circleGroup");
> >> > >> >> >>                        if (g == null)
> >> > >> >> >>                        {
> >> > >> >> >>                           g = 
doc.createElementNS(SVGNS,"g");
> >> > >> >> >>                           g.setAttributeNS(null, "id",
> >> > >> > "circleGroup");
> >> > >> >> >> doc.getRootElement().appendChild(g);
> >> > >> >> >>                        }
> >> > >> >> >>
> >> > >> >> >>
> >> > >> >> >>                         while (i.hasNext())
> >> > >> >> >>                         {
> >> > >> >> >>                           Point2D pt2d = (Point2D) 
i.next();
> >> > >> >> >>                           Element e =
> >> > >> >> > doc.createElementNS(SVGNS,"circle");
> >> > >> >> >> e.setAttributeNS(null,"cx",""+pt2d.getX());
> >> > >> >> >> e.setAttributeNS(null,"cy",""+pt2d.getY());
> >> > >> >> >>                           e.setAttributeNS(null,"r","8");
> >> > >> >> >> e.setAttributeNS(null,"fill","Red");
> >> > >> >> >>                           g.appendChild(e);
> >> > >> >> >>                         }
> >> > >> >> >>                       }
> >> > >> >> >>                       });
> >> > >> >> >>
> >> > >> >> >>                       canvas.repaint();
> >> > >> >> >
> >> > >> >> >
> >> > >> >> >
> >> > >
> > ---------------------------------------------------------------------
> >> > >> >> > 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
> >> > >> >
> >> > >> >
> >> > >> >
> >> > >>
> >> > >>
> >> > >>
> >> > >>
> > ---------------------------------------------------------------------
> >> > >> 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
> >> > >
> >> > >
> >> > >
> >> > [attachment "TestProgram.java" 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
> >
> >
> >
> 
> 
> 
> ---------------------------------------------------------------------
> 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: adding Elements to SVG Doc

Posted by ra...@blueyonder.co.uk.
Hi Thomas,

Here's the heading of my svg file, can you see anything that might be
causing the red circles not appearing?

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:gml="http://www.opengis.net/gml"
xmlns:osgb="http://www.ordnancesurvey.co.uk/xml/namespaces/osgb"
width="100%" height="100%" viewBox="424000.000 -518000 2000 2000">

Thx

yasmin



> Yasmin,
>
>     One other comment on the code.  I would suggest using the
> JSVGScrollPane
> instead of the swing JScrollPane.  The JScrollPane works in most cases
> it tends to be much less efficient than the JSVGScrollPane.
>
> thomas.deweese@kodak.com wrote on 03/12/2006 03:01:19 PM:
>
>> Hi Yasmin,
>>
>>     Your test code worked fine for me with one change, you had:
>>
>>                                 Element e =
>> doc.createElementNS(SVGNS,"spot");
>>
>>     This isn't right you want:
>>
>>                                 Element e =
>> doc.createElementNS(SVGNS,"circle");
>>
>>     Which is odd because an earlier e-mail had 'circle'
>> I tested by opening 'samples/mapSpain.svg'.  I think two of your circles
>> still didn't show because mapSpain isn't quite large enough but the ones
>> that should show did.
>>
>> rafiqy@blueyonder.co.uk wrote on 03/12/2006 02:07:00 PM:
>>
>> > I've just attached the java file only!
>> >
>> > Tx
>> > yasmin
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > Hi Yasmin,
>> > >
>> > > rafiqy@blueyonder.co.uk wrote on 03/12/2006 10:45:17 AM:
>> > >
>> > >> Now when I run my code I get the following error:
>> > >>
>> > >> org.w3c.dom.DOMException: The current document is unable to create
> an
>> > >> element of the requested type (namespace:
> http://www.w3.org/2000/svg,
>> > >> name: spot).
>> > >
>> > >    Batik's DOM implementation prevents you from creating elements in
>
>> the
>> > > SVG Namespace that aren't part of the SVG specification.
>> > >
>> > >    As far as path forward, I would suggest taking the code to create
>
>> the
>> > > circles and put it in a small example that just puts of the canvas
>> > > (with any old document) and a button that adds a list of preset
>> circles.
>> > >
>> > >    Then with all the code together I can either spot the error or
>> > > run it and debug why it isn't working for you.
>> > >
>> > >>
>> > >>    at org.apache.batik.dom.AbstractNode.createDOMException(Unknown
>> > > Source)
>> > >>
>> > >>    at
>> > >
> org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(Unknown
>> > >> Source)
>> > >>
>> > >>    at
> org.apache.batik.dom.svg.SVGOMDocument.createElementNS(Unknown
>> > > Source)
>> > >>
>> > >>    at
> mypackage22.KeyAccidentClient$4.run(KeyAccidentClient.java:349)
>> > >>
>> > >>    at org.apache.batik.util.RunnableQueue.run(Unknown Source)
>> > >>
>> > >>    at java.lang.Thread.run(Thread.java:534)
>> > >>
>> > >> Pls advice.
>> > >>
>> > >> Thx
>> > >>
>> > >> yasmin
>> > >>
>> > >>
>> > >>
>> > >>
>> > >> > Hi Yasmin,
>> > >> >
>> > >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36 AM:
>> > >> >
>> > >> >> When I tried putting a line to test if the code is running, the
>> code
>> > >> > does
>> > >> >> run, but apparently it does not create any elements, here's what
> I
>> > >> > tested:
>> > >> >>
>> > >> >> System.out.println("This is just testing :" +
>> > >> > g.getAttribute("circleGroup"));
>> > >> >>
>> > >> >> and nothing prints for g.getAttribute ...
>> > >> >
>> > >> >    This is expected, I think you want to use:
>> > >> >         g.getAttributeNS(null, "id");
>> > >> >
>> > >> >    This should result in the string 'circleGroup'.
>> > >> >
>> > >> >> > rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31 PM:
>> > >> >> >
>> > >> >> >> I did initially try to add the red circles to the svg
> document
>> > >> >> >> programatically, infact I think you emailed me a snippet of
>> your
>> > > code
>> > >> >> >> but it doesn't work, the code compiles but does not display
> the
>> > >> >> >> red-circles, I tried to repaint my canvas, that don't work...
>> > > here's
>> > >> >> >> the code I'm using maybe you might be able to spot where I'm
>> > > making
>> > >> >> >> the error...
>> > >> >> >
>> > >> >> >    The code looks pretty good.  You aren't that far from a
>> > >> >> > standalone example, this would help me help you...
>> > >> >> >
>> > >> >> >> //I added this in my constructor
>> > >> >> >> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>> > >> >> >
>> > >> >> >    This must be done _before_ you set the document on the
>> canvas.
>> > >> >> >
>> > >> >> >> //The following code I added in my ActionListener triggred by
> a
>> > >> > button
>> > >> >> >
>> > >> >> >    Are you sure this code runs?  Some println's might help
> make
>> > > sure
>> > >> >> > that your spots list isn't empty for some reason, etc.  You
>> don't
>> > >> >> > need to 'repaint' the canvas.
>> > >> >> >
>> > >> >> >>
>> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
>> > >> >> >> Runnable() {
>> > >> >> >>
>> > >> >> >>                       public void run()
>> > >> >> >>                       {
>> > >> >> >>                         SVGDocument doc =
>> canvas.getSVGDocument();
>> > >> >> >>                         String SVGNS =
>> > > "http://www.w3.org/2000/svg";
>> > >> >> >>                         Iterator i = spots.iterator();
>> > >> >> >>                         Element g =
>> > >> > doc.getElementById("circleGroup");
>> > >> >> >>                        if (g == null)
>> > >> >> >>                        {
>> > >> >> >>                           g = doc.createElementNS(SVGNS,"g");
>> > >> >> >>                           g.setAttributeNS(null, "id",
>> > >> > "circleGroup");
>> > >> >> >> doc.getRootElement().appendChild(g);
>> > >> >> >>                        }
>> > >> >> >>
>> > >> >> >>
>> > >> >> >>                         while (i.hasNext())
>> > >> >> >>                         {
>> > >> >> >>                           Point2D pt2d = (Point2D) i.next();
>> > >> >> >>                           Element e =
>> > >> >> > doc.createElementNS(SVGNS,"circle");
>> > >> >> >> e.setAttributeNS(null,"cx",""+pt2d.getX());
>> > >> >> >> e.setAttributeNS(null,"cy",""+pt2d.getY());
>> > >> >> >>                           e.setAttributeNS(null,"r","8");
>> > >> >> >> e.setAttributeNS(null,"fill","Red");
>> > >> >> >>                           g.appendChild(e);
>> > >> >> >>                         }
>> > >> >> >>                       }
>> > >> >> >>                       });
>> > >> >> >>
>> > >> >> >>                       canvas.repaint();
>> > >> >> >
>> > >> >> >
>> > >> >> >
>> > >
> ---------------------------------------------------------------------
>> > >> >> > 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
>> > >> >
>> > >> >
>> > >> >
>> > >>
>> > >>
>> > >>
>> > >>
> ---------------------------------------------------------------------
>> > >> 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
>> > >
>> > >
>> > >
>> > [attachment "TestProgram.java" 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
>
>
>



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


Re: adding Elements to SVG Doc

Posted by ra...@blueyonder.co.uk.
Thomas,

When I loaded the mapSpain.svg the red circles do appear, but when I use
my svg files they dnt - so it is my svg file, what do I need to check in
my svg file? Also, I changed the code so I am using the JSVGScrollPane but
the scrolls dnt work properly, they do appear once the document is loaded,
but when I try moving the horizontal scroll the document disappears
totally, here's the code:

JSVGScrollPane scroll = new JSVGScrollPane(canvas);

Thx

yasmin


> Yasmin,
>
>     One other comment on the code.  I would suggest using the
> JSVGScrollPane
> instead of the swing JScrollPane.  The JScrollPane works in most cases
> it tends to be much less efficient than the JSVGScrollPane.
>
> thomas.deweese@kodak.com wrote on 03/12/2006 03:01:19 PM:
>
>> Hi Yasmin,
>>
>>     Your test code worked fine for me with one change, you had:
>>
>>                                 Element e =
>> doc.createElementNS(SVGNS,"spot");
>>
>>     This isn't right you want:
>>
>>                                 Element e =
>> doc.createElementNS(SVGNS,"circle");
>>
>>     Which is odd because an earlier e-mail had 'circle'
>> I tested by opening 'samples/mapSpain.svg'.  I think two of your circles
>> still didn't show because mapSpain isn't quite large enough but the ones
>> that should show did.
>>
>> rafiqy@blueyonder.co.uk wrote on 03/12/2006 02:07:00 PM:
>>
>> > I've just attached the java file only!
>> >
>> > Tx
>> > yasmin
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > Hi Yasmin,
>> > >
>> > > rafiqy@blueyonder.co.uk wrote on 03/12/2006 10:45:17 AM:
>> > >
>> > >> Now when I run my code I get the following error:
>> > >>
>> > >> org.w3c.dom.DOMException: The current document is unable to create
> an
>> > >> element of the requested type (namespace:
> http://www.w3.org/2000/svg,
>> > >> name: spot).
>> > >
>> > >    Batik's DOM implementation prevents you from creating elements in
>
>> the
>> > > SVG Namespace that aren't part of the SVG specification.
>> > >
>> > >    As far as path forward, I would suggest taking the code to create
>
>> the
>> > > circles and put it in a small example that just puts of the canvas
>> > > (with any old document) and a button that adds a list of preset
>> circles.
>> > >
>> > >    Then with all the code together I can either spot the error or
>> > > run it and debug why it isn't working for you.
>> > >
>> > >>
>> > >>    at org.apache.batik.dom.AbstractNode.createDOMException(Unknown
>> > > Source)
>> > >>
>> > >>    at
>> > >
> org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(Unknown
>> > >> Source)
>> > >>
>> > >>    at
> org.apache.batik.dom.svg.SVGOMDocument.createElementNS(Unknown
>> > > Source)
>> > >>
>> > >>    at
> mypackage22.KeyAccidentClient$4.run(KeyAccidentClient.java:349)
>> > >>
>> > >>    at org.apache.batik.util.RunnableQueue.run(Unknown Source)
>> > >>
>> > >>    at java.lang.Thread.run(Thread.java:534)
>> > >>
>> > >> Pls advice.
>> > >>
>> > >> Thx
>> > >>
>> > >> yasmin
>> > >>
>> > >>
>> > >>
>> > >>
>> > >> > Hi Yasmin,
>> > >> >
>> > >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36 AM:
>> > >> >
>> > >> >> When I tried putting a line to test if the code is running, the
>> code
>> > >> > does
>> > >> >> run, but apparently it does not create any elements, here's what
> I
>> > >> > tested:
>> > >> >>
>> > >> >> System.out.println("This is just testing :" +
>> > >> > g.getAttribute("circleGroup"));
>> > >> >>
>> > >> >> and nothing prints for g.getAttribute ...
>> > >> >
>> > >> >    This is expected, I think you want to use:
>> > >> >         g.getAttributeNS(null, "id");
>> > >> >
>> > >> >    This should result in the string 'circleGroup'.
>> > >> >
>> > >> >> > rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31 PM:
>> > >> >> >
>> > >> >> >> I did initially try to add the red circles to the svg
> document
>> > >> >> >> programatically, infact I think you emailed me a snippet of
>> your
>> > > code
>> > >> >> >> but it doesn't work, the code compiles but does not display
> the
>> > >> >> >> red-circles, I tried to repaint my canvas, that don't work...
>> > > here's
>> > >> >> >> the code I'm using maybe you might be able to spot where I'm
>> > > making
>> > >> >> >> the error...
>> > >> >> >
>> > >> >> >    The code looks pretty good.  You aren't that far from a
>> > >> >> > standalone example, this would help me help you...
>> > >> >> >
>> > >> >> >> //I added this in my constructor
>> > >> >> >> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>> > >> >> >
>> > >> >> >    This must be done _before_ you set the document on the
>> canvas.
>> > >> >> >
>> > >> >> >> //The following code I added in my ActionListener triggred by
> a
>> > >> > button
>> > >> >> >
>> > >> >> >    Are you sure this code runs?  Some println's might help
> make
>> > > sure
>> > >> >> > that your spots list isn't empty for some reason, etc.  You
>> don't
>> > >> >> > need to 'repaint' the canvas.
>> > >> >> >
>> > >> >> >>
>> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
>> > >> >> >> Runnable() {
>> > >> >> >>
>> > >> >> >>                       public void run()
>> > >> >> >>                       {
>> > >> >> >>                         SVGDocument doc =
>> canvas.getSVGDocument();
>> > >> >> >>                         String SVGNS =
>> > > "http://www.w3.org/2000/svg";
>> > >> >> >>                         Iterator i = spots.iterator();
>> > >> >> >>                         Element g =
>> > >> > doc.getElementById("circleGroup");
>> > >> >> >>                        if (g == null)
>> > >> >> >>                        {
>> > >> >> >>                           g = doc.createElementNS(SVGNS,"g");
>> > >> >> >>                           g.setAttributeNS(null, "id",
>> > >> > "circleGroup");
>> > >> >> >> doc.getRootElement().appendChild(g);
>> > >> >> >>                        }
>> > >> >> >>
>> > >> >> >>
>> > >> >> >>                         while (i.hasNext())
>> > >> >> >>                         {
>> > >> >> >>                           Point2D pt2d = (Point2D) i.next();
>> > >> >> >>                           Element e =
>> > >> >> > doc.createElementNS(SVGNS,"circle");
>> > >> >> >> e.setAttributeNS(null,"cx",""+pt2d.getX());
>> > >> >> >> e.setAttributeNS(null,"cy",""+pt2d.getY());
>> > >> >> >>                           e.setAttributeNS(null,"r","8");
>> > >> >> >> e.setAttributeNS(null,"fill","Red");
>> > >> >> >>                           g.appendChild(e);
>> > >> >> >>                         }
>> > >> >> >>                       }
>> > >> >> >>                       });
>> > >> >> >>
>> > >> >> >>                       canvas.repaint();
>> > >> >> >
>> > >> >> >
>> > >> >> >
>> > >
> ---------------------------------------------------------------------
>> > >> >> > 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
>> > >> >
>> > >> >
>> > >> >
>> > >>
>> > >>
>> > >>
>> > >>
> ---------------------------------------------------------------------
>> > >> 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
>> > >
>> > >
>> > >
>> > [attachment "TestProgram.java" 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
>
>
>



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


Re: adding Elements to SVG Doc

Posted by th...@kodak.com.
Yasmin,

    One other comment on the code.  I would suggest using the 
JSVGScrollPane
instead of the swing JScrollPane.  The JScrollPane works in most cases 
it tends to be much less efficient than the JSVGScrollPane.

thomas.deweese@kodak.com wrote on 03/12/2006 03:01:19 PM:

> Hi Yasmin,
> 
>     Your test code worked fine for me with one change, you had:
> 
>                                 Element e = 
> doc.createElementNS(SVGNS,"spot");
> 
>     This isn't right you want:
> 
>                                 Element e = 
> doc.createElementNS(SVGNS,"circle");
> 
>     Which is odd because an earlier e-mail had 'circle'
> I tested by opening 'samples/mapSpain.svg'.  I think two of your circles
> still didn't show because mapSpain isn't quite large enough but the ones
> that should show did.
> 
> rafiqy@blueyonder.co.uk wrote on 03/12/2006 02:07:00 PM:
> 
> > I've just attached the java file only!
> > 
> > Tx
> > yasmin
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > Hi Yasmin,
> > >
> > > rafiqy@blueyonder.co.uk wrote on 03/12/2006 10:45:17 AM:
> > >
> > >> Now when I run my code I get the following error:
> > >>
> > >> org.w3c.dom.DOMException: The current document is unable to create 
an
> > >> element of the requested type (namespace: 
http://www.w3.org/2000/svg,
> > >> name: spot).
> > >
> > >    Batik's DOM implementation prevents you from creating elements in 

> the
> > > SVG Namespace that aren't part of the SVG specification.
> > >
> > >    As far as path forward, I would suggest taking the code to create 

> the
> > > circles and put it in a small example that just puts of the canvas
> > > (with any old document) and a button that adds a list of preset 
> circles.
> > >
> > >    Then with all the code together I can either spot the error or
> > > run it and debug why it isn't working for you.
> > >
> > >>
> > >>    at org.apache.batik.dom.AbstractNode.createDOMException(Unknown
> > > Source)
> > >>
> > >>    at
> > > 
org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(Unknown
> > >> Source)
> > >>
> > >>    at 
org.apache.batik.dom.svg.SVGOMDocument.createElementNS(Unknown
> > > Source)
> > >>
> > >>    at 
mypackage22.KeyAccidentClient$4.run(KeyAccidentClient.java:349)
> > >>
> > >>    at org.apache.batik.util.RunnableQueue.run(Unknown Source)
> > >>
> > >>    at java.lang.Thread.run(Thread.java:534)
> > >>
> > >> Pls advice.
> > >>
> > >> Thx
> > >>
> > >> yasmin
> > >>
> > >>
> > >>
> > >>
> > >> > Hi Yasmin,
> > >> >
> > >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36 AM:
> > >> >
> > >> >> When I tried putting a line to test if the code is running, the 
> code
> > >> > does
> > >> >> run, but apparently it does not create any elements, here's what 
I
> > >> > tested:
> > >> >>
> > >> >> System.out.println("This is just testing :" +
> > >> > g.getAttribute("circleGroup"));
> > >> >>
> > >> >> and nothing prints for g.getAttribute ...
> > >> >
> > >> >    This is expected, I think you want to use:
> > >> >         g.getAttributeNS(null, "id");
> > >> >
> > >> >    This should result in the string 'circleGroup'.
> > >> >
> > >> >> > rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31 PM:
> > >> >> >
> > >> >> >> I did initially try to add the red circles to the svg 
document
> > >> >> >> programatically, infact I think you emailed me a snippet of 
> your
> > > code
> > >> >> >> but it doesn't work, the code compiles but does not display 
the
> > >> >> >> red-circles, I tried to repaint my canvas, that don't work...
> > > here's
> > >> >> >> the code I'm using maybe you might be able to spot where I'm
> > > making
> > >> >> >> the error...
> > >> >> >
> > >> >> >    The code looks pretty good.  You aren't that far from a
> > >> >> > standalone example, this would help me help you...
> > >> >> >
> > >> >> >> //I added this in my constructor
> > >> >> >> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
> > >> >> >
> > >> >> >    This must be done _before_ you set the document on the 
> canvas.
> > >> >> >
> > >> >> >> //The following code I added in my ActionListener triggred by 
a
> > >> > button
> > >> >> >
> > >> >> >    Are you sure this code runs?  Some println's might help 
make
> > > sure
> > >> >> > that your spots list isn't empty for some reason, etc.  You 
> don't
> > >> >> > need to 'repaint' the canvas.
> > >> >> >
> > >> >> >> 
> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
> > >> >> >> Runnable() {
> > >> >> >>
> > >> >> >>                       public void run()
> > >> >> >>                       {
> > >> >> >>                         SVGDocument doc = 
> canvas.getSVGDocument();
> > >> >> >>                         String SVGNS =
> > > "http://www.w3.org/2000/svg";
> > >> >> >>                         Iterator i = spots.iterator();
> > >> >> >>                         Element g =
> > >> > doc.getElementById("circleGroup");
> > >> >> >>                        if (g == null)
> > >> >> >>                        {
> > >> >> >>                           g = doc.createElementNS(SVGNS,"g");
> > >> >> >>                           g.setAttributeNS(null, "id",
> > >> > "circleGroup");
> > >> >> >> doc.getRootElement().appendChild(g);
> > >> >> >>                        }
> > >> >> >>
> > >> >> >>
> > >> >> >>                         while (i.hasNext())
> > >> >> >>                         {
> > >> >> >>                           Point2D pt2d = (Point2D) i.next();
> > >> >> >>                           Element e =
> > >> >> > doc.createElementNS(SVGNS,"circle");
> > >> >> >> e.setAttributeNS(null,"cx",""+pt2d.getX());
> > >> >> >> e.setAttributeNS(null,"cy",""+pt2d.getY());
> > >> >> >>                           e.setAttributeNS(null,"r","8");
> > >> >> >> e.setAttributeNS(null,"fill","Red");
> > >> >> >>                           g.appendChild(e);
> > >> >> >>                         }
> > >> >> >>                       }
> > >> >> >>                       });
> > >> >> >>
> > >> >> >>                       canvas.repaint();
> > >> >> >
> > >> >> >
> > >> >> >
> > > 
---------------------------------------------------------------------
> > >> >> > 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
> > >> >
> > >> >
> > >> >
> > >>
> > >>
> > >>
> > >> 
---------------------------------------------------------------------
> > >> 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
> > >
> > >
> > >
> > [attachment "TestProgram.java" 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: adding Elements to SVG Doc

Posted by th...@kodak.com.
Hi Yasmin,

    Your test code worked fine for me with one change, you had:

                                Element e = 
doc.createElementNS(SVGNS,"spot");

    This isn't right you want:

                                Element e = 
doc.createElementNS(SVGNS,"circle");

    Which is odd because an earlier e-mail had 'circle'
I tested by opening 'samples/mapSpain.svg'.  I think two of your circles
still didn't show because mapSpain isn't quite large enough but the ones
that should show did.

rafiqy@blueyonder.co.uk wrote on 03/12/2006 02:07:00 PM:

> I've just attached the java file only!
> 
> Tx
> yasmin
> 
> 
> 
> 
> 
> 
> 
> > Hi Yasmin,
> >
> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 10:45:17 AM:
> >
> >> Now when I run my code I get the following error:
> >>
> >> org.w3c.dom.DOMException: The current document is unable to create an
> >> element of the requested type (namespace: http://www.w3.org/2000/svg,
> >> name: spot).
> >
> >    Batik's DOM implementation prevents you from creating elements in 
the
> > SVG Namespace that aren't part of the SVG specification.
> >
> >    As far as path forward, I would suggest taking the code to create 
the
> > circles and put it in a small example that just puts of the canvas
> > (with any old document) and a button that adds a list of preset 
circles.
> >
> >    Then with all the code together I can either spot the error or
> > run it and debug why it isn't working for you.
> >
> >>
> >>    at org.apache.batik.dom.AbstractNode.createDOMException(Unknown
> > Source)
> >>
> >>    at
> > org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(Unknown
> >> Source)
> >>
> >>    at org.apache.batik.dom.svg.SVGOMDocument.createElementNS(Unknown
> > Source)
> >>
> >>    at mypackage22.KeyAccidentClient$4.run(KeyAccidentClient.java:349)
> >>
> >>    at org.apache.batik.util.RunnableQueue.run(Unknown Source)
> >>
> >>    at java.lang.Thread.run(Thread.java:534)
> >>
> >> Pls advice.
> >>
> >> Thx
> >>
> >> yasmin
> >>
> >>
> >>
> >>
> >> > Hi Yasmin,
> >> >
> >> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36 AM:
> >> >
> >> >> When I tried putting a line to test if the code is running, the 
code
> >> > does
> >> >> run, but apparently it does not create any elements, here's what I
> >> > tested:
> >> >>
> >> >> System.out.println("This is just testing :" +
> >> > g.getAttribute("circleGroup"));
> >> >>
> >> >> and nothing prints for g.getAttribute ...
> >> >
> >> >    This is expected, I think you want to use:
> >> >         g.getAttributeNS(null, "id");
> >> >
> >> >    This should result in the string 'circleGroup'.
> >> >
> >> >> > rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31 PM:
> >> >> >
> >> >> >> I did initially try to add the red circles to the svg document
> >> >> >> programatically, infact I think you emailed me a snippet of 
your
> > code
> >> >> >> but it doesn't work, the code compiles but does not display the
> >> >> >> red-circles, I tried to repaint my canvas, that don't work...
> > here's
> >> >> >> the code I'm using maybe you might be able to spot where I'm
> > making
> >> >> >> the error...
> >> >> >
> >> >> >    The code looks pretty good.  You aren't that far from a
> >> >> > standalone example, this would help me help you...
> >> >> >
> >> >> >> //I added this in my constructor
> >> >> >> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
> >> >> >
> >> >> >    This must be done _before_ you set the document on the 
canvas.
> >> >> >
> >> >> >> //The following code I added in my ActionListener triggred by a
> >> > button
> >> >> >
> >> >> >    Are you sure this code runs?  Some println's might help make
> > sure
> >> >> > that your spots list isn't empty for some reason, etc.  You 
don't
> >> >> > need to 'repaint' the canvas.
> >> >> >
> >> >> >> 
canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
> >> >> >> Runnable() {
> >> >> >>
> >> >> >>                       public void run()
> >> >> >>                       {
> >> >> >>                         SVGDocument doc = 
canvas.getSVGDocument();
> >> >> >>                         String SVGNS =
> > "http://www.w3.org/2000/svg";
> >> >> >>                         Iterator i = spots.iterator();
> >> >> >>                         Element g =
> >> > doc.getElementById("circleGroup");
> >> >> >>                        if (g == null)
> >> >> >>                        {
> >> >> >>                           g = doc.createElementNS(SVGNS,"g");
> >> >> >>                           g.setAttributeNS(null, "id",
> >> > "circleGroup");
> >> >> >>                           doc.getRootElement().appendChild(g);
> >> >> >>                        }
> >> >> >>
> >> >> >>
> >> >> >>                         while (i.hasNext())
> >> >> >>                         {
> >> >> >>                           Point2D pt2d = (Point2D) i.next();
> >> >> >>                           Element e =
> >> >> > doc.createElementNS(SVGNS,"circle");
> >> >> >> e.setAttributeNS(null,"cx",""+pt2d.getX());
> >> >> >> e.setAttributeNS(null,"cy",""+pt2d.getY());
> >> >> >>                           e.setAttributeNS(null,"r","8");
> >> >> >>                           e.setAttributeNS(null,"fill","Red");
> >> >> >>                           g.appendChild(e);
> >> >> >>                         }
> >> >> >>                       }
> >> >> >>                       });
> >> >> >>
> >> >> >>                       canvas.repaint();
> >> >> >
> >> >> >
> >> >> >
> > ---------------------------------------------------------------------
> >> >> > 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
> >> >
> >> >
> >> >
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> 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
> >
> >
> >
> [attachment "TestProgram.java" 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: adding Elements to SVG Doc

Posted by ra...@blueyonder.co.uk.
I've just attached the java file only!

Tx
yasmin







> Hi Yasmin,
>
> rafiqy@blueyonder.co.uk wrote on 03/12/2006 10:45:17 AM:
>
>> Now when I run my code I get the following error:
>>
>> org.w3c.dom.DOMException: The current document is unable to create an
>> element of the requested type (namespace: http://www.w3.org/2000/svg,
>> name: spot).
>
>    Batik's DOM implementation prevents you from creating elements in the
> SVG Namespace that aren't part of the SVG specification.
>
>    As far as path forward, I would suggest taking the code to create the
> circles and put it in a small example that just puts of the canvas
> (with any old document) and a button that adds a list of preset circles.
>
>    Then with all the code together I can either spot the error or
> run it and debug why it isn't working for you.
>
>>
>>    at org.apache.batik.dom.AbstractNode.createDOMException(Unknown
> Source)
>>
>>    at
> org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(Unknown
>> Source)
>>
>>    at org.apache.batik.dom.svg.SVGOMDocument.createElementNS(Unknown
> Source)
>>
>>    at mypackage22.KeyAccidentClient$4.run(KeyAccidentClient.java:349)
>>
>>    at org.apache.batik.util.RunnableQueue.run(Unknown Source)
>>
>>    at java.lang.Thread.run(Thread.java:534)
>>
>> Pls advice.
>>
>> Thx
>>
>> yasmin
>>
>>
>>
>>
>> > Hi Yasmin,
>> >
>> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36 AM:
>> >
>> >> When I tried putting a line to test if the code is running, the code
>> > does
>> >> run, but apparently it does not create any elements, here's what I
>> > tested:
>> >>
>> >> System.out.println("This is just testing :" +
>> > g.getAttribute("circleGroup"));
>> >>
>> >> and nothing prints for g.getAttribute ...
>> >
>> >    This is expected, I think you want to use:
>> >         g.getAttributeNS(null, "id");
>> >
>> >    This should result in the string 'circleGroup'.
>> >
>> >> > rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31 PM:
>> >> >
>> >> >> I did initially try to add the red circles to the svg document
>> >> >> programatically, infact I think you emailed me a snippet of your
> code
>> >> >> but it doesn't work, the code compiles but does not display the
>> >> >> red-circles, I tried to repaint my canvas, that don't work...
> here's
>> >> >> the code I'm using maybe you might be able to spot where I'm
> making
>> >> >> the error...
>> >> >
>> >> >    The code looks pretty good.  You aren't that far from a
>> >> > standalone example, this would help me help you...
>> >> >
>> >> >> //I added this in my constructor
>> >> >> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>> >> >
>> >> >    This must be done _before_ you set the document on the canvas.
>> >> >
>> >> >> //The following code I added in my ActionListener triggred by a
>> > button
>> >> >
>> >> >    Are you sure this code runs?  Some println's might help make
> sure
>> >> > that your spots list isn't empty for some reason, etc.  You don't
>> >> > need to 'repaint' the canvas.
>> >> >
>> >> >> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
>> >> >> Runnable() {
>> >> >>
>> >> >>                       public void run()
>> >> >>                       {
>> >> >>                         SVGDocument doc = canvas.getSVGDocument();
>> >> >>                         String SVGNS =
> "http://www.w3.org/2000/svg";
>> >> >>                         Iterator i = spots.iterator();
>> >> >>                         Element g =
>> > doc.getElementById("circleGroup");
>> >> >>                        if (g == null)
>> >> >>                        {
>> >> >>                           g = doc.createElementNS(SVGNS,"g");
>> >> >>                           g.setAttributeNS(null, "id",
>> > "circleGroup");
>> >> >>                           doc.getRootElement().appendChild(g);
>> >> >>                        }
>> >> >>
>> >> >>
>> >> >>                         while (i.hasNext())
>> >> >>                         {
>> >> >>                           Point2D pt2d = (Point2D) i.next();
>> >> >>                           Element e =
>> >> > doc.createElementNS(SVGNS,"circle");
>> >> >> e.setAttributeNS(null,"cx",""+pt2d.getX());
>> >> >> e.setAttributeNS(null,"cy",""+pt2d.getY());
>> >> >>                           e.setAttributeNS(null,"r","8");
>> >> >>                           e.setAttributeNS(null,"fill","Red");
>> >> >>                           g.appendChild(e);
>> >> >>                         }
>> >> >>                       }
>> >> >>                       });
>> >> >>
>> >> >>                       canvas.repaint();
>> >> >
>> >> >
>> >> >
> ---------------------------------------------------------------------
>> >> > 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
>> >
>> >
>> >
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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: adding Elements to SVG Doc

Posted by ra...@blueyonder.co.uk.
Hi Thomas,

I'm having problems attaching my java file and the svg file... so that you
can have a look at the code for me?

Tx

yasmin


> Hi Yasmin,
>
> rafiqy@blueyonder.co.uk wrote on 03/12/2006 10:45:17 AM:
>
>> Now when I run my code I get the following error:
>>
>> org.w3c.dom.DOMException: The current document is unable to create an
>> element of the requested type (namespace: http://www.w3.org/2000/svg,
>> name: spot).
>
>    Batik's DOM implementation prevents you from creating elements in the
> SVG Namespace that aren't part of the SVG specification.
>
>    As far as path forward, I would suggest taking the code to create the
> circles and put it in a small example that just puts of the canvas
> (with any old document) and a button that adds a list of preset circles.
>
>    Then with all the code together I can either spot the error or
> run it and debug why it isn't working for you.
>
>>
>>    at org.apache.batik.dom.AbstractNode.createDOMException(Unknown
> Source)
>>
>>    at
> org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(Unknown
>> Source)
>>
>>    at org.apache.batik.dom.svg.SVGOMDocument.createElementNS(Unknown
> Source)
>>
>>    at mypackage22.KeyAccidentClient$4.run(KeyAccidentClient.java:349)
>>
>>    at org.apache.batik.util.RunnableQueue.run(Unknown Source)
>>
>>    at java.lang.Thread.run(Thread.java:534)
>>
>> Pls advice.
>>
>> Thx
>>
>> yasmin
>>
>>
>>
>>
>> > Hi Yasmin,
>> >
>> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36 AM:
>> >
>> >> When I tried putting a line to test if the code is running, the code
>> > does
>> >> run, but apparently it does not create any elements, here's what I
>> > tested:
>> >>
>> >> System.out.println("This is just testing :" +
>> > g.getAttribute("circleGroup"));
>> >>
>> >> and nothing prints for g.getAttribute ...
>> >
>> >    This is expected, I think you want to use:
>> >         g.getAttributeNS(null, "id");
>> >
>> >    This should result in the string 'circleGroup'.
>> >
>> >> > rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31 PM:
>> >> >
>> >> >> I did initially try to add the red circles to the svg document
>> >> >> programatically, infact I think you emailed me a snippet of your
> code
>> >> >> but it doesn't work, the code compiles but does not display the
>> >> >> red-circles, I tried to repaint my canvas, that don't work...
> here's
>> >> >> the code I'm using maybe you might be able to spot where I'm
> making
>> >> >> the error...
>> >> >
>> >> >    The code looks pretty good.  You aren't that far from a
>> >> > standalone example, this would help me help you...
>> >> >
>> >> >> //I added this in my constructor
>> >> >> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>> >> >
>> >> >    This must be done _before_ you set the document on the canvas.
>> >> >
>> >> >> //The following code I added in my ActionListener triggred by a
>> > button
>> >> >
>> >> >    Are you sure this code runs?  Some println's might help make
> sure
>> >> > that your spots list isn't empty for some reason, etc.  You don't
>> >> > need to 'repaint' the canvas.
>> >> >
>> >> >> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
>> >> >> Runnable() {
>> >> >>
>> >> >>                       public void run()
>> >> >>                       {
>> >> >>                         SVGDocument doc = canvas.getSVGDocument();
>> >> >>                         String SVGNS =
> "http://www.w3.org/2000/svg";
>> >> >>                         Iterator i = spots.iterator();
>> >> >>                         Element g =
>> > doc.getElementById("circleGroup");
>> >> >>                        if (g == null)
>> >> >>                        {
>> >> >>                           g = doc.createElementNS(SVGNS,"g");
>> >> >>                           g.setAttributeNS(null, "id",
>> > "circleGroup");
>> >> >>                           doc.getRootElement().appendChild(g);
>> >> >>                        }
>> >> >>
>> >> >>
>> >> >>                         while (i.hasNext())
>> >> >>                         {
>> >> >>                           Point2D pt2d = (Point2D) i.next();
>> >> >>                           Element e =
>> >> > doc.createElementNS(SVGNS,"circle");
>> >> >> e.setAttributeNS(null,"cx",""+pt2d.getX());
>> >> >> e.setAttributeNS(null,"cy",""+pt2d.getY());
>> >> >>                           e.setAttributeNS(null,"r","8");
>> >> >>                           e.setAttributeNS(null,"fill","Red");
>> >> >>                           g.appendChild(e);
>> >> >>                         }
>> >> >>                       }
>> >> >>                       });
>> >> >>
>> >> >>                       canvas.repaint();
>> >> >
>> >> >
>> >> >
> ---------------------------------------------------------------------
>> >> > 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
>> >
>> >
>> >
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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: adding Elements to SVG Doc

Posted by th...@kodak.com.
Hi Yasmin,

rafiqy@blueyonder.co.uk wrote on 03/12/2006 10:45:17 AM:

> Now when I run my code I get the following error:
> 
> org.w3c.dom.DOMException: The current document is unable to create an
> element of the requested type (namespace: http://www.w3.org/2000/svg,
> name: spot).

   Batik's DOM implementation prevents you from creating elements in the 
SVG Namespace that aren't part of the SVG specification.

   As far as path forward, I would suggest taking the code to create the
circles and put it in a small example that just puts of the canvas
(with any old document) and a button that adds a list of preset circles.

   Then with all the code together I can either spot the error or
run it and debug why it isn't working for you.

> 
>    at org.apache.batik.dom.AbstractNode.createDOMException(Unknown 
Source)
> 
>    at 
org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(Unknown
> Source)
> 
>    at org.apache.batik.dom.svg.SVGOMDocument.createElementNS(Unknown 
Source)
> 
>    at mypackage22.KeyAccidentClient$4.run(KeyAccidentClient.java:349)
> 
>    at org.apache.batik.util.RunnableQueue.run(Unknown Source)
> 
>    at java.lang.Thread.run(Thread.java:534)
> 
> Pls advice.
> 
> Thx
> 
> yasmin
> 
> 
> 
> 
> > Hi Yasmin,
> >
> > rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36 AM:
> >
> >> When I tried putting a line to test if the code is running, the code
> > does
> >> run, but apparently it does not create any elements, here's what I
> > tested:
> >>
> >> System.out.println("This is just testing :" +
> > g.getAttribute("circleGroup"));
> >>
> >> and nothing prints for g.getAttribute ...
> >
> >    This is expected, I think you want to use:
> >         g.getAttributeNS(null, "id");
> >
> >    This should result in the string 'circleGroup'.
> >
> >> > rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31 PM:
> >> >
> >> >> I did initially try to add the red circles to the svg document
> >> >> programatically, infact I think you emailed me a snippet of your 
code
> >> >> but it doesn't work, the code compiles but does not display the
> >> >> red-circles, I tried to repaint my canvas, that don't work... 
here's
> >> >> the code I'm using maybe you might be able to spot where I'm 
making
> >> >> the error...
> >> >
> >> >    The code looks pretty good.  You aren't that far from a
> >> > standalone example, this would help me help you...
> >> >
> >> >> //I added this in my constructor
> >> >> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
> >> >
> >> >    This must be done _before_ you set the document on the canvas.
> >> >
> >> >> //The following code I added in my ActionListener triggred by a
> > button
> >> >
> >> >    Are you sure this code runs?  Some println's might help make 
sure
> >> > that your spots list isn't empty for some reason, etc.  You don't
> >> > need to 'repaint' the canvas.
> >> >
> >> >> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
> >> >> Runnable() {
> >> >>
> >> >>                       public void run()
> >> >>                       {
> >> >>                         SVGDocument doc = canvas.getSVGDocument();
> >> >>                         String SVGNS = 
"http://www.w3.org/2000/svg";
> >> >>                         Iterator i = spots.iterator();
> >> >>                         Element g =
> > doc.getElementById("circleGroup");
> >> >>                        if (g == null)
> >> >>                        {
> >> >>                           g = doc.createElementNS(SVGNS,"g");
> >> >>                           g.setAttributeNS(null, "id",
> > "circleGroup");
> >> >>                           doc.getRootElement().appendChild(g);
> >> >>                        }
> >> >>
> >> >>
> >> >>                         while (i.hasNext())
> >> >>                         {
> >> >>                           Point2D pt2d = (Point2D) i.next();
> >> >>                           Element e =
> >> > doc.createElementNS(SVGNS,"circle");
> >> >> e.setAttributeNS(null,"cx",""+pt2d.getX());
> >> >> e.setAttributeNS(null,"cy",""+pt2d.getY());
> >> >>                           e.setAttributeNS(null,"r","8");
> >> >>                           e.setAttributeNS(null,"fill","Red");
> >> >>                           g.appendChild(e);
> >> >>                         }
> >> >>                       }
> >> >>                       });
> >> >>
> >> >>                       canvas.repaint();
> >> >
> >> >
> >> > 
---------------------------------------------------------------------
> >> > 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
> >
> >
> >
> 
> 
> 
> ---------------------------------------------------------------------
> 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: adding Elements to SVG Doc

Posted by ra...@blueyonder.co.uk.
Hi there,

Now when I run my code I get the following error:

org.w3c.dom.DOMException: The current document is unable to create an
element of the requested type (namespace: http://www.w3.org/2000/svg,
name: spot).

	at org.apache.batik.dom.AbstractNode.createDOMException(Unknown Source)

	at org.apache.batik.dom.svg.SVGDOMImplementation.createElementNS(Unknown
Source)

	at org.apache.batik.dom.svg.SVGOMDocument.createElementNS(Unknown Source)

	at mypackage22.KeyAccidentClient$4.run(KeyAccidentClient.java:349)

	at org.apache.batik.util.RunnableQueue.run(Unknown Source)

	at java.lang.Thread.run(Thread.java:534)

Pls advice.

Thx

yasmin




> Hi Yasmin,
>
> rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36 AM:
>
>> When I tried putting a line to test if the code is running, the code
> does
>> run, but apparently it does not create any elements, here's what I
> tested:
>>
>> System.out.println("This is just testing :" +
> g.getAttribute("circleGroup"));
>>
>> and nothing prints for g.getAttribute ...
>
>    This is expected, I think you want to use:
>         g.getAttributeNS(null, "id");
>
>    This should result in the string 'circleGroup'.
>
>> > rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31 PM:
>> >
>> >> I did initially try to add the red circles to the svg document
>> >> programatically, infact I think you emailed me a snippet of your code
>> >> but it doesn't work, the code compiles but does not display the
>> >> red-circles, I tried to repaint my canvas, that don't work... here's
>> >> the code I'm using maybe you might be able to spot where I'm making
>> >> the error...
>> >
>> >    The code looks pretty good.  You aren't that far from a
>> > standalone example, this would help me help you...
>> >
>> >> //I added this in my constructor
>> >> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>> >
>> >    This must be done _before_ you set the document on the canvas.
>> >
>> >> //The following code I added in my ActionListener triggred by a
> button
>> >
>> >    Are you sure this code runs?  Some println's might help make sure
>> > that your spots list isn't empty for some reason, etc.  You don't
>> > need to 'repaint' the canvas.
>> >
>> >> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
>> >> Runnable() {
>> >>
>> >>                       public void run()
>> >>                       {
>> >>                         SVGDocument doc = canvas.getSVGDocument();
>> >>                         String SVGNS = "http://www.w3.org/2000/svg";
>> >>                         Iterator i = spots.iterator();
>> >>                         Element g =
> doc.getElementById("circleGroup");
>> >>                        if (g == null)
>> >>                        {
>> >>                           g = doc.createElementNS(SVGNS,"g");
>> >>                           g.setAttributeNS(null, "id",
> "circleGroup");
>> >>                           doc.getRootElement().appendChild(g);
>> >>                        }
>> >>
>> >>
>> >>                         while (i.hasNext())
>> >>                         {
>> >>                           Point2D pt2d = (Point2D) i.next();
>> >>                           Element e =
>> > doc.createElementNS(SVGNS,"circle");
>> >>                           e.setAttributeNS(null,"cx",""+pt2d.getX());
>> >>                           e.setAttributeNS(null,"cy",""+pt2d.getY());
>> >>                           e.setAttributeNS(null,"r","8");
>> >>                           e.setAttributeNS(null,"fill","Red");
>> >>                           g.appendChild(e);
>> >>                         }
>> >>                       }
>> >>                       });
>> >>
>> >>                       canvas.repaint();
>> >
>> >
>> > ---------------------------------------------------------------------
>> > 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
>
>
>



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


Re: adding Elements to SVG Doc

Posted by ra...@blueyonder.co.uk.
Hi Thomas,

ThankU, it is outputing CircleGroup - but the circles are not being
displayed on canvas, I tested to see if my spots list was empty but no
that holds all the points ...any thoughts?

Tx

yasmin



> Hi Yasmin,
>
> rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36 AM:
>
>> When I tried putting a line to test if the code is running, the code
> does
>> run, but apparently it does not create any elements, here's what I
> tested:
>>
>> System.out.println("This is just testing :" +
> g.getAttribute("circleGroup"));
>>
>> and nothing prints for g.getAttribute ...
>
>    This is expected, I think you want to use:
>         g.getAttributeNS(null, "id");
>
>    This should result in the string 'circleGroup'.
>
>> > rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31 PM:
>> >
>> >> I did initially try to add the red circles to the svg document
>> >> programatically, infact I think you emailed me a snippet of your code
>> >> but it doesn't work, the code compiles but does not display the
>> >> red-circles, I tried to repaint my canvas, that don't work... here's
>> >> the code I'm using maybe you might be able to spot where I'm making
>> >> the error...
>> >
>> >    The code looks pretty good.  You aren't that far from a
>> > standalone example, this would help me help you...
>> >
>> >> //I added this in my constructor
>> >> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>> >
>> >    This must be done _before_ you set the document on the canvas.
>> >
>> >> //The following code I added in my ActionListener triggred by a
> button
>> >
>> >    Are you sure this code runs?  Some println's might help make sure
>> > that your spots list isn't empty for some reason, etc.  You don't
>> > need to 'repaint' the canvas.
>> >
>> >> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
>> >> Runnable() {
>> >>
>> >>                       public void run()
>> >>                       {
>> >>                         SVGDocument doc = canvas.getSVGDocument();
>> >>                         String SVGNS = "http://www.w3.org/2000/svg";
>> >>                         Iterator i = spots.iterator();
>> >>                         Element g =
> doc.getElementById("circleGroup");
>> >>                        if (g == null)
>> >>                        {
>> >>                           g = doc.createElementNS(SVGNS,"g");
>> >>                           g.setAttributeNS(null, "id",
> "circleGroup");
>> >>                           doc.getRootElement().appendChild(g);
>> >>                        }
>> >>
>> >>
>> >>                         while (i.hasNext())
>> >>                         {
>> >>                           Point2D pt2d = (Point2D) i.next();
>> >>                           Element e =
>> > doc.createElementNS(SVGNS,"circle");
>> >>                           e.setAttributeNS(null,"cx",""+pt2d.getX());
>> >>                           e.setAttributeNS(null,"cy",""+pt2d.getY());
>> >>                           e.setAttributeNS(null,"r","8");
>> >>                           e.setAttributeNS(null,"fill","Red");
>> >>                           g.appendChild(e);
>> >>                         }
>> >>                       }
>> >>                       });
>> >>
>> >>                       canvas.repaint();
>> >
>> >
>> > ---------------------------------------------------------------------
>> > 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
>
>
>



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


Re: adding Elements to SVG Doc

Posted by th...@kodak.com.
Hi Yasmin,

rafiqy@blueyonder.co.uk wrote on 03/12/2006 06:04:36 AM:

> When I tried putting a line to test if the code is running, the code 
does
> run, but apparently it does not create any elements, here's what I 
tested:
> 
> System.out.println("This is just testing :" + 
g.getAttribute("circleGroup"));
> 
> and nothing prints for g.getAttribute ...

   This is expected, I think you want to use:
        g.getAttributeNS(null, "id");

   This should result in the string 'circleGroup'.

> > rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31 PM:
> >
> >> I did initially try to add the red circles to the svg document
> >> programatically, infact I think you emailed me a snippet of your code
> >> but it doesn't work, the code compiles but does not display the 
> >> red-circles, I tried to repaint my canvas, that don't work... here's 
> >> the code I'm using maybe you might be able to spot where I'm making 
> >> the error...
> >
> >    The code looks pretty good.  You aren't that far from a
> > standalone example, this would help me help you...
> >
> >> //I added this in my constructor
> >> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
> >
> >    This must be done _before_ you set the document on the canvas.
> >
> >> //The following code I added in my ActionListener triggred by a 
button
> >
> >    Are you sure this code runs?  Some println's might help make sure
> > that your spots list isn't empty for some reason, etc.  You don't
> > need to 'repaint' the canvas.
> >
> >> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
> >> Runnable() {
> >>
> >>                       public void run()
> >>                       {
> >>                         SVGDocument doc = canvas.getSVGDocument();
> >>                         String SVGNS = "http://www.w3.org/2000/svg";
> >>                         Iterator i = spots.iterator();
> >>                         Element g = 
doc.getElementById("circleGroup");
> >>                        if (g == null)
> >>                        {
> >>                           g = doc.createElementNS(SVGNS,"g");
> >>                           g.setAttributeNS(null, "id", 
"circleGroup");
> >>                           doc.getRootElement().appendChild(g);
> >>                        }
> >>
> >>
> >>                         while (i.hasNext())
> >>                         {
> >>                           Point2D pt2d = (Point2D) i.next();
> >>                           Element e =
> > doc.createElementNS(SVGNS,"circle");
> >>                           e.setAttributeNS(null,"cx",""+pt2d.getX());
> >>                           e.setAttributeNS(null,"cy",""+pt2d.getY());
> >>                           e.setAttributeNS(null,"r","8");
> >>                           e.setAttributeNS(null,"fill","Red");
> >>                           g.appendChild(e);
> >>                         }
> >>                       }
> >>                       });
> >>
> >>                       canvas.repaint();
> >
> >
> > ---------------------------------------------------------------------
> > 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: adding Elements to SVG Doc

Posted by ra...@blueyonder.co.uk.
Hi Thomas,

When I tried putting a line to test if the code is running, the code does
run, but apparently it does not create any elements, here's what I tested:

System.out.println("This is just testing :" + g.getAttribute("circleGroup"));

and nothing prints for g.getAttribute ...

Thx

yasmin



> Hi Yasmin,
>
> rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31 PM:
>
>> I did initially try to add the red circles to the svg document
>> programatically, infact I think you emailed me a snippet of your code
> but
>> it doesn't work, the code compiles but does not display the red-circles,
> I
>> tried to repaint my canvas, that don't work... here's the code I'm using
>> maybe you might be able to spot where I'm making the error...
>
>    The code looks pretty good.  You aren't that far from a
> standalone example, this would help me help you...
>
>> //I added this in my constructor
>> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>
>    This must be done _before_ you set the document on the canvas.
>
>> //The following code I added in my ActionListener triggred by a button
>
>    Are you sure this code runs?  Some println's might help make sure
> that your spots list isn't empty for some reason, etc.  You don't
> need to 'repaint' the canvas.
>
>> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
>> Runnable() {
>>
>>                       public void run()
>>                       {
>>                         SVGDocument doc = canvas.getSVGDocument();
>>                         String SVGNS = "http://www.w3.org/2000/svg";
>>                         Iterator i = spots.iterator();
>>                         Element g = doc.getElementById("circleGroup");
>>                        if (g == null)
>>                        {
>>                           g = doc.createElementNS(SVGNS,"g");
>>                           g.setAttributeNS(null, "id", "circleGroup");
>>                           doc.getRootElement().appendChild(g);
>>                        }
>>
>>
>>                         while (i.hasNext())
>>                         {
>>                           Point2D pt2d = (Point2D) i.next();
>>                           Element e =
> doc.createElementNS(SVGNS,"circle");
>>                           e.setAttributeNS(null,"cx",""+pt2d.getX());
>>                           e.setAttributeNS(null,"cy",""+pt2d.getY());
>>                           e.setAttributeNS(null,"r","8");
>>                           e.setAttributeNS(null,"fill","Red");
>>                           g.appendChild(e);
>>                         }
>>                       }
>>                       });
>>
>>                       canvas.repaint();
>
>
> ---------------------------------------------------------------------
> 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: adding Elements to SVG Doc

Posted by th...@kodak.com.
Hi Yasmin,

rafiqy@blueyonder.co.uk wrote on 03/11/2006 05:44:31 PM:

> I did initially try to add the red circles to the svg document
> programatically, infact I think you emailed me a snippet of your code 
but
> it doesn't work, the code compiles but does not display the red-circles, 
I
> tried to repaint my canvas, that don't work... here's the code I'm using
> maybe you might be able to spot where I'm making the error...

   The code looks pretty good.  You aren't that far from a 
standalone example, this would help me help you...

> //I added this in my constructor
> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);

   This must be done _before_ you set the document on the canvas.

> //The following code I added in my ActionListener triggred by a button

   Are you sure this code runs?  Some println's might help make sure
that your spots list isn't empty for some reason, etc.  You don't
need to 'repaint' the canvas.

> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
> Runnable() {
> 
>                       public void run()
>                       {
>                         SVGDocument doc = canvas.getSVGDocument();
>                         String SVGNS = "http://www.w3.org/2000/svg";
>                         Iterator i = spots.iterator();
>                         Element g = doc.getElementById("circleGroup");
>                        if (g == null)
>                        {
>                           g = doc.createElementNS(SVGNS,"g");
>                           g.setAttributeNS(null, "id", "circleGroup");
>                           doc.getRootElement().appendChild(g);
>                        }
> 
> 
>                         while (i.hasNext())
>                         {
>                           Point2D pt2d = (Point2D) i.next();
>                           Element e = 
doc.createElementNS(SVGNS,"circle");
>                           e.setAttributeNS(null,"cx",""+pt2d.getX());
>                           e.setAttributeNS(null,"cy",""+pt2d.getY());
>                           e.setAttributeNS(null,"r","8");
>                           e.setAttributeNS(null,"fill","Red");
>                           g.appendChild(e);
>                         }
>                       }
>                       });
> 
>                       canvas.repaint();


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