logarithm scale issue
Celine Gestas
celine.gestas at gmail.com
Tue Mar 20 08:02:23 MDT 2007
Hi all,
I am working on displaying a logarithm scale on xAxis but I have the
following error :
" Single DisplayRealType DisplayXAxis occurs more than once:
ShadowType.testIndices"
and I don't understand why... I get X and Y values from a Class but I d like
to have a logarithm scale just for the xAxis.
My code is :
float xMin, xMax, yMax;
xMax = getMax(_linePlot.getValues(xAxis));
xMin = getMin(_linePlot.getValues(xAxis));
yMax = getMax(_linePlot.getValues((String)yAxis.get(0)));
for(i=1; i<yAxis.size(); i++) {
if (getMax(_linePlot.getValues((String)yAxis.get(i))) > yMax)
yMax = getMax(_linePlot.getValues((String)yAxis.get(i)));
}
/*************************/
/* Create the quantities */
/*************************/
// create the ScalarMaps : quantity x is to be _displayed along
XAxis and y along YAxis
RealType x = RealType.getRealType(xAxis);
xMap = new ScalarMap( x, Display.XAxis );
RealType y = RealType.getRealType("Y");
yMap = new ScalarMap( y, Display.YAxis );
yMap.setScaleEnable(true);
yMap.setRange(0, yMax);
CoordinateSystem logCoord = new LogCoordinateSystem(new
RealTupleType(x));
RealTupleType logX = new RealTupleType(x, logCoord, null);
// add them to the display
_display.addMap( xMap );
_display.addMap( yMap );
/*************************/
/* Create the quantities */
/*************************/
// our actual x and y values
float[][] x_vals = _linePlot.getValues(xAxis);
// rank the x values
for( i = (x_vals[0].length - 1); i > 0; i--) {
for( int j=0; j < i; j++) {
if (x_vals[0][j] > x_vals[0][j+1]) {
float L_iTemp= x_vals[0][j];
x_vals[0][j]= x_vals[0][j+1];
x_vals[0][j+1]= L_iTemp;
}
}
}
// create the index
x_set = new Gridded1DSet(logX, x_vals, x_vals[0].length, logCoord,
null, null);
float[][] y_vals = _linePlot.getValues((String) yAxis.get(i));
/******************************/
/* Code for setting LINE data */
/******************************/
// create the function to draw the line
func_x_y = new FunctionType(logX, y);
// associate the function (func_x_y) to the values (x_set)
line_ff = new FlatField( func_x_y, x_set);
// and put the y values above in it
line_ff.setSamples( y_vals );
/**************************/
/* Initialize the display */
/**************************/
// create data references and set the FlatFields (association
function/values) as our datas
line_ref = new DataReferenceImpl("line_ref");
line_ref.setData( line_ff );
_display.addReference( line_ref , lineCMap);
If someone could help me fixing this ....
Celine Gestas
More information about the visad
mailing list