Re: saving display

Thanks for the error message and stack dump.

The error message indicates that you are calling getImage() from
an AWT callback, which is illegal. Please put the call in a new
Thread. You can see and example in visad/ss/FancySSCell.java, in
the captureDialog() method. This makes a new Thread (Runnable)
that calls BasicSSCell.captureImage(), which in turn calls
getImage().

Good luck,
Bill

On Thu, 20 May 2004, Wong Ka Yan Ivy [PG] wrote:

> Hi,
>
>
> > >   How to save the display as a jpeg image?
> > >
> > >   I've tried to use getImage() of DisplayImpl, but I fail to get the 
> > > bufferedImage from it, It got a visad.VisADError. Thanks.
> >
> > Please send the whole text of the VisADError message. Or even
> > better, run under jdb, catch the VisADError, and send us a stack
> > dump (the output of 'where').
>
>       The error as follows:
> //-------------------------------------------------------------------------
> visad.VisADError: cannot call getImage() from Thread: AWT-EventQueue-0
>         at visad.DisplayImpl.getImage(DisplayImpl.java:2622)
>         at weathersys.ui.ContourDisplayFrame.visualize(Unknown Source)
>         at weathersys.ui.UserInterface.contour(Unknown Source)
>         at weathersys.ui.UserInterface$1.displayMenuClicked(Unknown Source)
>         at weathersys.ui.MenuBar.fireMenuClicked(Unknown Source)
>         at weathersys.ui.MenuBar$7.actionPerformed(Unknown Source)
>         at 
> javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
> 86)
>         at 
> javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
> ctButton.java:1839)
>         at 
> javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
> .java:420)
>         at 
> javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258
> )
>         at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
>         at 
> javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1
> 113)
>         at 
> javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseRelease
> d(BasicMenuItemUI.java:943)
>         at java.awt.Component.processMouseEvent(Component.java:5100)
>         at java.awt.Component.processEvent(Component.java:4897)
>         at java.awt.Container.processEvent(Container.java:1569)
>         at java.awt.Component.dispatchEventImpl(Component.java:3615)
>         at java.awt.Container.dispatchEventImpl(Container.java:1627)
>         at java.awt.Component.dispatchEvent(Component.java:3477)
>         at 
> java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483
> )
>         at 
> java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
>         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
>         at java.awt.Container.dispatchEventImpl(Container.java:1613)
>         at java.awt.Window.dispatchEventImpl(Window.java:1606)
>         at java.awt.Component.dispatchEvent(Component.java:3477)
>         at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
>         at 
> java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
> read.java:201)
>         at 
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
> ad.java:151)
>         at 
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
>
>         at 
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
>
>         at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
>
> //-------------------------------------------------------------------------
>
>       I've also try to add a line of code at one of the example of VisAD: 
> Test60.java
>       in the function: void setupServerData(LocalDisplay[] dpys);
>
>       I've added a line at:
>       // codes .....
>         DataReferenceImpl ref_imaget1 = new DataReferenceImpl("ref_imaget1");
>         ref_imaget1.setData(imaget1);
>         dpys[0].addReference(ref_imaget1, null);
>
>       // newly added:
>         BufferedImage bImage = dpys[0].getImage();
>
>       The program hangs during execution...
>
>       Any idea? Or any other methods to save the display as a jpeg or other 
> image file format? Thanks.
>
> Regards,
> Ivy
>