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

Re: get Graphics instance

Hi Celine,

Is it possible to get an instance of the current Graphics to be able to draw
String instead of using ScalarMap and References. I'd like to to the same
thing as the drawCursorStringVector methid from DisplayRendererJ2D.

Sorry for the delay in my response; I have been traveling these past few days.

It should be possible to get a handle on a Java2D display's Graphics2D
somehow, though I haven't explored it. For Java3D displays, however,
that's not how things work.

However, in VisBio, I use a technique to display text to a Display
without using a screen locked renderer or other method involving
ScalarMaps and DataReferences. Essentially, you can do it with
DataRenderer's setException method. Here is a boiled down version:

   DisplayImpl d = ...; // VisAD display
   DataRenderer rend = ...; // linked data renderer
   String[] messages = ...; // list of messages

   // set exception messages
   rend.clearExceptions();
   for (int i=0; i<messages.length; i++) {
     rend.addException(new VisADException(messages[i]));
   }

   // force redraw of exception messages
   // BE SURE TO DO THIS IN AWT EVENT THREAD
   DisplayRenderer dr = d.getDisplayRenderer();
   if (dr instanceof DisplayRendererJ2D) {
     ((DisplayRendererJ2D) dr).getCanvas().repaint();
   }
   else { // renderer instanceof DisplayRendererJ3D
     DisplayRendererJ3D dr3d = (DisplayRendererJ3D) dr;
     dr3d.getCanvas().renderField(0);
   }

-Curtis

On 3/28/07, Celine Gestas <celine.gestas@xxxxxxxxx> wrote:
Hi,

Is it possible to get an instance of the current Graphics to be able to draw
String instead of using ScalarMap and References. I'd like to to the same
thing as the drawCursorStringVector methid from DisplayRendererJ2D.

Cheers,

Celine Gestas


==============================================================================
To unsubscribe visad, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
==============================================================================


 
 
  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