NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
"Brobbey,Isaac" wrote: > > i still have not fix the PickManipulationRendererJ3D but i think i am > getting close to solving it except that i get an error message at runtime > even though it compiles alright; the error says > > "Exception in thread "main" java.lang.ClassCastException: visad.Real > at Spikesxxx.main(Spikesxxx.java:90)" > > which is on this line > > RealTuple coords = (RealTuple) field.getSample(0); The Exception occurs because the range values of your Field are Reals rather than RealTuples. You should be able to figure this out for yourself by: Data range = field.getSample(0); System.out.println("range = " + range); > is there any reason why i cannot return a tuple from the field ? knowing > very well i have declared the tuple earlier. It all depends on how you construct your Field. The range values of Fields can have any MathType. > so far, i can sucessfully retrieve the domain values, but not the range > values.the range values comes from the array contained in the loop below > > the other thing is also the fact that if i try using the data reference > "ref" to get or return a tuple it compiles and fails at run time. > > I wonder if getting the component zero from the array contained in the loop > below can cause such a thing to happen: > > for (int y=0; y<DENSITY * NUM_SPIKES_Y; y++) > { > for (int x=0; x<DENSITY * NUM_SPIKES_X; x++) > { > int ndx = y * DENSITY * NUM_SPIKES_X + x; > if (x % DENSITY == 0 && y % DENSITY == 0 ) > { > > i+=1; > // System.out.println(i); > Tuple data = (Tuple)fieldx.getSample(i);//next data sample > final Real ratiox = (Real) data.getComponent(0); > ratioxValues[i] = ratiox.getValue(); > samples[0][ndx] = ratioxValues[i];//put a spike here > } > else samples[0][ndx] =-30*Math.random(); > > } > if i try using data reference "ref" to get the tuple like : > > RealTuple coords = (RealTuple) ref.getData(); > > whiles in cellImpl,i get the almost the same error that says > > "java.lang.ClassCastException: visad.FlatField > at Spikesxxx$1.doAction(Spikesxxx.java:152) > at visad.ActionImpl.run(ActionImpl.java:243) > at visad.util.ThreadPool$ThreadMinnow.run(ThreadPool.java:95)" Again, the Data in a DataReference can have any MathType. You get this Exception because the Data object is a FlatField and you are trying to cast it as a RealTuple. Bill
visad
archives: