Re: Performance problem with multiple displays

Hi Mathias,

I have noticed the grey plane problem with my own application occasionally
as well, under similar circumstances, and I suspect it is Java3D-related.
If you haven't already, I suggest you try changing the size of your displays,
instead of removing and adding them to the frame repeatedly.

So, instead of doing:
   remove(displayPanel);
try:
   displayPanel.setSize(1, 1);
and instead of:
   add(displayPanel, BorderLayout.CENTER);
try:
   displayPanel.setSize(w, h);

-Curtis

At 08:18 AM 2/25/2002, Mathias Stü wrote:
>Hi all,
>
>I have two different displays, a DisplayImplJ3D with a DefaultRendererJ3D
>and a DisplayImplJ3D with a TwoDDisplayRendererJ3D. My application switches
>between these displays as needed. We discussed this issue in a former thread
>some weeks ago. The code switching the displays looks like this:
>
>private void setProjection(int policy) {
>  if (displayPanel != null) remove(displayPanel);
>  if (display != null) display.removeAllReferences();
>  if (policy == this.FLAT_PROJECTION) {
>    display = flatDisplay;
>  } else if ((policy == this.GLOBAL_PROJECTION) || (policy =
>this.NORTH_PROJECTION) || (policy == this.SOUTH_PROJECTION)) {
>    display = geoDisplay;
>  }
>  display.addReference(mapReference);
>  displayPanel = (JPanel)display.getComponent();
>  displayPanel.setBorder(BorderFactory.createLoweredBevelBorder());
>  add(displayPanel, BorderLayout.CENTER);
>  validate();
>}
>
>This code is called by the ActionListeners of four different JButtons (FLAT,
>GLOBAL, NORTH and SOUTH_PROJECTION). The mapReference is a FlatField
>representing a worldmap with elevation data which is mapped to Display.RGB. The
>first time the code is called everything looks fine. The second time I only 
>get a
>grey plane/sphere instead of the coloured worldmap. The third time I get the
>coloured worldmap but the visualization is extremely slow. From there on
>every further call causes a furter slowdown of the visualization. This 
>behaviour
>is independent of the order the two displays are used, e.g. the behaviour is
>the same if I only use the flat display or if I use the displays in
>alternating order. I can't see a memory leek or something else which could be 
>the
>cause of this. Are there any comments?
>
>Many thanks in advance, Mathias
>
>-- 
>GMX - Die Kommunikationsplattform im Internet.
>http://www.gmx.net