manipulating graphs in a GUI

Reply

Join Date: Nov 2004
Posts: 15
Reputation: matt_5104 is an unknown quantity at this point 
Solved Threads: 0
matt_5104 matt_5104 is offline Offline
Newbie Poster

manipulating graphs in a GUI

 
0
  #1
Dec 1st, 2004
Hi, I'm creating a GUI in which users are required to interact with graphs. I have a jFrame on which I have put a jLabel and used this label to import a JPEG of a graph (i.e it's an icon). My problem is that the user needs to pick a point on the graph, and from that two coordinates will be obtained. These coordinates obviously need to corespond with the axes on the graph. How can I convert the pixel coordinates of the jLabel that the mouseClicked event will give me into coordinates that correspond to the JPEG graph? Any help is great appreciated!
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: manipulating graphs in a GUI

 
0
  #2
Dec 1st, 2004
Determine the top corner of the component you use to display the image and use those as an offset.
For example if the image is displayed from 100,100 on your application window and your mouse coordinates are 150,150 your coordinates in the image would be 50,50 (or was that 49,49 ...).

Mind this is just an example, I haven't checked if the coordinates in either case are calculated from the top left corner of the application window (some libraries have a tendency to calculate from the bottom right corner in which case you need the window size as well to calculate another offset to determine the top left corner).
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC