Re: Export the Display

Hi Larsson,

>How can i export the display to ps (postscript),eps
>and my data that draw the display to a ascii file

VisAD does not currently have built-in support for PS or EPS,
and its ASCII support is limited to import only.  However,
there are many other formats that it does support (see
http://www.ssec.wisc.edu/~billh/visad.html#formats for a
complete list).  Among those that support data export are
netCDF, TIFF, Bio-Rad, QuickTime and VisAD binary format.

If you wish to take a snapshot of the display itself, you
can use DisplayImpl.getImage() to obtain an Image object,
which you can export to a JPEG (or other image file format).

Here is some code to export a display snapshot to JPEG:

    import com.sun.image.codec.jpeg.*;
    ...
    DisplayImpl display = ...;
    ...
    BufferedImage image = display.getImage();
    JPEGEncodeParam param = JPEGCodec.getDefaultJPEGEncodeParam(image);
    param.setQuality(1.0f, true);
    FileOutputStream fout = new FileOutputStream(f);
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(fout);
    encoder.encode(image, param);
    fout.close();

If you would prefer to save your actual data rather than
a display snapshot, you could export your data to TIFF format:

    import visad.data.tiff
    ...
    DataImpl d = ...;
    ...
    TiffForm saver = new TiffForm();
    saver.write("data.tiff", d, false);

In either case, you could then use an image editor/viewer program
to convert the TIFF or JPEG file to PS or EPS.

Lastly, if you want VisAD to directly support PS or EPS, you could
find some Java code to read and write these formats and write a
file form adapter.  Subpackages of visad.data provide many examples
of such implementations.

-Curtis