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 LOPES GOMES Victor <vm...@free.fr> on 2004/07/23 15:14:51 UTC

Drawing with JSVGCanvas

Hi,

I start to work with Batik and i need to create and manipulate basic Shapes in
the JSVGCanvas.
I would like to modify and manipulate the SVGDocument and (repaint) the
SVGCanvas to view the changement.

How to create and put new elements in the JSVGCanvas? I try this one below but
nothing
appear in the screen:

I've added a MouseListener in my JSVGCanvas
the createElement just create an Element at the pt coordinate.

public void mousePressed(MouseEvent e) {
		Point2D pt = e.getPoint();
		SVGDocument doc = canvas.getSVGDocument();
		Element root = doc.getDocumentElement();
		root.appendChild(createElement(pt));
	}

Is it a wrong way to do?



It will be fine to

--
Victor from Paris(France)

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


Re: Drawing with JSVGCanvas

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Victor,

    You don't need to request a repaint from the updateManager
but you do need to make a change in the UpdateManager's
Thread.  Read the FAQ for more info on this:

http://xml.apache.org/batik/faqs.html




vmlgomes@free.fr wrote:
> Hi Thomas,
> 
> Thanks a lot for your answer that's fixed my problems. You're right, i was
> creating the element by using the createElement method without any Name Space.
> however i didn't used any updateManager objet to repaint the JSVGCanvas, i
> suppose that the jsvgcanvas.setDocumentState(ALWAYS_DYNAMIC) method is the
> reason?
> 
> Bye
> 
> Victor
> 
> 
> 
>>Hi Victor,
>>
>>    Well, I can see one mistake and guess at two likely others.
>>First the one I can see is that you aren't making your changes
>>to the document in the UpdateManager thread (search the list
>>for UpdateManager for all the details) or read the FAQ.
>>
>>    Second (only a guess) is that your document may not be setup
>>for dynamic rendering.  To ensure your document is always in a
>>dynamic state when loaded you need to call
>>'jsvgcanvas.setDocumentState(ALWAYS_DYNAMIC)' _before_ loading
>>the document (with setURI or what ever).
>>
>>    Third (also only a guess) you may not be creating your
>>'element' in the SVG namespace:
>>
>>    Element myPath = doc.createElementNS("http://www.w3.org/2000/svg",
>>                                         "path");
>>    myPath.setAttribute("d", "M....");
>>
>>    Hope this helps, and good luck.
>>
>>LOPES GOMES Victor wrote:
>>
>>
>>>Hi,
>>>
>>>I start to work with Batik and i need to create and manipulate basic Shapes
>>
>>in
>>
>>>the JSVGCanvas.
>>>I would like to modify and manipulate the SVGDocument and (repaint) the
>>>SVGCanvas to view the changement.
>>>
>>>How to create and put new elements in the JSVGCanvas? I try this one below
>>
>>but
>>
>>>nothing
>>>appear in the screen:
>>>
>>>I've added a MouseListener in my JSVGCanvas
>>>the createElement just create an Element at the pt coordinate.
>>>
>>>public void mousePressed(MouseEvent e) {
>>>		Point2D pt = e.getPoint();
>>>		SVGDocument doc = canvas.getSVGDocument();
>>>		Element root = doc.getDocumentElement();
>>>		root.appendChild(createElement(pt));
>>>	}
>>>
>>>Is it a wrong way to do?
>>>
>>>
>>>
>>>It will be fine to
>>>
>>>--
>>>Victor from Paris(France)
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
>>>For additional commands, e-mail: batik-users-help@xml.apache.org
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
>>For additional commands, e-mail: batik-users-help@xml.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org


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


Re: Drawing with JSVGCanvas

Posted by vm...@free.fr.
Hi Thomas,

Thanks a lot for your answer that's fixed my problems. You're right, i was
creating the element by using the createElement method without any Name Space.
however i didn't used any updateManager objet to repaint the JSVGCanvas, i
suppose that the jsvgcanvas.setDocumentState(ALWAYS_DYNAMIC) method is the
reason?

Bye

Victor


> Hi Victor,
>
>     Well, I can see one mistake and guess at two likely others.
> First the one I can see is that you aren't making your changes
> to the document in the UpdateManager thread (search the list
> for UpdateManager for all the details) or read the FAQ.
>
>     Second (only a guess) is that your document may not be setup
> for dynamic rendering.  To ensure your document is always in a
> dynamic state when loaded you need to call
> 'jsvgcanvas.setDocumentState(ALWAYS_DYNAMIC)' _before_ loading
> the document (with setURI or what ever).
>
>     Third (also only a guess) you may not be creating your
> 'element' in the SVG namespace:
>
>     Element myPath = doc.createElementNS("http://www.w3.org/2000/svg",
>                                          "path");
>     myPath.setAttribute("d", "M....");
>
>     Hope this helps, and good luck.
>
> LOPES GOMES Victor wrote:
>
> > Hi,
> >
> > I start to work with Batik and i need to create and manipulate basic Shapes
> in
> > the JSVGCanvas.
> > I would like to modify and manipulate the SVGDocument and (repaint) the
> > SVGCanvas to view the changement.
> >
> > How to create and put new elements in the JSVGCanvas? I try this one below
> but
> > nothing
> > appear in the screen:
> >
> > I've added a MouseListener in my JSVGCanvas
> > the createElement just create an Element at the pt coordinate.
> >
> > public void mousePressed(MouseEvent e) {
> > 		Point2D pt = e.getPoint();
> > 		SVGDocument doc = canvas.getSVGDocument();
> > 		Element root = doc.getDocumentElement();
> > 		root.appendChild(createElement(pt));
> > 	}
> >
> > Is it a wrong way to do?
> >
> >
> >
> > It will be fine to
> >
> > --
> > Victor from Paris(France)
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: batik-users-help@xml.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
>
>

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


Re: Drawing with JSVGCanvas

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Victor,

    Well, I can see one mistake and guess at two likely others.
First the one I can see is that you aren't making your changes
to the document in the UpdateManager thread (search the list
for UpdateManager for all the details) or read the FAQ.

    Second (only a guess) is that your document may not be setup
for dynamic rendering.  To ensure your document is always in a
dynamic state when loaded you need to call 
'jsvgcanvas.setDocumentState(ALWAYS_DYNAMIC)' _before_ loading
the document (with setURI or what ever).

    Third (also only a guess) you may not be creating your
'element' in the SVG namespace:

    Element myPath = doc.createElementNS("http://www.w3.org/2000/svg",
                                         "path");
    myPath.setAttribute("d", "M....");

    Hope this helps, and good luck.

LOPES GOMES Victor wrote:

> Hi,
> 
> I start to work with Batik and i need to create and manipulate basic Shapes in
> the JSVGCanvas.
> I would like to modify and manipulate the SVGDocument and (repaint) the
> SVGCanvas to view the changement.
> 
> How to create and put new elements in the JSVGCanvas? I try this one below but
> nothing
> appear in the screen:
> 
> I've added a MouseListener in my JSVGCanvas
> the createElement just create an Element at the pt coordinate.
> 
> public void mousePressed(MouseEvent e) {
> 		Point2D pt = e.getPoint();
> 		SVGDocument doc = canvas.getSVGDocument();
> 		Element root = doc.getDocumentElement();
> 		root.appendChild(createElement(pt));
> 	}
> 
> Is it a wrong way to do?
> 
> 
> 
> It will be fine to
> 
> --
> Victor from Paris(France)
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org


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