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 David Proft <da...@motive.com> on 2003/10/11 19:00:54 UTC

Displaying Simple SVG without using JSVGComponent.

Hello,

I have seen many examples of how to write swing objects to SVG files and examples of showing SVG files in Swing using the JSVGComponent class.  However, I have not been able to find an example that shows how to simply write SVG to a given Graphics object.  Let me explain,

My problem is that I am using a graphing package where one can overwrite the node's (which, BTW, is not a Swing component) paint() method.  When this node is rendered by the graphing package, I want the SVG image to be drawn.

For example:

private class MyNode extends JGoBasicNode
{
    public void paint(Graphics2D g, JGoView view)
    {
        Rectangle boundingArea = getBoundingRect();   // The area/bounding box to draw the SVG into
--->    XXX.drawSVG(<some SVG reference>, g, boundingArea);  // Scale and draw the SVG into the bounding area
    }
}

I'm looking for a way to make the above marked line be real code.  I have looked at the JSVGComponent source code but am not sure what exactly is needed to do the above.

I know that this is not very efficient and maybe slow.  My SVG files are very simple, however.  If my performance is still too poor, I will use images (g.grawImage(...)).


Thank you in advance for your help,

David

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


Re: Displaying Simple SVG without using JSVGComponent.

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

maybe you can use use SwingUtilities.paintComponent(Graphics g,
Component c, Container p, Rectangle r) methods
where the 
g is the graphics you need to draw to
c could be JSVGComponent
p don't know check the java docs
r is the bounding box???


Regards
Tonny Kohar
http://www.kiyut.com

On Sun, 2003-10-12 at 00:00, David Proft wrote:
> Hello,
> 
> I have seen many examples of how to write swing objects to SVG files and examples of showing SVG files in Swing using the JSVGComponent class.  However, I have not been able to find an example that shows how to simply write SVG to a given Graphics object.  Let me explain,
> 
> My problem is that I am using a graphing package where one can overwrite the node's (which, BTW, is not a Swing component) paint() method.  When this node is rendered by the graphing package, I want the SVG image to be drawn.
> 
> For example:
> 
> private class MyNode extends JGoBasicNode
> {
>     public void paint(Graphics2D g, JGoView view)
>     {
>         Rectangle boundingArea = getBoundingRect();   // The area/bounding box to draw the SVG into
> --->    XXX.drawSVG(<some SVG reference>, g, boundingArea);  // Scale and draw the SVG into the bounding area
>     }
> }
> 
> I'm looking for a way to make the above marked line be real code.  I have looked at the JSVGComponent source code but am not sure what exactly is needed to do the above.
> 
> I know that this is not very efficient and maybe slow.  My SVG files are very simple, however.  If my performance is still too poor, I will use images (g.grawImage(...)).
> 
> 
> Thank you in advance for your help,
> 
> David
> 
> ---------------------------------------------------------------------
> 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: Displaying Simple SVG without using JSVGComponent.

Posted by Thomas DeWeese <Th...@Kodak.com>.
Tonny Kohar wrote:

> or you can get BufferedImage from JSVGComponent.getOffScreen(), if you
> enable offscreen on JSVGComponent, is this correct thomas?
> Then draw that bufferedImage to your comp

Hi Tonny,
   Yes, you could take this approach, although it is quite a bit of
overkill (although very simple code wise).  I would look at the
batik.app.slideshow this directly constructs the GVT tree.
The GVT tree (batik.gvt.GraphicsNode) has a paint method that takes
a Graphics2D and can be used to render the content.

   The Slideshow app actually uses the GVT tree to render
to an offscreen buffer using the StaticRenderer classes but
you don't need to do this.

> 
> Regards
> Tonny Kohar
> http://www.kiyut.com
> 
> On Sun, 2003-10-12 at 00:00, David Proft wrote:
> 
>>Hello,
>>
>>I have seen many examples of how to write swing objects to SVG files and examples of showing SVG files in Swing using the JSVGComponent class.  However, I have not been able to find an example that shows how to simply write SVG to a given Graphics object.  Let me explain,
>>
>>My problem is that I am using a graphing package where one can overwrite the node's (which, BTW, is not a Swing component) paint() method.  When this node is rendered by the graphing package, I want the SVG image to be drawn.
>>
>>For example:
>>
>>private class MyNode extends JGoBasicNode
>>{
>>    public void paint(Graphics2D g, JGoView view)
>>    {
>>        Rectangle boundingArea = getBoundingRect();   // The area/bounding box to draw the SVG into
>>--->    XXX.drawSVG(<some SVG reference>, g, boundingArea);  // Scale and draw the SVG into the bounding area
>>    }
>>}
>>
>>I'm looking for a way to make the above marked line be real code.  I have looked at the JSVGComponent source code but am not sure what exactly is needed to do the above.
>>
>>I know that this is not very efficient and maybe slow.  My SVG files are very simple, however.  If my performance is still too poor, I will use images (g.grawImage(...)).
>>
>>
>>Thank you in advance for your help,
>>
>>David
>>
>>---------------------------------------------------------------------
>>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: Displaying Simple SVG without using JSVGComponent.

Posted by Tonny Kohar <to...@kiyut.com>.
hi,
 
or you can get BufferedImage from JSVGComponent.getOffScreen(), if you
enable offscreen on JSVGComponent, is this correct thomas?
Then draw that bufferedImage to your comp

Regards
Tonny Kohar
http://www.kiyut.com

On Sun, 2003-10-12 at 00:00, David Proft wrote:
> Hello,
> 
> I have seen many examples of how to write swing objects to SVG files and examples of showing SVG files in Swing using the JSVGComponent class.  However, I have not been able to find an example that shows how to simply write SVG to a given Graphics object.  Let me explain,
> 
> My problem is that I am using a graphing package where one can overwrite the node's (which, BTW, is not a Swing component) paint() method.  When this node is rendered by the graphing package, I want the SVG image to be drawn.
> 
> For example:
> 
> private class MyNode extends JGoBasicNode
> {
>     public void paint(Graphics2D g, JGoView view)
>     {
>         Rectangle boundingArea = getBoundingRect();   // The area/bounding box to draw the SVG into
> --->    XXX.drawSVG(<some SVG reference>, g, boundingArea);  // Scale and draw the SVG into the bounding area
>     }
> }
> 
> I'm looking for a way to make the above marked line be real code.  I have looked at the JSVGComponent source code but am not sure what exactly is needed to do the above.
> 
> I know that this is not very efficient and maybe slow.  My SVG files are very simple, however.  If my performance is still too poor, I will use images (g.grawImage(...)).
> 
> 
> Thank you in advance for your help,
> 
> David
> 
> ---------------------------------------------------------------------
> 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