Re: contour

Hello Isaac,

I am cc'ing the list because others might benefit from your question.

-- part 1 --

To add contours to your display, add the following line to
the section of the code where you add your scalar maps:

Display.addMap(new ScalarMap(ratio, Display.IsoContour));

Please note the following:

- the contour lines will be coloured because you also have
 a scalar map that maps "ratio" to "Display.RGB"

If you want the data to be coloured, as it currently
is, with contour lines over it, then you can read Section 3.7
of Ugo's tutorial titled "IsoContours over image".  This will
involve creating another flat field that contains the same
domain/range data, but with a different real type in the
function type's range.
eg. (pi, isotopicmass)->contoured_ratio

You can then use:
display.addMap(new ScalarMap(ratio, Display.RGB));
to have the data coloured, and:
display.addMap(new ScalarMap(contoured_ratio, Display.IsoContour));
display.addMap(new ScalarMap(contoured_ratio, Display.RGB));
to add contoured lines and have them coloured.

- the contour lines will look like "mountain ranges" because
 you have a scalar map that maps "ratio" to "Display.ZAxis"

If you want the contour lines to lie in the same plane, ie. to
be flat, then remove the line:
display.addMap(new ScalarMap(ratio, Display.ZAxis));

-- part 2 --

The screenshot you sent me shows data extending past
the limits of the x-axis.  Your code creates a RangeWidget:
ranWidget = ranWidget = new RangeWidget(xmap0);
[ by the way, you can remove the extra "ranWidget = "
from this line ].
and "xmap0" is a ScalarMap that maps "isotopicmass" to
Display.XAxis.

So, I can only suppose that you have edited the "low" and
"high" values in the RangeWidget.  Specifically, you've set
the "high" value to "20", which is causing the x-axis to be
cut off at this value.  Try increasing the value and you should
see that the x-axis extends.  Alternatively, don't set the
low/high values, as they should be automatically calculated
from the data.

Hope this helps,
Jim.
---
Jim Koutsovasilis
Bureau of Meteorology, Australia
jimk@xxxxxxxxxx


Brobbey,Isaac wrote:

JIM: have a little problem with my display, which i am trying to fix. i am
trying to figure out how to make a contour for my display just like Ugo did
in his 3-dimensional display tutorials. but the thing is that my mathtype is
(pi,isotopicmass)->ratio which is abit  different from his.

i have been studying visad for a while, but i have a little difficulty with
the data structure. i am asking is there any simple way i can make a contour.?? please take a look at the screen shot, so i want to change or convert that
into a contour but i need a smallest case which i can follow:

i will be glad to hear any suggestions or workarounds from you.
the second thing is that the algorithm below puts spikes on a grid created
using Integer2DSet set = new Integer2DSet( DENSITY * NUM_SPIKES_X, DENSITY * NUM_SPIKES_Y); the scale on the x and y axis is not matching those of the spikes and i am
wondering what can really cause that ? the x and y values of the spikes is
not matching the scale on the axis.the complete code is shown below:

if you need furthur explanation, let me know as always i thank you Isaac **// public DisplayListener listener; private DataReferenceImpl ref; // needed variables // number of spikes along X axis private static final int NUM_SPIKES_X = 8; // number of spikes along Y axis private static final int NUM_SPIKES_Y = 5; // increase density value to make spikes "thinner" // decrease density value to make spikes "thicker" private static final int DENSITY = 5; private static final int MAX_HEIGHT = 100; private proteinxwc save;


public void show3D() { try { Integer2DSet set = new Integer2DSet( DENSITY * NUM_SPIKES_X, DENSITY * NUM_SPIKES_Y); RealType isotopicmass = RealType.getRealType("isotopicmass"); RealType pi = RealType.getRealType("pi"); RealType ratio = RealType.getRealType("ratio"); FunctionType type = new FunctionType( new RealTupleType(isotopicmass, pi), ratio); final FlatField field = new FlatField(type, set); ratioxValues=new Vector(); System.out.println("Generating 3D display...."); //System.out.println(tex.size()); //for(int g=0;g<tex.size();g++) // { // prodat proto=(prodat)tex.get(g); //
System.out.println("proto.ToString()="+"\t"+proto.getMass()+"\t"+proto.getPi
()+"\t"+proto.getProp());

// } //ratioxValues = new proteinxwc[tex.size()]; if (tex==null) { warnUser("Vector is Empty,data objects not found"); } int i=-1; double[][] samples = new double[1][DENSITY * NUM_SPIKES_X * DENSITY * NUM_SPIKES_Y]; OuterLoop: 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; if (i==tex.size()) break OuterLoop; prodat pro= (prodat)tex.get(i); String name=(String)pro.getName(); double ratiox=pro.getProp(); double massx=pro.getMass(); double pix = pro.getPi(); ratioxValues.addElement(new proteinxwc(name,massx,pix,ratiox,x,y)); proteinxwc xwc=(proteinxwc)ratioxValues.get(i); double spike=Math.round(100*xwc.getRatio()); if(spike > 20) { samples[0][ndx]= spike; if (i==tex.size()) break OuterLoop; } else samples[0][ndx] =-1*spike;//-30*Math.random(); if (i==tex.size()) break OuterLoop; } //else samples[0][ndx] =-30*Math.random(); } } field.setSamples(samples); System.out.println("after algorithm"); ref = new DataReferenceImpl("ref"); ref.setData(field); // setTextureEnable(false) - VERY IMPORTANT // prevents data subsampling // rendering may be a bit slower but spikes will look better // display.getGraphicsModeControl().setTextureEnable(false); GraphicsModeControl gmc = display.getGraphicsModeControl(); //gmc.setPointSize(5.0f); gmc.setTextureEnable(false); gmc.setScaleEnable(true); //freeze the screen ScalarMap xmap0=new ScalarMap(isotopicmass, Display.XAxis); xmap0.getAxisScale().setScreenBased(false); //ScalarMap selValMap = new ScalarMap( ratio, Display.SelectValue ); //VisADSlider vSlider = new VisADSlider(selValMap); ScalarMap timeRangeMap = new ScalarMap(isotopicmass, Display.SelectRange ); //display.addMap(selValMap); display.addMap(xmap0); display.addMap(timeRangeMap); //display.addMap(selValMap); display.addMap(new ScalarMap(pi, Display.YAxis)); display.addMap(new ScalarMap(ratio, Display.ZAxis)); display.addMap(new ScalarMap(ratio, Display.RGB)); ranWid = ranWid = new RangeWidget(xmap0); selRanWid = new SelectRangeWidget( timeRangeMap ); // This is NEW! // Create a RangeWidget with the ScalarMap timeMap java.util.Vector mapVector = display.getMapVector(); final int numMaps = mapVector.size(); ScalarMap map1color = (ScalarMap )mapVector.elementAt(numMaps-1); panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(new LabeledColorWidget(map1color)); //final DataReferenceImpl refx = new DataReferenceImpl("refx"); final PickManipulationRendererJ3D pmr3d = new PickManipulationRendererJ3D(); renderer = new DefaultRendererJ3D(); display.addReferences(pmr3d,ref); //display.addReference(renderer); //cellImpl computation and data retrieval CellImpl cellfield2d = new CellImpl() { private boolean nice = true; public void doAction() throws VisADException,RemoteException { if (nice) nice = false; else { int i = pmr3d.getCloseIndex(); System.out.println("i="+i); Set domainSet = field.getDomainSet(); float[][] values = domainSet.indexToValue(new int[] { i }); massx= values[0][0]; Pi= values[1][0]; save= ProteinData(massx,Pi); } } }; cellfield2d.addReference(ref);