RE: regarding 2d image and boundary

   you are very right. I missed the lower bound in the "color palette". I guess
I was in a hurry code something using VisAD that was earlier done using GMT. 
are reasons why this is being done and I know as much about VisAD as I know 
GMT, which is next to nothing.
   So I really need help. My question is actually illustrated better following 
suggested modification. All the contours are filled, but why is there a huge 
surrounding the image. Is there any way the image could occupy the entire 
space. I was
told by someone who used Vis5D a long time ago, that there was something like a
"viewing distance", which if reduced to zero (or something similar) would cause 
image to occupy the entire space available. I would like to know if there is 
to that effect. I searched the API documentation, but couldn't find anything.
   Thank you for your help.

P.S: Please find the code below. The missing brace happenned during a 
cut-and-paste of
code from my terminal screen to the E-mail. Thank you.

// ===========================================================================
import visad.*;
import visad.java2d.DisplayImplJ2D;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;

public class Image2D {
   private RealType longitude, latitude;
   private RealType temperature;

   private RealTupleType domain_tuple;

   private FunctionType func_domain_range;

   private Set domain_set;

   private FlatField vals_ff;

   private DataReferenceImpl data_ref;

   private DisplayImpl display;
   private ScalarMap latMap, lonMap;
   private ScalarMap tempIsoMap, tempRGBMap;

   public Image2D(float[] data, int NCOLS, int NROWS) throws Exception {
      latitude = RealType.getRealType("latitude");
      longitude = RealType.getRealType("longitude");

      domain_tuple = new RealTupleType(latitude, longitude);

      temperature = RealType.getRealType("temperature");

      func_domain_range = new FunctionType( domain_tuple, temperature);

      domain_set = new Linear2DSet(domain_tuple, 1,NROWS,NROWS, 1,NCOLS,NCOLS);

      float[][] set_samples = domain_set.getSamples(true);

      float[][] flat_samples = new float[1][NCOLS * NROWS];

      for (int dataIndex=0; dataIndex < data.length; dataIndex++) {
         int dataCol = (dataIndex % NCOLS);
         int dataRow = (dataIndex / NCOLS);

         int sampleIndex = ((dataCol * NROWS) + dataRow);

         flat_samples[0][sampleIndex] = data[dataIndex];

      vals_ff = new FlatField( func_domain_range, domain_set);
      vals_ff.setSamples( flat_samples , false );

      int NumXPixels = 450;
      int NumYPixels = 450;

      if (NROWS != NCOLS) {
         boolean Xmax = (NCOLS > NROWS);
         if (Xmax) {
            NumYPixels = (int) ((NumXPixels * NROWS) / NCOLS);
         } else {
            NumXPixels = (int) ((NumYPixels * NCOLS) / NROWS);

      display = new DisplayImplJ2D("display1", NumXPixels, NumYPixels);

      latMap = new ScalarMap( latitude,    Display.YAxis );
      lonMap = new ScalarMap( longitude, Display.XAxis );
      tempIsoMap = new ScalarMap( temperature,  Display.IsoContour );
      tempRGBMap = new ScalarMap( temperature,  Display.RGB );

      display.addMap( latMap );
      display.addMap( lonMap );
      display.addMap( tempIsoMap );
      display.addMap( tempRGBMap );

      ContourControl isoControl = (ContourControl) tempIsoMap.getControl();
      float[] levels = {200.0f, 295.0f, 305.0f, 500.0f};
      isoControl.setLevels(levels, 200.0f, false);

      data_ref = new DataReferenceImpl("data_ref");
      data_ref.setData( vals_ff );

      display.addReference( data_ref );

      double ar = ((double) NumYPixels) / ((double) NumXPixels);
      ProjectionControl pc = display.getProjectionControl();
      pc.setAspect(new double[] {1.0, ar});

   public void writeToFile() throws IOException {
      BufferedImage image = display.getImage(true);
      File file = new File("iso_contour_image.png");
      ImageIO.write(image, "PNG", file);

   public static void main(String[] args) {
      try {
         float[] data = {
                           318.0f, 312.0f, 297.0f, 299.0f, 302.0f,
                           315.0f, 311.0f, 296.0f, 297.0f, 299.0f,
                           306.0f, 298.0f, 297.0f, 294.0f, 294.0f,
                           297.0f, 296.0f, 294.0f, 291.0f, 294.0f,
                           297.0f, 291.0f, 293.0f, 287.0f, 285.0f,
                           297.0f, 296.0f, 296.0f, 291.0f, 291.0f

         Image2D imgObj = new Image2D(data, 5, 6);

         System.out.println("Image written to file");
      } catch (Exception e) {
// ===========================================================================