get Graphics instance
Curtis Rueden
ctrueden at wisc.edu
Tue Apr 3 15:01:48 MDT 2007
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 at gmail.com> 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
==============================================================================
More information about the visad
mailing list