Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

Re: DisplayImpl.getImage()

Hi Hank,
 
> 1.  I have had some limited success, except for the fact
> that when the image returns, it is the black screen with the
> small white lettered "please wait" at the bottom.  Obviously
> I am returning the image before it is fully loaded into the
> offscreen display.  I have tried using the
> getDisplayRenderer.getWaitFlag(), but it still does not wait
> long enough.  Is there another way for me to find out when
> the image is completely loaded into the offscreen display?
 
Glad to hear of your success.  Try making your class implement
the DisplayListener interface, add it to your DisplayImpl as a
DisplayListener:
 
  display.addDisplayListener(this);
 
and implement a method:
 
  public void displayChanged(DisplayEvent e) {
    if (e.getId() == DisplayEvent.TRANSFORM_DONE) {
      image = display.getImage();
    }
  }
 
Note that visad/jmet/ShowNCEPModel.java uses TRANSFORM_DONE
events.
 
You may also want to bracket your DisplayImpl setup between
display.disableAction() and display.enableAction() (as is done
in visad/jmet/NCEPPanel.java), so that there will only be one
DisplayEvent.TRANSFORM_DONE.
 
> 2.  When I run the DisplayTest cases 50-52 on an NT machine,
> the copied image is not loaded into its frame until I resize
> the frame.  I don't know if this has anything to do with
> image loading or if this is the intended functionality.
 
Sorry about this.  I don't use NT and will have to check
DisplayTest cases 50-52 on an NT machine.  If DisplayTest case
58 works on your NT machine, then the following might work:
 
  display.addDisplayListener(this);
  ProjectionControl control = display.getProjectionControl();
  int count = -1;
 
and then:
 
  public void displayChanged(DisplayEvent e) {
    if (e.getId() == DisplayEvent.TRANSFORM_DONE) {
      count = 4;
      control.setMatrix(control.getMatrix());
    }
    else if (e.getId() == DisplayEvent.FRAME_DONE) {
      if (count > 0) {
        control.setMatrix(control.getMatrix());
        count--;
      }
      else if (count == 0) {
        image = display.getImage();
        count--;
      }
    }
  }
 
This waits for your data to be transformed into a scene graph,
then triggers a sequence of 4 re-draws, then gets the image.
Since manually resizing the frame helps, it may be useful to
add:
 
  Component comp = display.getComponent();
  comp.setSize(comp.getSize());
 
to the above after both 'control.setMatrix(control.getMatrix())'.
 
Please let me know if these things do not solve your problem.
One way or another we'll get it.  These event things can be tricky,
and I don't think we completely understand AWT and Swing yet.
 
Cheers,
Bill



 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Community Programs   Unidata is a member of the UCAR Community Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690