[Rd] Getting the panel location of a xyplot matrix using a mouse click in a GDCanvas

From: Daniel Kornhauser <dkor_at_northwestern.edu>
Date: Thu, 23 Oct 2008 14:26:23 -0500


I would like to find out the panel of a xyplot matrix where a mouse clicked.

I know this functionality is already bundled in trellis.focus but I can't use it because I am coding a stand alone application in Java using with GDCanvas as a graphics device.

I tried calling trellis.focus from Java with:

   re.eval("t = trellis.focus()"));
However it did not work for an embedded GDCanvas. The above call to the trellis.focus() returns null no matter where I click.

(Side note: the functionality must be implemented in the GDCanvas because trellis.focus does work correctly in JGR)

I wish to handle all the user GUI events in Java to evaluate different commands in an Rengine.
With a GDCanvas, it's straightforward to get the x y position of a mouse click with the standard e.getX() and e.getY() So my handler would look like:

    public void mouseClicked(MouseEvent e) {

        System.out.println("Clicked" + e.getX() + " " + e.getY());
        System.out.println(re.eval("t = trellis.focus()"));
       // I would update the panel here ...

I am only using Java because:
- I am proficient in Java GUI programmer

Another way of posing the question is:
Given the coordinates from grid.location how can I find out the plane of an xyplot matrix where the user clicked.

I have tried to figure out how to do it from code using trellis.clickFocus, but I have have only been playing with R for a week, so I am quite lost reading R code.
I tried to look up to in the code of JGR and came out emplty handed.

This is my first post so I hope I did not break any rules ...

Thanks !


        [[alternative HTML version deleted]]

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 23 Oct 2008 - 19:29:08 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 23 Oct 2008 - 23:30:38 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive