
import visad.*;
import visad.java2d.DisplayImplJ2D;
import visad.java3d.DisplayImplJ3D;
import java.rmi.RemoteException;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import visad.util.*;


class f1 extends f_xj
{
public double func(double x[]) 
{
//çözümü istenen fonksiyon	
double ff;
ff=Math.sin(0.5*x[0])*Math.cos(x[1]);
return ff; 
}
}

class f2 extends f_xj
{
public double func(double x[]) 
{
//çözümü istenen fonksiyon	
double ff;
ff=1.0/(x[0]*x[0]+x[1]*x[1]+1.0);
return ff;
}
}

public class Plo3D{
public static void Plot_3D_RGB(f_xj f, double xmin[],double xmax[],int NROWS,int NCOLS)
    throws RemoteException, VisADException 
{
    // Declare variables
  // The domain quantities longitude and latitude
  // and the dependent quantity temperature
  // Declare variables
  // The domain quantities longitude and latitude
  // and the dependent quantities altitude, temperature

   RealType longitude, latitude;
   RealType altitude, temperature,  precipitation;

  // Two Tuples: one to pack longitude and latitude together, as the domain
  // and the other for the range (altitude, temperature)

   RealTupleType domain_tuple, range_tuple;


  // The function (domain_tuple -> range_tuple )

   FunctionType func_domain_range;


   // Our Data values for the domain are represented by the Set

   Set domain_set;


  // The Data class FlatField

   FlatField vals_ff;

  // The DataReference from data to display

   DataReferenceImpl data_ref;

  // The 2D display, and its the maps

   DisplayImpl display;
   ScalarMap latMap, lonMap;
   ScalarMap altZMap, tempRGBMap;
   ScalarMap tempZMap, altRGBMap;


    // Create the quantities
    // Use RealType(String name);

    latitude = RealType.getRealType("latitude",SI.meter,null);
    longitude = RealType.getRealType("longitude",SI.meter,null);

    domain_tuple = new RealTupleType(latitude, longitude);

    temperature = RealType.getRealType("temperature",SI.kelvin,null);
    altitude = RealType.getRealType("altitude",SI.meter,null);

    // Create the range tuple ( altitude, temperature )
    // Use RealTupleType( RealType[] )

    range_tuple = new RealTupleType( altitude, temperature  );
    ScalarMap tempIsoMap;

    // Create a FunctionType (domain_tuple -> range_tuple )
    // Use FunctionType(MathType domain, MathType range)

    func_domain_range = new FunctionType( domain_tuple, range_tuple);

       // Create the domain Set
    // Use LinearDSet(MathType type, double first1, double last1, int lengthX,
    //				     double first2, double last2, int lengthY)
    
    domain_set = new Linear2DSet(domain_tuple, xmin[0], xmax[0], NROWS,
    					       xmin[1], xmax[1], NCOLS);
    // Get the Set samples to facilitate the calculations
    float[][] set_samples = domain_set.getSamples( true );
    // We create another array, with the same number of elements of
    // altitude and temperature, but organized as
    // float[2][ number_of_samples ]
    double x[]=new double[2];
    float[][] flat_samples = new float[2][NCOLS * NROWS];
    // ...and then we fill our 'flat' array with the generated values
    // by looping over NCOLS and NROWS
    for(int c = 0; c < NCOLS; c++)
      {x[0]=xmin[0]+(xmax[0]-xmin[0])/(double)NCOLS*(double)c;
      for(int r = 0; r < NROWS; r++)
        {x[1]=xmin[1]+(xmax[1]-xmin[1])/(double)NROWS*(double)r;
	     flat_samples[0][ c * NROWS + r ] = (float)f.func(x);
	     flat_samples[1][ c * NROWS + r ] = (float)x[1];
        }
      }
      
    // Create a FlatField
    // Use FlatField(FunctionType type, Set domain_set)

    vals_ff = new FlatField( func_domain_range, domain_set);

    // ...and put the values above into it

    // Note the argument false, meaning that the array won't be copied

    vals_ff.setSamples( flat_samples , false );

    // Create Display and its maps

    // A 2D display

    display = new DisplayImplJ3D("display1");

    // Get display's graphics mode control and draw scales

    GraphicsModeControl dispGMC = (GraphicsModeControl)  display.getGraphicsModeControl();
    dispGMC.setScaleEnable(true);


    // Create the ScalarMaps: latitude to YAxis, longitude to XAxis and
    // altitude to ZAxis and temperature to RGB
    // Use ScalarMap(ScalarType scalar, DisplayRealType display_scalar)

    latMap = new ScalarMap( latitude,  Display.YAxis );
    lonMap = new ScalarMap( longitude, Display.XAxis );

    // Add maps to display

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

     // altitude to z-axis and temperature to color

    altZMap = new ScalarMap( altitude,  Display.ZAxis );
    tempRGBMap = new ScalarMap( temperature,  Display.RGB );
    //tempIsoMap = new ScalarMap( temperature,  Display.IsoContour );
   
    // Add maps to display
    display.addMap( altZMap );
    //display.addMap( tempIsoMap );
    display.addMap( tempRGBMap );
    


    // Uncomment following lines to have different data depiction
    // temperature to z-axis and altitude to color

    //altRGBMap = new ScalarMap( altitude,  Display.RGB );
    //tempZMap = new ScalarMap( temperature,  Display.ZAxis );
    //display.addMap( altRGBMap );
    //display.addMap( tempZMap );


    // Create a data reference and set the FlatField as our data

    data_ref = new DataReferenceImpl("data_ref");

    data_ref.setData( vals_ff );

    // Add reference to display

    display.addReference( data_ref );


    // Create application window and add display to window

    JFrame jframe = new JFrame("3 boyutlu grafik çıktısı");
    jframe.getContentPane().add(display.getComponent());


    // Set window size and make it visible

    jframe.setSize(500, 500);
    jframe.setVisible(true);
}

public static void Plot_3D_CM(f_xj f, double xmin[],double xmax[],int NROWS,int NCOLS)
    throws RemoteException, VisADException 
{
    // Declare variables
  // The domain quantities longitude and latitude
  // and the dependent quantity temperature
  // Declare variables
  // The domain quantities longitude and latitude
  // and the dependent quantities altitude, temperature

   RealType longitude, latitude;
   RealType altitude, temperature,  precipitation;

  // Two Tuples: one to pack longitude and latitude together, as the domain
  // and the other for the range (altitude, temperature)

   RealTupleType domain_tuple, range_tuple;


  // The function (domain_tuple -> range_tuple )

   FunctionType func_domain_range;


   // Our Data values for the domain are represented by the Set

   Set domain_set;


  // The Data class FlatField

   FlatField vals_ff;

  // The DataReference from data to display

   DataReferenceImpl data_ref;

  // The 2D display, and its the maps

   DisplayImpl display;
   ScalarMap latMap, lonMap;
   ScalarMap altZMap, tempRGBMap;
   ScalarMap tempZMap, altRGBMap;

    // Create the quantities
    // Use RealType(String name);

    latitude = RealType.getRealType("latitude",SI.meter,null);
    longitude = RealType.getRealType("longitude",SI.meter,null);

    domain_tuple = new RealTupleType(latitude, longitude);

    temperature = RealType.getRealType("temperature",SI.kelvin,null);
    altitude = RealType.getRealType("altitude",SI.meter,null);

    // Create the range tuple ( altitude, temperature )
    // Use RealTupleType( RealType[] )

    range_tuple = new RealTupleType( altitude, temperature  );
    ScalarMap tempIsoMap;

    // Create a FunctionType (domain_tuple -> range_tuple )
    // Use FunctionType(MathType domain, MathType range)

    func_domain_range = new FunctionType( domain_tuple, range_tuple);

       // Create the domain Set
    // Use LinearDSet(MathType type, double first1, double last1, int lengthX,
    //				     double first2, double last2, int lengthY)
    
    domain_set = new Linear2DSet(domain_tuple, xmin[0], xmax[0], NROWS,
    					       xmin[1], xmax[1], NCOLS);
    // Get the Set samples to facilitate the calculations
    float[][] set_samples = domain_set.getSamples( true );
    // We create another array, with the same number of elements of
    // altitude and temperature, but organized as
    // float[2][ number_of_samples ]
    double x[]=new double[2];
    float[][] flat_samples = new float[2][NCOLS * NROWS];
    // ...and then we fill our 'flat' array with the generated values
    // by looping over NCOLS and NROWS
    for(int c = 0; c < NCOLS; c++)
      {x[0]=xmin[0]+(xmax[0]-xmin[0])/(double)NCOLS*(double)c;
      for(int r = 0; r < NROWS; r++)
        {x[1]=xmin[1]+(xmax[1]-xmin[1])/(double)NROWS*(double)r;
	     flat_samples[0][ c * NROWS + r ] = (float)f.func(x);
	     flat_samples[1][ c * NROWS + r ] = (float)x[1];
        }
      }
      
    // Create a FlatField
    // Use FlatField(FunctionType type, Set domain_set)

    vals_ff = new FlatField( func_domain_range, domain_set);

    // ...and put the values above into it

    // Note the argument false, meaning that the array won't be copied

    vals_ff.setSamples( flat_samples , false );

    // Create Display and its maps

    // A 2D display

    display = new DisplayImplJ3D("display1");

    // Get display's graphics mode control and draw scales

    GraphicsModeControl dispGMC = (GraphicsModeControl)  display.getGraphicsModeControl();
    dispGMC.setScaleEnable(true);


    // Create the ScalarMaps: latitude to YAxis, longitude to XAxis and
    // altitude to ZAxis and temperature to RGB
    // Use ScalarMap(ScalarType scalar, DisplayRealType display_scalar)

    latMap = new ScalarMap( latitude,  Display.YAxis );
    lonMap = new ScalarMap( longitude, Display.XAxis );

    // Add maps to display

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

     // altitude to z-axis and temperature to color

    altZMap = new ScalarMap( altitude,  Display.ZAxis );
    tempRGBMap = new ScalarMap( temperature,  Display.RGB );
    tempIsoMap = new ScalarMap( temperature,  Display.IsoContour );
   
    // Add maps to display
    display.addMap( altZMap );
    display.addMap( tempIsoMap );
    display.addMap( tempRGBMap );

    // Uncomment following lines to have different data depiction
    // temperature to z-axis and altitude to color

    //altRGBMap = new ScalarMap( altitude,  Display.RGB );
    //tempZMap = new ScalarMap( temperature,  Display.ZAxis );
    //display.addMap( altRGBMap );
    //display.addMap( tempZMap );


    // Create a data reference and set the FlatField as our data

    data_ref = new DataReferenceImpl("data_ref");

    data_ref.setData( vals_ff );

    // Add reference to display

    display.addReference( data_ref );


    // Create application window and add display to window

    JFrame jframe = new JFrame("3 boyutlu grafik çıktısı");
    jframe.getContentPane().add(display.getComponent());


    // Set window size and make it visible

    jframe.setSize(500, 500);
    jframe.setVisible(true);
}

public static void Plot_3D(f_xj f, double xmin[],double xmax[],int NROWS,int NCOLS)
    throws RemoteException, VisADException 
{
// Declare variables
  // The domain quantities longitude and latitude
  // and the dependent quantities altitude, temperature

   RealType longitude, latitude;
   RealType altitude, temperature,  precipitation;

  // Two Tuples: one to pack longitude and latitude together, as the domain
  // and the other for the range (altitude, temperature)

   RealTupleType domain_tuple, range_tuple;


  // The function (domain_tuple -> range_tuple )

   FunctionType func_domain_range;


   // Our Data values for the domain are represented by the Set

   Set domain_set;


  // The Data class FlatField

   FlatField vals_ff;

  // The DataReference from data to display

   DataReferenceImpl data_ref;

  // The 2D display, and its the maps

   DisplayImpl display;
   ScalarMap latMap, lonMap;
   ScalarMap altZMap, tempRGBMap;
   ScalarMap tempZMap, altRGBMap;
   ScalarMap tempIsoMap, altIsoMap;

  // The ContourWidget

   ContourWidget contourWid;


    // Create the quantities
    // Use RealType(String name);

    latitude = RealType.getRealType("latitude",SI.meter,null);
    longitude = RealType.getRealType("longitude",SI.meter,null);

    domain_tuple = new RealTupleType(latitude, longitude);

    temperature = RealType.getRealType("temperature",SI.kelvin,null);
    altitude = RealType.getRealType("altitude",SI.meter,null);

    // Create the range tuple ( altitude, temperature )
    // Use RealTupleType( RealType[] )

    range_tuple = new RealTupleType( altitude, temperature  );


    // Create a FunctionType (domain_tuple -> range_tuple )
    // Use FunctionType(MathType domain, MathType range)

    func_domain_range = new FunctionType( domain_tuple, range_tuple);

    // Create the domain Set
    // Use LinearDSet(MathType type, double first1, double last1, int lengthX,
    //				     double first2, double last2, int lengthY)

    domain_set = new Linear2DSet(domain_tuple,xmin[0], xmax[0], NROWS,
    					       xmin[1], xmax[1], NCOLS);




    // Get the Set samples to facilitate the calculations

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


    // We create another array, with the same number of elements of
    // altitude and temperature, but organized as
    // float[2][ number_of_samples ]

    double x[]=new double[2];
    float[][] flat_samples = new float[2][NCOLS * NROWS];
    // ...and then we fill our 'flat' array with the generated values
    // by looping over NCOLS and NROWS
    for(int c = 0; c < NCOLS; c++)
      {x[0]=xmin[0]+(xmax[0]-xmin[0])/(double)NCOLS*(double)c;
      for(int r = 0; r < NROWS; r++)
        {x[1]=xmin[1]+(xmax[1]-xmin[1])/(double)NROWS*(double)r;
	     flat_samples[0][ c * NROWS + r ] = (float)f.func(x);
	     flat_samples[1][ c * NROWS + r ] = (float)x[1];
        }
      }

    // Create a FlatField
    // Use FlatField(FunctionType type, Set domain_set)

    vals_ff = new FlatField( func_domain_range, domain_set);

    // ...and put the values above into it

    // Note the argument false, meaning that the array won't be copied

    vals_ff.setSamples( flat_samples , false );

    // Create Display and its maps

    // A 2D display

    display = new DisplayImplJ3D("display1");

    // Get display's graphics mode control and draw scales

    GraphicsModeControl dispGMC = (GraphicsModeControl)  display.getGraphicsModeControl();
    dispGMC.setScaleEnable(true);


    // Create the ScalarMaps: latitude to YAxis, longitude to XAxis and
    // altitude to ZAxis and temperature to RGB
    // Use ScalarMap(ScalarType scalar, DisplayRealType display_scalar)

    latMap = new ScalarMap( latitude,    Display.YAxis );
    lonMap = new ScalarMap( longitude, Display.XAxis );

    // Add maps to display

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

     // altitude to z-axis and temperature to color

    altZMap = new ScalarMap( altitude,  Display.ZAxis );
    tempRGBMap = new ScalarMap( temperature,  Display.RGB );
    // Add maps to display
    display.addMap( altZMap );
    display.addMap( tempRGBMap );


    // Uncomment following lines to have different data depiction
    // temperature to z-axis and altitude to color

    //altRGBMap = new ScalarMap( altitude,  Display.RGB );
    //tempZMap = new ScalarMap( temperature,  Display.ZAxis );
    //display.addMap( altRGBMap );
    //display.addMap( tempZMap );

    // maps for isocontours

    tempIsoMap = new ScalarMap( temperature,  Display.IsoContour );
    display.addMap( tempIsoMap );

    //altIsoMap = new ScalarMap( altitude,  Display.IsoContour );
    //display.addMap( altIsoMap );



    // The ContourWidget
    // Note that we create the widget from the IsoContour map

    contourWid = new ContourWidget( tempIsoMap );


    // Create a data reference and set the FlatField as our data

    data_ref = new DataReferenceImpl("data_ref");

    data_ref.setData( vals_ff );

    // Add reference to display

    display.addReference( data_ref );


    // Create application window and add display to window

    JFrame jframe = new JFrame("");
    jframe.getContentPane().setLayout(new FlowLayout());
    jframe.getContentPane().add(display.getComponent());

    // Add the ContourWidget to the frame

    jframe.getContentPane().add(contourWid);

    // Set window size and make it visible

    jframe.setSize(500, 500);
    jframe.setVisible(true);
}  
  
public static void contour_Plot1(f_xj f, double xmin[],double xmax[],int NROWS,int NCOLS)
    throws RemoteException, VisADException 
    {
	// Declare variables
    // The domain quantities longitude and latitude
    // and the dependent quantity temperature

  RealType longitude, latitude;
  RealType temperature;


  // Tuple to pack longitude and latitude together, as the domain

  RealTupleType domain_tuple;


  // The function (domain_tuple -> temperature )
  // Remeber, range is only "temperature"

  FunctionType func_domain_temp;


   // Our Data values for the domain are represented by the Set

  Set domain_set;


  // The Data class FlatField

  FlatField vals_ff;

  // The DataReference from data to display

  DataReferenceImpl data_ref;

  // The 2D display, and its the maps

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

  // These objects are for drawing isocontours

  RealType isoTemperature;
  FunctionType func_domain_isoTemp;

  FlatField iso_vals_ff;
  DataReferenceImpl iso_data_ref;
    // Create the quantities
    // Use RealType(String name);
    latitude = RealType.getRealType("latitude");
    longitude = RealType.getRealType("longitude");
    domain_tuple = new RealTupleType(latitude, longitude);
    temperature = RealType.getRealType("temperature", SI.kelvin, null);
    isoTemperature = RealType.getRealType("isoTemperature", SI.kelvin, null);
    // Create a FunctionType (domain_tuple -> temperature )
    // Use FunctionType(MathType domain, MathType range)
    func_domain_temp = new FunctionType( domain_tuple, temperature);
    // ... the same for isoTemperature
    func_domain_isoTemp = new FunctionType( domain_tuple, isoTemperature);
    // Create the domain Set
    // Use LinearDSet(MathType type, double first1, double last1, int lengthX,
    //				     double first2, double last2, int lengthY)
    domain_set = new Linear2DSet(domain_tuple, xmin[0], xmax[0], NROWS,
    					      xmin[1], xmax[1], NCOLS);
    // Get the Set samples to facilitate the calculations

    float[][] set_samples = domain_set.getSamples( true );
    // The actual temperature values are stored in this array
    // float[1][ number_of_samples ]
    double x[]=new double[2];
    float[][] flat_samples = new float[1][NCOLS * NROWS];

    // We fill our 'flat' array with the generated values
    // by looping over NCOLS and NROWS

    for(int c = 0; c < NCOLS; c++)
      {x[0]=xmin[0]+(xmax[0]-xmin[0])/(double)NCOLS*(double)c;
      for(int r = 0; r < NROWS; r++)
        {x[1]=xmin[1]+(xmax[1]-xmin[1])/(double)NROWS*(double)r;
	     flat_samples[0][ c * NROWS + r ] = (float)f.func(x);
        }
      }
    // Create the FlatFields
    // Use FlatField(FunctionType type, Set domain_set)

      // For the colored image

    vals_ff = new FlatField( func_domain_temp, domain_set);

    // ...and put the values above into it
    // Note the argument false, meaning that the array won't be copied

    vals_ff.setSamples( flat_samples , false );


      // ...and for the isocontours

    iso_vals_ff = new FlatField( func_domain_isoTemp, domain_set);


    // Get the values from the temperature FlatField
    // create flat_isoVals array for clarity's sake
    // "false" argument means "don't copy"

    float[][] flat_isoVals = vals_ff.getFloats(false);


    // ...and put the values above into it

    // Note the argument false, meaning that the array won't be copied again

    iso_vals_ff.setSamples( flat_isoVals , false );



    // Create Display and its maps

    // A 2D display

    display = new DisplayImplJ2D("display1");

    // Get display's graphics mode control and draw scales

    GraphicsModeControl dispGMC = (GraphicsModeControl)  display.getGraphicsModeControl();
    dispGMC.setScaleEnable(true);



    // Create the ScalarMaps: latitude to YAxis, longitude to XAxis and
    // temperature to RGB and
    // isoTemperature to IsoContour
    // Use ScalarMap(ScalarType scalar, DisplayRealType display_scalar)

    latMap = new ScalarMap( latitude,    Display.YAxis );
    lonMap = new ScalarMap( longitude, Display.XAxis );

    tempIsoMap = new ScalarMap( isoTemperature,  Display.IsoContour );
    tempRGBMap = new ScalarMap( temperature,  Display.RGB );


    // Add maps to display

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

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

    // The ContourControl
    // Note that we get the control from the IsoContour map

    ContourControl isoControl = (ContourControl) tempIsoMap.getControl();

    // Define some parameters for contour lines

    float interval = 0.1250f;  // interval between lines

    float lowValue = -0.50f;   // lowest value

    float highValue = 1.0f;    // highest value

    float base = -1.0f;        //  starting at this base value

    // ...and set the lines with the method

    isoControl.setContourInterval(interval, lowValue, highValue, base);
    isoControl.enableLabels(true);

    // Create data references and set the FlatField as our data

    data_ref = new DataReferenceImpl("data_ref");
    iso_data_ref = new DataReferenceImpl("iso_data_ref");

    data_ref.setData( vals_ff );
    iso_data_ref.setData( iso_vals_ff );

    // Add reference to display

    display.addReference( data_ref );
    display.addReference( iso_data_ref );


    // Create application window and add display to window

    JFrame jframe = new JFrame("VisAD Tutorial example 3_07");
    jframe.getContentPane().add(display.getComponent());


    // Set window size and make it visible

    jframe.setSize(900, 900);
    jframe.setVisible(true);
	}

  public static void contour_Plot(f_xj f, double xmin[],double xmax[],int NROWS,int NCOLS)
    throws RemoteException, VisADException {
  RealType longitude, latitude;
  RealType temperature;
  // Tuple to pack longitude and latitude together, as the domain
  RealTupleType domain_tuple;
  // The function (domain_tuple -> temperature )
  // Remeber, range is only "temperature"
  FunctionType func_domain_range;
   // Our Data values for the domain are represented by the Set
  Set domain_set;
  // The Data class FlatField
  FlatField vals_ff;
  // The DataReference from data to display
  DataReferenceImpl data_ref;
  // The 2D display, and its the maps
  DisplayImpl display;
  ScalarMap latMap, lonMap;
  ScalarMap tempIsoMap, tempRGBMap;
    // Create the quantities
    // Use RealType(String name);

    latitude = RealType.getRealType("latitude");
    longitude = RealType.getRealType("longitude");

    domain_tuple = new RealTupleType(latitude, longitude);

    temperature = RealType.getRealType("temperature");

    // Create a FunctionType (domain_tuple -> range_tuple )
    // Use FunctionType(MathType domain, MathType range)

    func_domain_range = new FunctionType( domain_tuple, temperature);

    // Create the domain Set
    // Use LinearDSet(MathType type, double first1, double last1, int lengthX,
    //				     double first2, double last2, int lengthY)

    //int NCOLS = 50;
    //int NROWS = NCOLS;

    domain_set = new Linear2DSet(domain_tuple, xmin[0], xmax[0], NROWS,
    					      xmin[1], xmax[1], NCOLS);



    // Get the Set samples to facilitate the calculations

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


    // The actual temperature values are stored in this array
    // float[1][ number_of_samples ]
    double x[]=new double[2];
    float[][] flat_samples = new float[1][NCOLS * NROWS];

    // We fill our 'flat' array with the generated values
    // by looping over NCOLS and NROWS

    for(int c = 0; c < NCOLS; c++)
      {x[0]=xmin[0]+(xmax[0]-xmin[0])/(double)NCOLS*(double)c;
      for(int r = 0; r < NROWS; r++)
        {x[1]=xmin[1]+(xmax[1]-xmin[1])/(double)NROWS*(double)r;
	     flat_samples[0][ c * NROWS + r ] = (float)f.func(x);
        }
      }
	      // Create a FlatField
    // Use FlatField(FunctionType type, Set domain_set)

    vals_ff = new FlatField( func_domain_range, domain_set);

    // ...and put the values above into it

    // Note the argument false, meaning that the array won't be copied

    vals_ff.setSamples( flat_samples , false );

    // Create Display and its maps

    // A 2D display

    display = new DisplayImplJ2D("display1");

    // Get display's graphics mode control and draw scales

    GraphicsModeControl dispGMC = (GraphicsModeControl)  display.getGraphicsModeControl();
    dispGMC.setScaleEnable(true);


    // Create the ScalarMaps: latitude to YAxis, longitude to XAxis and
    // temperature to IsoContour and eventualy to RGB
    // Use ScalarMap(ScalarType scalar, DisplayRealType display_scalar)

    latMap = new ScalarMap( latitude,  Display.YAxis );
    lonMap = new ScalarMap( longitude, Display.XAxis );
    // This is new!
    tempIsoMap = new ScalarMap( temperature,  Display.IsoContour );
    // this ScalarMap will color the isolines
    // don't foget to add it to the display
    tempRGBMap = new ScalarMap( temperature,  Display.RGB );
    // Add maps to display
    display.addMap( latMap );
    display.addMap( lonMap );
    display.addMap( tempIsoMap );
    display.addMap( tempRGBMap );
    // Create a data reference and set the FlatField as our data
    data_ref = new DataReferenceImpl("data_ref");
    data_ref.setData( vals_ff );
    // Add reference to display
    display.addReference( data_ref );
    // Create application window and add display to window
    JFrame jframe = new JFrame("kontur grafiği");
    jframe.getContentPane().add(display.getComponent());
    // Set window size and make it visible
    jframe.setSize(900, 900);
    jframe.setVisible(true);
  }


  public static void main(String[] args)
  throws RemoteException, VisADException
  {
	f2 fa=new f2();
	double xmin[]=new double[2];
	double xmax[]=new double[2];
	int NROWS=200;
	int NCOLS=200;
	xmin[0]=-Math.PI;
	xmin[1]=-Math.PI;
	xmax[0]= Math.PI;
	xmax[1]= Math.PI;
	Plot_3D_CM(fa,xmin,xmax,NROWS,NCOLS);
  }

} 
