Hi Nihat,
The code below looks good. You can add the display to a user interface with:
JFrame f = new JFrame("My Frame");
JPanel p = new JPanel();
p.setLayout(new BorderLayout());
f.setContentPane(p);
p.add(display.getComponent(), BorderLayout.CENTER);
f.show();
Or some similar block of code.
There is no need to call getImage just to blit the image to a canvas on
screen. However, if you want to save a JPEG of the display to disk or
some such, then getImage is useful. However, you should not need to call
getImage for every frame -- just when the user clicks a "Save" button or
some such.
Also, if you are taking multiple snapshots, you only need build the
display and maps once. Then you can just call data_ref.setData(newField)
with your new data, and display.getImage() to get a new snapshot, each time.
-Curtis
ncubukcu wrote:
Thanks Curtis
I think I got it working now. You are right that my
com.app.lt.CreateImage throws me an image using getImage(). I don't
know any other way of creating an image in visad. Is there a
shorter way to add scalar maps to an image other than what I use below? .
.
contMap = new ScalarMap( field, Display.IsoContour );
colMap = new ScalarMap( longitude, Display.XAxis );
rowMap = new ScalarMap( latitude, Display.YAxis );
pixMap = new ScalarMap( field, Display.RGB );
DisplayImplJ2D display = new DisplayImplJ2D(" ", 700, 500);
GraphicsModeControl dispGMC = (GraphicsModeControl)
display.getGraphicsModeControl();
dispGMC.setScaleEnable(true);
// Add maps to display
display.addMap( colMap );
display.addMap( rowMap );
display.addMap( pixMap );
display.addMap( contMap );
// Create a data reference and set the FlatField as our data
DataReferenceImpl data_ref = new DataReferenceImpl("data_ref");
data_ref.setData( mapField );
// Add reference to display
display.addReference( data_ref ); return display.getImage();
Thanks again for your help
nihat
==============================================================================
To unsubscribe visad, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
==============================================================================