NASAWorldWind / WorldWindJava

The NASA WorldWind Java SDK (WWJ) is for building cross-platform 3D geospatial desktop applications in Java.
716 stars 325 forks source link

SelectListener may be called infinitely for a still mouse when many paths #162

Open backwindj opened 5 years ago

backwindj commented 5 years ago

Description

Rollover events may be sent infinitely to a selectListener in presence of many paths.

Steps to Reproduce

  1. Create many paths
  2. Zoom out so they are close to each other
  3. Roll gently over the paths until a loop gets started
  4. Stop rolling

Expected behavior: The currently rolled over path shall be returned only once or at a human rate

Actual behavior: I have seen two behaviors:

Operating System and Version

seen on Linux Fedora 29 with WorldWindJava 2.1.0

Additional Information

Here is the listener I am using:

private final SelectListener selection_listener = new SelectListener () { @Override public void selected (final SelectEvent event) { if (event.isRollover ()) { final Object object = event.getTopObject ();

        if (previous_path != null)
        {
           if (object == null || ! (object instanceof Path))
           {
              System.out.println ("delete");

              previous_path.setHighlighted (false);

              annotation_layer.setEnabled (false);

              previous_path = null;

              world.redraw ();
           }

           else if (previous_path != object)
           {
              System.out.println ("update");

              previous_path.setHighlighted (false);

              final Point point = event.getPickPoint ();

              final Path path = (Path) object;

              show (path, point);
           }
        }

        else if (object instanceof Path)
        {
           System.out.println ("create");

           final Point point = event.getPickPoint ();

           final Path path = (Path) object;

           annotation_layer.setEnabled (true);

           show (path, point);
        }
     }
  }

};

private void show (final Path path, final Point point) { final String text = path.getStringValue (AVKey.DISPLAY_NAME);

  annotation.setScreenPoint (point);

  annotation.setText (text);

  path.setHighlighted (true);

  previous_path = path;

  world.redraw ();

}

Somewhere in the code, the listener is registered like this: world.addSelectListener (selection_listener);

Sometimes, i get a repeated stream of creates & deletes, sometimes a repeated stream of updates.

I have also tried to get it working with Hover events and I did get a nice working solution. I would prefer my solution to be more responsive and therefore, it needs to listen to Rollover events.

Here is the listener with Hover events: private final SelectListener selection_listener = new SelectListener () { @Override public void selected (final SelectEvent event) { if (event.isHover ()) { final Object object = event.getTopObject ();

        if (object == null)
        {
           if (previous_path != null)
           {
              previous_path.setHighlighted (false);

              annotation_layer.setEnabled (false);

              world.redraw ();

              previous_path = null;
           }
        }

        else if (previous_path == null)
        {
           if (object instanceof Path)
           {
              final Point point = event.getPickPoint ();

              final Path path = (Path) object;

              final String text = path.getStringValue (AVKey.DISPLAY_NAME);

              annotation.setScreenPoint (point);

              annotation.setText (text);

              path.setHighlighted (true);

              annotation_layer.setEnabled (true);

              world.redraw ();

              previous_path = path;
           }
        }
     }
  }

};

Thanks for your time.

wcmatthysen commented 5 years ago

@backwindj, come over the community edition of WorldWind and we'll try to debug it there. You can open the issue there and we'll try and trace this bug.

backwindj commented 5 years ago

OK, I will. I am on vacation for now. François

Le 13 juillet 2019 19:22:26 GMT+02:00, Wiehann Matthysen notifications@github.com a écrit :

@backwindj, come over the community edition of WorldWind and we'll try to debug it there. You can open the issue there and we'll try and trace this bug.

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/NASAWorldWind/WorldWindJava/issues/162#issuecomment-511139419

-- Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.