1

I am developing a Java applet using Java3D. It starts up with a BranchGroup object (containing a set of points) which is added to a Locale object. A PickCanvas is created starting from the Locale and a class implementing MouseListener is constructed starting from said PickCanvas.

Mouse clicks are being detected correctly at this stage. The issue I am having is that whenever I start adding more points to my applet (by creating a new BranchGroup object for each set of points that is loaded and then appending this object to my initial Locale object) mouse clicks are not being registered when newly added points are selected.

I probably do something wrong when I refresh the PickCanvas of my MouseListener implementing object after adding new BranchGroup objs. How can I make it so that points that are added in branchgroups after startup are picked by mouse clicks?

Here's how the locale, the first branchgroup and mouselistener are created:

setLayout(new BorderLayout());
GraphicsConfiguration gc = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3D = new Canvas3D(gc);
Utm_Coord_3d observerPoint = new Utm_Coord_3d();
BranchGroup scene=loadPoints(geoPathID, startSequenceID, endSequenceID, observerPoint);
Locale mLocale = new Locale(simpleU);
mLocale.addBranchGraph(scene);
PickCanvas pickCanvas = new PickCanvas(canvas3D, mLocale);
pickCanvas.setMode(PickCanvas.BOUNDS);
MouseMethodsPoints myMouseEventListener = new MouseMethodsPoints(simpleU, viewT3D, pickCanvas);
canvas3D.addMouseListener(myMouseEventListener);
canvas3D.addMouseMotionListener(myMouseEventListener);
canvas3D.addMouseWheelListener(myMouseEventListener);
KeyMethodsPoints myKeyEventListener = new KeyMethodsPoints(canvas3D, simpleU, viewT3D, geoPathID, startSequenceID, endSequenceID, tiltX, scene,mLocale, myMouseEventListener);
canvas3D.addKeyListener(myKeyEventListener);
canvas3D.requestFocus();

And finally this is how I add branchgroups to the locale object updating the pickcanvas:

BranchGroup newBranchGroup=MainPoints.loadPoints(geoPathID, upperBound+1, upperBound+nFilesLoaded, null);
newBranchGroup.compile();
mLocale.addBranchGraph(newBranchGroup);         
PickCanvas pickCanvas = new PickCanvas(canvas3D,mLocale);       
pickCanvas.setMode(PickCanvas.BOUNDS);
mMouseMethodsPoints.setPickCanvas(pickCanvas);

Where setPickCanvas() sets pickCanvas in the MouseListener implementing class object. I even tried creating a new MouseMethodsPoints object every time I add a branchgroup but clicks would still find no points in the areas of the new branchgroups.

Thank you for your time!

wallen
  • 311
  • 1
  • 4
  • 13
  • I edited my answer to make what I wanted to know more clear and even added a question mark for your pleasure even if I think my request was pretty clear. – wallen May 14 '13 at 11:23
  • There's no accounting for what people think. Note that sometimes helpers will do a find on '?' & if the first hit is *"Know someone who can answer?"* they move to the next post that might not only have a question, but also a question mark. My advice is: add one for your *own* benefit. – Andrew Thompson May 14 '13 at 11:43

0 Answers0