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 "Snyder, Jim ( GE Transportation )" <Ji...@Trans.ge.com> on 2005/01/31 21:12:04 UTC

SVG and JLayeredPane

Hello,

I was able to get Batik to generate an SVG text output using the following algorithm (from the Batik website) on java components such as a JPanel ( the this instance is of JPanel). 


      try
      {

         DOMImplementation domImpl =
            GenericDOMImplementation.getDOMImplementation();

         // Create an instance of org.w3c.dom.Document
         Document document = domImpl.createDocument(null, "svg", null);

         // Create an instance of the SVG Generator
         SVGGraphics2D svgGenerator = new SVGGraphics2D(document);

         // Ask the test to render into the SVG Graphics2D implementation
         this.paint(svgGenerator);

         // Finally, stream out SVG to the standard output using UTF-8
         // character to byte encoding
         boolean useCSS = true; // we want to use CSS style attribute
         Writer out = new OutputStreamWriter(System.out, "UTF-8");
         svgGenerator.stream(out, useCSS);

      }
      catch (java.io.UnsupportedEncodingException e)
      {
                  e.printStackTrace();
      }
      catch (org.apache.batik.svggen.SVGGraphics2DIOException eSVGGraphics2DIOException)
      {
                  eSVGGraphics2DIOException.printStackTrace();
      }


However when I apply the same algorithm (the this instance is of MY_JLAYEREDPANE, which extends JLayeredPane) to a JLayeredPane I get the following exception:


java.lang.NullPointerException
 	at javax.swing.JLayeredPane.paint(JLayeredPane.java:539)
	at MY.COM.MY_JLAYEREDPANE.paint(MY_JLAYEREDPANE.java:88)
 	at MY.COM.MY_JLAYEREDPANE.renderSVG2(MY_JLAYEREDPANE.java:126)
	at MY.COM.MY_JLAYEREDPANE.paint(MY_JLAYEREDPANE.java:92)
	at javax.swing.JComponent.paintChildren(JComponent.java:493)
	at javax.swing.JComponent.paint(JComponent.java:691)
	at javax.swing.JViewport.paint(JViewport.java:663)
	at javax.swing.JComponent.paintChildren(JComponent.java:493)
	at javax.swing.JComponent.paint(JComponent.java:691)
	at javax.swing.JComponent.paintChildren(JComponent.java:493)
	at javax.swing.JComponent.paint(JComponent.java:691)
	at javax.swing.JComponent.paintChildren(JComponent.java:493)
	at javax.swing.JComponent.paint(JComponent.java:691)
	at javax.swing.JLayeredPane.paint(JLayeredPane.java:541)
	at javax.swing.JComponent.paintChildren(JComponent.java:493)
	at javax.swing.JComponent.paint(JComponent.java:664)
	at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:18)
	at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:49)
	at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:86)
	at java.awt.Container.paint(Container.java:955)
	at sun.awt.RepaintArea.paint(RepaintArea.java:293)
	at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:191)
	at java.awt.Component.dispatchEventImpl(Component.java:2658)
	at java.awt.Container.dispatchEventImpl(Container.java:1208)
	at java.awt.Window.dispatchEventImpl(Window.java:923)
	at java.awt.Component.dispatchEvent(Component.java:2492)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:334)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:126)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:88)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:80)

I've searched Google with no success. and the mailing list websites referenced from the batik is unsearchable. If you could reply directly to me that would be great.

I'm using Windows XP Pro on JDK 1.3.1.11.

Thanks...Jim


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


Re: SVG and JLayeredPane

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

    I would suggest trying to use the SwingSVGPrettyPrint class to
get and SVG 'dump' of your JLayeredPane.  Otherwise, I would look
at the src.jar that comes with the JDK distribution to see
what is going on at line 539 in JLayeredPane.java.


Snyder, Jim ( GE Transportation ) wrote:

> I was able to get Batik to generate an SVG text output using the 
> following algorithm (from the Batik website) on java components 
> such as a JPanel ( the this instance is of JPanel). 

> However when I apply the same algorithm (the this instance is of 
> MY_JLAYEREDPANE, which extends JLayeredPane) to a JLayeredPane I 
> get the following exception:
> 
> java.lang.NullPointerException
>  	at javax.swing.JLayeredPane.paint(JLayeredPane.java:539)


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


Re: SVG and JLayeredPane

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

    I would suggest trying to use the SwingSVGPrettyPrint class to
get and SVG 'dump' of your JLayeredPane.  Otherwise, I would look
at the src.jar that comes with the JDK distribution to see
what is going on at line 539 in JLayeredPane.java.


Snyder, Jim ( GE Transportation ) wrote:

> I was able to get Batik to generate an SVG text output using the 
> following algorithm (from the Batik website) on java components 
> such as a JPanel ( the this instance is of JPanel). 

> However when I apply the same algorithm (the this instance is of 
> MY_JLAYEREDPANE, which extends JLayeredPane) to a JLayeredPane I 
> get the following exception:
> 
> java.lang.NullPointerException
>  	at javax.swing.JLayeredPane.paint(JLayeredPane.java:539)


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