Re: [idvdevelopers] failure attempting use of Displayable.cloneForDisplay

Hi Stuart-

Stuart Maclean wrote:
I am trying to use IDV classes in a servlet environment, rendering 
BufferedImages (offscreen mode) for return to a web browser.

If I have a single Displayable, in my case a Contour2DDisplayable, and I attempt to add it directly to two different DisplayMasters (one for each web 'user') I get an error:

2007-08-09 16:21:39,274 23078 ERROR  - visad.DisplayException: 
ScalarMap.setDisplay: ScalarMap cannot belong to two Displays
visad.DisplayException: ScalarMap.setDisplay: ScalarMap cannot belong to two 
Displays
         at visad.ScalarMap.setDisplay(ScalarMap.java:393)
         at visad.DisplayImpl.addMap(DisplayImpl.java:1926)
         at visad.DisplayImpl.addMap(DisplayImpl.java:1866)
         at 
ucar.visad.display.DisplayMaster.addScalarMaps(DisplayMaster.java:1778)
         at ucar.visad.display.DisplayMaster.rebuild(DisplayMaster.java:605)
         at 
ucar.visad.display.DisplayMaster.rebuildDisplay(DisplayMaster.java:578)
         at ucar.visad.display.DisplayMaster.setActive(DisplayMaster.java:1956)
         at ucar.visad.display.DisplayMaster.draw(DisplayMaster.java:1481)

Which is what it should do because you can't have a ScalarMap in
two different displays. ;-)

But if I try to use the Contour2DDisplayable.cloneForDisplay() method to work around this, I get no image from the DisplayMaster.getImage call, it just hangs.

The problem is that the cloneForDisplay does not set the data on
the new displayable.  If you call loadData on the new Displayable,
you should get data displayed.

I'll have to think more about what the correct behavior should
be.

In I test in onscreen mode, I note that the use of cloneForDisplay means I 
never see the data in the Jframe.

It's as though the clone is only partial??

most cloneForDisplay implementations use a copy constructor and
not a clone method.  We don't use this method often, so it has
not been battle tested.  If you find more problems, let us know.

Any help gratefully appreciated.

BTW, in the IDV, do you recreate copies of Displayable 'from scratch' as it 
were, or use the clone technique??

We usually just create new Displayables since they all have different
ScalarMaps.

Don
*************************************************************
Don Murray                               UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx                        P.O. Box 3000
(303) 497-8628                              Boulder, CO 80307
http://www.unidata.ucar.edu/staff/donm
*************************************************************




  • 2007 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the idvdevelopers archives: