Hi Astrid,
Sorry for your problems. Here's a version of P3_09_.java
that works for me. You may want to make the 16 even
larger.
Cheers,
Bill
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI 53706
hibbard@xxxxxxxxxxxxxxxxx 608-263-4427 fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html
/*
VisAD Tutorial
Copyright (C) 2000 Ugo Taddei
*/
// Import needed classes
import visad.*;
import visad.java2d.DisplayImplJ2D;
import java.rmi.RemoteException;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class P3_09_{
private RealType xpos, ypos, val ;
private RealTupleType domain_tuple, range_tuple;
private FunctionType func_domain_range;
private Set domain_set;
private Set domain_set_gridded;
private FlatField vals_ff;
private DataReferenceImpl data_ref;
private DisplayImpl display;
private ScalarMap xMap, yMap;
private ScalarMap IsoMap, RGBMap;
private float[][] x_y_vals = new float
[][]{{0.0f,2.0f,2.0f,3.0f,3.0f,4.0f,4.0f},
{2.0f,1.0f,4.0f,3.0f,1.0f,4.0f,1.0f}};
private float[][] values = new float
[][]{{3.0f,1.0f,-1.0f,4.0f,2.0f,-2.0f,5.0f}};
public P3_09_(String []args)
throws RemoteException, VisADException {
xpos = new RealType("Xpos");
ypos = new RealType("Ypos");
domain_tuple = new RealTupleType(xpos, ypos);
val = new RealType("Values");
func_domain_range = new FunctionType( domain_tuple, val);
domain_set = new Irregular2DSet(domain_tuple, x_y_vals);
/*
float[][] grid = new float[2][4];
for (int i = 0; i<4; i++)
{ for (int j = 0; j<4; j++)
{ grid[0][i] = i;
grid[1][j] = j; }}
*/
float[][] grid = new float[2][256];
for (int i = 0; i<16; i++)
{ for (int j = 0; j<16; j++)
{ grid[0][i + 16 * j] = 0.25f * i;
grid[1][i + 16 * j] = 0.25f * j; }}
// domain_set_gridded = new Gridded2DSet(domain_tuple, grid,4);
// domain_set_gridded = new Gridded2DSet(domain_tuple, grid,4, 4);
domain_set_gridded = new Gridded2DSet(domain_tuple, grid,16, 16);
vals_ff = new FlatField( func_domain_range, domain_set );
// vals_ff.resample(domain_set_gridded);
vals_ff.setSamples( values , false );
vals_ff = (FlatField) vals_ff.resample(domain_set_gridded);
display = new DisplayImplJ2D("display1");
GraphicsModeControl dispGMC = (GraphicsModeControl)
display.getGraphicsModeControl();
dispGMC.setScaleEnable(true);
xMap = new ScalarMap( ypos, Display.YAxis );
yMap = new ScalarMap( xpos, Display.XAxis );
IsoMap = new ScalarMap( val, Display.IsoContour );
RGBMap = new ScalarMap( val, Display.RGB );
display.addMap( yMap );
display.addMap( xMap );
display.addMap( IsoMap );
display.addMap( RGBMap );
ContourControl isoControl = (ContourControl) IsoMap.getControl();
// float base = 0.0f;
float base = 2.0f;
float[] levs = new float[16];
for (int i = 0; i < 16; i++)
{ levs[i] = (float) (i-1)/2; }
isoControl.setLevels(levs, base, true);
isoControl.enableLabels(true);
data_ref = new DataReferenceImpl("data_ref");
data_ref.setData( vals_ff );
display.addReference( data_ref );
JFrame jframe = new JFrame("...");
jframe.getContentPane().add(display.getComponent());
jframe.setSize(300, 300);
jframe.setVisible(true);
}
public static void main(String[] args)
throws RemoteException, VisADException
{
new P3_09_(args);
}
}