xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Danh Hoai" <h...@indent.org>
Subject Re: repaint
Date Tue, 07 May 2002 14:56:16 GMT
Sorry, I still cannot get this to work.   When I tried to use
elem1.setAttribute("style", "fill:red;visibility:visible;opacity:2;");,
it returned back with an error: Unsupported attribute modification: style on
rec.  (elem1 is a rectangle)

If I changed the x, y, or width of the elem1, it seems to work fine. But it
does not work when I changed the style attribute.

Also, I tried to download the latest version of Batik(CVS).  Do you know
where can I get it?  Maybe, I am using wrong version of Batik.
(Currently, I have 1.5beta).  Thank you.

Danh Hoai


----- Original Message -----
From: "M. van Veen" <michiel@microweb.nl>
To: "Batik Users" <batik-users@xml.apache.org>
Sent: Tuesday, May 07, 2002 3:46 AM
Subject: Re: repaint


> Hi Danh!
>
> I tried this and it works fine, just don't forget to do:
>
> JSVGCanvas canvas = new JSVGCanvas();
> canvas.setDocumentState( JSVGComponent.ALWAYS_DYNAMIC );
>
> When a change occurres some code piece( it's ugly, I know ;-) ):
>
> final String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
> final SVGDocument sd = canvas.getSVGDocument();
> final org.w3c.dom.Element root = sd.getDocumentElement();
> final int centx = x + (width/2);
> final int centy = y + (height/2);
> final int wd = width;
> final int hg = height;
> final org.w3c.dom.Element e = sd.createElementNS(svgNS, "ellipse");
>
> UpdateManager um = canvas.getUpdateManager();
> RunnableQueue rq = um.getUpdateRunnableQueue();
> rq.invokeLater(new Runnable() {
> public void run()
> {
> e.setAttributeNS( null, "cx", new Integer( centx ).toString() );
> e.setAttributeNS( null, "cy", new Integer( centy ).toString() );
> e.setAttributeNS( null, "rx", new Integer( wd/2 ).toString() );
> e.setAttributeNS( null, "ry", new Integer( hg/2 ).toString() );
> e.setAttributeNS( null, "stroke", "red" );
> e.setAttributeNS( null, "stroke-width", "2px" );
> e.setAttributeNS( null, "style", "fill:none"  );
> root.appendChild( e );
> }
> });
>
> rq.invokeLater(new Runnable() {
> public void run()
> {
> e.setAttributeNS( null, "stroke", "blue" );
> }
> });
>
> This example shows a circle being drawn and appended to the root of the
> doc. After that the stroke attribute is set. In practice this results
> into a red circle being painted and very quickly after that it turns to
> blue.
>
> I also tried: e.setAttribute( style", "blue" ). This works fine too.
>
> invokeAndWait, lets my app hang (why?).
>
> About GVT: What I know is that the GVT tree is build (and changed)
> according to the DOMtree. The GVT tree is therefor not to be changed; I
> assume you don't want to interfere with the way the SVG xml is rendered?
>
> Maybe use java140 + Batik CVS.
>
> Good luck and happy codin',
>
> Michael.
>
>
> Danh Hoai wrote:
> > I tried to do the following with no success (no visible change to
> > JSVGcanvas):
> >      rq.invokeLater(new Runnable()
> >      {
> >         public void run()
> >         {
> >
elem1.setAttribute("style","fill:red;display:inline;opacity:2;");
> >         }
> >      });
> >
> > I also tried invokeAndWait but I got an error:
> > java.lang.IllegalStateException: cannot be called  from RunnableQueue
thread
> >
> >
> > Another related (may be unrelated) question--do we need to mess with GVT
to
> > change DOM?
> >
> >
> >
> > ----- Original Message -----
> > From: "Thomas E Deweese" <thomas.deweese@kodak.com>
> > To: "Batik Users" <batik-users@xml.apache.org>; "Danh Hoai"
> > <hoai@indent.org>
> > Cc: <michiel@microweb.nl>; <thomas.deweese@kodak.com>
> > Sent: Monday, May 06, 2002 12:31 PM
> > Subject: repaint
> >
> >
> >
> >>>>>>>"DH" == Danh Hoai <hoai@indent.org> writes:
> >>>>>>
> >>DH> We are running into a similar problem.  Can you elaborate on how
> >>DH> you got your case to work.
> >>
> >>>>JSVGCanvas canvas = ...
> >>>>canvas.setDocumentState(JSVGCanvs.ALWAYS_DYNAMIC);
> >>>>
> >>>>import org.apache.batik.bridge.UpdateManager; import
> >>>>org.apache.batik.util.RunnableQueue;
> >>>>
> >>>>UpdateManager um = canvas.getUpdateManager(); RunnableQueue rq =
> >>>>um.getUpdateRunnableQueue(); rq.invokeLater(new Runnable() { public
> >>>>void run() { /*...*/ } }); rq.invokeAndWait(new Runnable() { public
> >>>>void run() { /*...*/ } });
> >>>
> >>
> >>DH> Specifically, where do you make the change to DOM.  Is it done
> >>DH> inside the run()
> >>
> >>    Yes you make your changes inside the run method of the
> >>runnable you pass to either invokeLater or invokeAndWait.
> >>
> >>
> >>>>rq.invokeLater(new Runnable() { public void run() { /*...*/ } });
> >>>>rq.invokeAndWait(new Runnable() { public void run() { /*...*/ } });
> >>>
> >>DH> Do we need to invoke both methods?
> >>
> >>    No, pick one.
> >>
> >>DH> Also, how do methods invokeAndWait and invokeLater work? do they
> >>DH> invoke after the change inside the DOM?
> >>
> >>    InvokeAndWait will not return until the change has been made in
> >>the DOM.  InvokeLater will return 'immediately' usually before your
> >>change as been made to the DOM (this of course is left to the vagures
> >>of thread scheduling in the JDK).
> >>
> >>---------------------------------------------------------------------
> >>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


Mime
View raw message