Hello VisAD comunnity,
I am facing a problem with the Display.IsoContour ScalarMap. In few
words, when I change the values, the Range dosen´t ajusts itself like it
does when I use another mapping like Display.RGB. It sounds like I am
missing something, but can be a bug also.
To make thing more clear, I am sending a single test that demonstrates
the problem.
Thanks already,
Cicero A. W. Zandoná
//Code starts here
import visad.*;
import visad.java2d.DisplayImplJ2D;
import java.rmi.RemoteException;
import javax.swing.JFrame;
public class NoRefresh {
private RealType longitude, latitude, sombreado;
// Para juntar lat e lon
private RealTupleType domain_tuple;
// função (domain_tuple -> sombreado )
private FunctionType func_dom_sombreado;
// Set para sombreado
private Set set_sombreado;
// FlatField dos dados da sombreado
private FlatField ff_sombreado;
// DataReference das sombreado
private DataReferenceImpl ref_sombreado;
// O display e seus mapas
private DisplayImpl display;
private ScalarMap latMap, lonMap, sombreadoMap;
static int NLINES = 30;
/** Creates a new instance of Display */
public NoRefresh() throws RemoteException, VisADException {
// Create the quantities
// Use RealType(String name);
latitude = RealType.Latitude;
longitude = RealType.Longitude;
domain_tuple = new RealTupleType(latitude, longitude);
sombreado = RealType.getRealType("sombreado");
// Cria a função (domain_tuple -> sombreado )
func_dom_sombreado = new FunctionType( domain_tuple, sombreado);
//Display 2D
display = new DisplayImplJ2D("display1");
//Para Displays 2D
latMap = new ScalarMap( RealType.Latitude, visad.Display.YAxis);
lonMap = new ScalarMap( RealType.Longitude, visad.Display.XAxis
);
display.addMap( latMap );
display.addMap( lonMap );
//Scalar Maps
sombreadoMap = new ScalarMap( sombreado,
visad.Display.IsoContour );
ScalarMap sombreadoMapColor = new ScalarMap( sombreado,
visad.Display.RGB );
display.addMap( sombreadoMap );
display.addMap( sombreadoMapColor );
//Setting Contour Fill
ContourControl isoControl = (ContourControl)
sombreadoMap.getControl();
isoControl.setContourFill(true);
System.out.println(sombreadoMap.isAutoScale());
ref_sombreado = new DataReferenceImpl("ref_sombreado");
// Adicionar ao display
display.addReference( ref_sombreado );
}
public void plotaSombreado(float[][] domain, float[][] vals)
throws RemoteException, VisADException {
display.removeReference(ref_sombreado);
sombreadoMap.resetAutoScale();
set_sombreado = new Gridded2DSet(domain_tuple, domain, NLINES,
NLINES);
ff_sombreado = new FlatField( func_dom_sombreado, set_sombreado);
ff_sombreado.setSamples( vals );
ref_sombreado.setData( ff_sombreado );
display.addReference( ref_sombreado );
}
public visad.DisplayImpl getDisplay() {return display;}
public static void main(String[] args) throws RemoteException,
VisADException {
NoRefresh noR = new NoRefresh();
//Janela que mostrará o display
JFrame jframe = new JFrame("Display do Metvis");
jframe.getContentPane().add(noR.getDisplay().getComponent());
jframe.setSize(610, 610);
jframe.setVisible(true);
float[][] matrix_1 = new float[1][NLINES*NLINES];
float[][] matrix_2 = new float[1][NLINES*NLINES];
float[][] domain = new float[2][NLINES*NLINES];
//Creating Domain
for(int c = 0; c < NLINES; c++)
for(int r = 0; r < NLINES; r++){
domain[0][ c * NLINES + r ] = 0f + r;
domain[1][ c * NLINES + r ] = 0f+ c;
}
//Creating Values
for(int c = 0; c < NLINES; c++)
for(int r = 0; r < NLINES; r++){
matrix_1[0][c * NLINES + r] = (float)
(Math.sin(r*200)*Math.cos(c*200));
matrix_2[0][c * NLINES + r] = (float)
(2*Math.sin(r*200)*Math.cos(c*200));
}
System.out.println("Drawing Data_1");
noR.plotaSombreado(domain, matrix_1);
//Waits some time.
try{ Thread.sleep(5*1000); }
catch (InterruptedException ex) {}
System.out.println("Drawing Data_2 = Data_1*2");
noR.plotaSombreado(domain, matrix_2);
}
}