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 Benjamin Hill <bh...@SIMS.Berkeley.EDU> on 2005/04/13 01:43:55 UTC

Q: Rendering an Applet (Java Container) as SVG

Is there a way to drop in a java awt Container into the rendering engine 
and get back a SVG rendering of the applet? 

My issue: I have an applet that is written in 1.5.0, and need to render 
the applet on a server and present a screen shot of the applet in an 
image form (png or gif) to users that can't run 1.5.0.  If people have 
another method that I could render an applet to an image, I'm all ears 
(I'm using buttons, containers, panels, etc, so I can't, that I know of, 
just grab a Graphics2D of the applet and render that to a file).

Thanks!


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


Re: Q: Rendering an Applet (Java Container) as SVG

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

Benjamin Hill wrote:

> I've used the Robot class with much success to take screen shots in 
> general, it works great (and would be ok answering questions about it if 
> anyone has any).  The problem is more along the lines of a server-side 
> rendering of an applet or of applet components without a screen, 
> in-memory on a server - optimally the process would be to pass an object 
> (class: Container) to a method that returns a SVG representation of how 
> that Container would have rendered if it were to be used in an applet.

    The SVGGraphics2D package (batik.svggen) has a class called
SwingSVGPrettyPrint that can take a JComponent and render it to
an SVGGraphics2D (it does all the children as well).

    You will need to turn on java 'headless' mode if you don't have
a screen attached.

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


Re: Changing the attributes of an element

Posted by Jorg Heymans <jh...@domek.be>.
myElement.setAttributeNS(null,"fill", "blue") should do the trick.

bader houmad wrote:
> Hi
> 
> I want to change the attributes of an element, but not all of them: (ex: 
> myElement is a rectangle, "fill:BLACK" "stroke:RED"and "stroke-width:15")
> 
> myElement.setAttributeNS(null,"style", "fill:BLUE");
> 
> this way myRectangle becomes BLUE but its stroke is set by default to 
> black and stroke-width to zero.
> 
> is there a method to change only the "fill" for example?
> 
> thanks
> 
> Bader
> 
> 
> ------------------------------------------------------------------------
> MSN Hotmail : choisissez votre adresse @hotmail.fr 
> <http://g.msn.com/8HMBFRFR/2731??PS=47575>


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


Re: How to bring one of a SVG element to the foreground

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

Maik Schürer wrote:

> a reapply of getParentElement().appendChild(theElement) works fine to 
> bring theElement to top.
> But why is a previous removeChild() unnecessary ?

    Because appendChild (and essentially all insert/add DOM methods)
are defined to call 'e.getParentElement().removeChild(e)' - assuming
that 'e' has a parent - before appending.

> Is the parent element so clever to make a "reappend" only ?

    I'm not sure what you mean by 'reappend' but it is smart enough
to 'remove' it when needed before adding it.  In fact two DOM mutation
events are generated (one for remove, one for append).


> Andreas Neumann schrieb:
> 
>> Hi,
>>
>> http://www.carto.net/papers/svg/manipulating_svg_with_dom_ecmascript/ 
>> is a tutorial with small examples on manipulating the DOM. Amongst 
>> others it also discusses reordering of elements.
>>
>> The examples where tested with Batik and Adobe SVG viewer.
>>
>> Andreas
>>
>> Maik Schürer wrote:
>>
>>> Hi there,
>>> I have several overlapped elements on my canvas.
>>> How can I one of these to the foreground (on top of all) ?
>>> Maik
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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: How to bring one of a SVG element to the foreground

Posted by Maik Schürer <Ma...@proveo.de>.
Thanks Thomas and Andreas,
a reapply of getParentElement().appendChild(theElement) works fine to 
bring theElement to top.
But why is a previous removeChild() unnecessary ?
Is the parent element so clever to make a "reappend" only ?
Maik

Andreas Neumann schrieb:
> Hi,
> 
> http://www.carto.net/papers/svg/manipulating_svg_with_dom_ecmascript/ is 
> a tutorial with small examples on manipulating the DOM. Amongst others 
> it also discusses reordering of elements.
> 
> The examples where tested with Batik and Adobe SVG viewer.
> 
> Andreas
> 
> Maik Schürer wrote:
> 
>> Hi there,
>> I have several overlapped elements on my canvas.
>> How can I one of these to the foreground (on top of all) ?
>> Maik
>>
>>
>> ---------------------------------------------------------------------
>> 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: How to bring one of a SVG element to the foreground

Posted by Tonny Kohar <to...@kiyut.com>.
Hi,

> Maik Schürer wrote:
> 
> > Hi there,
> > I have several overlapped elements on my canvas.
> > How can I one of these to the foreground (on top of all) ?
> > Maik

This is related to SVG z-order. The SVG z-order is very dependant on the
element on the DOM Tree. Basicly the most bottom element is the most
front, where the most top element is the most back in the z-order.

You could use DOM API to move the element node in the DOM Tree to change
the z-order of the SVG.

Regards
Tonny Kohar
-- 
Sketsa 
SVG Graphics Editor
http://www.kiyut.com


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


Re: How to bring one of a SVG element to the foreground

Posted by Andreas Neumann <ne...@karto.baug.ethz.ch>.
Hi,

http://www.carto.net/papers/svg/manipulating_svg_with_dom_ecmascript/ is 
a tutorial with small examples on manipulating the DOM. Amongst others 
it also discusses reordering of elements.

The examples where tested with Batik and Adobe SVG viewer.

Andreas

Maik Schürer wrote:

> Hi there,
> I have several overlapped elements on my canvas.
> How can I one of these to the foreground (on top of all) ?
> Maik
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>


-- 
----------------------------------------------
Andreas Neumann - Institute of Cartography
Swiss Federal Institute of Technology (ETH)
ETH Hoenggerberg
CH-8093  Zurich, Switzerland
Phone: ++41-1-633 3031, Fax: ++41-1-633 1153
e-mail: neumann@karto.baug.ethz.ch
www: http://www.carto.net/neumann/
SVG.Open: http://www.svgopen.org/
Carto.net: http://www.carto.net/


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


Re: How to bring one of a SVG element to the foreground

Posted by Jorg Heymans <jh...@domek.be>.
svg elements are rendered in order, ie if element b comes after element 
a in the document then b is drawn on top of a.

Maik Schürer wrote:
> Hi there,
> I have several overlapped elements on my canvas.
> How can I one of these to the foreground (on top of all) ?
> Maik


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


Re: How to bring one of a SVG element to the foreground

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

Maik Schürer wrote:

> I have several overlapped elements on my canvas.
> How can I one of these to the foreground (on top of all) ?

    Assuming they are all in a common group you can use:

     Element toMove = ....
     toMove.getParentElement().appendChild(toMove);

    This makes 'toMove' the last child of it's parent. This will
make it draw 'on top' of all the other children of the parent.
If you move it out of the group you need to be careful if
fill/stroke properties were set on the group they won't move with
it.

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


How to bring one of a SVG element to the foreground

Posted by Maik Schürer <Ma...@proveo.de>.
Hi there,
I have several overlapped elements on my canvas.
How can I one of these to the foreground (on top of all) ?
Maik


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


Re: Q: Rendering an Applet (Java Container) as SVG

Posted by Urs Reupke <ur...@gmx.net>.
> The problem is more along the lines of a server-side 
> rendering of an applet or of applet components without a screen, 
> in-memory on a server - optimally the process would be to pass an object 
> (class: Container) to a method that returns a SVG representation of how 
> that Container would have rendered if it were to be used in an applet.

You aim for a server-side svg-based emulation of the Java Runtime 
Environment?

Bye
-Urs

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


Re: Q: Rendering an Applet (Java Container) as SVG

Posted by Benjamin Hill <bh...@SIMS.Berkeley.EDU>.
Tonny Kohar wrote:

>Hi,
>
>  
>
>>My issue: I have an applet that is written in 1.5.0, and need to render 
>>the applet on a server and present a screen shot of the applet in an 
>>image form (png or gif) to users that can't run 1.5.0.  If people have 
>>another method that I could render an applet to an image, I'm all ears 
>>(I'm using buttons, containers, panels, etc, so I can't, that I know of, 
>>just grab a Graphics2D of the applet and render that to a file).
>>    
>>
>
>I sometimes heard that Java AWT Robot class could take a screenshoot.
>Maybe you could use this method. I am myself not familiar with this
>Robot class.
>
>Regards
>Tonny Kohar
>  
>
I've used the Robot class with much success to take screen shots in 
general, it works great (and would be ok answering questions about it if 
anyone has any).  The problem is more along the lines of a server-side 
rendering of an applet or of applet components without a screen, 
in-memory on a server - optimally the process would be to pass an object 
(class: Container) to a method that returns a SVG representation of how 
that Container would have rendered if it were to be used in an applet.



Re: Q: Rendering an Applet (Java Container) as SVG

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

> I sometimes heard that Java AWT Robot class could take a screenshoot.
> Maybe you could use this method. I am myself not familiar with this
> Robot class.
You're right. The Robot class can take screenshots via the
createScreenCapture(Rectangle)
method, where rectangle specifies the on-screen coordinates to be 
captured. The return value is a BufferedImage, so you can easily stream 
them to a file.

Regards
-Urs


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


Re: Q: Rendering an Applet (Java Container) as SVG

Posted by Tonny Kohar <to...@kiyut.com>.
Hi,

> My issue: I have an applet that is written in 1.5.0, and need to render 
> the applet on a server and present a screen shot of the applet in an 
> image form (png or gif) to users that can't run 1.5.0.  If people have 
> another method that I could render an applet to an image, I'm all ears 
> (I'm using buttons, containers, panels, etc, so I can't, that I know of, 
> just grab a Graphics2D of the applet and render that to a file).

I sometimes heard that Java AWT Robot class could take a screenshoot.
Maybe you could use this method. I am myself not familiar with this
Robot class.

Regards
Tonny Kohar
-- 
Sketsa 
SVG Graphics Editor
http://www.kiyut.com


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