Re: DisplayListener

Hi Desiree,

Nice to hear from you again. For your problem, I suggest
calling:

  display.addDisplayListener(listener);

before:

  display.addReferences(renderer, data_ref);

It could be that by the time you call addDisplayListener(),
the display is already done transforming and rendering the
data, which is triggered by the call to addReferences().

Please let me know if this does not solve your problem.

Good luck,
Bill

On Thu, 27 May 2004, Desiree Hilbring wrote:

> Hi Bill and others,
>
> I am using VisAD for creating 3D object content. The object content
> represents a terrain surface and is reused in my own Java3D based
> 3D-GIS-Service. The terrain consists of several parts. Thus I am
> creating several objects of the class DEMFeatureProxy3D.
> For each DEMFeatureProxy3D the method addSurfacePart is called once.
> This method includes the VisAD code, which is creating my terrainpart
> object:
>
>       // VisAD stuff
>       //
>       eastValues = RealType.getRealType("eastValues");
>       northValues = RealType.getRealType("northValues");
>       heightValues = RealType.getRealType("heightValues");
>       try {
>               domain_tuple = new RealTupleType(eastValues, northValues);
>               // Create a FunctionType (domain_tuple -> range_tuple);
>               func_en_h = new FunctionType(domain_tuple, heightValues);
>
>               domain_set
>                       new Linear2DSet(
>                               domain_tuple,
>                               northMin,
>                               northMax,
>                               nRows,
>                               eastMin,
>                               eastMax,
>                               nCols);
>
>               double[][] flat_samples = new double[1][nCols * nRows];
>               for (int c = 0; c < (nRows); c++) {
>                       for (int r = 0; r < (nCols); r++) {
>                               // dgm 1 x y z
>                               flat_samples[0][c * nCols + r] = height[c
> * nCols + r];
>                       }
>               }
>
>               // Create a FlatField
>               // Use FlatField(FunctionType type, Set domain_set)
>               vals_ff = new FlatField(func_en_h, domain_set);
>
>               // ...and put the values above into it
>               // Note the argument false, meaning that the array won't
> be copied
>               vals_ff.setSamples(flat_samples, false);
>
>               // Create Display and its maps
>               // A 2D display
>               display = new DisplayImplJ3D("display1");
>
>               // Create the ScalarMaps: latitude to XAxis, longitude to
> YAxis and
>               // altitude to RGB and temperature to IsoContour
>               // Use ScalarMap(ScalarType scalar, DisplayRealType
> display_scalar)
>               eastMap = new ScalarMap(eastValues, visad.Display.YAxis);
>               northMap = new ScalarMap(northValues,
> visad.Display.XAxis);
>               heightMap = new ScalarMap(heightValues,
> visad.Display.ZAxis);
>
>               eastMap.setRange(-1.0, 1.0);
>               northMap.setRange(-1.0, 1.0);
>               heightMap.setRange(-1.0, 1.0);
>
>               // Add maps to display
>               display.addMap(eastMap);
>               display.addMap(northMap);
>               display.addMap(heightMap);
>
>               // Create a data reference and set the FlatField as our
> data
>               data_ref = new DataReferenceImpl("data_ref");
>               data_ref.setData(vals_ff);
>               renderer = new DefaultRendererJ3D();
>
>               // Add reference to display
>               GraphicsModeControl dispGMC
>
> (GraphicsModeControl) display.getGraphicsModeControl();
>               //dispGMC.setScaleEnable(true);
>               //dispGMC.setPolygonMode(1);
>               dispGMC.setTextureEnable(false);
>
>               display.addReferences(renderer, data_ref);
>
>               //      For DEM part indentification
>               display.setName(String.valueOf(partNumber));
>
>               display.addDisplayListener(listener);
>
>       } catch (VisADException ve) {
>               System.out.println("VisAd TupleType Exception");
>       } catch (RemoteException re) {
>               System.out.println("RemoteExcpetion");
>       }
>
> Add the end the DisplayListener is attached.
> I thought the method displayChanged is called when
> VisAD is ready. In displayChanged I am looking for
> the object content and transform so that I can reuse
> the object geometry for my 3D-Service.
>
> public synchronized void displayChanged(DisplayEvent e) {
>
> // DEM-Konzept-Test multiple parts of DEM
> WorldVolume wv2 = null;
> if (e.getId() == DisplayEvent.TRANSFORM_DONE) {
>       DisplayImplJ3D displayInC = (DisplayImplJ3D) e.getDisplay();
>       Vector renderers = displayInC.getRenderers();
>       if (renderers.size() != 1) {
>               System.err.println(
>                       "Error: Number of Renderes should be one! Num: "
>                               + renderers.size());
>       } else {
>               DefaultRendererJ3D rendererInC
>                       (DefaultRendererJ3D) renderers.elementAt(0);
>
>               // Look for DEM part number
>               String pns = displayInC.getName();
>               Integer pnI = new Integer(pns);
>               int partNumber = pnI.intValue();
>               //System.out.println("partNumber " + partNumber);
>               BranchGroup branchGroup = rendererInC.getBranch();
>
>               try {
>                       renderer.clearScene();
>                       renderer.clearBranch();
>                       display.destroy();
>               } catch (VisADException ex) {
>                       System.err.println(ex);
>               } catch (RemoteException re) {
>                       System.err.println(re);
>               }
>
>               if (branchGroup != null) {
>                       branchGroup.detach();
>                       Enumeration enum = branchGroup.getAllChildren();
>                       while (enum.hasMoreElements()) {
>
>                               ...
>                       }
>               }
>       }
> }
> }
>
> Unfortunately sometimes I never come into the displayChanged method.
> Say the terrain consists of 9 parts, thus I shoul reach the method
> displayChanged 9 times, but sometimes I reach it only 2 times or
> 5 times. Thus some parts for my final terrain are missing.
>
> Any ideas?
>
> Thank for your help in advance.
>
> Greetings Desiree
>
>
>
>
>
> oooooooooooooooooooooooooooooooooooooooooooooooo
> Desiree Hilbring
>
> Institut fuer Photogrammetrie und Fernerkundung
> Universitaet Karlsruhe, Germany
> email: hilbring@xxxxxxxxxxxxxxxxxxxx
> # 0721 6083676
> oooooooooooooooooooooooooooooooooooooooooooooooo
>
>
>


  • 2004 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: